pyosmium
pyosmium copied to clipboard
Using node cache to quickly find roads?
I'm looking for an efficient (as possible) way to find ways that contain a given node. I started by just using a SimpleHandler to walk all of the pbf and make a cache that maps nodes to ways, but can https://github.com/osmcode/pyosmium/blob/master/examples/use_nodecache.py be used to make this more efficient?
NodeLocationsForWays is the reverse of what you need. Skimming through the libosmium code I found ObjectRelations which, as far as I understand, may create the node to way index.
Though I don't see this exposed in pyosmium.
OK, cool, then I'll just walk all the ways.
Should I walk the relations too to find the names, or do ways always have a name?
Depends on what names you plan to find. If you're looking for street names then usually they are on way level.
This needs indeed the osmium::index::MultiMap because a node may be in multiple ways. That class is not yet exposed to pyosmium. It would be interesting to have though together with the ObjectRelations handler.