@wemap/routers 12.8.8 → 12.8.10

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.mjs CHANGED
@@ -447,7 +447,7 @@ class StepsBuilder {
447
447
  const forceEndOfLevelChange = Boolean(
448
448
  previousEdgeProperties.incline && previousEdgeProperties.areStairs && (!incline || !areStairs)
449
449
  );
450
- const createNewStep = vertex.properties.isSubwayEntrance;
450
+ const isEntrance = vertex.properties.isSubwayEntrance;
451
451
  const stepName = edge.properties.name || null;
452
452
  const duration = graphRoute.edgesWeights[i];
453
453
  const stepExtras = {
@@ -459,7 +459,7 @@ class StepsBuilder {
459
459
  const splitByLevel = Level.isRange(edge.level) && !Level.isRange(currentCoords.level) || forceLevelChange;
460
460
  splitByAngle = splitByAngle && !(currentCoords.level && Level.isRange(currentCoords.level));
461
461
  const splitByEndOfLevelChange = (previousStep == null ? void 0 : previousStep.levelChange) && !Level.isRange(currentCoords.level) || forceEndOfLevelChange;
462
- const splitStepCondition = splitByAngle || splitByLevel || splitByEndOfLevelChange || createNewStep;
462
+ const splitStepCondition = splitByAngle || splitByLevel || splitByEndOfLevelChange || isEntrance;
463
463
  if (isFirstStep || splitStepCondition) {
464
464
  let levelChange;
465
465
  if (splitByLevel) {
@@ -2786,7 +2786,10 @@ const _OsmGraphUtils = class _OsmGraphUtils {
2786
2786
  })) == null ? void 0 : _a[1]) || null;
2787
2787
  if (vertex) {
2788
2788
  if (!Level.equals(vertex.coords.level, nodeLevel)) {
2789
- vertex.coords.level = Level.intersection(vertex.coords.level, nodeLevel) || nodeLevel;
2789
+ vertex.coords.level = Level.intersection(vertex.coords.level, nodeLevel);
2790
+ if (vertex.coords.level === null) {
2791
+ vertex.coords.level = nodeLevel;
2792
+ }
2790
2793
  }
2791
2794
  return vertex;
2792
2795
  }
@@ -2873,6 +2876,7 @@ var StatusCode = /* @__PURE__ */ ((StatusCode2) => {
2873
2876
  StatusCode2[StatusCode2["UNIMPLEMENTED"] = 12] = "UNIMPLEMENTED";
2874
2877
  StatusCode2[StatusCode2["INTERNAL"] = 13] = "INTERNAL";
2875
2878
  StatusCode2[StatusCode2["UNAVAILABLE"] = 14] = "UNAVAILABLE";
2879
+ StatusCode2[StatusCode2["UNAUTHENTICATED"] = 16] = "UNAUTHENTICATED";
2876
2880
  return StatusCode2;
2877
2881
  })(StatusCode || {});
2878
2882
  class RoutingError extends Error {
@@ -2906,6 +2910,9 @@ class RemoteRoutingError extends RoutingError {
2906
2910
  static notFound(routerName, details) {
2907
2911
  return new RemoteRoutingError(StatusCode.NOT_FOUND, routerName, `Cannot found an itinerary with ${routerName}. Details: ${details}`);
2908
2912
  }
2913
+ static missingApiKey(routerName, details) {
2914
+ return new RemoteRoutingError(StatusCode.UNAUTHENTICATED, routerName, `API key is missing for ${routerName}. Details: ${details}`);
2915
+ }
2909
2916
  static unreachableServer(routerName, url) {
2910
2917
  return new RemoteRoutingError(StatusCode.NOT_FOUND, routerName, `Remote router server ${routerName} is unreachable. URL: ${url}`);
2911
2918
  }
@@ -2924,7 +2931,7 @@ function dateWithTimeZone(year, month, day, hour, minute, second, timeZone = "Eu
2924
2931
  date.setTime(date.getTime() + offset);
2925
2932
  return date;
2926
2933
  }
2927
- function jsonToCoordinates$2(json) {
2934
+ function jsonToCoordinates$3(json) {
2928
2935
  return new Coordinates(json.Lat, json.Long);
2929
2936
  }
2930
2937
  function jsonDateToTimestamp(jsonDate) {
@@ -2945,29 +2952,29 @@ inputModeCorrespondance$1.set("CAR", "Car");
2945
2952
  inputModeCorrespondance$1.set("WALK", "Walk");
2946
2953
  inputModeCorrespondance$1.set("BIKE", "Bike");
2947
2954
  inputModeCorrespondance$1.set("TRANSIT", "PT");
2948
- const transitModeCorrespondance$2 = /* @__PURE__ */ new Map();
2949
- transitModeCorrespondance$2.set("WALK", "WALK");
2950
- transitModeCorrespondance$2.set("BICYCLE", "BIKE");
2951
- transitModeCorrespondance$2.set("TRAMWAY", "TRAM");
2952
- transitModeCorrespondance$2.set("METRO", "METRO");
2953
- transitModeCorrespondance$2.set("FUNICULAR", "FUNICULAR");
2954
- transitModeCorrespondance$2.set("BUS", "BUS");
2955
- transitModeCorrespondance$2.set("COACH", "BUS");
2956
- transitModeCorrespondance$2.set("SCHOOL", "BUS");
2957
- transitModeCorrespondance$2.set("BUS_PMR", "BUS");
2958
- transitModeCorrespondance$2.set("MINIBUS", "BUS");
2959
- transitModeCorrespondance$2.set("TROLLEY_BUS", "BUS");
2960
- transitModeCorrespondance$2.set("TAXIBUS", "BUS");
2961
- transitModeCorrespondance$2.set("SHUTTLE", "BUS");
2962
- transitModeCorrespondance$2.set("TRAIN", "TRAIN");
2963
- transitModeCorrespondance$2.set("HST", "TRAIN");
2964
- transitModeCorrespondance$2.set("LOCAL_TRAIN", "TRAIN");
2965
- transitModeCorrespondance$2.set("AIR", "AIRPLANE");
2966
- transitModeCorrespondance$2.set("FERRY", "BOAT");
2967
- transitModeCorrespondance$2.set("TAXI", "UNKNOWN");
2968
- transitModeCorrespondance$2.set("CAR_POOL", "UNKNOWN");
2969
- transitModeCorrespondance$2.set("PRIVATE_VEHICLE", "CAR");
2970
- transitModeCorrespondance$2.set("SCOOTER", "MOTO");
2955
+ const transitModeCorrespondance$3 = /* @__PURE__ */ new Map();
2956
+ transitModeCorrespondance$3.set("WALK", "WALK");
2957
+ transitModeCorrespondance$3.set("BICYCLE", "BIKE");
2958
+ transitModeCorrespondance$3.set("TRAMWAY", "TRAM");
2959
+ transitModeCorrespondance$3.set("METRO", "METRO");
2960
+ transitModeCorrespondance$3.set("FUNICULAR", "FUNICULAR");
2961
+ transitModeCorrespondance$3.set("BUS", "BUS");
2962
+ transitModeCorrespondance$3.set("COACH", "BUS");
2963
+ transitModeCorrespondance$3.set("SCHOOL", "BUS");
2964
+ transitModeCorrespondance$3.set("BUS_PMR", "BUS");
2965
+ transitModeCorrespondance$3.set("MINIBUS", "BUS");
2966
+ transitModeCorrespondance$3.set("TROLLEY_BUS", "BUS");
2967
+ transitModeCorrespondance$3.set("TAXIBUS", "BUS");
2968
+ transitModeCorrespondance$3.set("SHUTTLE", "BUS");
2969
+ transitModeCorrespondance$3.set("TRAIN", "TRAIN");
2970
+ transitModeCorrespondance$3.set("HST", "TRAIN");
2971
+ transitModeCorrespondance$3.set("LOCAL_TRAIN", "TRAIN");
2972
+ transitModeCorrespondance$3.set("AIR", "AIRPLANE");
2973
+ transitModeCorrespondance$3.set("FERRY", "BOAT");
2974
+ transitModeCorrespondance$3.set("TAXI", "UNKNOWN");
2975
+ transitModeCorrespondance$3.set("CAR_POOL", "UNKNOWN");
2976
+ transitModeCorrespondance$3.set("PRIVATE_VEHICLE", "CAR");
2977
+ transitModeCorrespondance$3.set("SCOOTER", "MOTO");
2971
2978
  const planTripType = /* @__PURE__ */ new Map();
2972
2979
  planTripType.set(0, "BUS");
2973
2980
  planTripType.set(1, "WALK");
@@ -3050,7 +3057,7 @@ class CitywayRemoteRouter extends RemoteRouter {
3050
3057
  const legs = [];
3051
3058
  for (const jsonSection of trip.sections.Section) {
3052
3059
  const jsonLeg = jsonSection.Leg ? jsonSection.Leg : jsonSection.PTRide;
3053
- const legMode = transitModeCorrespondance$2.get(jsonLeg.TransportMode);
3060
+ const legMode = transitModeCorrespondance$3.get(jsonLeg.TransportMode);
3054
3061
  const legCoords = [];
3055
3062
  let legStart, legEnd;
3056
3063
  let transportInfo;
@@ -3061,11 +3068,11 @@ class CitywayRemoteRouter extends RemoteRouter {
3061
3068
  if (legMode === "WALK" || legMode === "BIKE" || legMode === "CAR") {
3062
3069
  legStart = {
3063
3070
  name: jsonLeg.Departure.Site.Name,
3064
- coords: jsonToCoordinates$2(jsonLeg.Departure.Site.Position)
3071
+ coords: jsonToCoordinates$3(jsonLeg.Departure.Site.Position)
3065
3072
  };
3066
3073
  legEnd = {
3067
3074
  name: jsonLeg.Arrival.Site.Name,
3068
- coords: jsonToCoordinates$2(jsonLeg.Arrival.Site.Position)
3075
+ coords: jsonToCoordinates$3(jsonLeg.Arrival.Site.Position)
3069
3076
  };
3070
3077
  for (const jsonPathLink of jsonLeg.pathLinks.PathLink) {
3071
3078
  let stepCoords;
@@ -3093,11 +3100,11 @@ class CitywayRemoteRouter extends RemoteRouter {
3093
3100
  } else if (isTransitModePublicTransport(legMode)) {
3094
3101
  legStart = {
3095
3102
  name: jsonLeg.Departure.StopPlace.Name,
3096
- coords: jsonToCoordinates$2(jsonLeg.Departure.StopPlace.Position)
3103
+ coords: jsonToCoordinates$3(jsonLeg.Departure.StopPlace.Position)
3097
3104
  };
3098
3105
  legEnd = {
3099
3106
  name: jsonLeg.Arrival.StopPlace.Name,
3100
- coords: jsonToCoordinates$2(jsonLeg.Arrival.StopPlace.Position)
3107
+ coords: jsonToCoordinates$3(jsonLeg.Arrival.StopPlace.Position)
3101
3108
  };
3102
3109
  let transportName = jsonLeg.Line.Number;
3103
3110
  if (legMode === "TRAM" && transportName.toLowerCase().includes("tram")) {
@@ -3145,9 +3152,9 @@ class CitywayRemoteRouter extends RemoteRouter {
3145
3152
  const itinerary = new Itinerary({
3146
3153
  duration: this.parseDuration(trip.Duration),
3147
3154
  startTime: jsonDateToTimestamp(trip.Departure.Time),
3148
- origin: jsonToCoordinates$2(trip.Departure.Site.Position),
3155
+ origin: jsonToCoordinates$3(trip.Departure.Site.Position),
3149
3156
  endTime: jsonDateToTimestamp(trip.Arrival.Time),
3150
- destination: jsonToCoordinates$2(trip.Arrival.Site.Position),
3157
+ destination: jsonToCoordinates$3(trip.Arrival.Site.Position),
3151
3158
  legs
3152
3159
  });
3153
3160
  itineraries.push(itinerary);
@@ -3172,6 +3179,336 @@ class CitywayRemoteRouter extends RemoteRouter {
3172
3179
  }
3173
3180
  }
3174
3181
  const CitywayRemoteRouter$1 = new CitywayRemoteRouter();
3182
+ const transitModeCorrespondance$2 = /* @__PURE__ */ new Map();
3183
+ transitModeCorrespondance$2.set("Air", "AIRPLANE");
3184
+ transitModeCorrespondance$2.set("Boat", "BOAT");
3185
+ transitModeCorrespondance$2.set("Bus", "BUS");
3186
+ transitModeCorrespondance$2.set("BusRapidTransit", "BUS");
3187
+ transitModeCorrespondance$2.set("Coach", "BUS");
3188
+ transitModeCorrespondance$2.set("Ferry", "FERRY");
3189
+ transitModeCorrespondance$2.set("Funicular", "FUNICULAR");
3190
+ transitModeCorrespondance$2.set("LocalTrain", "TRAIN");
3191
+ transitModeCorrespondance$2.set("LongDistanceTrain", "TRAIN");
3192
+ transitModeCorrespondance$2.set("Metro", "METRO");
3193
+ transitModeCorrespondance$2.set("Métro", "METRO");
3194
+ transitModeCorrespondance$2.set("RailShuttle", "TRAIN");
3195
+ transitModeCorrespondance$2.set("RapidTransit", "BUS");
3196
+ transitModeCorrespondance$2.set("Shuttle", "BUS");
3197
+ transitModeCorrespondance$2.set("SuspendedCableCar", "FUNICULAR");
3198
+ transitModeCorrespondance$2.set("Taxi", "TAXI");
3199
+ transitModeCorrespondance$2.set("Train", "TRAIN");
3200
+ transitModeCorrespondance$2.set("RER", "TRAIN");
3201
+ transitModeCorrespondance$2.set("Tramway", "TRAM");
3202
+ transitModeCorrespondance$2.set("walking", "WALK");
3203
+ transitModeCorrespondance$2.set("bike", "BIKE");
3204
+ const TRANSPORT_IDS$1 = [
3205
+ "physical_mode:Air",
3206
+ "physical_mode:Boat",
3207
+ "physical_mode:Bus",
3208
+ "physical_mode:BusRapidTransit",
3209
+ "physical_mode:Coach",
3210
+ "physical_mode:Ferry",
3211
+ "physical_mode:Funicular",
3212
+ "physical_mode:LocalTrain",
3213
+ "physical_mode:LongDistanceTrain",
3214
+ "physical_mode:Metro",
3215
+ "physical_mode:RailShuttle",
3216
+ "physical_mode:RapidTransit",
3217
+ "physical_mode:Shuttle",
3218
+ "physical_mode:SuspendedCableCar",
3219
+ "physical_mode:Taxi",
3220
+ "physical_mode:Train",
3221
+ "physical_mode:Tramway"
3222
+ ];
3223
+ function jsonToCoordinates$2(json) {
3224
+ return new Coordinates(Number(json.lat), Number(json.lon));
3225
+ }
3226
+ function last$2(array) {
3227
+ return array[array.length - 1];
3228
+ }
3229
+ function dateStringToTimestamp$1(stringDate, timeZone) {
3230
+ const yearStr = stringDate.substr(0, 4);
3231
+ const monthStr = stringDate.substr(4, 2);
3232
+ const dayStr = stringDate.substr(6, 2);
3233
+ const hoursStr = stringDate.substr(9, 2);
3234
+ const minutesStr = stringDate.substr(11, 2);
3235
+ const secondsStr = stringDate.substr(13, 2);
3236
+ return dateWithTimeZone(
3237
+ Number(yearStr),
3238
+ Number(monthStr) - 1,
3239
+ Number(dayStr),
3240
+ Number(hoursStr),
3241
+ Number(minutesStr),
3242
+ Number(secondsStr),
3243
+ timeZone
3244
+ ).getTime();
3245
+ }
3246
+ class NavitiaRemoteRouter extends RemoteRouter {
3247
+ get rname() {
3248
+ return "navitia";
3249
+ }
3250
+ async getItineraries(endpointUrl, routerRequest) {
3251
+ const url = this.getURL(endpointUrl, routerRequest);
3252
+ const api_key = url.searchParams.get("api_key");
3253
+ if (!api_key) {
3254
+ throw RemoteRoutingError.missingApiKey(this.rname);
3255
+ }
3256
+ const res = await fetch(url, {
3257
+ method: "GET",
3258
+ headers: {
3259
+ "Authorization": api_key
3260
+ }
3261
+ }).catch(() => {
3262
+ throw RemoteRoutingError.unreachableServer(this.rname, url.toString());
3263
+ });
3264
+ const jsonResponse = await res.json().catch(() => {
3265
+ throw RemoteRoutingError.responseNotParsing(this.rname, url.toString());
3266
+ });
3267
+ if (jsonResponse && jsonResponse.error) {
3268
+ throw RemoteRoutingError.notFound(this.rname, jsonResponse.error.message);
3269
+ }
3270
+ const itineraries = this.parseResponse(jsonResponse);
3271
+ const sameModeFound = itineraries.some((itinerary) => areTransitAndTravelModeConsistent(itinerary.transitMode, routerRequest.travelMode));
3272
+ if (!sameModeFound) {
3273
+ throw RemoteRoutingError.notFound(
3274
+ this.rname,
3275
+ "Selected mode of transport was not found for this itinerary."
3276
+ );
3277
+ }
3278
+ return itineraries;
3279
+ }
3280
+ getURL(endpointUrl, routerRequest) {
3281
+ var _a;
3282
+ const { origin, destination, waypoints, travelMode } = routerRequest;
3283
+ if ((waypoints || []).length > 0) {
3284
+ Logger.warn(`${this.rname} router uses only the first 2 waypoints (asked ${waypoints == null ? void 0 : waypoints.length})`);
3285
+ }
3286
+ const url = new URL(endpointUrl);
3287
+ const coreParams = new URLSearchParams();
3288
+ coreParams.set("from", `${origin.longitude};${origin.latitude}`);
3289
+ coreParams.set("to", `${destination.longitude};${destination.latitude}`);
3290
+ coreParams.set("data_freshness", "realtime");
3291
+ if ((_a = routerRequest.itineraryModifiers) == null ? void 0 : _a.avoidStairs) {
3292
+ coreParams.set("wheelchair", "true");
3293
+ }
3294
+ let queryParams = new URLSearchParams();
3295
+ switch (travelMode) {
3296
+ case "WALK":
3297
+ queryParams = this.getWalkingQuery();
3298
+ break;
3299
+ case "BIKE":
3300
+ queryParams = this.getBikeQuery();
3301
+ break;
3302
+ case "CAR":
3303
+ queryParams = this.getCarQuery();
3304
+ break;
3305
+ }
3306
+ [coreParams, queryParams].map((params) => {
3307
+ for (const pair of params.entries()) {
3308
+ url.searchParams.append(pair[0], pair[1]);
3309
+ }
3310
+ });
3311
+ return url;
3312
+ }
3313
+ getCarQuery() {
3314
+ const urlSearchParams = new URLSearchParams();
3315
+ TRANSPORT_IDS$1.forEach((id) => {
3316
+ urlSearchParams.append("forbidden_uris[]", id);
3317
+ });
3318
+ urlSearchParams.append("first_section_mode[]", "walking");
3319
+ urlSearchParams.append("first_section_mode[]", "car");
3320
+ urlSearchParams.append("last_section_mode[]", "walking");
3321
+ urlSearchParams.append("last_section_mode[]", "car");
3322
+ return urlSearchParams;
3323
+ }
3324
+ getWalkingQuery() {
3325
+ const urlSearchParams = new URLSearchParams();
3326
+ TRANSPORT_IDS$1.forEach((id) => {
3327
+ urlSearchParams.append("forbidden_uris[]", id);
3328
+ });
3329
+ urlSearchParams.append("first_section_mode[]", "walking");
3330
+ urlSearchParams.append("last_section_mode[]", "walking");
3331
+ return urlSearchParams;
3332
+ }
3333
+ getBikeQuery() {
3334
+ const urlSearchParams = new URLSearchParams();
3335
+ TRANSPORT_IDS$1.forEach((id) => {
3336
+ urlSearchParams.append("forbidden_uris[]", id);
3337
+ });
3338
+ urlSearchParams.append("first_section_mode[]", "bike");
3339
+ urlSearchParams.append("last_section_mode[]", "bike");
3340
+ return urlSearchParams;
3341
+ }
3342
+ getSectionCoords(section) {
3343
+ let from;
3344
+ let to;
3345
+ if ("stop_point" in section.from) {
3346
+ from = section.from.stop_point.coord;
3347
+ } else if ("address" in section.from) {
3348
+ from = section.from.address.coord;
3349
+ } else {
3350
+ from = section.from.poi.coord;
3351
+ }
3352
+ if ("stop_point" in section.to) {
3353
+ to = section.to.stop_point.coord;
3354
+ } else if ("address" in section.to) {
3355
+ to = section.to.address.coord;
3356
+ } else {
3357
+ to = section.to.poi.coord;
3358
+ }
3359
+ return {
3360
+ from: jsonToCoordinates$2(from),
3361
+ to: jsonToCoordinates$2(to)
3362
+ };
3363
+ }
3364
+ /**
3365
+ * Since the navitia API does not provide coords for each step, we need to compute them
3366
+ * We trim the coordinates of the leg with the distance of each step and keep the last result as the coords of the step
3367
+ * @param {Leg} leg
3368
+ */
3369
+ findStepsCoord(legCoords, steps) {
3370
+ const coords = legCoords;
3371
+ const duplicatedCoords = [...coords];
3372
+ let previousStep = steps[0];
3373
+ let accumulatedIndex = 0;
3374
+ const outputSteps = [];
3375
+ for (const [idx, step] of steps.entries()) {
3376
+ let newCoords;
3377
+ let _idCoordsInLeg;
3378
+ if (idx === 0) {
3379
+ _idCoordsInLeg = 0;
3380
+ newCoords = coords[0];
3381
+ } else if (idx === steps.length - 1) {
3382
+ _idCoordsInLeg = coords.length - 1;
3383
+ newCoords = last$2(coords);
3384
+ } else if (duplicatedCoords.length === 1) {
3385
+ accumulatedIndex++;
3386
+ _idCoordsInLeg = accumulatedIndex;
3387
+ newCoords = duplicatedCoords[0];
3388
+ coords[_idCoordsInLeg] = newCoords;
3389
+ } else {
3390
+ const result = Utils.trimRoute(duplicatedCoords, duplicatedCoords[0], previousStep.distance);
3391
+ accumulatedIndex += result.length - 1;
3392
+ duplicatedCoords.splice(0, result.length - 1);
3393
+ _idCoordsInLeg = accumulatedIndex;
3394
+ newCoords = last$2(result);
3395
+ coords[_idCoordsInLeg] = newCoords;
3396
+ }
3397
+ outputSteps.push({
3398
+ ...step,
3399
+ coords: newCoords
3400
+ });
3401
+ previousStep = step;
3402
+ }
3403
+ return outputSteps;
3404
+ }
3405
+ findStepCoords(step, section) {
3406
+ var _a;
3407
+ if ("instruction_start_coordinate" in step) {
3408
+ return jsonToCoordinates$2(step.instruction_start_coordinate);
3409
+ }
3410
+ const via = (_a = section.vias) == null ? void 0 : _a.find((via2) => via2.id === step.via_uri);
3411
+ if (via) {
3412
+ return jsonToCoordinates$2(via.access_point.coord);
3413
+ }
3414
+ }
3415
+ parseResponse(json) {
3416
+ var _a;
3417
+ if (!json || !json.journeys) {
3418
+ throw RemoteRoutingError.notFound(this.rname, (_a = json.error) == null ? void 0 : _a.message);
3419
+ }
3420
+ const itineraries = [];
3421
+ const timeZone = json.context.timezone;
3422
+ for (const jsonItinerary of json.journeys) {
3423
+ const legs = [];
3424
+ for (const jsonSection of jsonItinerary.sections) {
3425
+ if (jsonSection.type === "waiting" || jsonSection.type === "transfer") {
3426
+ continue;
3427
+ }
3428
+ const { from: startSection, to: endSection } = this.getSectionCoords(jsonSection);
3429
+ let existingCoords = [];
3430
+ const legCoords = jsonSection.geojson.coordinates.reduce((acc, [lon, lat]) => {
3431
+ if (!existingCoords.includes(`${lon}-${lat}`)) {
3432
+ existingCoords = existingCoords.concat(`${lon}-${lat}`);
3433
+ acc.push(new Coordinates(lat, lon));
3434
+ }
3435
+ return acc;
3436
+ }, []);
3437
+ const stepsBuilder = new StepsBuilder().setStart(startSection).setEnd(endSection).setPathCoords(legCoords);
3438
+ let transportInfo;
3439
+ let transitMode = transitModeCorrespondance$2.get(jsonSection.mode);
3440
+ if (jsonSection.path) {
3441
+ const useNavitiaSteps = jsonSection.path.every((step) => "instruction_start_coordinate" in step || step.via_uri);
3442
+ const navitiaIntermediateSteps = [];
3443
+ for (const jsonPathLink of jsonSection.path) {
3444
+ let coords;
3445
+ if (useNavitiaSteps) {
3446
+ coords = this.findStepCoords(jsonPathLink, jsonSection);
3447
+ const intermediateStep = {
3448
+ name: jsonPathLink.name,
3449
+ distance: jsonPathLink.length,
3450
+ coords
3451
+ };
3452
+ stepsBuilder.addStepInfo(intermediateStep);
3453
+ } else {
3454
+ navitiaIntermediateSteps.push({
3455
+ name: jsonPathLink.name,
3456
+ distance: jsonPathLink.length
3457
+ });
3458
+ }
3459
+ }
3460
+ if (!useNavitiaSteps) {
3461
+ stepsBuilder.setStepsInfo(this.findStepsCoord(legCoords, navitiaIntermediateSteps));
3462
+ }
3463
+ }
3464
+ if (jsonSection.type === "public_transport") {
3465
+ transportInfo = {
3466
+ name: jsonSection.display_informations.code,
3467
+ routeColor: jsonSection.display_informations.color,
3468
+ routeTextColor: jsonSection.display_informations.text_color,
3469
+ directionName: jsonSection.display_informations.direction
3470
+ };
3471
+ transitMode = transitModeCorrespondance$2.get(jsonSection.display_informations.physical_mode);
3472
+ const legStep = {
3473
+ coords: legCoords[0],
3474
+ name: transportInfo.directionName,
3475
+ distance: jsonSection.geojson.properties[0].length
3476
+ };
3477
+ stepsBuilder.setStepsInfo([legStep]);
3478
+ }
3479
+ const leg = new Leg({
3480
+ transitMode,
3481
+ duration: jsonSection.duration,
3482
+ startTime: dateStringToTimestamp$1(jsonSection.departure_date_time, timeZone),
3483
+ endTime: dateStringToTimestamp$1(jsonSection.arrival_date_time, timeZone),
3484
+ start: {
3485
+ name: jsonSection.from.name,
3486
+ coords: startSection
3487
+ },
3488
+ end: {
3489
+ name: jsonSection.to.name,
3490
+ coords: endSection
3491
+ },
3492
+ coords: legCoords,
3493
+ transportInfo,
3494
+ steps: stepsBuilder.build()
3495
+ });
3496
+ legs.push(leg);
3497
+ }
3498
+ const itinerary = new Itinerary({
3499
+ duration: jsonItinerary.duration,
3500
+ startTime: dateStringToTimestamp$1(jsonItinerary.departure_date_time, timeZone),
3501
+ endTime: dateStringToTimestamp$1(jsonItinerary.arrival_date_time, timeZone),
3502
+ origin: this.getSectionCoords(jsonItinerary.sections[0]).from,
3503
+ destination: this.getSectionCoords(last$2(jsonItinerary.sections)).to,
3504
+ legs
3505
+ });
3506
+ itineraries.push(itinerary);
3507
+ }
3508
+ return itineraries;
3509
+ }
3510
+ }
3511
+ const NavitiaRemoteRouter$1 = new NavitiaRemoteRouter();
3175
3512
  class DeutscheBahnRemoteRouter extends RemoteRouter {
3176
3513
  /**
3177
3514
  * @override
@@ -4067,6 +4404,7 @@ class WemapMultiRemoteRouter extends RemoteRouter {
4067
4404
  const WemapMultiRemoteRouter$1 = new WemapMultiRemoteRouter();
4068
4405
  const remoteRouters = [
4069
4406
  CitywayRemoteRouter$1,
4407
+ NavitiaRemoteRouter$1,
4070
4408
  DeutscheBahnRemoteRouter$1,
4071
4409
  IdfmRemoteRouter$1,
4072
4410
  OsrmRemoteRouter$1,
@@ -4731,6 +5069,7 @@ export {
4731
5069
  Itinerary,
4732
5070
  ItineraryInfoManager,
4733
5071
  Leg,
5072
+ NavitiaRemoteRouter$1 as NavitiaRemoteRouter,
4734
5073
  NoRouteFoundError,
4735
5074
  OsmGraphUtils,
4736
5075
  OsrmRemoteRouter$1 as OsrmRemoteRouter,