@wemap/geo 3.2.3 → 3.2.15
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/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/geo"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/geo",
|
|
15
|
-
"version": "3.2.
|
|
15
|
+
"version": "3.2.15",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@wemap/logger": "^3.2.3",
|
|
30
|
-
"@wemap/maths": "^3.2.
|
|
30
|
+
"@wemap/maths": "^3.2.15"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "adde2357c87a5429e7b3bea068729d6e06c9c3ca"
|
|
33
33
|
}
|
package/src/Utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-statements */
|
|
2
|
+
import Constants from './Constants.js';
|
|
2
3
|
import Coordinates from './coordinates/Coordinates.js';
|
|
3
4
|
|
|
4
5
|
class Utils {
|
|
@@ -106,7 +107,8 @@ class Utils {
|
|
|
106
107
|
while (currentPointIndex < route.length) {
|
|
107
108
|
const currentPoint = route[currentPointIndex];
|
|
108
109
|
const dist = previousPoint.distanceTo(currentPoint);
|
|
109
|
-
if (cumulativeDistance + dist >= length
|
|
110
|
+
if (cumulativeDistance + dist >= length
|
|
111
|
+
|| Math.abs(cumulativeDistance + dist - length) <= Constants.EPS_MM) {
|
|
110
112
|
const bearing = previousPoint.bearingTo(currentPoint);
|
|
111
113
|
const remainingLength = length - cumulativeDistance;
|
|
112
114
|
const end = previousPoint.destinationPoint(remainingLength, bearing);
|
|
@@ -6,10 +6,10 @@ class BoundingBox {
|
|
|
6
6
|
southWest;
|
|
7
7
|
|
|
8
8
|
constructor(northEast, southWest) {
|
|
9
|
-
this.southWest = southWest || null;
|
|
10
9
|
this.northEast = northEast || null;
|
|
10
|
+
this.southWest = southWest || null;
|
|
11
11
|
|
|
12
|
-
if (this.
|
|
12
|
+
if (this.northEast && this.southWest && this.getNorth() < this.getSouth()) {
|
|
13
13
|
throw new Error('Incorrect bounding box');
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -18,6 +18,8 @@ import Level from './Level.js';
|
|
|
18
18
|
*/
|
|
19
19
|
class Coordinates {
|
|
20
20
|
|
|
21
|
+
autoWrap = true;
|
|
22
|
+
|
|
21
23
|
constructor(lat, lng, alt, level) {
|
|
22
24
|
this.lat = lat;
|
|
23
25
|
this.lng = lng;
|
|
@@ -66,13 +68,8 @@ class Coordinates {
|
|
|
66
68
|
set lng(lng) {
|
|
67
69
|
if (typeof lng === 'number') {
|
|
68
70
|
this._lng = lng;
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
this._lng = this._lng % 360;
|
|
72
|
-
this._lng = (this._lng + 360) % 360;
|
|
73
|
-
if (this._lng > 180) {
|
|
74
|
-
this._lng -= 360;
|
|
75
|
-
}
|
|
71
|
+
if (this.autoWrap) {
|
|
72
|
+
this.wrap();
|
|
76
73
|
}
|
|
77
74
|
} else {
|
|
78
75
|
throw new Error('lng argument is not a number');
|
|
@@ -111,6 +108,12 @@ class Coordinates {
|
|
|
111
108
|
return output;
|
|
112
109
|
}
|
|
113
110
|
|
|
111
|
+
wrap() {
|
|
112
|
+
if (this._lng <= -180 || this._lng > 180) {
|
|
113
|
+
this._lng = Utils.wrap(this._lng, -180, 180);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
114
117
|
/**
|
|
115
118
|
* Compares two Coordinates
|
|
116
119
|
* @param {Coordinates} pos1 position 1
|
|
@@ -316,7 +319,7 @@ class Coordinates {
|
|
|
316
319
|
const projection = new Coordinates(poseCoordinates.lat, poseCoordinates.lng,
|
|
317
320
|
alt, Level.intersect(p1.level, p2.level));
|
|
318
321
|
|
|
319
|
-
if (Math.abs((p1.distanceTo(p2) - p1.distanceTo(projection) - p2.distanceTo(projection))) >
|
|
322
|
+
if (Math.abs((p1.distanceTo(p2) - p1.distanceTo(projection) - p2.distanceTo(projection))) > Constants.EPS_MM) {
|
|
320
323
|
return null;
|
|
321
324
|
}
|
|
322
325
|
|