-
Hello, I need node with name and geometry (point) in local node_table = {};
function osm2pgsql.process_node(object)
if object.tags.place then -- consider only places not to fill-up whole RAM
node_table[object.id] = { point = object:as_point(), name = object.tags.name }
end
end
function osm2pgsql.process_relation(object)
local type = object.tags.type;
for _, member in ipairs(object.members) do
if member.role == 'admin_centre' and member.type == 'n' then
local node = node_table[member.ref]
// now I can use `node.name` and `node.point`
end
end
end Is it correct? I mean it works but it requires storing potential nodes to Maybe another approach could be to store references to admin_centre nodes in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can get a collection of all member geometries of a relation with
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 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. |
Beta Was this translation helpful? Give feedback.
You can get a collection of all member geometries of a relation with
object:as_geometrycollection()
and then get the nth geometry withgeometry_n()
. So something like this should work: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…