GoogleMaps or OpenStreetMap get graph

253 views Asked by At

Is there opportunity to get the graph of all crossroads from Google Maps or OpenStreetMap? Not the whole world, but for some piece :) For every crossroad I need to know coordinates, list of all neighbours (closest crossroads) and distance to those crossroads. I'm trying to implement one search algorithm, so I need this data to provide search of the shortest road. Thanks!

2

There are 2 answers

0
Karussell On BEST ANSWER

This is easily doable with GraphHopper (disclosure: I'm the author). Just download the Java source and implement your custom search algorithm. All so called tower nodes are the junctions you need and you can easily get the coordinates of them (pseudo code):

g = hopper.getGraph()
loop from i=0 to g.getNodes()
 print g.getLatitude(i) // or getLongitude
0
ffflabs On

Google maps API does not provide what you're looking for. However, there are some indirect approaches you could use.

The Google maps road API will accept a set of random points and snap them to a suitable road. You'd still need to figure out how to locate intersections and distances between them.

The google.maps.DistanceMatrix will vive you distance and times between a matriz of origina and destinations. You got to figure our which origina and destinations to query for.

The google.maps.DirectionsService will suggest you a route if you pasa in original, destinations and optional waypoints.

It looks like you meed to use two of the aforementioned to detect intersections.

The other way around is installing postGis with tiger geocoder. Bu it'l be a whole day

  1. List item