Question

I'm using Graphhopper as a routing service for my Android project and I want to know how can I extract street data (as a polygon) from *.osm.pbf format?

Later I want to use that data so that I could detect if user is within boundaries of that street.

Edit:

I've used Osmosis as it was referenced in this answer (selecting highways) but when I try to investigate xml after extraction I still don't understand how can I get a particular street since there still are some other objects left (like houses, bus stops).

Was it helpful?

Solution 2

Street data is stored in GraphHopper. You could traverse the full graph e.g. via extending XFirstSearch and then do on checkAdjacent:

boolean checkAdjacent( EdgeIterator iter ) {
   PointList pl = iter.fetchGeometry(3);
   String name = iter.getName();
}

If you want to get an edge from a location for the "fence-use-case" you can have a look into LocationIndexTree.

Some clarifications:

Routing graphs usually don't contain spatial informations

The routing graph itself does not need this data but still we need this data to display the route etc.

Is there a way then to add weight to a node during the calculation

As explained on the mailing list.

OTHER TIPS

Well I guess here are a few misunderstandings, so I go trough your wishes step by step:

  1. OSM street data What grasshopper uses aren't street polygones (closed shapes) nor simple street lineshapes. It processes pure OSM data and creates a so called routing-graph presentation. Here are a few informations about the import process itself: https://github.com/graphhopper/graphhopper/wiki/World-Wide-Road-Network

  2. User position on road
    This is called reverse geocoding and has different requirements on the indexing structures and models. OSM offers Nominatim as a solution to query like (lat, lon) -> OSM object. Your idea with a spatial buffer is even possible but creates a lot of overhead (here: memory) to preprocess your roadnetwork or doing it on demand for a particular area.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top