You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the OSMReader (osmreader.graph=sg-sh osmreader.osm=malaysia_singapore_brunei.osm osmreader.size=5000000 osmreader.dataaccess=mmap) to create a graph for android.
But if I want to use this graph with GraphHopper I'm getting following error:
"D/RouteCalculation(2119): An error happend while creating graph: Cannot load the graph - it wasn't create via com.graphhopper.storage.LevelGraphStorage! sdcard/graphhopper/singapore-gh/"
This is not an android issue. A levelgraph is used on android to make everything faster via Contraction Hierarchies
So, either specify
osmreader.levelgraph=true
osmreader.chShortcuts=true
when creating the graph. Or use the normal GraphStorage on android (a bit slower but more powerful).
Thanks for the fast reply.
I managed it to calculate routes on an Android device. But I still have one issue. The route distance is around 30x bigger than the real route length if getting it with the distance() function of GHResponse. Do you have an explanation for this? I took the same request as in the Android example.
By the way: I looked long time for an appropriate routing algorithm for android and this is the first one I really like! Thx!
This is not an android issue. A levelgraph is used on android to make everything faster via Contraction Hierarchies
So, either specify
osmreader.levelgraph=true
osmreader.chShortcuts=true
when creating the graph. Or use the normal GraphStorage on android (a bit slower but more powerful).
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-12134276.
Creating the graph with osmreader.sortGraph=false fixed the problem. I calculated the route via levelgraph.
I also wanted to use the GraphHopperWeb(). But it always appends to the URL "&type=bin&minPathPrecision=1.0&algo=dijkstrabi" and it is not working with the Servlet.
It seems the sortGraph only sort the nodes, the order of edges won't be touched. Is it right?
I noticed the comments
/**
* Sorts the graph according to depth-first search traversal. Other traversals have either no
* significant difference (bfs) for querying or are worse (z-curve).
*/
Do we have an explanation why DFS helps?
Thanks!
I re-read the code. For edges, I think the order is kept. Only skip some invalid edge.
For nodes, it's totally re-sorted.
And this change would only improve latency for single thread query? Or it's also valid for multi-thread server scenario?
I assume the change is make the geographical nearby data also close inside disk/memory. So there is high chance the connected edge data is already in high speed cache. Is it right?
Sorry I am still not very clear. Below is the code I looked:
AllEdgesIterator will iterate edge from the beginning to the end.
looks like the below code only read all the edges then translate the nodeID to new nodeID and store the new edge in another graph. So I thought the edge order are kept except some empty entries might be skipped.
static Graph createSortedGraph(Graph fromGraph, Graph toSortedGraph, final IntIndexedContainer oldToNewNodeList) {
AllEdgesIterator eIter = fromGraph.getAllEdges();
while (eIter.next()) {
int base = eIter.getBaseNode();
int newBaseIndex = oldToNewNodeList.get(base);
int adj = eIter.getAdjNode();
int newAdjIndex = oldToNewNodeList.get(adj);
// ignore empty entries
if (newBaseIndex < 0 || newAdjIndex < 0)
continue;
eIter.copyPropertiesTo(toSortedGraph.edge(newBaseIndex, newAdjIndex));
}
Hah, usually each CPU core has its own high-speed cache. So the improvement should also work for server scenario. I still feel a little strange. I think the Hilbert curve should works, too. Or even better.
Activity
karussell commentedon Jan 11, 2013
This is not an android issue. A levelgraph is used on android to make everything faster via Contraction Hierarchies
So, either specify
osmreader.levelgraph=true
osmreader.chShortcuts=true
when creating the graph. Or use the normal GraphStorage on android (a bit slower but more powerful).
martinschaller commentedon Jan 11, 2013
Thanks for the fast reply.
I managed it to calculate routes on an Android device. But I still have one issue. The route distance is around 30x bigger than the real route length if getting it with the distance() function of GHResponse. Do you have an explanation for this? I took the same request as in the Android example.
By the way: I looked long time for an appropriate routing algorithm for android and this is the first one I really like! Thx!
Martin
Von: Peter <[email protected]mailto:[email protected]>
Antworten an: graphhopper/graphhopper <[email protected]mailto:[email protected]>
Datum: Freitag, 11. Januar 2013 15:26
An: graphhopper/graphhopper <[email protected]mailto:[email protected]>
Cc: Martin Schaller <[email protected]mailto:[email protected]>
Betreff: Re: [graphhopper] creating graph for android (#9)
This is not an android issue. A levelgraph is used on android to make everything faster via Contraction Hierarchies
So, either specify
osmreader.levelgraph=true
osmreader.chShortcuts=true
when creating the graph. Or use the normal GraphStorage on android (a bit slower but more powerful).
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-12134276.
karussell commentedon Jan 11, 2013
via levelgraph?
hmmh this could be a bug. I'll investigate
Thanks! Of course it is in a very early stage (and a bit slow and weak here and there) but it will improve :) !
karussell commentedon Jan 11, 2013
If you set osmreader.sortGraph=false before creating the graph - does it fix your problem? If not, I need your code snippet to reproduce this bug.
martinschaller commentedon Jan 12, 2013
Creating the graph with osmreader.sortGraph=false fixed the problem. I calculated the route via levelgraph.
I also wanted to use the GraphHopperWeb(). But it always appends to the URL "&type=bin&minPathPrecision=1.0&algo=dijkstrabi" and it is not working with the Servlet.
karussell commentedon Jan 12, 2013
Regarding sortGraph -> that is a known bug ;) ... regarding the web api, please make sure you append the "api" path like so:
I'll document that better ...
karussell commentedon Jan 20, 2013
I'll close this for now. Let me know if still something is broken. Regarding the sortGraph=false - I've opened #12
zhiqiangZHAO commentedon Jul 25, 2018
It seems the sortGraph only sort the nodes, the order of edges won't be touched. Is it right?
I noticed the comments
/**
* Sorts the graph according to depth-first search traversal. Other traversals have either no
* significant difference (bfs) for querying or are worse (z-curve).
*/
Do we have an explanation why DFS helps?
karussell commentedon Jul 26, 2018
We recreate the entire graph, so both are sorted.
Not really - I would have expected BFS. Still some paper mention DFS too.
zhiqiangZHAO commentedon Jul 26, 2018
Thanks!
I re-read the code. For edges, I think the order is kept. Only skip some invalid edge.
For nodes, it's totally re-sorted.
And this change would only improve latency for single thread query? Or it's also valid for multi-thread server scenario?
I assume the change is make the geographical nearby data also close inside disk/memory. So there is high chance the connected edge data is already in high speed cache. Is it right?
karussell commentedon Jul 27, 2018
No. It recreates the whole graph and it creates the new edges according to the traversal so the order changes.
Improves single thread and therefore also multi-thread accordingly
Yes, exactly.
zhiqiangZHAO commentedon Jul 30, 2018
Hi Karussell,
Sorry I am still not very clear. Below is the code I looked:
AllEdgesIterator will iterate edge from the beginning to the end.
looks like the below code only read all the edges then translate the nodeID to new nodeID and store the new edge in another graph. So I thought the edge order are kept except some empty entries might be skipped.
zhiqiangZHAO commentedon Jul 30, 2018
Hah, usually each CPU core has its own high-speed cache. So the improvement should also work for server scenario. I still feel a little strange. I think the Hilbert curve should works, too. Or even better.