[OSRM-talk] Need help understanding viaroute hints and checksums
Stephen Woodbridge
woodbri at swoodbridge.com
Sat Dec 14 01:26:13 UTC 2013
Hi Dennis,
I have code working in postgresql that can call viaroute and it is
currently returning 90 route requests in just under 400 ms without using
hints. I'm using this to populate a distance matrix.
Here is the basic code for doing this:
for (i=0; i<cnt; i++) {
for (j=0; j<cnt; j++) {
if (i == j) continue;
// currently hints are getting ignored
url = makeViaRouteUrl(lat[i], lon[i], lat[j], lon[j],
hints[i], hints[j], baseurl, 18, inst, false );
//DBG("-- URL(%d, %d): %s", i, j, url);
cache->json[i*cnt + j] = callOSRM(url);
pfree(url);
if (!cache->json[i*cnt + j]) {
cache->failures++;
DBG("-- back from callOSRM(): FAILED!");
continue;
}
thesehints = jget_hints(cache->json[i*cnt + j], &nhints);
if (thesehints) {
if (!hints[i] && nhints>0) hints[i] = thesehints[0];
if (!hints[j] && nhints>1) hints[j] = thesehints[1];
}
}
}
I have an array of lat[] and lon[] values cnt long. I loop through the
array getting the route for every possible combination of the locations
and save the json results in a cache.
So I'm trying to understand how to use the hints to improve the performance.
Lets simplify the problem to requesting two routes: A -> B for one and
then B -> C from the next.
When I request the route A -> B, I get back
"hint_data": {
"checksum": ".checksumAB.",
"locations": ["hintA", "hintB"]
}
So later when I request the route B -> C, I have the hints for B from
the previous request. One could assume that in my viaroute request for
B -> C would look like:
http://localhost:5000/viaroute?z=18&instructions=false&alt=false&loc=latB,lonB&hint=hintB&loc=latC,lonC
because we have hints for B but not for C.
According to https://github.com/DennisOSRM/Project-OSRM/wiki/Server-api
we need to also append &checksum=...
If I had previously done route A -> B and D -> E, I would have hints
from A, B, D, and E and checksums for AB and DE, but if I do a route
from B -> E, I have both these hints from the previous routes and two
different checksums.
It seems that the checksums get in the way of using hints?
Hence my question on IRC about whether I can use hints without checksums
and if not, how do I apply hints and checksums in these two scenarios?
I'm happy to update the wiki with your clarifications.
Best regards,
-Steve
More information about the OSRM-talk
mailing list