lutraconsulting / ostranslator-ii

A graphical QGIS plugin for loading Ordnance Survey MasterMap into PostGIS.
16 stars 8 forks source link

Failed to start import process - please ensure you have ogr2ogr installed #52

Closed gibsonc1 closed 10 months ago

gibsonc1 commented 4 years ago

Hi All,

I'm trying to get Os importer to work but failing miserably! I get an error saying I don't have ogr2ogr installed (I believe I do).

I'm running QGIS3.4 on OSX 10.14.6.

Screenshot 2019-12-05 at 15 51 44

Any help would be great!

Thanks, Chris

citizenfish commented 4 years ago

Same problem on Mac OSX. Tried QGIS 3.10 and 3.11. I then dug into the python code and found some strangeness in the ogr2ogr parameters.

I dumped these out from import_task.py and tried running ogr2ogr by hand, this gave me a number of issues (they may not be the cause as I am no expert in passing parameters to QProcess)

Issue one was that the parameter -f PostGresQL " was being separated from the connection string. I edited build_args in utils.py to fix this, by making pg_source come after 'PostgreSQL' rather than before input_file:-

        args = ['-f', 'PostgreSQL', pg_source,
                '--config', 'PG_USE_COPY', 'YES',
                '--config', 'GML_GFS_TEMPLATE', gfs_file_path,
                input_file]

Issue two was a space in the filename which MacOSX did not like. I fixed this with:-

input_file = '"' + '/vsigzip/' + input_file + '"'

Issue three was the fact that my postgres user was not making it into the connection string. I hacked it in with:-

if user == '':
            user = 'postgres'

Issue four was the injection of single quotes into the postgres string which I fixed in os_translator_ii_dialog.py with:-

# pgSource = 'PG:dbname=\'%s\' host=\'%s\' port=\'%d\' active_schema=%s user=\'%s\' password=\'%s\'' % \
        pgSource = 'PG:"dbname=%s host=%s port=%d active_schema=%s user=%s password=%s"' % \
            (self.dbDetails['database'], self.dbDetails['host'], self.dbDetails['port'], self.schema_name + '_tmp', user, password)

Having done this ogr2ogr would run using the passed parameters. But It was still failing with the error:-

ERROR 1: ERROR:  column s.consrc does not exist
LINE 1: ...nrelid = c.oid AND a.attnum = ANY (s.conkey) AND (s.consrc L...
                                                             ^
HINT:  Perhaps you meant to reference the column "s.conkey" or the column "s.conbin".

ERROR 1: ERROR:  column s.consrc does not exist
LINE 1: ...nrelid = c.oid AND a.attnum = ANY (s.conkey) AND (s.consrc L...
                                                             ^
HINT:  Perhaps you meant to reference the column "s.conkey" or the column "s.conbin".

Not sure if any of that helps. I've tried with gml files in plain and .gz format.

saberraz commented 10 months ago

Closed as it should be addressed in Mac installer.