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

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()),
@@ -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