@wemap/routers 11.8.3 → 11.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1386,7 +1386,17 @@ class IdfmRemoteRouter extends RemoteRouter {
1386
1386
  error: jsonResponse.error.message || "no details."
1387
1387
  });
1388
1388
  }
1389
- return this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
1389
+ const routerResponse = this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
1390
+ const sameModeFound = routerResponse.itineraries.some((itinerary) => itinerary.legs.every((leg) => leg.mode === mode));
1391
+ if (!sameModeFound) {
1392
+ return new RouterResponse({
1393
+ routerName: this.rname,
1394
+ from: waypoints[0],
1395
+ to: waypoints[1],
1396
+ error: "Selected mode of transport was not found for this itinerary."
1397
+ });
1398
+ }
1399
+ return routerResponse;
1390
1400
  }
1391
1401
  getURL(endpointUrl, mode, waypoints, options) {
1392
1402
  if (waypoints.length > 2) {
@@ -2074,8 +2084,11 @@ class WemapMultiRouter {
2074
2084
  if (mapOfThisWaypoint && map && mapOfThisWaypoint !== map) {
2075
2085
  throw Error(`Cannot handle this itineraries, because two points are on different maps (${mapOfThisWaypoint} and ${mapOfWaypoints}). Multi-map multiple destinations are not implemented.`);
2076
2086
  }
2077
- return mapOfThisWaypoint;
2087
+ return mapOfThisWaypoint || map;
2078
2088
  }, null);
2089
+ if (mapOfWaypoints === null) {
2090
+ throw Error(`No map found for this itineraries.`);
2091
+ }
2079
2092
  const wemapOsmRouterOptions = this.convertOptionsToWemapOsmOptions(options);
2080
2093
  const itineraries = mapOfWaypoints.getItinerariesMultipleDestinationsInsideMap(start, ends, wemapOsmRouterOptions);
2081
2094
  return {