@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/dist/index.js
CHANGED
|
@@ -182,6 +182,7 @@ class Graph {
|
|
|
182
182
|
toCompressedJson() {
|
|
183
183
|
return {
|
|
184
184
|
vertices: this.vertices.map((vertex) => vertex.toJson()),
|
|
185
|
+
verticesIds: this.vertices.map((vertex) => vertex.id),
|
|
185
186
|
edges: this.edges.map((edge) => {
|
|
186
187
|
const vertex1Idx = this.vertices.indexOf(edge.vertex1);
|
|
187
188
|
const vertex2Idx = this.vertices.indexOf(edge.vertex2);
|
|
@@ -195,13 +196,11 @@ class Graph {
|
|
|
195
196
|
}
|
|
196
197
|
static fromCompressedJson(json) {
|
|
197
198
|
const vertices = json.vertices.map((vertex) => Vertex.fromJson(vertex));
|
|
198
|
-
const edges = json.edges.map(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
)
|
|
204
|
-
);
|
|
199
|
+
const edges = json.edges.map((jsonEdge) => new Edge(
|
|
200
|
+
vertices[jsonEdge[0]],
|
|
201
|
+
vertices[jsonEdge[1]],
|
|
202
|
+
jsonEdge.length > 2 ? jsonEdge[2] : {}
|
|
203
|
+
));
|
|
205
204
|
return new Graph(vertices, edges);
|
|
206
205
|
}
|
|
207
206
|
static fromCoordinatesSegments(segments) {
|
|
@@ -842,33 +841,37 @@ class Itinerary {
|
|
|
842
841
|
}
|
|
843
842
|
}
|
|
844
843
|
toGeoJson() {
|
|
845
|
-
const transformToPoint = (point, name) => ({
|
|
844
|
+
const transformToPoint = (point, name, type) => ({
|
|
846
845
|
type: "Feature",
|
|
847
|
-
properties: { name, level: point.level },
|
|
846
|
+
properties: { name, level: point.level, ...type && { type } },
|
|
848
847
|
geometry: {
|
|
849
848
|
type: "Point",
|
|
850
849
|
coordinates: [point.lng, point.lat]
|
|
851
850
|
}
|
|
852
851
|
});
|
|
853
|
-
const transformToMultiLineStrings = (segments, level) => {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
};
|
|
862
|
-
};
|
|
852
|
+
const transformToMultiLineStrings = (segments, level) => ({
|
|
853
|
+
type: "Feature",
|
|
854
|
+
properties: { level, name: level == null ? void 0 : level.toString() },
|
|
855
|
+
geometry: {
|
|
856
|
+
type: "MultiLineString",
|
|
857
|
+
coordinates: segments.map((s) => s.map(({ lat, lng }) => [lng, lat]))
|
|
858
|
+
}
|
|
859
|
+
});
|
|
863
860
|
const levelsOfItinerary = [...new Set(this.coords.map((c) => geo.Level.toString(c.level)))].map(geo.Level.fromString);
|
|
864
861
|
const segmentsSplitted = levelsOfItinerary.map((loi) => [loi, geo.Utils.createSegmentsAtLevel(this.coords, loi, true)]);
|
|
865
862
|
const multiLineStrings = segmentsSplitted.map(([loi, segments]) => transformToMultiLineStrings(segments, loi));
|
|
863
|
+
const legsStarts = this.legs.map((leg, idx) => transformToPoint(leg.start.coords, `Leg ${idx} start`, "leg-start"));
|
|
864
|
+
const legsEnds = this.legs.map((leg, idx) => transformToPoint(leg.end.coords, `Leg ${idx} end`, "leg-end"));
|
|
865
|
+
const steps = this.steps.map((step) => transformToPoint(step.coords, `Step ${step.number}`, "step"));
|
|
866
866
|
return {
|
|
867
867
|
type: "FeatureCollection",
|
|
868
868
|
features: [
|
|
869
|
-
transformToPoint(this.origin, "origin"),
|
|
870
|
-
transformToPoint(this.destination, "destination"),
|
|
871
|
-
...multiLineStrings
|
|
869
|
+
transformToPoint(this.origin, "origin", "origin"),
|
|
870
|
+
transformToPoint(this.destination, "destination", "destination"),
|
|
871
|
+
...multiLineStrings,
|
|
872
|
+
...legsStarts,
|
|
873
|
+
...legsEnds,
|
|
874
|
+
...steps
|
|
872
875
|
]
|
|
873
876
|
};
|
|
874
877
|
}
|
|
@@ -1205,12 +1208,14 @@ class GraphRouter extends GraphRouterEngine {
|
|
|
1205
1208
|
if (projection.nearestElement instanceof Edge) {
|
|
1206
1209
|
const edge = projection.nearestElement;
|
|
1207
1210
|
const newVertex = new Vertex(projection.coords, {
|
|
1208
|
-
name: `proj on ${edge.properties.name || null} (tmp)
|
|
1211
|
+
name: `proj on ${edge.properties.name || null} (tmp)`,
|
|
1212
|
+
...typeof edge.properties.externalId !== "undefined" && { externalId: edge.properties.externalId }
|
|
1209
1213
|
});
|
|
1210
1214
|
newVertex.id = this.graph.vertices.length + createdVertices.size;
|
|
1211
1215
|
const newEdgesOptions = {
|
|
1212
1216
|
...edge.properties,
|
|
1213
|
-
name: `splitted ${edge.properties.name || null} (tmp)
|
|
1217
|
+
name: `splitted ${edge.properties.name || null} (tmp)`,
|
|
1218
|
+
...typeof edge.properties.externalId !== "undefined" && { externalId: edge.properties.externalId }
|
|
1214
1219
|
};
|
|
1215
1220
|
const newEdge1 = new Edge(edge.vertex1, newVertex, newEdgesOptions);
|
|
1216
1221
|
const newEdge2 = new Edge(newVertex, edge.vertex2, newEdgesOptions);
|
|
@@ -1334,6 +1339,7 @@ const _OsmGraphUtils = class _OsmGraphUtils {
|
|
|
1334
1339
|
static parseNodeProperties(osmNode) {
|
|
1335
1340
|
return {
|
|
1336
1341
|
...osmNode.name && { name: osmNode.name },
|
|
1342
|
+
...osmNode.id && { externalId: osmNode.id },
|
|
1337
1343
|
...osmNode.isGate && { isGate: osmNode.isGate },
|
|
1338
1344
|
...osmNode.isSubwayEntrance && { isSubwayEntrance: osmNode.isSubwayEntrance },
|
|
1339
1345
|
...osmNode.subwayEntranceRef && { subwayEntrsanceRef: osmNode.subwayEntranceRef }
|
|
@@ -1342,6 +1348,7 @@ const _OsmGraphUtils = class _OsmGraphUtils {
|
|
|
1342
1348
|
static parseWayProperties(osmWay) {
|
|
1343
1349
|
return {
|
|
1344
1350
|
...osmWay.name && { name: osmWay.name },
|
|
1351
|
+
...osmWay.id && { externalId: osmWay.id },
|
|
1345
1352
|
...osmWay.isOneway && { isOneway: osmWay.isOneway },
|
|
1346
1353
|
...osmWay.areStairs && { areStairs: osmWay.areStairs },
|
|
1347
1354
|
...osmWay.isElevator && { isElevator: osmWay.isElevator },
|
|
@@ -1415,11 +1422,11 @@ const _OsmGraphUtils = class _OsmGraphUtils {
|
|
|
1415
1422
|
const elevatorCenterFakeOsmNode = new osm.OsmNode(fakeOsmNodeId--, elevatorCenterCoords, { highway: "elevator" });
|
|
1416
1423
|
entryVertices.forEach((entryVertex) => {
|
|
1417
1424
|
const vertexCenter = getOrCreateVertex(elevatorCenterFakeOsmNode, entryVertex.coords.level);
|
|
1418
|
-
edges.push(new Edge(vertexCenter, entryVertex));
|
|
1425
|
+
edges.push(new Edge(vertexCenter, entryVertex, { externalId: way.id }));
|
|
1419
1426
|
});
|
|
1420
1427
|
});
|
|
1421
|
-
elevatorVertices.forEach(([, name, verticesOfEachLevel]) => {
|
|
1422
|
-
const elevatorEdgeProps = { name, isElevator: true };
|
|
1428
|
+
elevatorVertices.forEach(([id, name, verticesOfEachLevel]) => {
|
|
1429
|
+
const elevatorEdgeProps = { name, isElevator: true, externalId: id };
|
|
1423
1430
|
for (let i = 0; i < verticesOfEachLevel.length; i++) {
|
|
1424
1431
|
for (let j = i + 1; j < verticesOfEachLevel.length; j++) {
|
|
1425
1432
|
edges.push(new Edge(verticesOfEachLevel[i], verticesOfEachLevel[j], elevatorEdgeProps));
|
|
@@ -2784,17 +2791,6 @@ class CustomNetworkMap {
|
|
|
2784
2791
|
getRoutesMultipleDestinationsInsideMap(start, ends, options) {
|
|
2785
2792
|
return this.router.calculateShortestPathToMultipleDestinations(start, ends, options);
|
|
2786
2793
|
}
|
|
2787
|
-
get disabledEdges() {
|
|
2788
|
-
return this.router.disabledEdges;
|
|
2789
|
-
}
|
|
2790
|
-
enableEdge(edgeId) {
|
|
2791
|
-
const edge = this.graph.edges.find((e) => e.id === edgeId);
|
|
2792
|
-
return Boolean(edge && this.router.disabledEdges.delete(edge));
|
|
2793
|
-
}
|
|
2794
|
-
disableEdge(edgeId) {
|
|
2795
|
-
const edge = this.graph.edges.find((e) => e.id === edgeId);
|
|
2796
|
-
return Boolean(edge && this.router.disabledEdges.add(edge));
|
|
2797
|
-
}
|
|
2798
2794
|
}
|
|
2799
2795
|
class ItineraryInfoManager {
|
|
2800
2796
|
constructor(itinerary = null) {
|