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

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
@@ -1023,6 +1023,54 @@ class GraphRouterEngineResults {
1023
1023
  }
1024
1024
  return new GraphRoute(this.source.coords, to.coords, path, edges, edgesWeights);
1025
1025
  }
1026
+ toGeoJson(graph) {
1027
+ return {
1028
+ type: "FeatureCollection",
1029
+ features: [
1030
+ ...graph.vertices.map((v) => {
1031
+ const prev = this.prev[v.id];
1032
+ const dist = this.dist[v.id];
1033
+ const isSource = v === this.source;
1034
+ const isTarget = this.targets.includes(v);
1035
+ const level = v.coords.level;
1036
+ return {
1037
+ type: "Feature",
1038
+ properties: {
1039
+ id: v.id,
1040
+ ...prev && { prev: prev.id },
1041
+ dist: dist === Number.MAX_VALUE ? "infinity" : dist,
1042
+ ...isSource && { name: "source" },
1043
+ ...isTarget && { name: "target" },
1044
+ ...level !== null && { level },
1045
+ ...v.properties
1046
+ },
1047
+ geometry: {
1048
+ type: "Point",
1049
+ coordinates: [v.coords.lng, v.coords.lat]
1050
+ }
1051
+ };
1052
+ }),
1053
+ ...graph.edges.map((e) => {
1054
+ const level = e.level;
1055
+ return {
1056
+ type: "Feature",
1057
+ properties: {
1058
+ id: e.id,
1059
+ ...level !== null && { level },
1060
+ ...e.properties
1061
+ },
1062
+ geometry: {
1063
+ type: "LineString",
1064
+ coordinates: [
1065
+ [e.vertex1.coords.lng, e.vertex1.coords.lat],
1066
+ [e.vertex2.coords.lng, e.vertex2.coords.lat]
1067
+ ]
1068
+ }
1069
+ };
1070
+ })
1071
+ ]
1072
+ };
1073
+ }
1026
1074
  }
1027
1075
  class GraphRouterEngine {
1028
1076
  constructor(graph) {
@@ -1285,7 +1333,7 @@ class NoRouteFoundError extends Error {
1285
1333
  const _OsmGraphUtils = class _OsmGraphUtils {
1286
1334
  static parseNodeProperties(osmNode) {
1287
1335
  return {
1288
- ...osmNode.name !== null && { name: osmNode.name },
1336
+ ...osmNode.name && { name: osmNode.name },
1289
1337
  ...osmNode.isGate && { isGate: osmNode.isGate },
1290
1338
  ...osmNode.isSubwayEntrance && { isSubwayEntrance: osmNode.isSubwayEntrance },
1291
1339
  ...osmNode.subwayEntranceRef && { subwayEntrsanceRef: osmNode.subwayEntranceRef }
@@ -1293,7 +1341,7 @@ const _OsmGraphUtils = class _OsmGraphUtils {
1293
1341
  }
1294
1342
  static parseWayProperties(osmWay) {
1295
1343
  return {
1296
- ...osmWay.name !== null && { name: osmWay.name },
1344
+ ...osmWay.name && { name: osmWay.name },
1297
1345
  ...osmWay.isOneway && { isOneway: osmWay.isOneway },
1298
1346
  ...osmWay.areStairs && { areStairs: osmWay.areStairs },
1299
1347
  ...osmWay.isElevator && { isElevator: osmWay.isElevator },
@@ -2639,6 +2687,7 @@ class CustomNetworkMap {
2639
2687
  return vertex || null;
2640
2688
  });
2641
2689
  const entryPoints = entryPointsToCheck.filter((it) => it !== null);
2690
+ entryPoints.forEach((v) => graph.exitVertices.add(v));
2642
2691
  const bounds = {
2643
2692
  type: "MultiPolygon",
2644
2693
  coordinates: []