[OSM-dev] osm2pgsql: access flatfile from postgresql via foreign data wrapper

Jochen Topf jochen at remote.org
Sun Nov 10 09:52:49 UTC 2013


On Sun, Nov 10, 2013 at 01:39:40AM -0800, Walter Nordmann wrote:
> after using osm2pgsql with --flat-nodes everything is running fine during
> import and update via diffs.
> 
> Now i would like to access the raw node-data, which is in the external
> flatfile, from postgresql using a "foreign data wrapper"
> http://www.postgresql.org/docs/9.1/static/ddl-foreign-data.html.
> 
> I have to export some data from the database as an osm-file to send it to
> *osmcoastline*. so i need access to the "non tagges nodes" which should be
> in planet_osm_nodes but now are - on my own wish - in the flatfile.
> 
> i can try to write a program, but: *has anybody done that before*?

That's a pretty neat idea. Could be useful for lots of cases. Go for it!

I your case there might be a simpler way. Osmcoastline comes with a program
called osmcoastline_filter. It reads an OSM file twice. On the first pass it
finds all ways tagged natural=coastline, writes them out and remembers the
node ids it needs. In the second pass it finds those nodes and adds them
to the output file. If you change this filter program slightly, you can
use it to do the first pass as usual on a dump of the ways from your
database. At the end of the first pass you then have the list of node ids
you need. You could then read the flat nodes file directly (you'd have to
write that code in any case) and synthesize the necessary nodes from it.
This is probably slightly easier to do than the postgresql fdw, but, of
course, not as general.

Jochen
-- 
Jochen Topf  jochen at remote.org  http://www.jochentopf.com/  +49-721-388298



More information about the dev mailing list