While trying to use the API of the demo server at router.project-osrm.org I stumbled upon some things which puzzle me and I hope you can me help out there.
First, the wiki page on "API usage policy" requires clients to query the route geometry by the parameter "&geomformat=cmp", however I cannot see a difference in the returned json. That is the value of the "route_geometry" attribute does not seem to change at all, whether I add "&geomformat=cmp" to the URL or not. Is this is already the default? If so, what other value than "cmp" can it have? Or am I misunderstanding things and send wrong queries? My application sends queries to URIs like this "http://router.project-osrm.org/viaroute?geomformat=cmp&loc=$X1,$Y1&loc=$X2,$Y2" as described in the "Server API" wiki page. Second, (and this might be related to the first) it seems that either I am missing some subtleties in the Google's Polyline Algorithm Format or the coordinates which are returned by demo server are off by a factor of ten. As an example, querying the demo server with "/viaroute?loc=52,13&loc=52.001,13&geomformat=cmp" returns a route_geometry of "svzdbBurpxWaP~Ecd@`O" which is parsed by my code (see bottom for full code) and the Google Online Utility (https://developers.google.com/maps/documentation/utilities/polylineutility?csw=1) to the following route: [[520.00634, 130.01531], [520.0090700000001, 130.01419], [520.0150100000001, 130.01162000000002]] Those are obviously off by a factor of 10. I currently work around this issue by just dividing the decoded integers by 1e6 instead of 1e5 as specified by Google's Algorithm. Am I missing something or did you deliberately chose to provide coordinates up to a precision of 6 decimal places? Third, the "Server API" wiki page specifies that &checksum=$value should be added to the URI when using coordinate hinting, where $value is drawn from the last query's hint.checksum attribute. I noticed however, that in all responses I checked in the last week (about a good two dozen, which I checked manually) that this value is always 1373382413. Again, am I missing something? If not what point does this value serve? Turned out longer than I expected, hope this is not too much to ask, thanks in advance. ===== Poly.js ===== This is the code I use to parse the route_geometry attribute. If I use it with 1e5 in decodeValue it seems to be consistent with the examples Google provides (https://developers.google.com/maps/documentation/utilities/polylinealgorithm), I only get meaningful results with 1e6 with the responses from the demo server. function decodeValue (val) { var z = 0; for (i = 0; i < val.length; i++) { z += ((val.charCodeAt (i) - 63) % 0x20) << (5 * i); } var neg = z % 2; z >>= 1; if (neg) { z = ~z; } return z / 1e6 // this is supposed to be 1e5 by the google algorithm.. } function decodePolyline (line) { var last_p = [0, 0]; var points = []; var index = 0; while (line != "") { var o = index % 2; var i = 0; for (; (line.charCodeAt (i) - 63) >> 5; i++); i++; var c = line.slice (0, i); line = line.slice (i); var new_c = decodeValue (c); last_p [o] += new_c; if (o == 1) { points [Math.floor (index / 2)] [1] = last_p [1]; } else { points.push ([last_p [0], 0]); } index += 1; } return points; } _______________________________________________ OSRM-talk mailing list [email protected] http://lists.openstreetmap.org/listinfo/osrm-talk
