@wemap/routers 12.7.4 → 12.7.5
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 +15 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/graph/Graph.ts +17 -4
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/routers"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/routers",
|
|
15
|
-
"version": "12.7.
|
|
15
|
+
"version": "12.7.5",
|
|
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": "b35505c8f8fbcd73aa7203c315fdc2fbaca129e1"
|
|
56
56
|
}
|
package/src/graph/Graph.ts
CHANGED
|
@@ -72,7 +72,20 @@ class Graph {
|
|
|
72
72
|
|
|
73
73
|
const useMultiLevelSegments = !('useMultiLevelSegments' in options) || options.useMultiLevelSegments;
|
|
74
74
|
|
|
75
|
-
let bestProjection: GraphProjection | null = null;
|
|
75
|
+
let bestProjection: GraphProjection<U> | null = null;
|
|
76
|
+
|
|
77
|
+
// (for as any) See. https://www.totaltypescript.com/any-considered-harmful#returning-conditional-types-from-generic-functions
|
|
78
|
+
const adaptProjectionCoords = (projCoords: Coordinates): U => {
|
|
79
|
+
if (!(origin instanceof UserPosition)) return projCoords as any;
|
|
80
|
+
const p = origin.clone();
|
|
81
|
+
p.lat = projCoords.lat;
|
|
82
|
+
p.lng = projCoords.lng;
|
|
83
|
+
p.level = projCoords.level;
|
|
84
|
+
p.alt = projCoords.alt;
|
|
85
|
+
p.heightFromFloor = projCoords.heightFromFloor;
|
|
86
|
+
p.heightFromGround = projCoords.heightFromGround;
|
|
87
|
+
return p as any;
|
|
88
|
+
}
|
|
76
89
|
|
|
77
90
|
this.edges.forEach(edge => {
|
|
78
91
|
|
|
@@ -92,7 +105,7 @@ class Graph {
|
|
|
92
105
|
if (useMaxDistance && distanceToSegment > maxDistance) return;
|
|
93
106
|
|
|
94
107
|
if (distanceToSegment < (bestProjection?.distanceFromNearestElement ?? Number.MAX_VALUE)) {
|
|
95
|
-
bestProjection = new GraphProjection(origin, distanceToSegment, segmentProjection, edge);
|
|
108
|
+
bestProjection = new GraphProjection(origin, distanceToSegment, adaptProjectionCoords(segmentProjection), edge);
|
|
96
109
|
}
|
|
97
110
|
});
|
|
98
111
|
|
|
@@ -117,14 +130,14 @@ class Graph {
|
|
|
117
130
|
|
|
118
131
|
// If distance below epsilon consider it as best projection
|
|
119
132
|
if (distanceToVertex < GeoConstants.EPS_MM) {
|
|
120
|
-
bestProjection = new GraphProjection(origin, 0, vertexCoords, vertex);
|
|
133
|
+
bestProjection = new GraphProjection(origin, 0, adaptProjectionCoords(vertexCoords), vertex);
|
|
121
134
|
return;
|
|
122
135
|
}
|
|
123
136
|
|
|
124
137
|
if (useMaxDistance && distanceToVertex > maxDistance) return;
|
|
125
138
|
|
|
126
139
|
if (distanceToVertex < (bestProjection?.distanceFromNearestElement ?? Number.MAX_VALUE)) {
|
|
127
|
-
bestProjection = new GraphProjection(origin, distanceToVertex, vertexCoords, vertex);
|
|
140
|
+
bestProjection = new GraphProjection(origin, distanceToVertex, adaptProjectionCoords(vertexCoords), vertex);
|
|
128
141
|
}
|
|
129
142
|
});
|
|
130
143
|
|