@wemap/routers 11.0.0-alpha.3 → 11.0.0-alpha.4

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
@@ -1,17 +1,24 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
4
  var __publicField = (obj, key, value) => {
4
5
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
6
  return value;
6
7
  };
7
- import { Coordinates, Level, Utils, Network, GraphRouterOptions, GraphRouter, GraphUtils, NoRouteFoundError, MapMatching, GraphNode, GraphEdge } from "@wemap/geo";
8
- import { deg2rad, diffAngle, positiveMod, rad2deg } from "@wemap/maths";
9
- import { OsmNode, OsmWay, OsmParser, OsmNetworkUtils } from "@wemap/osm";
10
- import Logger from "@wemap/logger";
11
- import Polyline from "@mapbox/polyline";
12
- import pointInPolygon from "@turf/boolean-point-in-polygon";
13
- import convexHullFn from "@turf/convex";
14
- import { polygon } from "@turf/helpers";
8
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
9
+ const geo = require("@wemap/geo");
10
+ const maths = require("@wemap/maths");
11
+ const osm = require("@wemap/osm");
12
+ const Logger = require("@wemap/logger");
13
+ const Polyline = require("@mapbox/polyline");
14
+ const pointInPolygon = require("@turf/boolean-point-in-polygon");
15
+ const convexHullFn = require("@turf/convex");
16
+ const helpers = require("@turf/helpers");
17
+ const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
18
+ const Logger__default = /* @__PURE__ */ _interopDefaultLegacy(Logger);
19
+ const Polyline__default = /* @__PURE__ */ _interopDefaultLegacy(Polyline);
20
+ const pointInPolygon__default = /* @__PURE__ */ _interopDefaultLegacy(pointInPolygon);
21
+ const convexHullFn__default = /* @__PURE__ */ _interopDefaultLegacy(convexHullFn);
15
22
  function getDurationFromLength(length, speed = 5) {
16
23
  return length / (speed * 1e3 / 3600);
17
24
  }
@@ -58,11 +65,11 @@ class StepInfo {
58
65
  }
59
66
  static fromJson(json) {
60
67
  return new StepInfo(Object.assign({}, json, {
61
- coords: Coordinates.fromCompressedJson(json.coords)
68
+ coords: geo.Coordinates.fromCompressedJson(json.coords)
62
69
  }));
63
70
  }
64
71
  }
