X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2b252e8337109de714bb8aa38ccf6d46e7686e42..6b0d4dcab2c72397dbbabd768e47323c0e2e42b2:/app/assets/javascripts/index/directions_engines/osrm.js?ds=inline diff --git a/app/assets/javascripts/index/directions_engines/osrm.js b/app/assets/javascripts/index/directions_engines/osrm.js index ebcbf1fb1..69b78c25e 100644 --- a/app/assets/javascripts/index/directions_engines/osrm.js +++ b/app/assets/javascripts/index/directions_engines/osrm.js @@ -2,12 +2,14 @@ // Doesn't yet support hints function OSRMEngine() { + var previousPoints, hintData; + return { - name: "javascripts.directions.engines.osrm_car", + id: "osrm_car", creditline: 'OSRM', draggable: true, - getRoute: function (isFinal, points, callback) { + getRoute: function (points, callback) { var TURN_INSTRUCTIONS = [ "", I18n.t('javascripts.directions.instructions.continue_on'), // 1 @@ -29,14 +31,18 @@ function OSRMEngine() { I18n.t('javascripts.directions.instructions.end_oneway') // 17 ]; - var url = "http://router.project-osrm.org/viaroute?z=14&output=json"; + var url = "http://router.project-osrm.org/viaroute?z=14&output=json&instructions=true"; for (var i = 0; i < points.length; i++) { url += "&loc=" + points[i].lat + ',' + points[i].lng; + if (hintData && previousPoints && previousPoints[i].equals(points[i])) { + url += "&hint=" + hintData.locations[i]; + } } - if (isFinal) - url += "&instructions=true"; + if (hintData && hintData.checksum) { + url += "&checksum=" + hintData.checksum; + } $.ajax({ url: url, @@ -45,6 +51,9 @@ function OSRMEngine() { if (data.status == 207) return callback(true); + previousPoints = points; + hintData = data.hint_data; + var line = L.PolylineUtil.decode(data.route_geometry); for (var i = 0; i < line.length; i++) { line[i].lat /= 10;