[GraphHopper] create graph structure from OSM data
Peter K
peathal at yahoo.de
Sun Mar 2 10:42:11 UTC 2014
Hey Phil,
if I understand you correctly you need to assign a "tile number" to
every edge. To confuse you a bit more I call this spatial key in the
code:
http://karussell.wordpress.com/2012/05/23/spatial-keys-memory-efficient-geohashes/
So, no need to change the import process IMO.
This should work as follows, where spatialKeyAlgo can be an
implementation of KeyAlgo (see com.graphhopper.geohash):
graph = hopper.getGraph()
allEdgeIter = graph.getAllEdges();
while(allEdgeIter.next()) {
// now it depends which lat,lon you pick
// you can pick base, adjacent or pillar nodes (the nodes between):
base = allEdgeIter.getBaseNode();
lat = graph.getLatitude(base)
lon = graph.getLongitude(base)
// now get you cellID
cellID = spatialKeyAlgo.encode(lat, lon)
yourDataStructure.put(cellID, edge.getEdge())
}
> Can anybody explain me, in which steps the OSM file must be converted into GraphHopper data directory?
You can take a look into nearly all unit tests where the Graph is filled
without the need of OSM. You normally only need to set the lat,lon of a
node (==junction) as well as the connection ala:
graph.setNode(nodeA, lat, lon);
graph.setNode(nodeB, ...);
...
edge = graph.edge(nodeA, nodeB);
edge.setDistance(..)
edge.setFlags(flagEncoder.setProperties(..))
edge.setWayGeometry(points)
Kind Regards,
Peter.
> Hello,
>
> I'm new with graphhopper and I would like to create a full graph of a OSM for a simulation, so each edge must be sampled into cells.
> My first question is, how can I create a sampling of the edges?
>
> I know I can convert a OSM with the shell script graphhopper.sh into a directory with edges and vertex data, but I have checked the GraphHopper.java
> for creating my own OSM converting structure, because my application should create the GraphHopper data on-fly, but I cannot create
> a working source code. Can anybody explain me, in which steps the OSM file must be converted into GraphHopper data directory?
>
> Thanks
>
> Phil
>
More information about the GraphHopper
mailing list