Skip to content

Commit

Permalink
Fixed OSRM native response's waypoints, and intersections geometry fo…
Browse files Browse the repository at this point in the history
…rmat.
  • Loading branch information
XavDmz committed Jan 18, 2024
1 parent 300c00f commit d9d931b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/js/apis/osrm/1.0.0/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,4 @@ module.exports = {
return userResponse;
}

}
}
18 changes: 10 additions & 8 deletions src/js/sources/osrmSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,15 @@ module.exports = class osrmSource extends Source {
LOGGER.debug("osrm response has 1 or more routes");
}

for (let sourceWaypoint in osrmResponse.waypoints) {
let nativeWaypoint = {
"hint": sourceWaypoint.hint,
"distance": sourceWaypoint.distance,
"name": sourceWaypoint.name
for (let waypointIdx = 0; waypointIdx < osrmResponse.waypoints.length; waypointIdx++) {
engineExtras.waypoints[waypointIdx] = {
"hint": osrmResponse.waypoints[waypointIdx].hint,
"distance": osrmResponse.waypoints[waypointIdx].distance,
"name": osrmResponse.waypoints[waypointIdx].name
};
engineExtras.waypoints.push(nativeWaypoint);
}
LOGGER.debug("OSRM engineExtras waypoints (before adding to routeResponse:");
LOGGER.debug(engineExtras.waypoints);

// routes
// Il peut y avoir plusieurs itinéraires
Expand Down Expand Up @@ -556,10 +557,11 @@ module.exports = class osrmSource extends Source {
for (let intersectionIndex = 0; intersectionIndex < currentOsrmRouteStep.intersections.length; intersectionIndex++) {
let currentIntersection = currentOsrmRouteStep.intersections[intersectionIndex];
nativeIntersections[intersectionIndex] = copyManager.deepCopy(currentIntersection);
nativeIntersections[intersectionIndex].location = new Point(currentIntersection.location[0], currentIntersection.location[1], super.projection)
if (!nativeIntersections[intersectionIndex].location.transform(askedProjection)) {
let location = new Point(currentIntersection.location[0], currentIntersection.location[1], super.projection);
if (!location.transform(askedProjection)) {
throw errorManager.createError(" Error during reprojection of intersection in OSRM response. ");
}
nativeIntersections[intersectionIndex].location = [location.x, location.y];
}
nativeSteps[k].intersections = nativeIntersections;
}
Expand Down

0 comments on commit d9d931b

Please sign in to comment.