@wemap/geo 11.3.1 → 11.5.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 +27 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/graph/GeoGraph.spec.ts +13 -13
- package/src/graph/GeoGraphEdge.spec.ts +12 -12
- package/src/graph/GeoGraphItinerary.spec.ts +2 -2
- package/src/graph/GeoGraphProjectionHandler.spec.ts +15 -15
- package/src/graph/GeoGraphProjectionHandler.ts +32 -32
- package/src/graph/NoRouteFoundError.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1384,19 +1384,19 @@ const _GeoGraphProjectionHandler = class {
|
|
|
1384
1384
|
get maxDistance() {
|
|
1385
1385
|
return this._maxDistance;
|
|
1386
1386
|
}
|
|
1387
|
-
|
|
1387
|
+
_shouldProjectOnEdgeAndVertices(edge, location, useBearing, useMultiLevelSegments, acceptEdgeFn) {
|
|
1388
1388
|
if (!acceptEdgeFn(edge)) {
|
|
1389
1389
|
return [false, false, false];
|
|
1390
1390
|
}
|
|
1391
1391
|
let checkEdge = Level.intersect(location.level, edge.level);
|
|
1392
|
-
let
|
|
1393
|
-
let
|
|
1394
|
-
|
|
1395
|
-
|
|
1392
|
+
let checkVertex1 = Level.intersect(location.level, edge.vertex1.coords.level);
|
|
1393
|
+
let checkVertex2 = Level.intersect(location.level, edge.vertex2.coords.level);
|
|
1394
|
+
checkVertex1 = checkVertex1 || edge.vertex1.io && location.level === null;
|
|
1395
|
+
checkVertex2 = checkVertex2 || edge.vertex2.io && location.level === null;
|
|
1396
1396
|
if (!useMultiLevelSegments) {
|
|
1397
1397
|
checkEdge = checkEdge && !Level.isRange(edge.level);
|
|
1398
|
-
|
|
1399
|
-
|
|
1398
|
+
checkVertex1 = checkVertex1 && !Level.isRange(edge.vertex1.coords.level);
|
|
1399
|
+
checkVertex2 = checkVertex2 && !Level.isRange(edge.vertex2.coords.level);
|
|
1400
1400
|
}
|
|
1401
1401
|
if (useBearing) {
|
|
1402
1402
|
if (checkEdge) {
|
|
@@ -1405,18 +1405,18 @@ const _GeoGraphProjectionHandler = class {
|
|
|
1405
1405
|
checkEdge = false;
|
|
1406
1406
|
}
|
|
1407
1407
|
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1408
|
+
checkVertex1 = false;
|
|
1409
|
+
checkVertex2 = false;
|
|
1410
1410
|
}
|
|
1411
|
-
return [checkEdge,
|
|
1411
|
+
return [checkEdge, checkVertex1, checkVertex2];
|
|
1412
1412
|
}
|
|
1413
1413
|
static _assignLatLngLevel(fromCoordinates, toCoordinates) {
|
|
1414
1414
|
toCoordinates.lat = fromCoordinates.lat;
|
|
1415
1415
|
toCoordinates.lng = fromCoordinates.lng;
|
|
1416
1416
|
toCoordinates.level = Level.clone(fromCoordinates.level);
|
|
1417
1417
|
}
|
|
1418
|
-
static
|
|
1419
|
-
if (location.level === null &&
|
|
1418
|
+
static _handleLevelsWithIOVertices(projection, location, projectionVertex) {
|
|
1419
|
+
if (location.level === null && projectionVertex.io) {
|
|
1420
1420
|
projection.level = null;
|
|
1421
1421
|
}
|
|
1422
1422
|
}
|
|
@@ -1434,33 +1434,33 @@ const _GeoGraphProjectionHandler = class {
|
|
|
1434
1434
|
return distanceOfNewProjection < distanceFromNearestElement && (!useDistance || distanceOfNewProjection <= this._maxDistance);
|
|
1435
1435
|
};
|
|
1436
1436
|
for (const edge of this.graph.edges) {
|
|
1437
|
-
const [checkEdge,
|
|
1437
|
+
const [checkEdge, checkVertex1, checkVertex2] = this._shouldProjectOnEdgeAndVertices(
|
|
1438
1438
|
edge,
|
|
1439
1439
|
location,
|
|
1440
1440
|
useBearing,
|
|
1441
1441
|
useMultiLevelSegments,
|
|
1442
1442
|
acceptEdgeFn
|
|
1443
1443
|
);
|
|
1444
|
-
if (
|
|
1445
|
-
const
|
|
1446
|
-
if (isProjectionBetter(
|
|
1447
|
-
distanceFromNearestElement =
|
|
1444
|
+
if (checkVertex1) {
|
|
1445
|
+
const distVertex1 = location.distanceTo(edge.vertex1.coords);
|
|
1446
|
+
if (isProjectionBetter(distVertex1) || distVertex1 <= EPS_MM) {
|
|
1447
|
+
distanceFromNearestElement = distVertex1;
|
|
1448
1448
|
nearestElement = edge.vertex1;
|
|
1449
1449
|
_GeoGraphProjectionHandler._assignLatLngLevel(edge.vertex1.coords, projection);
|
|
1450
|
-
_GeoGraphProjectionHandler.
|
|
1451
|
-
if (
|
|
1450
|
+
_GeoGraphProjectionHandler._handleLevelsWithIOVertices(projection, location, edge.vertex1);
|
|
1451
|
+
if (distVertex1 <= EPS_MM) {
|
|
1452
1452
|
break;
|
|
1453
1453
|
}
|
|
1454
1454
|
}
|
|
1455
1455
|
}
|
|
1456
|
-
if (
|
|
1457
|
-
const
|
|
1458
|
-
if (isProjectionBetter(
|
|
1459
|
-
distanceFromNearestElement =
|
|
1456
|
+
if (checkVertex2) {
|
|
1457
|
+
const distVertex2 = location.distanceTo(edge.vertex2.coords);
|
|
1458
|
+
if (isProjectionBetter(distVertex2) || distVertex2 <= EPS_MM) {
|
|
1459
|
+
distanceFromNearestElement = distVertex2;
|
|
1460
1460
|
nearestElement = edge.vertex2;
|
|
1461
1461
|
_GeoGraphProjectionHandler._assignLatLngLevel(edge.vertex2.coords, projection);
|
|
1462
|
-
_GeoGraphProjectionHandler.
|
|
1463
|
-
if (
|
|
1462
|
+
_GeoGraphProjectionHandler._handleLevelsWithIOVertices(projection, location, edge.vertex2);
|
|
1463
|
+
if (distVertex2 <= EPS_MM) {
|
|
1464
1464
|
break;
|
|
1465
1465
|
}
|
|
1466
1466
|
}
|
|
@@ -1539,13 +1539,13 @@ class NoRouteFoundError extends Error {
|
|
|
1539
1539
|
}
|
|
1540
1540
|
get startStr() {
|
|
1541
1541
|
if (this.start instanceof GeoGraphVertex) {
|
|
1542
|
-
return `
|
|
1542
|
+
return `GeoGraphVertex ${this.start.coords.toString()}`;
|
|
1543
1543
|
}
|
|
1544
1544
|
return this.start.toString();
|
|
1545
1545
|
}
|
|
1546
1546
|
get endStr() {
|
|
1547
1547
|
if (this.end instanceof GeoGraphVertex) {
|
|
1548
|
-
return `
|
|
1548
|
+
return `GeoGraphVertex ${this.end.coords.toString()}`;
|
|
1549
1549
|
}
|
|
1550
1550
|
return this.end.toString();
|
|
1551
1551
|
}
|