@wemap/geo 3.1.20 → 3.1.21
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 +3 -6
- package/src/coordinates/BoundingBox.js +2 -4
- package/src/coordinates/Coordinates.js +4 -6
- package/src/coordinates/Coordinates.spec.js +0 -1
- package/src/coordinates/Level.js +9 -13
- package/src/coordinates/RelativePosition.js +6 -9
- package/src/coordinates/UserPosition.js +3 -6
- package/src/coordinates/UserPosition.spec.js +0 -4
- package/src/rotations/AbsoluteHeading.js +3 -6
- package/src/rotations/Attitude.js +2 -5
- package/src/rotations/Attitude.spec.js +0 -1
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.21",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
@@ -28,10 +28,7 @@
|
|
|
28
28
|
"license": "ISC",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@wemap/logger": "^3.0.0",
|
|
31
|
-
"@wemap/maths": "^3.1.15"
|
|
32
|
-
"lodash.isfinite": "^3.3.2",
|
|
33
|
-
"lodash.isnumber": "^3.0.3",
|
|
34
|
-
"lodash.isstring": "^4.0.1"
|
|
31
|
+
"@wemap/maths": "^3.1.15"
|
|
35
32
|
},
|
|
36
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "17f72afdcf6098bf90d3dffc2cf0b15f9284d4d4"
|
|
37
34
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import Coordinates from './Coordinates';
|
|
2
|
-
import isNumber from 'lodash.isnumber';
|
|
3
|
-
import isFinite from 'lodash.isfinite';
|
|
4
2
|
|
|
5
3
|
class BoundingBox {
|
|
6
4
|
|
|
@@ -86,11 +84,11 @@ class BoundingBox {
|
|
|
86
84
|
/**
|
|
87
85
|
* This method extends the bounding box with a value in meters
|
|
88
86
|
* /*\ This method is not precise as distance differs in function of latitude
|
|
89
|
-
* @param {
|
|
87
|
+
* @param {!number} measure in meters
|
|
90
88
|
*/
|
|
91
89
|
extendsWithMeasure(measure) {
|
|
92
90
|
|
|
93
|
-
if (
|
|
91
|
+
if (typeof measure !== 'number') {
|
|
94
92
|
throw new Error('measure is not a number');
|
|
95
93
|
}
|
|
96
94
|
|
|
@@ -2,8 +2,6 @@ import {
|
|
|
2
2
|
Utils, Vector3, Quaternion, rad2deg
|
|
3
3
|
} from '@wemap/maths';
|
|
4
4
|
import Constants from '../Constants';
|
|
5
|
-
import isNumber from 'lodash.isnumber';
|
|
6
|
-
import isFinite from 'lodash.isfinite';
|
|
7
5
|
import Level from './Level';
|
|
8
6
|
|
|
9
7
|
/**
|
|
@@ -48,7 +46,7 @@ class Coordinates {
|
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
set lat(lat) {
|
|
51
|
-
if (
|
|
49
|
+
if (typeof lat === 'number' && Math.abs(lat) <= 90) {
|
|
52
50
|
this._lat = lat;
|
|
53
51
|
} else {
|
|
54
52
|
throw new Error('lat argument is not in [-90; 90]');
|
|
@@ -57,7 +55,7 @@ class Coordinates {
|
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
set lng(lng) {
|
|
60
|
-
if (
|
|
58
|
+
if (typeof lng === 'number') {
|
|
61
59
|
this._lng = lng;
|
|
62
60
|
if (Math.abs(lng) >= 180) {
|
|
63
61
|
// from https://stackoverflow.com/a/2323034/2239938
|
|
@@ -74,7 +72,7 @@ class Coordinates {
|
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
set alt(alt) {
|
|
77
|
-
if (
|
|
75
|
+
if (typeof alt === 'number') {
|
|
78
76
|
this._alt = alt;
|
|
79
77
|
} else {
|
|
80
78
|
if (typeof alt !== 'undefined' && alt !== null) {
|
|
@@ -162,7 +160,7 @@ class Coordinates {
|
|
|
162
160
|
this.lat = Utils.rad2deg(phi2);
|
|
163
161
|
this.lng = Utils.rad2deg(lambda2);
|
|
164
162
|
|
|
165
|
-
if (
|
|
163
|
+
if (typeof elevation === 'number') {
|
|
166
164
|
if (this.alt === null) {
|
|
167
165
|
throw new Error('Point altitude is not defined');
|
|
168
166
|
}
|
|
@@ -23,7 +23,6 @@ describe('Coordinates', () => {
|
|
|
23
23
|
expect(() => new Coordinates(45, 5, false)).throw(Error);
|
|
24
24
|
expect(() => new Coordinates(45, 5, null)).not.throw(Error);
|
|
25
25
|
expect(() => new Coordinates(45, 5, 0)).not.throw(Error);
|
|
26
|
-
expect(() => new Coordinates(45, 5, Number.POSITIVE_INFINITY)).throw(Error);
|
|
27
26
|
|
|
28
27
|
expect(() => new Coordinates(45, 5, null, null)).not.throw(Error);
|
|
29
28
|
expect(() => new Coordinates(45, 5, null, true)).throw(Error);
|
package/src/coordinates/Level.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import Logger from '@wemap/logger';
|
|
2
|
-
import isFinite from 'lodash.isfinite';
|
|
3
|
-
import isString from 'lodash.isstring';
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* A Level is the representation of a building floor number
|
|
@@ -13,14 +11,14 @@ class Level {
|
|
|
13
11
|
* Level constructor
|
|
14
12
|
* 1 argument: level is not a range and first argument is the level
|
|
15
13
|
* 2 arguments: level is a range
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
14
|
+
* @param {number} arg1 if arg2: low value, otherwise: level
|
|
15
|
+
* @param {number} arg2 (optional) up value
|
|
18
16
|
*/
|
|
19
17
|
constructor(arg1, arg2) {
|
|
20
|
-
if (
|
|
18
|
+
if (typeof arg1 !== 'number' || isNaN(arg1)) {
|
|
21
19
|
throw new Error('first argument is mandatory');
|
|
22
20
|
}
|
|
23
|
-
if (
|
|
21
|
+
if (typeof arg2 === 'number' && !isNaN(arg2)) {
|
|
24
22
|
if (arg1 === arg2) {
|
|
25
23
|
this.isRange = false;
|
|
26
24
|
this.val = arg1;
|
|
@@ -46,24 +44,22 @@ class Level {
|
|
|
46
44
|
|
|
47
45
|
/**
|
|
48
46
|
* Create a level from a string
|
|
49
|
-
* @param {
|
|
47
|
+
* @param {string} str level in str format (eg. 1, -2, 1;2, -2;3, 2;-1, 0.5;1 ...)
|
|
50
48
|
*/
|
|
51
49
|
static fromString(str) {
|
|
52
50
|
|
|
53
|
-
if (
|
|
51
|
+
if (typeof str !== 'string') {
|
|
54
52
|
return null;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
if (!isNaN(Number(str))) {
|
|
58
|
-
return new Level(
|
|
56
|
+
return new Level(parseFloat(str));
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
const splited = str.split(';');
|
|
62
60
|
if (splited.length === 2) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (!isNaN(num1) && !isNaN(num2)) {
|
|
66
|
-
return new Level(num1, num2);
|
|
61
|
+
if (!isNaN(Number(splited[0])) && !isNaN(Number(splited[1]))) {
|
|
62
|
+
return new Level(parseFloat(splited[0]), parseFloat(splited[1]));
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
65
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import isNumber from 'lodash.isnumber';
|
|
2
|
-
import isFinite from 'lodash.isfinite';
|
|
3
|
-
|
|
4
1
|
import Constants from '../Constants';
|
|
5
2
|
|
|
6
3
|
class RelativePosition {
|
|
@@ -26,7 +23,7 @@ class RelativePosition {
|
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
set x(x) {
|
|
29
|
-
if (
|
|
26
|
+
if (typeof x === 'number') {
|
|
30
27
|
this._x = x;
|
|
31
28
|
} else if (typeof x !== 'undefined' && x !== null) {
|
|
32
29
|
throw new Error('x argument is not a number');
|
|
@@ -38,7 +35,7 @@ class RelativePosition {
|
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
set y(y) {
|
|
41
|
-
if (
|
|
38
|
+
if (typeof y === 'number') {
|
|
42
39
|
this._y = y;
|
|
43
40
|
} else if (typeof y !== 'undefined' && y !== null) {
|
|
44
41
|
throw new Error('y argument is not a number');
|
|
@@ -50,7 +47,7 @@ class RelativePosition {
|
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
set z(z) {
|
|
53
|
-
if (
|
|
50
|
+
if (typeof z === 'number') {
|
|
54
51
|
this._z = z;
|
|
55
52
|
} else if (typeof z !== 'undefined' && z !== null) {
|
|
56
53
|
throw new Error('z argument is not a number');
|
|
@@ -62,7 +59,7 @@ class RelativePosition {
|
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
set time(time) {
|
|
65
|
-
if (
|
|
62
|
+
if (typeof time === 'number') {
|
|
66
63
|
this._time = time;
|
|
67
64
|
} else {
|
|
68
65
|
if (typeof time !== 'undefined' && time !== null) {
|
|
@@ -78,7 +75,7 @@ class RelativePosition {
|
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
set accuracy(accuracy) {
|
|
81
|
-
if (
|
|
78
|
+
if (typeof accuracy === 'number' && accuracy >= 0) {
|
|
82
79
|
this._accuracy = accuracy;
|
|
83
80
|
} else {
|
|
84
81
|
if (typeof accuracy !== 'undefined' && accuracy !== null) {
|
|
@@ -94,7 +91,7 @@ class RelativePosition {
|
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
set bearing(bearing) {
|
|
97
|
-
if (
|
|
94
|
+
if (typeof bearing === 'number') {
|
|
98
95
|
this._bearing = bearing % (2 * Math.PI);
|
|
99
96
|
} else {
|
|
100
97
|
if (typeof bearing !== 'undefined' && bearing !== null) {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import isNumber from 'lodash.isnumber';
|
|
2
|
-
import isFinite from 'lodash.isfinite';
|
|
3
|
-
|
|
4
1
|
import Coordinates from './Coordinates';
|
|
5
2
|
import Constants from '../Constants';
|
|
6
3
|
|
|
@@ -25,7 +22,7 @@ class UserPosition extends Coordinates {
|
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
set time(time) {
|
|
28
|
-
if (
|
|
25
|
+
if (typeof time === 'number') {
|
|
29
26
|
this._time = time;
|
|
30
27
|
} else {
|
|
31
28
|
if (typeof time !== 'undefined' && time !== null) {
|
|
@@ -41,7 +38,7 @@ class UserPosition extends Coordinates {
|
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
set accuracy(accuracy) {
|
|
44
|
-
if (
|
|
41
|
+
if (typeof accuracy === 'number' && accuracy >= 0) {
|
|
45
42
|
this._accuracy = accuracy;
|
|
46
43
|
} else {
|
|
47
44
|
if (typeof accuracy !== 'undefined' && accuracy !== null) {
|
|
@@ -57,7 +54,7 @@ class UserPosition extends Coordinates {
|
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
set bearing(bearing) {
|
|
60
|
-
if (
|
|
57
|
+
if (typeof bearing === 'number') {
|
|
61
58
|
this._bearing = bearing % (2 * Math.PI);
|
|
62
59
|
} else {
|
|
63
60
|
if (typeof bearing !== 'undefined' && bearing !== null) {
|
|
@@ -24,13 +24,11 @@ describe('UserPosition', () => {
|
|
|
24
24
|
expect(() => new UserPosition(45, 5, null, null, 0)).not.throw(Error);
|
|
25
25
|
expect(() => new UserPosition(45, 5, null, null, 10)).not.throw(Error);
|
|
26
26
|
expect(() => new UserPosition(45, 5, null, null, -10)).not.throw(Error);
|
|
27
|
-
expect(() => new UserPosition(45, 5, null, null, Number.POSITIVE_INFINITY)).throw(Error);
|
|
28
27
|
|
|
29
28
|
expect(() => new UserPosition(45, 5, null, null, null, null)).not.throw(Error);
|
|
30
29
|
expect(() => new UserPosition(45, 5, null, null, null, 0)).not.throw(Error);
|
|
31
30
|
expect(() => new UserPosition(45, 5, null, null, null, 10)).not.throw(Error);
|
|
32
31
|
expect(() => new UserPosition(45, 5, null, null, null, -10)).throw(Error);
|
|
33
|
-
expect(() => new UserPosition(45, 5, null, null, null, Number.POSITIVE_INFINITY)).throw(Error);
|
|
34
32
|
|
|
35
33
|
expect(() => new UserPosition(45, 5, null, null, null,
|
|
36
34
|
null, null)).not.throw(Error);
|
|
@@ -40,8 +38,6 @@ describe('UserPosition', () => {
|
|
|
40
38
|
null, 10)).not.throw(Error);
|
|
41
39
|
expect(() => new UserPosition(45, 5, null, null, null,
|
|
42
40
|
null, -10)).not.throw(Error);
|
|
43
|
-
expect(() => new UserPosition(45, 5, null, null, null,
|
|
44
|
-
null, Number.POSITIVE_INFINITY)).throw(Error);
|
|
45
41
|
|
|
46
42
|
const position = new UserPosition(45, 5, 0, new Level(2), 123456, 10, Math.PI, 'foo');
|
|
47
43
|
expect(position.lat).equals(45);
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import isNumber from 'lodash.isnumber';
|
|
2
|
-
import isFinite from 'lodash.isfinite';
|
|
3
|
-
|
|
4
1
|
import { Quaternion } from '@wemap/maths';
|
|
5
2
|
import Attitude from './Attitude';
|
|
6
3
|
|
|
@@ -33,7 +30,7 @@ class AbsoluteHeading {
|
|
|
33
30
|
* @param {Number} heading
|
|
34
31
|
*/
|
|
35
32
|
set heading(heading) {
|
|
36
|
-
if (
|
|
33
|
+
if (typeof heading === 'number') {
|
|
37
34
|
this._heading = heading;
|
|
38
35
|
} else {
|
|
39
36
|
throw new Error('heading argument is not a number');
|
|
@@ -51,7 +48,7 @@ class AbsoluteHeading {
|
|
|
51
48
|
* @param {Number} time
|
|
52
49
|
*/
|
|
53
50
|
set time(time) {
|
|
54
|
-
if (
|
|
51
|
+
if (typeof time === 'number') {
|
|
55
52
|
this._time = time;
|
|
56
53
|
} else {
|
|
57
54
|
if (typeof time !== 'undefined' && time !== null) {
|
|
@@ -72,7 +69,7 @@ class AbsoluteHeading {
|
|
|
72
69
|
* @param {Number} accuracy
|
|
73
70
|
*/
|
|
74
71
|
set accuracy(accuracy) {
|
|
75
|
-
if (
|
|
72
|
+
if (typeof accuracy === 'number' && accuracy >= 0 && accuracy <= Math.PI) {
|
|
76
73
|
this._accuracy = accuracy;
|
|
77
74
|
} else {
|
|
78
75
|
if (typeof accuracy !== 'undefined' && accuracy !== null) {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import isNumber from 'lodash.isnumber';
|
|
2
|
-
import isFinite from 'lodash.isfinite';
|
|
3
|
-
|
|
4
1
|
import {
|
|
5
2
|
Rotations, Quaternion, rad2deg, deg2rad
|
|
6
3
|
} from '@wemap/maths';
|
|
@@ -61,7 +58,7 @@ class Attitude {
|
|
|
61
58
|
* @param {Number} time
|
|
62
59
|
*/
|
|
63
60
|
set time(time) {
|
|
64
|
-
if (
|
|
61
|
+
if (typeof time === 'number') {
|
|
65
62
|
this._time = time;
|
|
66
63
|
} else {
|
|
67
64
|
if (typeof time !== 'undefined' && time !== null) {
|
|
@@ -82,7 +79,7 @@ class Attitude {
|
|
|
82
79
|
* @param {Number} accuracy
|
|
83
80
|
*/
|
|
84
81
|
set accuracy(accuracy) {
|
|
85
|
-
if (
|
|
82
|
+
if (typeof accuracy === 'number' && accuracy >= 0 && accuracy <= Math.PI) {
|
|
86
83
|
this._accuracy = accuracy;
|
|
87
84
|
} else {
|
|
88
85
|
if (typeof accuracy !== 'undefined' && accuracy !== null) {
|
|
@@ -103,7 +103,6 @@ describe('Attitude', () => {
|
|
|
103
103
|
expect(() => new Attitude([1, 0, 0, 0], false)).throw(Error);
|
|
104
104
|
expect(() => new Attitude([1, 0, 0, 0], true)).throw(Error);
|
|
105
105
|
expect(() => new Attitude([1, 0, 0, 0], null)).not.throw(Error);
|
|
106
|
-
expect(() => new Attitude([1, 0, 0, 0], Number.POSITIVE_INFINITY)).throw(Error);
|
|
107
106
|
|
|
108
107
|
expect(() => new Attitude([1, 0, 0, 0], 10, deg2rad(10))).not.throw(Error);
|
|
109
108
|
expect(() => new Attitude([1, 0, 0, 0], 10, -1)).throw(Error);
|