@wemap/routers 12.0.0-alpha.13 → 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) {
@@ -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: []