@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/dist/index.js
CHANGED
|
@@ -141,6 +141,18 @@ class Graph {
|
|
|
141
141
|
const useAcceptEdgeFn = "acceptEdgeFn" in options;
|
|
142
142
|
const useMultiLevelSegments = !("useMultiLevelSegments" in options) || options.useMultiLevelSegments;
|
|
143
143
|
let bestProjection = null;
|
|
144
|
+
const adaptProjectionCoords = (projCoords) => {
|
|
145
|
+
if (!(origin instanceof geo.UserPosition))
|
|
146
|
+
return projCoords;
|
|
147
|
+
const p = origin.clone();
|
|
148
|
+
p.lat = projCoords.lat;
|
|
149
|
+
p.lng = projCoords.lng;
|
|
150
|
+
p.level = projCoords.level;
|
|
151
|
+
p.alt = projCoords.alt;
|
|
152
|
+
p.heightFromFloor = projCoords.heightFromFloor;
|
|
153
|
+
p.heightFromGround = projCoords.heightFromGround;
|
|
154
|
+
return p;
|
|
155
|
+
};
|
|
144
156
|
this.edges.forEach((edge) => {
|
|
145
157
|
if (useAcceptEdgeFn && !options.acceptEdgeFn(edge))
|
|
146
158
|
return;
|
|
@@ -159,7 +171,7 @@ class Graph {
|
|
|
159
171
|
if (useMaxDistance && distanceToSegment > maxDistance)
|
|
160
172
|
return;
|
|
161
173
|
if (distanceToSegment < ((bestProjection == null ? void 0 : bestProjection.distanceFromNearestElement) ?? Number.MAX_VALUE)) {
|
|
162
|
-
bestProjection = new GraphProjection(origin, distanceToSegment, segmentProjection, edge);
|
|
174
|
+
bestProjection = new GraphProjection(origin, distanceToSegment, adaptProjectionCoords(segmentProjection), edge);
|
|
163
175
|
}
|
|
164
176
|
});
|
|
165
177
|
if (useMaxBearingAngle) {
|
|
@@ -177,13 +189,13 @@ class Graph {
|
|
|
177
189
|
return;
|
|
178
190
|
const distanceToVertex = vertexCoords.distanceTo(origin);
|
|
179
191
|
if (distanceToVertex < geo.Constants.EPS_MM) {
|
|
180
|
-
bestProjection = new GraphProjection(origin, 0, vertexCoords, vertex);
|
|
192
|
+
bestProjection = new GraphProjection(origin, 0, adaptProjectionCoords(vertexCoords), vertex);
|
|
181
193
|
return;
|
|
182
194
|
}
|
|
183
195
|
if (useMaxDistance && distanceToVertex > maxDistance)
|
|
184
196
|
return;
|
|
185
197
|
if (distanceToVertex < ((bestProjection == null ? void 0 : bestProjection.distanceFromNearestElement) ?? Number.MAX_VALUE)) {
|
|
186
|
-
bestProjection = new GraphProjection(origin, distanceToVertex, vertexCoords, vertex);
|
|
198
|
+
bestProjection = new GraphProjection(origin, distanceToVertex, adaptProjectionCoords(vertexCoords), vertex);
|
|
187
199
|
}
|
|
188
200
|
});
|
|
189
201
|
return bestProjection;
|