65
- const SKIP_STEP_ANGLE_MAX = deg2rad(20);
72
+ const SKIP_STEP_ANGLE_MAX = maths.deg2rad(20);
66
73
  function generateSteps(leg, rules) {
67
74
  const steps = [];
68
75
  const { from, to, coords: coordsArray } = leg;
@@ -72,18 +79,18 @@ function generateSteps(leg, rules) {
72
79
  const isFirstStep = i === 0;
73
80
  const currentCoords = coordsArray[i];
74
81
  const nextCoords = coordsArray[i + 1];
75
- const edgeLevel = Level.union(currentCoords.level, nextCoords.level);
82
+ const edgeLevel = geo.Level.union(currentCoords.level, nextCoords.level);
76
83
  const nextBearing = currentCoords.bearingTo(nextCoords);
77
- const angle = diffAngle(previousBearing, nextBearing + Math.PI);
78
- let splitByAngle = Math.abs(diffAngle(Math.PI, angle)) >= SKIP_STEP_ANGLE_MAX;
79
- const splitByLevel = Level.isRange(edgeLevel) && !Level.isRange(currentCoords.level);
80
- splitByAngle = splitByAngle && !(currentCoords.level && Level.isRange(currentCoords.level));
84
+ const angle = maths.diffAngle(previousBearing, nextBearing + Math.PI);
85
+ let splitByAngle = Math.abs(maths.diffAngle(Math.PI, angle)) >= SKIP_STEP_ANGLE_MAX;
86
+ const splitByLevel = geo.Level.isRange(edgeLevel) && !geo.Level.isRange(currentCoords.level);
87
+ splitByAngle = splitByAngle && !(currentCoords.level && geo.Level.isRange(currentCoords.level));
81
88
  const customRules = rules == null ? void 0 : rules(currentCoords, nextCoords);
82
89
  const splitStepCondition = splitByAngle || splitByLevel || (customRules == null ? void 0 : customRules.createNewStep);
83
90
  if (isFirstStep || splitStepCondition) {
84
91
  let levelChange;
85
92
  if (splitByLevel) {
86
- const difference = Level.diff(currentCoords.level, nextCoords.level);
93
+ const difference = geo.Level.diff(currentCoords.level, nextCoords.level);
87
94
  const direction = difference > 0 ? "up" : "down";
88
95
  levelChange = { difference, direction, type: customRules == null ? void 0 : customRules.levelChangeType };
89
96
  }
@@ -107,7 +114,7 @@ function generateSteps(leg, rules) {
107
114
  previousBearing = nextBearing;
108
115
  }
109
116
  const lastCoords = coordsArray[coordsArray.length - 1];
110
- if (!Coordinates.equals(lastCoords, to.coords)) {
117
+ if (!geo.Coordinates.equals(lastCoords, to.coords)) {
111
118
  steps.push(new StepInfo({ coords: lastCoords }));
112
119
  }
113
120
  return steps;
@@ -156,7 +163,7 @@ class Leg {
156
163
  };
157
164
  this.coords = coords;
158
165
  this.mode = mode;
159
- this.distance = Utils.calcDistance(coords);
166
+ this.distance = geo.Utils.calcDistance(coords);
160
167
  this.duration = typeof duration === "number" ? duration : getDurationFromLength(this.distance);
161
168
  this.startTime = typeof startTime === "number" ? startTime : null;
162
169
  this.endTime = typeof endTime === "number" ? endTime : null;
@@ -167,7 +174,7 @@ class Leg {
167
174
  return isRoutingModePublicTransport(this.mode);
168
175
  }
169
176
  toNetwork() {
170
- return Network.fromCoordinates([this.coords]);
177
+ return geo.Network.fromCoordinates([this.coords]);
171
178
  }
172
179
  static equals(obj1, obj2) {
173
180
  var _a, _b;
@@ -224,14 +231,14 @@ class Leg {
224
231
  var _a;
225
232
  const leg = new Leg(Object.assign({}, json, {
226
233
  from: {
227
- coords: Coordinates.fromCompressedJson(json.from.coords),
234
+ coords: geo.Coordinates.fromCompressedJson(json.from.coords),
228
235
  name: json.from.name || null
229
236
  },
230
237
  to: {
231
- coords: Coordinates.fromCompressedJson(json.to.coords),
238
+ coords: geo.Coordinates.fromCompressedJson(json.to.coords),
232
239
  name: json.to.name || null
233
240
  },
234
- coords: json.coords.map(Coordinates.fromCompressedJson),
241
+ coords: json.coords.map(geo.Coordinates.fromCompressedJson),
235
242
  stepsInfo: ((_a = json.steps) == null ? void 0 : _a.map(StepInfo.fromJson)) || null,
236
243
  stepsGenerationRules: void 0
237
244
  }));
@@ -248,13 +255,13 @@ class Leg {
248
255
  });
249
256
  }
250
257
  multiplyLevel(levelFactor) {
251
- this.from.coords.level = Level.multiplyBy(this.from.coords.level, levelFactor);
252
- this.to.coords.level = Level.multiplyBy(this.to.coords.level, levelFactor);
258
+ this.from.coords.level = geo.Level.multiplyBy(this.from.coords.level, levelFactor);
259
+ this.to.coords.level = geo.Level.multiplyBy(this.to.coords.level, levelFactor);
253
260
  for (const coords of this.coords) {
254
- coords.level = Level.multiplyBy(coords.level, levelFactor);
261
+ coords.level = geo.Level.multiplyBy(coords.level, levelFactor);
255
262
  }
256
263
  this.stepsInfo.forEach((step) => {
257
- step.coords.level = Level.multiplyBy(step.coords.level, levelFactor);
264
+ step.coords.level = geo.Level.multiplyBy(step.coords.level, levelFactor);
258
265
  });
259
266
  }
260
267
  getSteps(itinerarySteps) {
@@ -329,7 +336,7 @@ class Itinerary {
329
336
  number: stepId + 1,
330
337
  previousBearing,
331
338
  nextBearing,
332
- angle: diffAngle(previousBearing, nextBearing + Math.PI),
339
+ angle: maths.diffAngle(previousBearing, nextBearing + Math.PI),
333
340
  firstStep: stepId === 0,
334
341
  lastStep: stepId === stepsInfo.length - 1,
335
342
  distance,
@@ -370,12 +377,12 @@ class Itinerary {
370
377
  }
371
378
  get distance() {
372
379
  if (this._distance === null) {
373
- this._distance = Utils.calcDistance(this.coords);
380
+ this._distance = geo.Utils.calcDistance(this.coords);
374
381
  }
375
382
  return this._distance;
376
383
  }
377
384
  toNetwork() {
378
- return Network.fromCoordinates([this.coords]);
385
+ return geo.Network.fromCoordinates([this.coords]);
379
386
  }
380
387
  static fromItineraries(...itineraries) {
381
388
  let duration = 0;
@@ -392,7 +399,7 @@ class Itinerary {
392
399
  });
393
400
  }
394
401
  static fromOrderedPointsArray(points, start, end) {
395
- const pointToCoordinates = (point) => new Coordinates(point[0], point[1], null, point[2]);
402
+ const pointToCoordinates = (point) => new geo.Coordinates(point[0], point[1], null, point[2]);
396
403
  return this.fromOrderedCoordinates(
397
404
  points.map(pointToCoordinates),
398
405
  pointToCoordinates(start),
@@ -436,8 +443,8 @@ class Itinerary {
436
443
  }
437
444
  static fromJson(json) {
438
445
  return new Itinerary({
439
- from: Coordinates.fromCompressedJson(json.from),
440
- to: Coordinates.fromCompressedJson(json.to),
446
+ from: geo.Coordinates.fromCompressedJson(json.from),
447
+ to: geo.Coordinates.fromCompressedJson(json.to),
441
448
  duration: json.duration,
442
449
  legs: json.legs.map(Leg.fromJson),
443
450
  startTime: json.startTime,
@@ -454,8 +461,8 @@ class Itinerary {
454
461
  });
455
462
  }
456
463
  multiplyLevel(levelFactor) {
457
- this.from.level = Level.multiplyBy(this.from.level, levelFactor);
458
- this.to.level = Level.multiplyBy(this.to.level, levelFactor);
464
+ this.from.level = geo.Level.multiplyBy(this.from.level, levelFactor);
465
+ this.to.level = geo.Level.multiplyBy(this.to.level, levelFactor);
459
466
  this.legs.forEach((leg) => leg.multiplyLevel(levelFactor));
460
467
  }
461
468
  forceUnknownLevelTo0() {
@@ -537,24 +544,24 @@ class RouterResponse {
537
544
  var _a;
538
545
  return new RouterResponse({
539
546
  routerName: json.routerName,
540
- from: Coordinates.fromCompressedJson(json.from),
541
- to: Coordinates.fromCompressedJson(json.to),
547
+ from: geo.Coordinates.fromCompressedJson(json.from),
548
+ to: geo.Coordinates.fromCompressedJson(json.to),
542
549
  itineraries: (_a = json.itineraries) == null ? void 0 : _a.map(Itinerary.fromJson),
543
550
  error: json.error
544
551
  });
545
552
  }
546
553
  multiplyLevel(levelFactor) {
547
- this.from.level = Level.multiplyBy(this.from.level, levelFactor);
548
- this.to.level = Level.multiplyBy(this.to.level, levelFactor);
554
+ this.from.level = geo.Level.multiplyBy(this.from.level, levelFactor);
555
+ this.to.level = geo.Level.multiplyBy(this.to.level, levelFactor);
549
556
  for (const itinerary of this.itineraries) {
550
557
  itinerary.multiplyLevel(levelFactor);
551
558
  }
552
559
  }
553
560
  }
554
- const _WemapOsmRouterOptions = class extends GraphRouterOptions {
561
+ const _WemapOsmRouterOptions = class extends geo.GraphRouterOptions {
555
562
  constructor() {
556
563
  super(...arguments);
557
- __publicField(this, "weightEdgeFn", (edge) => edge.builtFrom instanceof OsmNode && edge.builtFrom.isElevator ? 30 : getDurationFromLength(edge.length));
564
+ __publicField(this, "weightEdgeFn", (edge) => edge.builtFrom instanceof osm.OsmNode && edge.builtFrom.isElevator ? 30 : getDurationFromLength(edge.length));
558
565
  }
559
566
  static get WITHOUT_STAIRS() {
560
567
  const options = new _WemapOsmRouterOptions();
@@ -571,22 +578,22 @@ const buildStepsRules = (graphItinerary) => (currentCoords, nextCoords) => {
571
578
  var _a, _b, _c, _d, _e;
572
579
  const edges = graphItinerary.edges;
573
580
  const nodes = graphItinerary.nodes;
574
- const node = GraphUtils.getNodeByCoords(nodes, currentCoords);
575
- const nextNode = GraphUtils.getNodeByCoords(nodes, nextCoords);
581
+ const node = geo.GraphUtils.getNodeByCoords(nodes, currentCoords);
582
+ const nextNode = geo.GraphUtils.getNodeByCoords(nodes, nextCoords);
576
583
  if (!node || !nextNode)
577
584
  return {};
578
- const edge = GraphUtils.getEdgeByNodes(edges, node, nextNode);
585
+ const edge = geo.GraphUtils.getEdgeByNodes(edges, node, nextNode);
579
586
  if (!edge)
580
587
  return {};
581
588
  const edgeId = edges.findIndex((_edge) => _edge === edge);
582
589
  const isSubwayEntrance = node ? ((_a = node.builtFrom) == null ? void 0 : _a.tags.railway) === "subway_entrance" : false;
583
590
  const isGate = node ? ((_b = node.builtFrom) == null ? void 0 : _b.tags.barrier) === "gate" || ((_c = node.builtFrom) == null ? void 0 : _c.tags.aeroway) === "gate" : false;
584
591
  let levelChangeType = null;
585
- if (edge.builtFrom instanceof OsmNode && edge.builtFrom.isElevator) {
592
+ if (edge.builtFrom instanceof osm.OsmNode && edge.builtFrom.isElevator) {
586
593
  levelChangeType = "elevator";
587
- } else if (edge.builtFrom instanceof OsmNode || edge.builtFrom instanceof OsmWay && edge.builtFrom.isConveying) {
594
+ } else if (edge.builtFrom instanceof osm.OsmNode || edge.builtFrom instanceof osm.OsmWay && edge.builtFrom.isConveying) {
588
595
  levelChangeType = "conveyor";
589
- } else if (edge.builtFrom instanceof OsmWay && edge.builtFrom.areStairs) {
596
+ } else if (edge.builtFrom instanceof osm.OsmWay && edge.builtFrom.areStairs) {
590
597
  levelChangeType = "stairs";
591
598
  }
592
599
  return {
@@ -601,7 +608,7 @@ const buildStepsRules = (graphItinerary) => (currentCoords, nextCoords) => {
601
608
  ...levelChangeType && { levelChangeType }
602
609
  };
603
610
  };
604
- class WemapOsmRouter extends GraphRouter {
611
+ class WemapOsmRouter extends geo.GraphRouter {
605
612
  constructor(network) {
606
613
  super(network);
607
614
  }
@@ -639,10 +646,10 @@ function dateWithTimeZone(year, month, day, hour, minute, second, timeZone = "Eu
639
646
  return date;
640
647
  }
641
648
  function isRoutingError(e) {
642
- return e instanceof RemoteRouterServerUnreachable || e instanceof RoutingModeCorrespondanceNotFound || e instanceof NoRouteFoundError;
649
+ return e instanceof RemoteRouterServerUnreachable || e instanceof RoutingModeCorrespondanceNotFound || e instanceof geo.NoRouteFoundError;
643
650
  }
644
651
  function jsonToCoordinates$2(json) {
645
- return new Coordinates(json.Lat, json.Long);
652
+ return new geo.Coordinates(json.Lat, json.Long);
646
653
  }
647
654
  function jsonDateToTimestamp(jsonDate) {
648
655
  const [dateStr, timeStr] = jsonDate.split(" ");
@@ -707,11 +714,11 @@ function parseWKTGeometry(wktGeometry) {
707
714
  const tmpCoordsPt = wktGeometry.match(/POINT ?\((.*)\)/i);
708
715
  if (tmpCoordsPt) {
709
716
  const [lng, lat] = tmpCoordsPt[1].split(" ");
710
- return [new Coordinates(Number(lat), Number(lng))];
717
+ return [new geo.Coordinates(Number(lat), Number(lng))];
711
718
  }
712
719
  return tmpCoordsStr[1].split(",").map((str) => {
713
720
  const sp = str.trim().split(" ");
714
- return new Coordinates(Number(sp[1]), Number(sp[0]));
721
+ return new geo.Coordinates(Number(sp[1]), Number(sp[0]));
715
722
  });
716
723
  }
717
724
  class CitywayRemoteRouter extends RemoteRouter {
@@ -734,7 +741,7 @@ class CitywayRemoteRouter extends RemoteRouter {
734
741
  throw new RoutingModeCorrespondanceNotFound(this.rname, mode);
735
742
  }
736
743
  if (waypoints.length > 2) {
737
- Logger.warn(`${this.rname} router uses only the first 2 waypoints (asked ${waypoints.length})`);
744
+ Logger__default.default.warn(`${this.rname} router uses only the first 2 waypoints (asked ${waypoints.length})`);
738
745
  }
739
746
  const fromPlace = `DepartureLatitude=${waypoints[0].latitude}&DepartureLongitude=${waypoints[0].longitude}`;
740
747
  const toPlace = `ArrivalLatitude=${waypoints[1].latitude}&ArrivalLongitude=${waypoints[1].longitude}`;
@@ -832,7 +839,7 @@ class CitywayRemoteRouter extends RemoteRouter {
832
839
  distance: jsonLeg.Distance
833
840
  })];
834
841
  } else {
835
- Logger.warn(`[CitywayParser] Unknown leg mode: ${jsonLeg.TransportMode}`);
842
+ Logger__default.default.warn(`[CitywayParser] Unknown leg mode: ${jsonLeg.TransportMode}`);
836
843
  continue;
837
844
  }
838
845
  const leg = new Leg({
@@ -891,7 +898,7 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
891
898
  let url = endpointUrl + "/route/v1/walking/";
892
899
  url += waypoints.map((waypoint) => {
893
900
  if (waypoint.level !== null) {
894
- const altitude = Level.isRange(waypoint.level) ? waypoint.level[0] : waypoint.level;
901
+ const altitude = geo.Level.isRange(waypoint.level) ? waypoint.level[0] : waypoint.level;
895
902
  return waypoint.longitude + "," + waypoint.latitude + "," + altitude;
896
903
  }
897
904
  return waypoint.longitude + "," + waypoint.latitude;
@@ -905,9 +912,9 @@ class DeutscheBahnRemoteRouter extends RemoteRouter {
905
912
  return routerResponse;
906
913
  }
907
914
  const legs = json.segments.map((segment) => {
908
- const level = Level.union(segment.fromLevel, segment.toLevel);
915
+ const level = geo.Level.union(segment.fromLevel, segment.toLevel);
909
916
  const coords = segment.polyline.map(
910
- ({ lon, lat }) => new Coordinates(lat, lon, null, level)
917
+ ({ lon, lat }) => new geo.Coordinates(lat, lon, null, level)
911
918
  );
912
919
  return new Leg({
913
920
  mode: "WALK",
@@ -964,7 +971,7 @@ const TRANSPORT_IDS = [
964
971
  ];
965
972
  const apiKey = "qWHj6ax6DMttG8DX6tH9CQARaiTgQ1Di";
966
973
  function jsonToCoordinates$1(json) {
967
- return new Coordinates(Number(json.lat), Number(json.lon));
974
+ return new geo.Coordinates(Number(json.lat), Number(json.lon));
968
975
  }
969
976
  function last(array) {
970
977
  return array[array.length - 1];
@@ -1013,7 +1020,7 @@ class IdfmRemoteRouter extends RemoteRouter {
1013
1020
  }
1014
1021
  getURL(endpointUrl, mode, waypoints) {
1015
1022
  if (waypoints.length > 2) {
1016
- Logger.warn(`${this.rname} router uses only the first 2 waypoints (asked ${waypoints.length})`);
1023
+ Logger__default.default.warn(`${this.rname} router uses only the first 2 waypoints (asked ${waypoints.length})`);
1017
1024
  }
1018
1025
  const fromPlace = `from=${waypoints[0].longitude};${waypoints[0].latitude}`;
1019
1026
  const toPlace = `to=${waypoints[1].longitude};${waypoints[1].latitude}`;
@@ -1078,7 +1085,7 @@ class IdfmRemoteRouter extends RemoteRouter {
1078
1085
  newCoords = duplicatedCoords[0];
1079
1086
  coords[_idCoordsInLeg] = newCoords;
1080
1087
  } else {
1081
- const result = Utils.trimRoute(duplicatedCoords, duplicatedCoords[0], previousStep.distance);
1088
+ const result = geo.Utils.trimRoute(duplicatedCoords, duplicatedCoords[0], previousStep.distance);
1082
1089
  accumulatedIndex += result.length - 1;
1083
1090
  duplicatedCoords.splice(0, result.length - 1);
1084
1091
  _idCoordsInLeg = accumulatedIndex;
@@ -1111,7 +1118,7 @@ class IdfmRemoteRouter extends RemoteRouter {
1111
1118
  const legCoords = jsonSection.geojson.coordinates.reduce((acc, [lon, lat]) => {
1112
1119
  if (!existingCoords.includes(`${lon}-${lat}`)) {
1113
1120
  existingCoords = existingCoords.concat(`${lon}-${lat}`);
1114
- acc.push(new Coordinates(lat, lon));
1121
+ acc.push(new geo.Coordinates(lat, lon));
1115
1122
  }
1116
1123
  return acc;
1117
1124
  }, []);
@@ -1209,20 +1216,20 @@ class OsrmRemoteRouter extends RemoteRouter {
1209
1216
  if (level === null) {
1210
1217
  return [lng, lat];
1211
1218
  }
1212
- if (Level.isRange(level)) {
1219
+ if (geo.Level.isRange(level)) {
1213
1220
  return [lng, lat, level[0]];
1214
1221
  }
1215
1222
  return [lng, lat, level];
1216
1223
  }
1217
1224
  jsonToCoordinates(json) {
1218
- const coords = new Coordinates(json[1], json[0]);
1225
+ const coords = new geo.Coordinates(json[1], json[0]);
1219
1226
  if (json.length > 2) {
1220
1227
  coords.level = json[2];
1221
1228
  }
1222
1229
  return coords;
1223
1230
  }
1224
1231
  getModifierFromAngle(_angle) {
1225
- const angle = positiveMod(rad2deg(_angle), 360);
1232
+ const angle = maths.positiveMod(maths.rad2deg(_angle), 360);
1226
1233
  if (angle > 0 && angle < 60) {
1227
1234
  return "sharp right";
1228
1235
  }
@@ -1277,8 +1284,8 @@ class OsrmRemoteRouter extends RemoteRouter {
1277
1284
  duration: step.duration || 0,
1278
1285
  ...step.name && { name: step.name },
1279
1286
  maneuver: {
1280
- bearing_before: rad2deg(step.previousBearing),
1281
- bearing_after: rad2deg(step.nextBearing),
1287
+ bearing_before: maths.rad2deg(step.previousBearing),
1288
+ bearing_after: maths.rad2deg(step.nextBearing),
1282
1289
  location: this.coordinatesToJson(step.coords),
1283
1290
  modifier: this.getModifierFromAngle(step.angle),
1284
1291
  type
@@ -1363,7 +1370,7 @@ function isLegPT(leg) {
1363
1370
  return leg.mode === "BUS" || leg.mode === "TRAM";
1364
1371
  }
1365
1372
  function jsonToCoordinates(json) {
1366
- return new Coordinates(json.lat, json.lon);
1373
+ return new geo.Coordinates(json.lat, json.lon);
1367
1374
  }
1368
1375
  const inputModeCorrespondance = /* @__PURE__ */ new Map();
1369
1376
  inputModeCorrespondance.set("CAR", "CAR");
@@ -1391,7 +1398,7 @@ class OtpRemoteRouter extends RemoteRouter {
1391
1398
  throw new RoutingModeCorrespondanceNotFound(this.rname, mode);
1392
1399
  }
1393
1400
  if (waypoints.length > 2) {
1394
- Logger.warn(`${this.rname} router uses only the first 2 waypoints (asked ${waypoints.length})`);
1401
+ Logger__default.default.warn(`${this.rname} router uses only the first 2 waypoints (asked ${waypoints.length})`);
1395
1402
  }
1396
1403
  const fromPlace = `fromPlace=${waypoints[0].latitude},${waypoints[0].longitude}`;
1397
1404
  const toPlace = `toPlace=${waypoints[1].latitude},${waypoints[1].longitude}`;
@@ -1412,7 +1419,7 @@ class OtpRemoteRouter extends RemoteRouter {
1412
1419
  for (const jsonItinerary of jsonPlan.itineraries) {
1413
1420
  const legs = [];
1414
1421
  for (const jsonLeg of jsonItinerary.legs) {
1415
- const legCoords = Polyline.decode(jsonLeg.legGeometry.points).map(([lat, lon]) => new Coordinates(lat, lon));
1422
+ const legCoords = Polyline__default.default.decode(jsonLeg.legGeometry.points).map(([lat, lon]) => new geo.Coordinates(lat, lon));
1416
1423
  let transportInfo;
1417
1424
  let stepsInfo;
1418
1425
  if (isLegPT(jsonLeg)) {
@@ -1487,7 +1494,7 @@ class WemapMultiRemoteRouterPayload {
1487
1494
  }
1488
1495
  static fromJson(json) {
1489
1496
  return new WemapMultiRemoteRouterPayload(
1490
- json.waypoints.map(Coordinates.fromCompressedJson),
1497
+ json.waypoints.map(geo.Coordinates.fromCompressedJson),
1491
1498
  json.mode,
1492
1499
  json.options
1493
1500
  );
@@ -1577,7 +1584,7 @@ class WemapMultiRouter {
1577
1584
  async getItineraries(mode, waypoints, options) {
1578
1585
  var _a;
1579
1586
  if (waypoints.length > 2) {
1580
- Logger.warn(`WemapMultiRouter uses only the first 2 waypoints (asked ${waypoints.length})`);
1587
+ Logger__default.default.warn(`WemapMultiRouter uses only the first 2 waypoints (asked ${waypoints.length})`);
1581
1588
  }
1582
1589
  const start = waypoints[0];
1583
1590
  const end = waypoints[1];
@@ -1594,7 +1601,7 @@ class WemapMultiRouter {
1594
1601
  if (ioMapsToTest.length !== targetMaps.length) {
1595
1602
  ioMapsToTest.forEach((map) => {
1596
1603
  if (map.name && !targetMaps.includes(map.name)) {
1597
- Logger.warn(`CustomNetworkMap "${map.name}" not found in WemapMultiRouter`);
1604
+ Logger__default.default.warn(`CustomNetworkMap "${map.name}" not found in WemapMultiRouter`);
1598
1605
  }
1599
1606
  });
1600
1607
  }
@@ -1654,7 +1661,7 @@ class WemapMultiRouter {
1654
1661
  [ioMapItinerary.to, end]
1655
1662
  );
1656
1663
  if (!remoteRouterResponse.itineraries.length) {
1657
- throw new NoRouteFoundError(ioMapItinerary.to, end, remoteRouterResponse.error);
1664
+ throw new geo.NoRouteFoundError(ioMapItinerary.to, end, remoteRouterResponse.error);
1658
1665
  }
1659
1666
  } catch (e) {
1660
1667
  if (!isRoutingError(e)) {
@@ -1683,7 +1690,7 @@ class WemapMultiRouter {
1683
1690
  [start, ioMapItinerary.from]
1684
1691
  );
1685
1692
  if (!remoteRouterResponse.itineraries.length) {
1686
- throw new NoRouteFoundError(start, ioMapItinerary.from, remoteRouterResponse.error);
1693
+ throw new geo.NoRouteFoundError(start, ioMapItinerary.from, remoteRouterResponse.error);
1687
1694
  }
1688
1695
  } catch (e) {
1689
1696
  if (!isRoutingError(e)) {
@@ -1721,7 +1728,7 @@ class WemapMultiRouter {
1721
1728
  [ioMapItinerary1.to, ioMapItinerary2.from]
1722
1729
  );
1723
1730
  if (!remoteRouterResponse.itineraries.length) {
1724
- throw new NoRouteFoundError(ioMapItinerary1.to, ioMapItinerary2.from, remoteRouterResponse.error);
1731
+ throw new geo.NoRouteFoundError(ioMapItinerary1.to, ioMapItinerary2.from, remoteRouterResponse.error);
1725
1732
  }
1726
1733
  } catch (e) {
1727
1734
  if (!isRoutingError(e)) {
@@ -1761,10 +1768,10 @@ class CustomNetworkMap {
1761
1768
  });
1762
1769
  this.entryPoints = entryPoints;
1763
1770
  if (bounds) {
1764
- this.bounds = polygon([bounds.map((coords) => [coords.lng, coords.lat])]);
1771
+ this.bounds = helpers.polygon([bounds.map((coords) => [coords.lng, coords.lat])]);
1765
1772
  } else {
1766
- const polygon2 = [network.nodes.map((node) => [node.coords.lng, node.coords.lat])];
1767
- const convexHull = convexHullFn({ type: "polygon", coordinates: polygon2 });
1773
+ const polygon = [network.nodes.map((node) => [node.coords.lng, node.coords.lat])];
1774
+ const convexHull = convexHullFn__default.default({ type: "polygon", coordinates: polygon });
1768
1775
  if (!convexHull) {
1769
1776
  throw new Error(`Cannot calculate convexHull of network "${name}"`);
1770
1777
  }
@@ -1772,8 +1779,8 @@ class CustomNetworkMap {
1772
1779
  }
1773
1780
  }
1774
1781
  static fromOsmXml(osmXmlString, name = null) {
1775
- const osmModel = OsmParser.parseOsmXmlString(osmXmlString);
1776
- const network = OsmNetworkUtils.createNetworkFromOsmModel(osmModel);
1782
+ const osmModel = osm.OsmParser.parseOsmXmlString(osmXmlString);
1783
+ const network = osm.OsmNetworkUtils.createNetworkFromOsmModel(osmModel);
1777
1784
  const entryPoints = osmModel.nodes.filter(({ tags }) => tags && tags["wemap:routing-io"]).map((osmNode) => network.getNodeByCoords(osmNode.coords));
1778
1785
  if (entryPoints.some((el) => el === null) || new Set(entryPoints).size !== entryPoints.length) {
1779
1786
  throw new Error("Cannot parse wemap:routing-io correctly");
@@ -1786,7 +1793,7 @@ class CustomNetworkMap {
1786
1793
  return new CustomNetworkMap(network, entryPoints, bounds, name);
1787
1794
  }
1788
1795
  isPointInside(coordinates) {
1789
- return pointInPolygon([coordinates.lng, coordinates.lat], this.bounds);
1796
+ return pointInPolygon__default.default([coordinates.lng, coordinates.lat], this.bounds);
1790
1797
  }
1791
1798
  getOrderedEntryPointsSortedByDistance(start, end) {
1792
1799
  const entryPointsCopy = [...this.entryPoints];
@@ -1802,7 +1809,7 @@ class CustomNetworkMap {
1802
1809
  return itinerary;
1803
1810
  }
1804
1811
  }
1805
- throw new NoRouteFoundError(
1812
+ throw new geo.NoRouteFoundError(
1806
1813
  start,
1807
1814
  end,
1808
1815
  `No route found from entry points to ${end.toString()} in map: ${this.name}`
@@ -1816,7 +1823,7 @@ class CustomNetworkMap {
1816
1823
  return itinerary;
1817
1824
  }
1818
1825
  }
1819
- throw new NoRouteFoundError(
1826
+ throw new geo.NoRouteFoundError(
1820
1827
  start,
1821
1828
  end,
1822
1829
  `No route found from ${start.toString()} to entry points in map: ${this.name}`
@@ -1842,7 +1849,7 @@ class CustomNetworkMap {
1842
1849
  }
1843
1850
  function getTurnInfoFromAngle(_angle) {
1844
1851
  let direction, directionExtra;
1845
- const directionAngle = rad2deg(diffAngle(_angle, Math.PI));
1852
+ const directionAngle = maths.rad2deg(maths.diffAngle(_angle, Math.PI));
1846
1853
  const directionAngleAbs = Math.abs(directionAngle);
1847
1854
  if (directionAngleAbs <= 20) {
1848
1855
  direction = "straight";
@@ -1882,7 +1889,7 @@ class ItineraryInfoManager {
1882
1889
  this._itinerary = itinerary;
1883
1890
  this._steps = itinerary.steps;
1884
1891
  const network = itinerary.toNetwork();
1885
- this._mapMatching = new MapMatching(network);
1892
+ this._mapMatching = new geo.MapMatching(network);
1886
1893
  this._coordsNextStep = new Array(itinerary.coords.length);
1887
1894
  this._coordsPreviousStep = new Array(itinerary.coords.length);
1888
1895
  this._coordsDistanceTraveled = new Array(itinerary.coords.length);
@@ -1915,7 +1922,7 @@ class ItineraryInfoManager {
1915
1922
  return null;
1916
1923
  }
1917
1924
  let itineraryInfo = null;
1918
- if (projection.nearestElement instanceof GraphNode) {
1925
+ if (projection.nearestElement instanceof geo.GraphNode) {
1919
1926
  const idx = this._itinerary.coords.findIndex(
1920
1927
  (coords) => projection.nearestElement.coords === coords
1921
1928
  );
@@ -1934,7 +1941,7 @@ class ItineraryInfoManager {
1934
1941
  traveledPercentage: traveledDistance / this._itinerary.distance,
1935
1942
  remainingPercentage: remainingDistance / this._itinerary.distance
1936
1943
  };
1937
- } else if (projection.nearestElement instanceof GraphEdge) {
1944
+ } else if (projection.nearestElement instanceof geo.GraphEdge) {
1938
1945
  let firstNode = projection.nearestElement.node1.coords;
1939
1946
  let idx = this._itinerary.coords.findIndex((coords) => firstNode === coords);
1940
1947
  if (idx === -1) {
@@ -1960,26 +1967,24 @@ class ItineraryInfoManager {
1960
1967
  return itineraryInfo;
1961
1968
  }
1962
1969
  }
1963
- export {
1964
- CitywayRemoteRouter$1 as CitywayRemoteRouter,
1965
- DeutscheBahnRemoteRouter$1 as DeutscheBahnRemoteRouter,
1966
- IdfmRemoteRouter$1 as IdfmRemoteRouter,
1967
- Itinerary,
1968
- ItineraryInfoManager,
1969
- Leg,
1970
- OsrmRemoteRouter$1 as OsrmRemoteRouter,
1971
- OtpRemoteRouter$1 as OtpRemoteRouter,
1972
- RemoteRouterManager$1 as RemoteRouterManager,
1973
- RemoteRouterServerUnreachable,
1974
- RouterResponse,
1975
- StepInfo,
1976
- CustomNetworkMap as WemapMetaRouterIOMap,
1977
- WemapMultiRemoteRouter$1 as WemapMultiRemoteRouter,
1978
- WemapMultiRemoteRouterPayload,
1979
- WemapMultiRouter,
1980
- WemapOsmRouter,
1981
- WemapOsmRouterOptions,
1982
- WemapOsmRouterUtils,
1983
- getDurationFromLength
1984
- };
1970
+ exports.CitywayRemoteRouter = CitywayRemoteRouter$1;
1971
+ exports.DeutscheBahnRemoteRouter = DeutscheBahnRemoteRouter$1;
1972
+ exports.IdfmRemoteRouter = IdfmRemoteRouter$1;
1973
+ exports.Itinerary = Itinerary;
1974
+ exports.ItineraryInfoManager = ItineraryInfoManager;
1975
+ exports.Leg = Leg;
1976
+ exports.OsrmRemoteRouter = OsrmRemoteRouter$1;
1977
+ exports.OtpRemoteRouter = OtpRemoteRouter$1;
1978
+ exports.RemoteRouterManager = RemoteRouterManager$1;
1979
+ exports.RemoteRouterServerUnreachable = RemoteRouterServerUnreachable;
1980
+ exports.RouterResponse = RouterResponse;
1981
+ exports.StepInfo = StepInfo;
1982
+ exports.WemapMetaRouterIOMap = CustomNetworkMap;
1983
+ exports.WemapMultiRemoteRouter = WemapMultiRemoteRouter$1;
1984
+ exports.WemapMultiRemoteRouterPayload = WemapMultiRemoteRouterPayload;
1985
+ exports.WemapMultiRouter = WemapMultiRouter;
1986
+ exports.WemapOsmRouter = WemapOsmRouter;
1987
+ exports.WemapOsmRouterOptions = WemapOsmRouterOptions;
1988
+ exports.WemapOsmRouterUtils = WemapOsmRouterUtils;
1989
+ exports.getDurationFromLength = getDurationFromLength;
1985
1990
  //# sourceMappingURL=index.js.map