@wemap/routers 12.0.0 → 12.1.0
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 +34 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/graph/Edge.ts +3 -0
- package/src/graph/Graph.ts +2 -2
- package/src/graph/GraphRouter.ts +3 -1
- package/src/graph/Vertex.ts +1 -0
- package/src/model/Itinerary.ts +18 -14
- package/src/types.ts +1 -0
- package/src/wemap-multi/CustomNetworkMap.ts +0 -11
- package/src/wemap-osm/OsmGraphUtils.ts +5 -3
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/routers"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/routers",
|
|
15
|
-
"version": "12.
|
|
15
|
+
"version": "12.1.0",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
},
|
|
53
53
|
"./helpers/*": "./helpers/*"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "a9ae25d8931032e8779034182c62aa6af1528819"
|
|
56
56
|
}
|
package/src/graph/Edge.ts
CHANGED
package/src/graph/Graph.ts
CHANGED
|
@@ -135,6 +135,7 @@ class Graph {
|
|
|
135
135
|
toCompressedJson(): GeoGraphJson {
|
|
136
136
|
return {
|
|
137
137
|
vertices: this.vertices.map(vertex => vertex.toJson()),
|
|
138
|
+
verticesIds: this.vertices.map(vertex => vertex.id),
|
|
138
139
|
edges: this.edges.map(edge => {
|
|
139
140
|
const vertex1Idx = this.vertices.indexOf(edge.vertex1);
|
|
140
141
|
const vertex2Idx = this.vertices.indexOf(edge.vertex2);
|
|
@@ -155,8 +156,7 @@ class Graph {
|
|
|
155
156
|
vertices[jsonEdge[0]],
|
|
156
157
|
vertices[jsonEdge[1]],
|
|
157
158
|
jsonEdge.length > 2 ? jsonEdge[2] : {}
|
|
158
|
-
)
|
|
159
|
-
);
|
|
159
|
+
));
|
|
160
160
|
|
|
161
161
|
return new Graph(vertices, edges);
|
|
162
162
|
}
|
package/src/graph/GraphRouter.ts
CHANGED
|
@@ -107,12 +107,14 @@ class GraphRouter extends GraphRouterEngine {
|
|
|
107
107
|
if (projection.nearestElement instanceof Edge) {
|
|
108
108
|
const edge = projection.nearestElement;
|
|
109
109
|
const newVertex = new Vertex(projection.coords, {
|
|
110
|
-
name: `proj on ${edge.properties.name || null} (tmp)
|
|
110
|
+
name: `proj on ${edge.properties.name || null} (tmp)`,
|
|
111
|
+
...(typeof edge.properties.externalId !== 'undefined' && { externalId: edge.properties.externalId })
|
|
111
112
|
});
|
|
112
113
|
newVertex.id = this.graph.vertices.length + createdVertices.size;
|
|
113
114
|
const newEdgesOptions: EdgeProperties = {
|
|
114
115
|
...edge.properties,
|
|
115
116
|
name: `splitted ${edge.properties.name || null} (tmp)`,
|
|
117
|
+
...(typeof edge.properties.externalId !== 'undefined' && { externalId: edge.properties.externalId })
|
|
116
118
|
};
|
|
117
119
|
const newEdge1 = new Edge(edge.vertex1, newVertex, newEdgesOptions);
|
|
118
120
|
const newEdge2 = new Edge(newVertex, edge.vertex2, newEdgesOptions);
|
package/src/graph/Vertex.ts
CHANGED
package/src/model/Itinerary.ts
CHANGED
|
@@ -301,34 +301,38 @@ export default class Itinerary {
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
toGeoJson(): FeatureCollection {
|
|
304
|
-
const transformToPoint = (point: Coordinates, name?: string): Feature<Point> => ({
|
|
304
|
+
const transformToPoint = (point: Coordinates, name?: string, type?: string): Feature<Point> => ({
|
|
305
305
|
type: "Feature",
|
|
306
|
-
properties: { name, level: point.level },
|
|
306
|
+
properties: { name, level: point.level, ...(type && { type }) },
|
|
307
307
|
geometry: {
|
|
308
308
|
type: 'Point',
|
|
309
309
|
coordinates: [point.lng, point.lat]
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
|
-
const transformToMultiLineStrings = (segments: Coordinates[][], level: Level_t): Feature<MultiLineString> => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
coordinates: segments.map(s => s.map(({ lat, lng }) => [lng, lat]))
|
|
319
|
-
}
|
|
312
|
+
const transformToMultiLineStrings = (segments: Coordinates[][], level: Level_t): Feature<MultiLineString> => ({
|
|
313
|
+
type: "Feature",
|
|
314
|
+
properties: { level, name: level?.toString() },
|
|
315
|
+
geometry: {
|
|
316
|
+
type: 'MultiLineString',
|
|
317
|
+
coordinates: segments.map(s => s.map(({ lat, lng }) => [lng, lat]))
|
|
320
318
|
}
|
|
321
|
-
}
|
|
319
|
+
});
|
|
322
320
|
|
|
323
321
|
const levelsOfItinerary = [...new Set(this.coords.map(c => Level.toString(c.level)))].map(Level.fromString);
|
|
324
322
|
const segmentsSplitted: [Level_t, Coordinates[][]][] = levelsOfItinerary.map(loi => [loi, GeoUtils.createSegmentsAtLevel(this.coords, loi, true)]);
|
|
325
323
|
const multiLineStrings = segmentsSplitted.map(([loi, segments]) => transformToMultiLineStrings(segments, loi))
|
|
324
|
+
const legsStarts = this.legs.map((leg, idx) => transformToPoint(leg.start.coords, `Leg ${idx} start`, 'leg-start'));
|
|
325
|
+
const legsEnds = this.legs.map((leg, idx) => transformToPoint(leg.end.coords, `Leg ${idx} end`, 'leg-end'));
|
|
326
|
+
const steps = this.steps.map(step => transformToPoint(step.coords, `Step ${step.number}`, 'step'))
|
|
326
327
|
return {
|
|
327
328
|
type: "FeatureCollection",
|
|
328
329
|
features: [
|
|
329
|
-
transformToPoint(this.origin, 'origin'),
|
|
330
|
-
transformToPoint(this.destination, 'destination'),
|
|
331
|
-
...multiLineStrings
|
|
330
|
+
transformToPoint(this.origin, 'origin', 'origin'),
|
|
331
|
+
transformToPoint(this.destination, 'destination', 'destination'),
|
|
332
|
+
...multiLineStrings,
|
|
333
|
+
...legsStarts,
|
|
334
|
+
...legsEnds,
|
|
335
|
+
...steps
|
|
332
336
|
]
|
|
333
337
|
};
|
|
334
338
|
}
|
package/src/types.ts
CHANGED
|
@@ -190,17 +190,6 @@ class CustomNetworkMap {
|
|
|
190
190
|
return this.router.calculateShortestPathToMultipleDestinations(start, ends, options);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
get disabledEdges() { return this.router.disabledEdges }
|
|
194
|
-
|
|
195
|
-
enableEdge(edgeId: number) {
|
|
196
|
-
const edge = this.graph.edges.find(e => e.id === edgeId);
|
|
197
|
-
return Boolean(edge && this.router.disabledEdges.delete(edge));
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
disableEdge(edgeId: number) {
|
|
201
|
-
const edge = this.graph.edges.find(e => e.id === edgeId);
|
|
202
|
-
return Boolean(edge && this.router.disabledEdges.add(edge));
|
|
203
|
-
}
|
|
204
193
|
}
|
|
205
194
|
|
|
206
195
|
export default CustomNetworkMap;
|
|
@@ -24,6 +24,7 @@ export default class OsmGraphUtils {
|
|
|
24
24
|
static parseNodeProperties(osmNode: OsmNode): VertexProperties {
|
|
25
25
|
return {
|
|
26
26
|
...(osmNode.name && { name: osmNode.name }),
|
|
27
|
+
...(osmNode.id && { externalId: osmNode.id }),
|
|
27
28
|
...(osmNode.isGate && { isGate: osmNode.isGate }),
|
|
28
29
|
...(osmNode.isSubwayEntrance && { isSubwayEntrance: osmNode.isSubwayEntrance }),
|
|
29
30
|
...(osmNode.subwayEntranceRef && { subwayEntrsanceRef: osmNode.subwayEntranceRef })
|
|
@@ -33,6 +34,7 @@ export default class OsmGraphUtils {
|
|
|
33
34
|
static parseWayProperties(osmWay: OsmWay): EdgeProperties {
|
|
34
35
|
return {
|
|
35
36
|
...(osmWay.name && { name: osmWay.name }),
|
|
37
|
+
...(osmWay.id && { externalId: osmWay.id }),
|
|
36
38
|
...(osmWay.isOneway && { isOneway: osmWay.isOneway }),
|
|
37
39
|
...(osmWay.areStairs && { areStairs: osmWay.areStairs }),
|
|
38
40
|
...(osmWay.isElevator && { isElevator: osmWay.isElevator }),
|
|
@@ -143,14 +145,14 @@ export default class OsmGraphUtils {
|
|
|
143
145
|
|
|
144
146
|
entryVertices.forEach(entryVertex => {
|
|
145
147
|
const vertexCenter = getOrCreateVertex(elevatorCenterFakeOsmNode, entryVertex.coords.level);
|
|
146
|
-
edges.push(new Edge(vertexCenter, entryVertex));
|
|
148
|
+
edges.push(new Edge(vertexCenter, entryVertex, { externalId: way.id }));
|
|
147
149
|
})
|
|
148
150
|
});
|
|
149
151
|
|
|
150
152
|
|
|
151
153
|
// 4. Link elevators vertices
|
|
152
|
-
elevatorVertices.forEach(([, name, verticesOfEachLevel]) => {
|
|
153
|
-
const elevatorEdgeProps = { name, isElevator: true };
|
|
154
|
+
elevatorVertices.forEach(([id, name, verticesOfEachLevel]) => {
|
|
155
|
+
const elevatorEdgeProps = { name, isElevator: true, externalId: id };
|
|
154
156
|
// Link vertices of each level together
|
|
155
157
|
for (let i = 0; i < verticesOfEachLevel.length; i++) {
|
|
156
158
|
for (let j = i + 1; j < verticesOfEachLevel.length; j++) {
|