[GraphHopper] getting the list of sorted shortest path
Alexandre Vallette
alexandre.vallette at snips.net
Fri Jul 19 07:40:10 UTC 2013
hello all,
I am currently using graphhopper from scala. It works the same way as in
java:
// Building GraphHopper graph
val ram = new RAMDirectory("graphhopper.map", true)
val encodingmanager = new EncodingManager("CAR")
val carEncoder = encodingmanager.getEncoder("CAR")
val graph = new LevelGraphStorage(ram, encodingmanager)
graph.create(nb_vertices)
val vertices = mynodes.flatMap(i => List(i._1, i._2)).distinct
val indices = (0 to vertices.length)
val bijection = (vertices zip indices).toMap
intersections.map(i => graph.edge(bijection(i._1.toInt),
bijection(i._2.toInt), 1, false))
// Precompute a contraction hierarchy.
val prepare = new
PrepareContractionHierarchies().setVehicle(carEncoder).setGraph(graph)
prepare.doWork
graph.flush
val algo = prepare.createAlgo
val path = algo.calcPath(9, 999)
println(path)
1) So first, am i doing things right? I had to define a bijection because
my vertices have id starting from 300000 and it seems that graphhopper
creates all the intermediary vertices.
2) Second, how would it be possible to retrieve a list (or even a stream)
of the shortest paths between two nodes: the first being the shortest,
second shortest etc...
Thanks for your help
--
--
Dr Alexandre Vallette, PhD
co-founder
+ 33 (0) 6 71358943
alexandre.vallette at snips.net
skype: vallettea
linkedIn: fr.linkedin.com/in/vallettea/
twitter: @vallettea
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20130719/056381f8/attachment.html>
More information about the GraphHopper
mailing list