pramsey / pgsql-ogr-fdw

PostgreSQL foreign data wrapper for OGR
MIT License
237 stars 34 forks source link

osm INTERLEAVED_READING how to specify or can it be #217

Open robe2 opened 3 years ago

robe2 commented 3 years ago

I was trying to link this file using ogr_fdw and got slapped with the turn on INTERLEAVE notice.

https://download.geofabrik.de/europe/belarus-latest.osm.pbf

I tried this:

CREATE SERVER svr_osm FOREIGN DATA WRAPPER ogr_fdw
OPTIONS (
    datasource '/fdw_data/belarus-latest.osm.pbf', 
    config_options 'OGR_INTERLEAVED_READING=YES',
    format 'OSM'
);

But then the tables all come up empty.

I also tried INTERLEAVED_READING=YES but it said option not available. In GDAL 3.1 I can use ogr2ogr without specifying this option as it's turned on by default I guess since GDAL 2.2

SELECT ogr_fdw_version();

outputs: OGR_FDW="1.1" GDAL="3.2.1"

So not sure why I can't get it to work. Can you try it. Way easier than trying to fumble with ogr2ogr if I can get it to work.

Using QGIS GDAL 3.1.4

I can load fine with this command:

ogr2ogr -f "PostgreSQL" PG:"dbname=gisdb" -lco SCHEMA=staging -lco GEOMETRY_NAME=geom belarus-latest.osm.pbf

pramsey commented 1 year ago

The points table doesn't come up empty. But I get the same issues otherwise. All other tables empty if the option is provided, and an error message if it is left off.

DROP SERVER svr_osm CASCADE;
CREATE SERVER svr_osm FOREIGN DATA WRAPPER ogr_fdw
OPTIONS (
    datasource '/tmp/belarus-latest.osm.pbf', 
--    open_options 'INTERLEAVED_READING=YES',
    config_options 'OGR_INTERLEAVED_READING=YES CPL_DEBUG=YES',
    format 'OSM'
);

DROP SCHEMA IF EXISTS osm CASCADE;
CREATE SCHEMA osm;

SET search_path = public,osm;

IMPORT FOREIGN SCHEMA ogr_all FROM SERVER svr_osm INTO osm;

SELECT count(*) FROM lines;
SELECT count(*) FROM points;