@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 +14 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -3
- package/dist/index.mjs.map +1 -1
- package/index.ts +1 -1
- package/package.json +3 -3
- package/src/model/Itinerary.ts +2 -0
- package/src/model/Leg.ts +2 -0
- package/src/model/RouterRequest.ts +10 -0
- package/src/types.ts +0 -1
- package/src/wemap-osm/OsmGraphUtils.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,15 @@ import { OsmNode, OsmParser } from "@wemap/osm";
|
|
|
12
12
|
import Polyline from "@mapbox/polyline";
|
|
13
13
|
import pointInPolygon from "@turf/boolean-point-in-polygon";
|
|
14
14
|
import convexHullFn from "@turf/convex";
|
|
15
|
+
function routerRequestToJson(routerRequest) {
|
|
16
|
+
const { origin, destination, waypoints, ...rest } = routerRequest;
|
|
17
|
+
return {
|
|
18
|
+
origin: origin.toJson(),
|
|
19
|
+
destination: destination.toJson(),
|
|
20
|
+
...waypoints && { waypoints: waypoints.map((w) => w.toJson()) },
|
|
21
|
+
...rest
|
|
22
|
+
};
|
|
23
|
+
}
|
|
15
24
|
const _Edge = class _Edge {
|
|
16
25
|
constructor(vertex1, vertex2, properties = {}) {
|
|
17
26
|
__publicField(this, "id", _Edge.currentUniqueId++);
|
|
@@ -589,6 +598,7 @@ class Leg {
|
|
|
589
598
|
coords: this.end.coords.toCompressedJson(),
|
|
590
599
|
...this.end.name && { name: this.end.name }
|
|
591
600
|
},
|
|
601
|
+
distance: Number(this.distance.toFixed(1)),
|
|
592
602
|
duration: Number(this.duration.toFixed(1)),
|
|
593
603
|
coords: this.coords.map((coords) => coords.toCompressedJson()),
|
|
594
604
|
steps: this.steps.map(stepToJson),
|
|
@@ -772,6 +782,7 @@ class Itinerary {
|
|
|
772
782
|
return {
|
|
773
783
|
origin: this.origin.toJson(),
|
|
774
784
|
destination: this.destination.toJson(),
|
|
785
|
+
distance: Number(this.distance.toFixed(1)),
|
|
775
786
|
duration: Number(this.duration.toFixed(1)),
|
|
776
787
|
transitMode: this.transitMode,
|
|
777
788
|
legs: this.legs.map((leg) => leg.toJson()),
|
|
@@ -1272,7 +1283,7 @@ class NoRouteFoundError extends Error {
|
|
|
1272
1283
|
const _OsmGraphUtils = class _OsmGraphUtils {
|
|
1273
1284
|
static parseNodeProperties(osmNode) {
|
|
1274
1285
|
return {
|
|
1275
|
-
...osmNode.name
|
|
1286
|
+
...osmNode.name && { name: osmNode.name },
|
|
1276
1287
|
...osmNode.isGate && { isGate: osmNode.isGate },
|
|
1277
1288
|
...osmNode.isSubwayEntrance && { isSubwayEntrance: osmNode.isSubwayEntrance },
|
|
1278
1289
|
...osmNode.subwayEntranceRef && { subwayEntrsanceRef: osmNode.subwayEntranceRef }
|
|
@@ -1280,7 +1291,7 @@ const _OsmGraphUtils = class _OsmGraphUtils {
|
|
|
1280
1291
|
}
|
|
1281
1292
|
static parseWayProperties(osmWay) {
|
|
1282
1293
|
return {
|
|
1283
|
-
...osmWay.name
|
|
1294
|
+
...osmWay.name && { name: osmWay.name },
|
|
1284
1295
|
...osmWay.isOneway && { isOneway: osmWay.isOneway },
|
|
1285
1296
|
...osmWay.areStairs && { areStairs: osmWay.areStairs },
|
|
1286
1297
|
...osmWay.isElevator && { isElevator: osmWay.isElevator },
|
|
@@ -2857,6 +2868,7 @@ export {
|
|
|
2857
2868
|
WemapMultiRemoteRouter$1 as WemapMultiRemoteRouter,
|
|
2858
2869
|
WemapMultiRouter,
|
|
2859
2870
|
WemapMultiRoutingError,
|
|
2860
|
-
getDurationFromLength
|
|
2871
|
+
getDurationFromLength,
|
|
2872
|
+
routerRequestToJson
|
|
2861
2873
|
};
|
|
2862
2874
|
//# sourceMappingURL=index.mjs.map
|