Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/osrm-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@
}

actualWaypoints = this._toWaypoints(inputWaypoints, response.waypoints);

for (i = 0; i < response.routes.length; i++) {
route = this._convertRoute(response.routes[i]);
//Mapbox optimization route returns trips instead of routes
let routes = response.routes || response.trips;
for (i = 0; i < routes.length; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some indentation mistake here, perhaps spaces/tabs getting mixed up?

route = this._convertRoute(routes[i]);
route.inputWaypoints = inputWaypoints;
route.waypoints = actualWaypoints;
route.properties = {isSimplified: !options || !options.geometryOnly || options.simplifyGeometry};
Expand Down Expand Up @@ -331,12 +332,14 @@
},

buildRouteUrl: function(waypoints, options) {

var locs = [],
hints = [],
wp,
latLng,
computeInstructions,
computeAlternative = true;
computeInstructions = options.steps && options.steps !== "default" ? true : false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this new "default" mean? How is it intended to be used?

computeRoundtrip = options.roundtrip && options.roundtrip !== "default" ? true : false,
computeAlternative = options.alternatives && options.alternatives !== "default" ? true : false;

for (var i = 0; i < waypoints.length; i++) {
wp = waypoints[i];
Expand All @@ -345,14 +348,13 @@
hints.push(this._hints.locations[this._locationKey(latLng)] || '');
}

computeInstructions =
true;

return this.options.serviceUrl + '/' + this.options.profile + '/' +
locs.join(';') + '?' +
(options.geometryOnly ? (options.simplifyGeometry ? '' : 'overview=full') : 'overview=false') +
'&alternatives=' + computeAlternative.toString() +
'&steps=' + computeInstructions.toString() +
(computeInstructions ? '&steps=' + (typeof options.steps == "boolean" ? options.steps : true).toString() : '') +
(computeRoundtrip ? '&roundtrip=' + (typeof options.roundtrip == "boolean" ? options.roundtrip : false).toString() : '') +
(computeAlternative ? '&alternatives=' + (typeof options.alternatives == "boolean" ? options.alternatives : true).toString() : '') +
(this.options.useHints ? '&hints=' + hints.join(';') : '') +
(options.allowUTurns ? '&continue_straight=' + !options.allowUTurns : '');
},
Expand Down