[Tile-serving] [osm2pgsql-dev/osm2pgsql] How to omit certain relation members with flex output? (Discussion #2204)
Candid Dauth
notifications at github.com
Mon Jun 17 18:22:21 UTC 2024
I am completely new to osm2pgsql and I'm trying to bring the [Openptmap](https://github.com/giggls/openptmap) scripts up to date.
The way that it works right now is that it uses [Osmfilter](https://wiki.openstreetmap.org/wiki/Osmfilter) to keep only certain tags and only objects with certain tags _before_ importing the planet/region file with osm2pgsql. I am trying to rewrite this into an osm2pgsql flex output Lua script so that I can apply deltas to the database later. One thing that I'm struggling to implement is that the [osmfilter file](https://wiki.openstreetmap.org/wiki/Openptmap/Installation#Filter_the_Planet_File) removes any objects with a `railway=platform` tag. Because the removal happens before the import to `osm2pgsql`, such objects will also be omitted from the geometries of relations that contain objects with such tags, because the members simply cannot be found in the imported data.
I'm struggling to implement this in my Lua script. I successfully manage to ignore ways with `railway=platform` in my `osm2pgsql.process_way` script, but if those ways are a member of any relation, they still end up in the geometry of that relation.
Right now I’m trying to reproduce the layout of the previous pgsql output with 3 tables, one for points, one for lines and one for polygons. From what I read [online](https://gis.stackexchange.com/questions/420135/filtering-out-parts-of-a-relation-on-osm2pgsql-import), one way to do it would be to instead create tables for nodes, ways and relations and make the relations table not contain any actual geometries, but make it reference the nodes/ways and pull them in using joins in mapnik.xml. I'm imagining I would have to create a `nodes`, `ways`, `routes`, `routes_members`, `polygons` and `polygons_members` table, where `routes` and `polygons` would contain the relations with their tags and `routes_members` and `polygons_members` tables would reference the relation members. However, I’m not sure what the SQL query to construct the actual relation geometries would actually look like. Specifically, I'm wondering about:
* How to support relations that are members of other relations? The tags of a relation should be applied to all its descendent ways in the hierarchy of member relations. Is this even possible with an SQL join?
* How to construct a multipolygon from the members of a polygon relation?
Is there maybe some example code somewhere that already does this?
--
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/discussions/2204
You are receiving this because you are subscribed to this thread.
Message ID: <osm2pgsql-dev/osm2pgsql/repo-discussions/2204 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20240617/8b8dac7b/attachment.htm>
More information about the Tile-serving
mailing list