@wemap/routers 12.7.5 → 12.7.6
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/assets/itinerary-paris-idfm-2.json +1032 -26921
- package/assets/itinerary-paris-idfm.json +25421 -7140
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/model/TransitMode.spec.ts +1 -1
- package/src/model/TransitMode.ts +10 -1
- package/src/remote/idfm/IdfmRemoteRouter.spec.ts +46 -34
- package/src/remote/idfm/IdfmRemoteRouter.ts +61 -11
package/dist/index.js
CHANGED
|
@@ -322,7 +322,7 @@ function isTransitModePublicTransport(transitMode) {
|
|
|
322
322
|
].includes(transitMode);
|
|
323
323
|
}
|
|
324
324
|
function areTransitAndTravelModeConsistent(transitMode, travelMode) {
|
|
325
|
-
return transitMode === travelMode || isTransitModePublicTransport(transitMode) && travelMode === "TRANSIT";
|
|
325
|
+
return transitMode === travelMode || isTransitModePublicTransport(transitMode) && travelMode === "TRANSIT" || transitMode === "WALK" && travelMode === "TRANSIT";
|
|
326
326
|
}
|
|
327
327
|
function stepToJson(step) {
|
|
328
328
|
return {
|
|
@@ -3434,6 +3434,16 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
3434
3434
|
}
|
|
3435
3435
|
return outputSteps;
|
|
3436
3436
|
}
|
|
3437
|
+
findStepCoords(step, section) {
|
|
3438
|
+
var _a;
|
|
3439
|
+
if ("instruction_start_coordinate" in step) {
|
|
3440
|
+
return jsonToCoordinates$1(step.instruction_start_coordinate);
|
|
3441
|
+
}
|
|
3442
|
+
const via = (_a = section.vias) == null ? void 0 : _a.find((via2) => via2.id === step.via_uri);
|
|
3443
|
+
if (via) {
|
|
3444
|
+
return jsonToCoordinates$1(via.access_point.coord);
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3437
3447
|
parseResponse(json) {
|
|
3438
3448
|
var _a;
|
|
3439
3449
|
if (!json || !json.journeys) {
|
|
@@ -3460,14 +3470,28 @@ class IdfmRemoteRouter extends RemoteRouter {
|
|
|
3460
3470
|
let transportInfo;
|
|
3461
3471
|
let transitMode = transitModeCorrespondance.get(jsonSection.mode);
|
|
3462
3472
|
if (jsonSection.path) {
|
|
3473
|
+
const useIDFMSteps = jsonSection.path.every((step) => "instruction_start_coordinate" in step || step.via_uri);
|
|
3463
3474
|
const idfmIntermediateSteps = [];
|
|
3464
3475
|
for (const jsonPathLink of jsonSection.path) {
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3476
|
+
let coords;
|
|
3477
|
+
if (useIDFMSteps) {
|
|
3478
|
+
coords = this.findStepCoords(jsonPathLink, jsonSection);
|
|
3479
|
+
const intermediateStep = {
|
|
3480
|
+
name: jsonPathLink.name,
|
|
3481
|
+
distance: jsonPathLink.length,
|
|
3482
|
+
coords
|
|
3483
|
+
};
|
|
3484
|
+
stepsBuilder.addStepInfo(intermediateStep);
|
|
3485
|
+
} else {
|
|
3486
|
+
idfmIntermediateSteps.push({
|
|
3487
|
+
name: jsonPathLink.name,
|
|
3488
|
+
distance: jsonPathLink.length
|
|
3489
|
+
});
|
|
3490
|
+
}
|
|
3491
|
+
}
|
|
3492
|
+
if (!useIDFMSteps) {
|
|
3493
|
+
stepsBuilder.setStepsInfo(this.findStepsCoord(legCoords, idfmIntermediateSteps));
|
|
3469
3494
|
}
|
|
3470
|
-
stepsBuilder.setStepsInfo(this.findStepsCoord(legCoords, idfmIntermediateSteps));
|
|
3471
3495
|
}
|
|
3472
3496
|
if (jsonSection.type === "public_transport") {
|
|
3473
3497
|
transportInfo = {
|