@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/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/routers"
13
13
  },
14
14
  "name": "@wemap/routers",
15
- "version": "11.8.3",
15
+ "version": "11.8.5",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -52,5 +52,5 @@
52
52
  },
53
53
  "./helpers/*": "./helpers/*"
54
54
  },
55
- "gitHead": "397bf109830445141c90a8222bbcde98bc567f01"
55
+ "gitHead": "b811f47998e121da18d85857c9a1ddd1ae25c53b"
56
56
  }
@@ -54,6 +54,9 @@ type IdfmJson = {
54
54
  }[],
55
55
  context: {
56
56
  timezone: string
57
+ };
58
+ error: {
59
+ message?: string;
57
60
  }
58
61
  };
59
62
 
@@ -172,7 +175,7 @@ class IdfmRemoteRouter extends RemoteRouter {
172
175
  }));
173
176
 
174
177
 
175
- const jsonResponse = await res.json().catch(() => {
178
+ const jsonResponse: IdfmJson = await res.json().catch(() => {
176
179
  throw new RemoteRouterServerUnreachable(this.rname, url);
177
180
  });
178
181
 
@@ -188,7 +191,19 @@ class IdfmRemoteRouter extends RemoteRouter {
188
191
  });
189
192
  }
190
193
 
191
- return this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
194
+ const routerResponse = this.createRouterResponseFromJson(jsonResponse, waypoints[0], waypoints[1]);
195
+
196
+ const sameModeFound = routerResponse.itineraries.some((itinerary) => itinerary.legs.every((leg) => leg.mode === mode));
197
+ if (!sameModeFound) {
198
+ return new RouterResponse({
199
+ routerName: this.rname,
200
+ from: waypoints[0],
201
+ to: waypoints[1],
202
+ error: 'Selected mode of transport was not found for this itinerary.'
203
+ });
204
+ }
205
+
206
+ return routerResponse;
192
207
  }
193
208
 
194
209
  getURL(endpointUrl: string, mode: RoutingMode, waypoints: Coordinates[], options: RemoteRouterOptions) {
@@ -115,13 +115,17 @@ class WemapMultiRouter {
115
115
  throw Error(`Cannot handle this itineraries, because two points are on different maps (${mapOfThisWaypoint} and ${mapOfWaypoints}). ` +
116
116
  `Multi-map multiple destinations are not implemented.`)
117
117
  }
118
- return mapOfThisWaypoint
118
+ return mapOfThisWaypoint || map
119
119
  }, null as CustomNetworkMap | null);
120
120
 
121
+ if (mapOfWaypoints === null) {
122
+ throw Error(`No map found for this itineraries.`)
123
+ }
124
+
121
125
  // Create WemapOsmRouterOptions from WemapMultiRouterOptions
122
126
  const wemapOsmRouterOptions = this.convertOptionsToWemapOsmOptions(options);
123
127
 
124
- const itineraries = mapOfWaypoints!.getItinerariesMultipleDestinationsInsideMap(start, ends, wemapOsmRouterOptions);
128
+ const itineraries = mapOfWaypoints.getItinerariesMultipleDestinationsInsideMap(start, ends, wemapOsmRouterOptions);
125
129
 
126
130
  return {
127
131
  routerName: this.rname,