pyosmium icon indicating copy to clipboard operation
pyosmium copied to clipboard

Using node cache to quickly find roads?

Open retorquere opened this issue 7 years ago • 4 comments

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?

retorquere avatar Jun 26 '18 13:06 retorquere

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.

wiktorn avatar Jun 26 '18 18:06 wiktorn

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?

retorquere avatar Jun 26 '18 19:06 retorquere

Depends on what names you plan to find. If you're looking for street names then usually they are on way level.

wiktorn avatar Jun 26 '18 21:06 wiktorn

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.

lonvia avatar Jun 27 '18 20:06 lonvia