@wemap/routers 12.7.5 → 12.7.7

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
@@ -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 {
@@ -2630,7 +2630,6 @@ class GraphRouter extends GraphRouterEngine {
2630
2630
  newVertex.id = this.graph.vertices.length + createdVertices.size;
2631
2631
  const newEdgesOptions = {
2632
2632
  ...edge.properties,
2633
- name: `splitted ${edge.properties.name || null} (tmp)`,
2634
2633
  ...typeof edge.properties.externalId !== "undefined" && { externalId: edge.properties.externalId }
2635
2634
  };
2636
2635
  const newEdge1 = new Edge(edge.vertex1, newVertex, newEdgesOptions);
@@ -3434,6 +3433,16 @@ class IdfmRemoteRouter extends RemoteRouter {
3434
3433
  }
3435
3434
  return outputSteps;
3436
3435
  }
3436
+ findStepCoords(step, section) {
3437
+ var _a;
3438
+ if ("instruction_start_coordinate" in step) {
3439
+ return jsonToCoordinates$1(step.instruction_start_coordinate);
3440
+ }
3441
+ const via = (_a = section.vias) == null ? void 0 : _a.find((via2) => via2.id === step.via_uri);
3442
+ if (via) {
3443
+ return jsonToCoordinates$1(via.access_point.coord);
3444
+ }
3445
+ }
3437
3446
  parseResponse(json) {
3438
3447
  var _a;
3439
3448
  if (!json || !json.journeys) {
@@ -3460,14 +3469,28 @@ class IdfmRemoteRouter extends RemoteRouter {
3460
3469
  let transportInfo;
3461
3470
  let transitMode = transitModeCorrespondance.get(jsonSection.mode);
3462
3471
  if (jsonSection.path) {
3472
+ const useIDFMSteps = jsonSection.path.every((step) => "instruction_start_coordinate" in step || step.via_uri);
3463
3473
  const idfmIntermediateSteps = [];
3464
3474
  for (const jsonPathLink of jsonSection.path) {
3465
- idfmIntermediateSteps.push({
3466
- name: jsonPathLink.name,
3467
- distance: jsonPathLink.length
3468
- });
3475
+ let coords;
3476
+ if (useIDFMSteps) {
3477
+ coords = this.findStepCoords(jsonPathLink, jsonSection);
3478
+ const intermediateStep = {
3479
+ name: jsonPathLink.name,
3480
+ distance: jsonPathLink.length,
3481
+ coords
3482
+ };
3483
+ stepsBuilder.addStepInfo(intermediateStep);
3484
+ } else {
3485
+ idfmIntermediateSteps.push({
3486
+ name: jsonPathLink.name,
3487
+ distance: jsonPathLink.length
3488
+ });
3489
+ }
3490
+ }
3491
+ if (!useIDFMSteps) {
3492
+ stepsBuilder.setStepsInfo(this.findStepsCoord(legCoords, idfmIntermediateSteps));
3469
3493
  }
3470
- stepsBuilder.setStepsInfo(this.findStepsCoord(legCoords, idfmIntermediateSteps));
3471
3494
  }
3472
3495
  if (jsonSection.type === "public_transport") {
3473
3496
  transportInfo = {