1

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).

IgnasK
  • 384
  • 2
  • 19
  • What kind of polygone do you try to get? Just the (opened) linestring of the road or with a buffer (here: road width)? – MaM Dec 19 '13 at 18:12
  • I really don't know at this point. I suppose the one with a road width since there always gonna be some inadequacy within the GPS data and Openstreetmap data. Though I'd love to know how to extract both of them – IgnasK Dec 19 '13 at 18:49

2 Answers2

2

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.

MaM
  • 2,043
  • 10
  • 20
  • Well, I'm working with relatively small map - one city. Okay so I can't actually extract streets with graphhopper. Longshot and sorry if it's retarded - is there a way (tool) to convert (a small subset) of graph that I get from Graphhopper into a Polygon(s) so that I could try to figure out if user is within/near the street? – IgnasK Dec 20 '13 at 13:18
  • AFAIK there is no Graphhopper export. Routing graphs usually don't contain spatial informations, as it's a graph and the distances etc. are a weight along the graph edges. You can use original OSM data and for example QGIS to do a buffer calculation, but I really recommend a professional geocoding solution to avoid coding and making mistakes ;) – MaM Dec 20 '13 at 15:37
  • Is there a way then to add weight to a node during the calculation if i.e. I want to simulate traffic jam or a closed road? My final goal would be to simulate dynamic routing (even if it's far from the best way) when not only the length of the road is taken into consideration but also timetables for streets just to show off how Dijkstra and A* behave in such conditions. – IgnasK Dec 20 '13 at 16:27
0

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.

Karussell
  • 17,085
  • 16
  • 97
  • 197