@wemap/routers 12.0.0-alpha.11 → 12.0.0-alpha.13

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
@@ -14,6 +14,15 @@ const osm = require("@wemap/osm");
14
14
  const Polyline = require("@mapbox/polyline");
15
15
  const pointInPolygon = require("@turf/boolean-point-in-polygon");
16
16
  const convexHullFn = require("@turf/convex");
17
+ function routerRequestToJson(routerRequest) {
18
+ const { origin, destination, waypoints, ...rest } = routerRequest;
19
+ return {
20
+ origin: origin.toJson(),
21
+ destination: destination.toJson(),
22
+ ...waypoints && { waypoints: waypoints.map((w) => w.toJson()) },
23
+ ...rest
24
+ };
25
+ }
17
26
  const _Edge = class _Edge {
18
27
  constructor(vertex1, vertex2, properties = {}) {
19
28
  __publicField(this, "id", _Edge.currentUniqueId++);
@@ -591,6 +600,7 @@ class Leg {
591
600
  coords: this.end.coords.toCompressedJson(),
592
601
  ...this.end.name && { name: this.end.name }
593
602
  },
603
+ distance: Number(this.distance.toFixed(1)),
594
604
  duration: Number(this.duration.toFixed(1)),
595
605
  coords: this.coords.map((coords) => coords.toCompressedJson()),
596
606
  steps: this.steps.map(stepToJson),
@@ -774,6 +784,7 @@ class Itinerary {
774
784
  return {
775
785
  origin: this.origin.toJson(),
776
786
  destination: this.destination.toJson(),
787
+ distance: Number(this.distance.toFixed(1)),
777
788
  duration: Number(this.duration.toFixed(1)),
778
789
  transitMode: this.transitMode,
779
790
  legs: this.legs.map((leg) => leg.toJson()),
@@ -1274,7 +1285,7 @@ class NoRouteFoundError extends Error {
1274
1285
  const _OsmGraphUtils = class _OsmGraphUtils {
1275
1286
  static parseNodeProperties(osmNode) {
1276
1287
  return {
1277
- ...osmNode.name !== null && { name: osmNode.name },
1288
+ ...osmNode.name && { name: osmNode.name },
1278
1289
  ...osmNode.isGate && { isGate: osmNode.isGate },
1279
1290
  ...osmNode.isSubwayEntrance && { isSubwayEntrance: osmNode.isSubwayEntrance },
1280
1291
  ...osmNode.subwayEntranceRef && { subwayEntrsanceRef: osmNode.subwayEntranceRef }
@@ -1282,7 +1293,7 @@ const _OsmGraphUtils = class _OsmGraphUtils {
1282
1293
  }
1283
1294
  static parseWayProperties(osmWay) {
1284
1295
  return {
1285
- ...osmWay.name !== null && { name: osmWay.name },
1296
+ ...osmWay.name && { name: osmWay.name },
1286
1297
  ...osmWay.isOneway && { isOneway: osmWay.isOneway },
1287
1298
  ...osmWay.areStairs && { areStairs: osmWay.areStairs },
1288
1299
  ...osmWay.isElevator && { isElevator: osmWay.isElevator },
@@ -2859,4 +2870,5 @@ exports.WemapMultiRemoteRouter = WemapMultiRemoteRouter$1;
2859
2870
  exports.WemapMultiRouter = WemapMultiRouter;
2860
2871
  exports.WemapMultiRoutingError = WemapMultiRoutingError;
2861
2872
  exports.getDurationFromLength = getDurationFromLength;
2873
+ exports.routerRequestToJson = routerRequestToJson;
2862
2874
  //# sourceMappingURL=index.js.map