[Tile-serving] [openstreetmap/osm2pgsql] Getting admin_centre node in process_relation (Discussion #1763)

Jochen Topf notifications at github.com
Fri Sep 16 14:06:51 UTC 2022


You can get a collection of all member geometries of a relation with `object:as_geometrycollection()` and then get the nth geometry with `geometry_n()`. So something like this should work:

```
function osm2pgsql.process_relation(object)
  local geom = object.as_geometrycollection()
  for i, member in ipairs(object.members) do
    if member.role == 'admin_centre' and member.type == 'n' then
      local point_geom = geom.geometry_n(i)
      ... 
    end
  end
end
```

But that only gives you the geometry, not the name.

If you don't want to store *all* place points, but only those actually mentioned in a relation, you can look at [two-stage processing](https://osm2pgsql.org/doc/manual.html#stages). I's a bit tricky to get right though.

You can also just take advantage of the database you have. Add those place nodes to a database table, create another table from the relation members and join them afterwards.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/discussions/1763#discussioncomment-3663034
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/osm2pgsql/repo-discussions/1763/comments/3663034 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20220916/bc20ac1b/attachment.htm>


More information about the Tile-serving mailing list