@wemap/routers 7.4.0 → 7.5.1
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/wemap-routers.es.js +379 -237
- package/dist/wemap-routers.es.js.map +1 -1
- package/package.json +5 -5
- package/src/model/RouterResponse.js +1 -1
- package/src/remote/cityway/CitywayRemoteRouter.js +10 -10
- package/src/remote/deutsche-bahn/DeutscheBahnRemoteRouter.js +10 -11
- package/src/remote/idfm/IdfmRemoteRouter.js +9 -8
- package/src/remote/osrm/OsrmRemoteRouter.js +13 -15
- package/src/remote/otp/OtpRemoteRouter.js +8 -9
- package/src/wemap-meta/WemapMetaRouter.js +1 -1
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/routers"
|
|
12
12
|
},
|
|
13
13
|
"name": "@wemap/routers",
|
|
14
|
-
"version": "7.
|
|
14
|
+
"version": "7.5.1",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
17
17
|
},
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@turf/boolean-point-in-polygon": "^6.5.0",
|
|
30
30
|
"@turf/convex": "^6.5.0",
|
|
31
31
|
"@turf/helpers": "^6.5.0",
|
|
32
|
-
"@wemap/geo": "^7.
|
|
32
|
+
"@wemap/geo": "^7.5.0",
|
|
33
33
|
"@wemap/logger": "^7.0.0",
|
|
34
|
-
"@wemap/maths": "^7.
|
|
35
|
-
"@wemap/osm": "^7.
|
|
34
|
+
"@wemap/maths": "^7.5.0",
|
|
35
|
+
"@wemap/osm": "^7.5.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "8bb7768dce76ad5aef46128c4761505725fb0105"
|
|
38
38
|
}
|
|
@@ -100,7 +100,7 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
100
100
|
const jsonResponse = await res.json().catch(() => {
|
|
101
101
|
throw new RemoteRouterServerUnreachable(this.rname, url);
|
|
102
102
|
});
|
|
103
|
-
return this.createRouterResponseFromJson(jsonResponse);
|
|
103
|
+
return this.createRouterResponseFromJson(jsonResponse, waypoints);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
|
|
@@ -132,17 +132,20 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
132
132
|
/**
|
|
133
133
|
* Generate multi itineraries from Cityway JSON
|
|
134
134
|
* @param {object} json JSON file provided by Cityway.
|
|
135
|
-
* @
|
|
135
|
+
* @param {Array<Coordinates>} waypoints
|
|
136
|
+
* @returns {!RouterResponse}
|
|
136
137
|
* @example https://preprod.api.lia2.cityway.fr/journeyplanner/api/opt/PlanTrips/json?DepartureLatitude=49.51509388236216&DepartureLongitude=0.09341749619366316&ArrivalLatitude=49.5067090188444&ArrivalLongitude=0.1694842115417831&DepartureType=COORDINATES&ArrivalType=COORDINATES
|
|
137
138
|
*/
|
|
138
|
-
createRouterResponseFromJson(json) {
|
|
139
|
-
|
|
140
|
-
if (json.StatusCode !== 200 || !json.Data || !json.Data.length) {
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
139
|
+
createRouterResponseFromJson(json, waypoints) {
|
|
143
140
|
|
|
144
141
|
const routerResponse = new RouterResponse();
|
|
145
142
|
routerResponse.routerName = this.rname;
|
|
143
|
+
routerResponse.from = waypoints[0];
|
|
144
|
+
routerResponse.to = waypoints[1];
|
|
145
|
+
|
|
146
|
+
if (json.StatusCode !== 200 || !json.Data || !json.Data.length) {
|
|
147
|
+
return routerResponse;
|
|
148
|
+
}
|
|
146
149
|
|
|
147
150
|
|
|
148
151
|
// Do not know if it the best approach, but it works...
|
|
@@ -302,9 +305,6 @@ class CitywayRemoteRouter extends RemoteRouter {
|
|
|
302
305
|
generateStepsMetadata(itinerary);
|
|
303
306
|
}
|
|
304
307
|
|
|
305
|
-
routerResponse.from = routerResponse.itineraries[0].from;
|
|
306
|
-
routerResponse.to = routerResponse.itineraries[routerResponse.itineraries.length - 1].to;
|
|
307
|
-
|
|
308
308
|
return routerResponse;
|
|
309
309
|
}
|
|
310
310
|
|
|
@@ -64,23 +64,22 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
|
|
|
64
64
|
/**
|
|
65
65
|
* Generate multi itineraries from the DB JSON
|
|
66
66
|
* @param {object} json JSON file provided by the DB.
|
|
67
|
-
* @param {Coordinates}
|
|
68
|
-
* @
|
|
69
|
-
* @returns {?RouterResponse}
|
|
67
|
+
* @param {Coordinates[]} waypoints
|
|
68
|
+
* @returns {!RouterResponse}
|
|
70
69
|
*/
|
|
71
|
-
createRouterResponseFromJson(json,
|
|
70
|
+
createRouterResponseFromJson(json, waypoints) {
|
|
71
|
+
|
|
72
|
+
const routerResponse = new RouterResponse();
|
|
73
|
+
routerResponse.routerName = this.rname;
|
|
74
|
+
routerResponse.from = waypoints[0];
|
|
75
|
+
routerResponse.to = waypoints[1];
|
|
72
76
|
|
|
73
77
|
const { segments: jsonSegments } = json;
|
|
74
78
|
|
|
75
79
|
if (!jsonSegments) {
|
|
76
|
-
return
|
|
80
|
+
return routerResponse;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
const routerResponse = new RouterResponse();
|
|
80
|
-
routerResponse.routerName = this.rname;
|
|
81
|
-
|
|
82
|
-
routerResponse.from = from;
|
|
83
|
-
routerResponse.to = to;
|
|
84
83
|
|
|
85
84
|
/** @type {GraphEdge<OsmElement>[]} */
|
|
86
85
|
const edges = [];
|
|
@@ -129,7 +128,7 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
|
|
|
129
128
|
graphItinerary.end = nodes[nodes.length - 1].coords;
|
|
130
129
|
|
|
131
130
|
const points = nodes.map(node => node.coords);
|
|
132
|
-
const itinerary = Itinerary.fromOrderedCoordinates(points,
|
|
131
|
+
const itinerary = Itinerary.fromOrderedCoordinates(points, waypoints[0], waypoints[1]);
|
|
133
132
|
itinerary.legs[0].steps = StepsGeneration.fromGraphItinerary(graphItinerary);
|
|
134
133
|
itinerary.legs[0].steps.map((step, idx) => (step._idCoordsInLeg = idx));
|
|
135
134
|
|
|
@@ -127,7 +127,7 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
127
127
|
return routerResponse;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
return this.createRouterResponseFromJson(jsonResponse);
|
|
130
|
+
return this.createRouterResponseFromJson(jsonResponse, waypoints);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
@@ -327,19 +327,20 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
327
327
|
/**
|
|
328
328
|
* Generate multi itineraries from OTP JSON
|
|
329
329
|
* @param {object} json JSON file provided by OTP.
|
|
330
|
+
* @param {Coordinates[]} waypoints
|
|
330
331
|
* @returns {?RouterResponse}
|
|
331
332
|
*/
|
|
332
|
-
createRouterResponseFromJson(json) {
|
|
333
|
-
|
|
334
|
-
if (!json || !json.journeys) {
|
|
335
|
-
return null;
|
|
336
|
-
}
|
|
333
|
+
createRouterResponseFromJson(json, waypoints) {
|
|
337
334
|
|
|
338
335
|
const routerResponse = new RouterResponse();
|
|
339
336
|
routerResponse.routerName = this.rname;
|
|
337
|
+
routerResponse.from = waypoints[0];
|
|
338
|
+
routerResponse.to = waypoints[1];
|
|
339
|
+
|
|
340
|
+
if (!json || !json.journeys) {
|
|
341
|
+
return routerResponse;
|
|
342
|
+
}
|
|
340
343
|
|
|
341
|
-
routerResponse.from = this.getSectionCoords(json.journeys[0].sections[0]).from;
|
|
342
|
-
routerResponse.to = this.getSectionCoords(last(json.journeys[0].sections)).to;
|
|
343
344
|
|
|
344
345
|
const timeZone = json.context.timezone;
|
|
345
346
|
|
|
@@ -53,7 +53,7 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
53
53
|
throw new RemoteRouterServerUnreachable(this.rname, url);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
return this.createRouterResponseFromJson(jsonResponse, waypoints
|
|
56
|
+
return this.createRouterResponseFromJson(jsonResponse, waypoints);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
@@ -259,16 +259,20 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
259
259
|
/**
|
|
260
260
|
* Generate multi itineraries from OSRM JSON
|
|
261
261
|
* @param {object} json JSON file provided by OSRM.
|
|
262
|
-
* @param {Coordinates}
|
|
263
|
-
* @param {Coordinates} to itinerary end
|
|
262
|
+
* @param {Coordinates[]} waypoints
|
|
264
263
|
* @param {?string} routingMode [walking|driving|bicycle]
|
|
265
|
-
* @returns {
|
|
264
|
+
* @returns {!RouterResponse}
|
|
266
265
|
*/
|
|
267
|
-
createRouterResponseFromJson(json,
|
|
268
|
-
const { routes: jsonRoutes } = json;
|
|
266
|
+
createRouterResponseFromJson(json, waypoints, routingMode = 'walking') {
|
|
269
267
|
|
|
268
|
+
const routerResponse = new RouterResponse();
|
|
269
|
+
routerResponse.routerName = this.rname;
|
|
270
|
+
routerResponse.from = waypoints[0];
|
|
271
|
+
routerResponse.to = waypoints[1];
|
|
272
|
+
|
|
273
|
+
const { routes: jsonRoutes } = json;
|
|
270
274
|
if (!jsonRoutes) {
|
|
271
|
-
return
|
|
275
|
+
return routerResponse;
|
|
272
276
|
}
|
|
273
277
|
|
|
274
278
|
const routingModeCorrespondance = new Map();
|
|
@@ -277,12 +281,6 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
277
281
|
routingModeCorrespondance.set('bicycle', 'BIKE');
|
|
278
282
|
const mode = routingModeCorrespondance.get(routingMode) || null;
|
|
279
283
|
|
|
280
|
-
const routerResponse = new RouterResponse();
|
|
281
|
-
routerResponse.routerName = this.rname;
|
|
282
|
-
|
|
283
|
-
routerResponse.from = from;
|
|
284
|
-
routerResponse.to = to;
|
|
285
|
-
|
|
286
284
|
for (const jsonItinerary of jsonRoutes) {
|
|
287
285
|
|
|
288
286
|
const itinerary = new Itinerary();
|
|
@@ -290,8 +288,8 @@ class OsrmRemoteRouter extends RemoteRouter {
|
|
|
290
288
|
// itinerary.coords = jsonItinerary.geometry.coordinates.map(jsonToCoordinates);
|
|
291
289
|
itinerary.distance = jsonItinerary.distance;
|
|
292
290
|
itinerary.duration = jsonItinerary.duration;
|
|
293
|
-
itinerary.from =
|
|
294
|
-
itinerary.to =
|
|
291
|
+
itinerary.from = waypoints[0];
|
|
292
|
+
itinerary.to = waypoints[1];
|
|
295
293
|
|
|
296
294
|
routerResponse.itineraries.push(itinerary);
|
|
297
295
|
|
|
@@ -127,21 +127,20 @@ class OtpRemoteRouter extends RemoteRouter {
|
|
|
127
127
|
/**
|
|
128
128
|
* Generate multi itineraries from OTP JSON
|
|
129
129
|
* @param {object} json JSON file provided by OTP.
|
|
130
|
+
* @param {Coordinates[]} waypoints
|
|
130
131
|
* @returns {?RouterResponse}
|
|
131
132
|
*/
|
|
132
|
-
createRouterResponseFromJson(json) {
|
|
133
|
-
|
|
134
|
-
const { plan: jsonPlan } = json;
|
|
135
|
-
|
|
136
|
-
if (!jsonPlan) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
133
|
+
createRouterResponseFromJson(json, waypoints) {
|
|
139
134
|
|
|
140
135
|
const routerResponse = new RouterResponse();
|
|
141
136
|
routerResponse.routerName = this.rname;
|
|
137
|
+
routerResponse.from = waypoints[0];
|
|
138
|
+
routerResponse.to = waypoints[1];
|
|
142
139
|
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
const { plan: jsonPlan } = json;
|
|
141
|
+
if (!jsonPlan) {
|
|
142
|
+
return routerResponse;
|
|
143
|
+
}
|
|
145
144
|
|
|
146
145
|
for (const jsonItinerary of jsonPlan.itineraries) {
|
|
147
146
|
|
|
@@ -44,7 +44,7 @@ class WemapMetaRouter {
|
|
|
44
44
|
* @param {string} mode see Constants.ROUTING_MODE
|
|
45
45
|
* @param {Coordinates[]} waypoints
|
|
46
46
|
* @param {WemapMetaRouterOptions} options
|
|
47
|
-
* @returns {RouterResponse}
|
|
47
|
+
* @returns {!RouterResponse}
|
|
48
48
|
*/
|
|
49
49
|
async getItineraries(mode, waypoints, options) {
|
|
50
50
|
|