@wemap/geo 3.1.6 → 3.1.7
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.1.
|
|
15
|
+
"version": "3.1.7",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"lodash.isnumber": "^3.0.3",
|
|
34
34
|
"lodash.isstring": "^4.0.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "57ceac64e857a53046b297774286024a157a57af"
|
|
37
37
|
}
|
|
@@ -209,6 +209,18 @@ class BoundingBox {
|
|
|
209
209
|
equalsTo(other) {
|
|
210
210
|
return BoundingBox.equalsTo(this, other);
|
|
211
211
|
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Create a BoundingBox from a WSEN array
|
|
215
|
+
* @param {Number[4]} bounds a WSEN array
|
|
216
|
+
* @returns {BoundingBox} the corresponding BoundingBox
|
|
217
|
+
*/
|
|
218
|
+
static fromArray(bounds) {
|
|
219
|
+
return new BoundingBox(
|
|
220
|
+
new Coordinates(bounds[3], bounds[2]),
|
|
221
|
+
new Coordinates(bounds[1], bounds[0])
|
|
222
|
+
);
|
|
223
|
+
}
|
|
212
224
|
}
|
|
213
225
|
|
|
214
226
|
export default BoundingBox;
|
|
@@ -33,6 +33,9 @@ describe('Bounding Box', () => {
|
|
|
33
33
|
boundingBox = new BoundingBox(northEast, southWest);
|
|
34
34
|
expect(boundingBox.northEast).equals(northEast);
|
|
35
35
|
expect(boundingBox.southWest).equals(southWest);
|
|
36
|
+
|
|
37
|
+
const boundingBox2 = BoundingBox.fromArray([-20, -5, 40, 10]);
|
|
38
|
+
expect(boundingBox2.equalsTo(boundingBox)).is.true;
|
|
36
39
|
});
|
|
37
40
|
|
|
38
41
|
|
|
@@ -57,10 +57,18 @@ class Coordinates {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
set lng(lng) {
|
|
60
|
-
if (isNumber(lng)
|
|
60
|
+
if (isNumber(lng)) {
|
|
61
61
|
this._lng = lng;
|
|
62
|
+
if (Math.abs(lng) >= 180) {
|
|
63
|
+
// from https://stackoverflow.com/a/2323034/2239938
|
|
64
|
+
this._lng = this._lng % 360;
|
|
65
|
+
this._lng = (this._lng + 360) % 360;
|
|
66
|
+
if (this._lng > 180) {
|
|
67
|
+
this._lng -= 360;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
62
70
|
} else {
|
|
63
|
-
throw new Error('lng argument is not
|
|
71
|
+
throw new Error('lng argument is not a number');
|
|
64
72
|
}
|
|
65
73
|
this._ecef = null;
|
|
66
74
|
}
|
|
@@ -17,7 +17,7 @@ describe('Coordinates', () => {
|
|
|
17
17
|
expect(() => new Coordinates(45)).throw(Error);
|
|
18
18
|
expect(() => new Coordinates(45, 5)).not.throw(Error);
|
|
19
19
|
expect(() => new Coordinates(-93, 5)).throw(Error);
|
|
20
|
-
expect(() => new Coordinates(45, 202)).throw(Error);
|
|
20
|
+
expect(() => new Coordinates(45, 202)).not.throw(Error);
|
|
21
21
|
|
|
22
22
|
expect(() => new Coordinates(45, 5, true)).throw(Error);
|
|
23
23
|
expect(() => new Coordinates(45, 5, false)).throw(Error);
|
|
@@ -52,6 +52,12 @@ describe('Coordinates', () => {
|
|
|
52
52
|
expect(Level.equalsTo(position.level, new Level(2))).true;
|
|
53
53
|
expect(position._ecef).equals(null);
|
|
54
54
|
expect(position.ecef).is.not.null;
|
|
55
|
+
|
|
56
|
+
position.lng = 202;
|
|
57
|
+
expect(position.lng).equals(-158);
|
|
58
|
+
|
|
59
|
+
position.lng = -202;
|
|
60
|
+
expect(position.lng).equals(158);
|
|
55
61
|
});
|
|
56
62
|
|
|
57
63
|
it('clone', () => {
|