@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.js CHANGED
@@ -1388,7 +1388,17 @@ class IdfmRemoteRouter extends RemoteRouter {
1388
1388
  error: jsonResponse.error.message || "no details."
1389
1389
  });
1390
1390
  }
1391
- return this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
1391
+ const routerResponse = this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
1392
+ const sameModeFound = routerResponse.itineraries.some((itinerary) => itinerary.legs.every((leg) => leg.mode === mode));
1393
+ if (!sameModeFound) {
1394
+ return new RouterResponse({
1395
+ routerName: this.rname,
1396
+ from: waypoints[0],
1397
+ to: waypoints[1],
1398
+ error: "Selected mode of transport was not found for this itinerary."
1399
+ });
1400
+ }
1401
+ return routerResponse;
1392
1402
  }
1393
1403
  getURL(endpointUrl, mode, waypoints, options) {
1394
1404
  if (waypoints.length > 2) {
@@ -2076,8 +2086,11 @@ class WemapMultiRouter {
2076
2086
  if (mapOfThisWaypoint && map && mapOfThisWaypoint !== map) {
2077
2087
  throw Error(`Cannot handle this itineraries, because two points are on different maps (${mapOfThisWaypoint} and ${mapOfWaypoints}). Multi-map multiple destinations are not implemented.`);
2078
2088
  }
2079
- return mapOfThisWaypoint;
2089
+ return mapOfThisWaypoint || map;
2080
2090
  }, null);
2091
+ if (mapOfWaypoints === null) {
2092
+ throw Error(`No map found for this itineraries.`);
2093
+ }
2081
2094
  const wemapOsmRouterOptions = this.convertOptionsToWemapOsmOptions(options);
2082
2095
  const itineraries = mapOfWaypoints.getItinerariesMultipleDestinationsInsideMap(start, ends, wemapOsmRouterOptions);
2083
2096
  return {