Skip to content

Getting admin_centre node in process_relation #1763

Answered by joto
zdila asked this question in Q&A
Discussion options

You must be logged in to vote

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. I's a bit tricky to get right though.

You can also jus…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zdila
Comment options

Answer selected by zdila
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants