@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/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/* Model */
|
|
3
|
-
export { type RouterRequest } from './src/model/RouterRequest.js';
|
|
3
|
+
export { type RouterRequest, routerRequestToJson } from './src/model/RouterRequest.js';
|
|
4
4
|
export { default as Itinerary, type ItineraryJson } from './src/model/Itinerary.js';
|
|
5
5
|
export { default as Leg, type LegJson, type DestinationJson, type TransportInfo } from './src/model/Leg.js';
|
|
6
6
|
export type { Step, MinStepInfo, StepJson } from './src/model/Step.js';
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/routers"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/routers",
|
|
15
|
-
"version": "12.0.0-alpha.
|
|
15
|
+
"version": "12.0.0-alpha.13",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@wemap/geo": "^12.0.0-alpha.11",
|
|
38
38
|
"@wemap/logger": "^12.0.0-alpha.0",
|
|
39
39
|
"@wemap/maths": "^11.0.1",
|
|
40
|
-
"@wemap/osm": "^12.0.0-alpha.
|
|
40
|
+
"@wemap/osm": "^12.0.0-alpha.13",
|
|
41
41
|
"@wemap/salesman.js": "^2.1.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
},
|
|
53
53
|
"./helpers/*": "./helpers/*"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "d96b3c94a650a0d67a1706ac3c71d5c571f75ac0"
|
|
56
56
|
}
|
package/src/model/Itinerary.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type ItineraryJson = {
|
|
|
20
20
|
transitMode: TransitMode,
|
|
21
21
|
origin: CoordinatesJson,
|
|
22
22
|
destination: CoordinatesJson,
|
|
23
|
+
distance: number,
|
|
23
24
|
duration: number,
|
|
24
25
|
legs: LegJson[]
|
|
25
26
|
} & ItineraryCommon;
|
|
@@ -229,6 +230,7 @@ export default class Itinerary {
|
|
|
229
230
|
return {
|
|
230
231
|
origin: this.origin.toJson(),
|
|
231
232
|
destination: this.destination.toJson(),
|
|
233
|
+
distance: Number(this.distance.toFixed(1)),
|
|
232
234
|
duration: Number(this.duration.toFixed(1)),
|
|
233
235
|
transitMode: this.transitMode,
|
|
234
236
|
legs: this.legs.map(leg => leg.toJson()),
|
package/src/model/Leg.ts
CHANGED
|
@@ -54,6 +54,7 @@ export type LegJson = {
|
|
|
54
54
|
end: DestinationJson,
|
|
55
55
|
coords: CoordinatesCompressedJson[],
|
|
56
56
|
steps: StepJson[],
|
|
57
|
+
distance: number,
|
|
57
58
|
duration: number
|
|
58
59
|
} & LegCommon;
|
|
59
60
|
|
|
@@ -167,6 +168,7 @@ export default class Leg {
|
|
|
167
168
|
coords: this.end.coords.toCompressedJson(),
|
|
168
169
|
...(this.end.name && { name: this.end.name }),
|
|
169
170
|
},
|
|
171
|
+
distance: Number(this.distance.toFixed(1)),
|
|
170
172
|
duration: Number(this.duration.toFixed(1)),
|
|
171
173
|
coords: this.coords.map(coords => coords.toCompressedJson()),
|
|
172
174
|
steps: this.steps.map(stepToJson),
|
|
@@ -20,4 +20,14 @@ export type RouterRequest = {
|
|
|
20
20
|
output?: {
|
|
21
21
|
distanceAndDurationOnly?: boolean
|
|
22
22
|
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function routerRequestToJson(routerRequest: RouterRequest) {
|
|
26
|
+
const { origin, destination, waypoints, ...rest } = routerRequest;
|
|
27
|
+
return {
|
|
28
|
+
origin: origin.toJson(),
|
|
29
|
+
destination: destination.toJson(),
|
|
30
|
+
...(waypoints && { waypoints: waypoints.map(w => w.toJson()) }),
|
|
31
|
+
...rest
|
|
32
|
+
}
|
|
23
33
|
}
|
package/src/types.ts
CHANGED
|
@@ -22,7 +22,7 @@ export default class OsmGraphUtils {
|
|
|
22
22
|
|
|
23
23
|
static parseNodeProperties(osmNode: OsmNode): VertexProperties {
|
|
24
24
|
return {
|
|
25
|
-
...(osmNode.name
|
|
25
|
+
...(osmNode.name && { name: osmNode.name }),
|
|
26
26
|
...(osmNode.isGate && { isGate: osmNode.isGate }),
|
|
27
27
|
...(osmNode.isSubwayEntrance && { isSubwayEntrance: osmNode.isSubwayEntrance }),
|
|
28
28
|
...(osmNode.subwayEntranceRef && { subwayEntrsanceRef: osmNode.subwayEntranceRef })
|
|
@@ -31,7 +31,7 @@ export default class OsmGraphUtils {
|
|
|
31
31
|
|
|
32
32
|
static parseWayProperties(osmWay: OsmWay): EdgeProperties {
|
|
33
33
|
return {
|
|
34
|
-
...(osmWay.name
|
|
34
|
+
...(osmWay.name && { name: osmWay.name }),
|
|
35
35
|
...(osmWay.isOneway && { isOneway: osmWay.isOneway }),
|
|
36
36
|
...(osmWay.areStairs && { areStairs: osmWay.areStairs }),
|
|
37
37
|
...(osmWay.isElevator && { isElevator: osmWay.isElevator }),
|