From 85baf151d9a8cab26aa57116a040232cd10a0d32 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Dec 2024 10:21:23 +0100 Subject: [PATCH] feat: refs #7882 Fixed problems osrm service --- back/methods/osrm-config/optimize.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index 9440800f6..a7c81f33a 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -47,27 +47,26 @@ module.exports = Self => { const latitude = waypoint.location[1]; const matchedAddress = coords.find(coord => - !coord.position && + coord.position === undefined && Math.abs(coord.latitude - latitude) <= tolerance && Math.abs(coord.longitude - longitude) <= tolerance ); if (matchedAddress) matchedAddress.position = waypoint.waypoint_index; - else - console.log(`Las coordenadas no se han podido asociar: ${latitude} | ${longitude}`); } coords.sort((a, b) => { const posA = a.position !== undefined ? a.position : Infinity; const posB = b.position !== undefined ? b.position : Infinity; return posA - posB; }); - // Temporal para abrir en maps + const coordsString = coords .map(item => `point=${item.latitude},${item.longitude}`) .join('&'); - console.log(`https://graphhopper.com/maps/?${coordsString}&profile=small_truck`); - // --------- - return coords; + return { + coords, + view: `https://graphhopper.com/maps/?${coordsString}&profile=small_truck` + }; } catch (err) { switch (err.response?.data?.code) { case 'NoTrips':