@wemap/geo 3.1.20 → 3.2.1
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/index.js +10 -10
- package/package.json +6 -10
- package/src/Utils.js +1 -1
- package/src/Utils.spec.js +2 -2
- package/src/coordinates/BoundingBox.js +3 -5
- package/src/coordinates/BoundingBox.spec.js +3 -2
- package/src/coordinates/Coordinates.js +14 -8
- package/src/coordinates/Coordinates.spec.js +3 -4
- package/src/coordinates/GeoRelativePosition.js +1 -1
- package/src/coordinates/Level.js +9 -13
- package/src/coordinates/Level.spec.js +5 -2
- package/src/coordinates/RelativePosition.js +7 -10
- package/src/coordinates/UserPosition.js +5 -8
- package/src/coordinates/UserPosition.spec.js +3 -7
- package/src/rotations/AbsoluteHeading.js +5 -7
- package/src/rotations/Attitude.js +2 -5
- package/src/rotations/Attitude.spec.js +2 -2
package/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import Constants from './src/Constants';
|
|
2
|
-
import Utils from './src/Utils';
|
|
1
|
+
import Constants from './src/Constants.js';
|
|
2
|
+
import Utils from './src/Utils.js';
|
|
3
3
|
|
|
4
|
-
import Attitude from './src/rotations/Attitude';
|
|
5
|
-
import AbsoluteHeading from './src/rotations/AbsoluteHeading';
|
|
4
|
+
import Attitude from './src/rotations/Attitude.js';
|
|
5
|
+
import AbsoluteHeading from './src/rotations/AbsoluteHeading.js';
|
|
6
6
|
|
|
7
|
-
import BoundingBox from './src/coordinates/BoundingBox';
|
|
8
|
-
import GeoRelativePosition from './src/coordinates/GeoRelativePosition';
|
|
9
|
-
import Level from './src/coordinates/Level';
|
|
10
|
-
import RelativePosition from './src/coordinates/RelativePosition';
|
|
11
|
-
import Coordinates from './src/coordinates/Coordinates';
|
|
12
|
-
import UserPosition from './src/coordinates/UserPosition';
|
|
7
|
+
import BoundingBox from './src/coordinates/BoundingBox.js';
|
|
8
|
+
import GeoRelativePosition from './src/coordinates/GeoRelativePosition.js';
|
|
9
|
+
import Level from './src/coordinates/Level.js';
|
|
10
|
+
import RelativePosition from './src/coordinates/RelativePosition.js';
|
|
11
|
+
import Coordinates from './src/coordinates/Coordinates.js';
|
|
12
|
+
import UserPosition from './src/coordinates/UserPosition.js';
|
|
13
13
|
|
|
14
14
|
export {
|
|
15
15
|
AbsoluteHeading,
|
package/package.json
CHANGED
|
@@ -12,14 +12,13 @@
|
|
|
12
12
|
"directory": "packages/geo"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/geo",
|
|
15
|
-
"version": "3.1
|
|
15
|
+
"version": "3.2.1",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/wemap/wemap-modules-js#readme",
|
|
20
|
-
"scripts": {
|
|
21
|
-
|
|
22
|
-
},
|
|
20
|
+
"scripts": {},
|
|
21
|
+
"type": "module",
|
|
23
22
|
"keywords": [
|
|
24
23
|
"utils",
|
|
25
24
|
"geo",
|
|
@@ -27,11 +26,8 @@
|
|
|
27
26
|
],
|
|
28
27
|
"license": "ISC",
|
|
29
28
|
"dependencies": {
|
|
30
|
-
"@wemap/logger": "^3.
|
|
31
|
-
"@wemap/maths": "^3.1
|
|
32
|
-
"lodash.isfinite": "^3.3.2",
|
|
33
|
-
"lodash.isnumber": "^3.0.3",
|
|
34
|
-
"lodash.isstring": "^4.0.1"
|
|
29
|
+
"@wemap/logger": "^3.2.1",
|
|
30
|
+
"@wemap/maths": "^3.2.1"
|
|
35
31
|
},
|
|
36
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "0d430815358a23068c8473b2c310b2945667b2c1"
|
|
37
33
|
}
|
package/src/Utils.js
CHANGED
package/src/Utils.spec.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import chai from 'chai';
|
|
3
3
|
import chaiAlmost from 'chai-almost';
|
|
4
4
|
|
|
5
|
-
import Utils from './Utils';
|
|
6
|
-
import Coordinates from './coordinates/Coordinates';
|
|
5
|
+
import Utils from './Utils.js';
|
|
6
|
+
import Coordinates from './coordinates/Coordinates.js';
|
|
7
7
|
|
|
8
8
|
const expect = chai.expect;
|
|
9
9
|
chai.use(chaiAlmost(1e-3));
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import Coordinates from './Coordinates';
|
|
2
|
-
import isNumber from 'lodash.isnumber';
|
|
3
|
-
import isFinite from 'lodash.isfinite';
|
|
1
|
+
import Coordinates from './Coordinates.js';
|
|
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,9 +2,10 @@
|
|
|
2
2
|
import chai from 'chai';
|
|
3
3
|
import chaiAlmost from 'chai-almost';
|
|
4
4
|
|
|
5
|
-
import BoundingBox from './BoundingBox';
|
|
6
5
|
import Logger from '@wemap/logger';
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
import BoundingBox from './BoundingBox.js';
|
|
8
|
+
import Coordinates from './Coordinates.js';
|
|
8
9
|
|
|
9
10
|
const expect = chai.expect;
|
|
10
11
|
chai.use(chaiAlmost());
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Utils, Vector3, Quaternion, rad2deg
|
|
3
3
|
} from '@wemap/maths';
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import Level from './Level';
|
|
4
|
+
|
|
5
|
+
import Constants from '../Constants.js';
|
|
6
|
+
import Level from './Level.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* A Coordinates position using at least latitude (lat) and longitude (lng).
|
|
@@ -48,7 +47,7 @@ class Coordinates {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
set lat(lat) {
|
|
51
|
-
if (
|
|
50
|
+
if (typeof lat === 'number' && Math.abs(lat) <= 90) {
|
|
52
51
|
this._lat = lat;
|
|
53
52
|
} else {
|
|
54
53
|
throw new Error('lat argument is not in [-90; 90]');
|
|
@@ -57,7 +56,7 @@ class Coordinates {
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
set lng(lng) {
|
|
60
|
-
if (
|
|
59
|
+
if (typeof lng === 'number') {
|
|
61
60
|
this._lng = lng;
|
|
62
61
|
if (Math.abs(lng) >= 180) {
|
|
63
62
|
// from https://stackoverflow.com/a/2323034/2239938
|
|
@@ -74,7 +73,7 @@ class Coordinates {
|
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
set alt(alt) {
|
|
77
|
-
if (
|
|
76
|
+
if (typeof alt === 'number') {
|
|
78
77
|
this._alt = alt;
|
|
79
78
|
} else {
|
|
80
79
|
if (typeof alt !== 'undefined' && alt !== null) {
|
|
@@ -162,7 +161,7 @@ class Coordinates {
|
|
|
162
161
|
this.lat = Utils.rad2deg(phi2);
|
|
163
162
|
this.lng = Utils.rad2deg(lambda2);
|
|
164
163
|
|
|
165
|
-
if (
|
|
164
|
+
if (typeof elevation === 'number') {
|
|
166
165
|
if (this.alt === null) {
|
|
167
166
|
throw new Error('Point altitude is not defined');
|
|
168
167
|
}
|
|
@@ -350,6 +349,13 @@ class Coordinates {
|
|
|
350
349
|
return new Coordinates(json.lat, json.lng, json.alt, Level.fromString(json.level));
|
|
351
350
|
}
|
|
352
351
|
|
|
352
|
+
toCompressedJson() {
|
|
353
|
+
return [this.lat, this.lng, this.alt, this.level === null ? null : this.level.toString()];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
static fromCompressedJson(json) {
|
|
357
|
+
return new Coordinates(json[0], json[1], json[2], Level.fromString(json[3]));
|
|
358
|
+
}
|
|
353
359
|
}
|
|
354
360
|
|
|
355
361
|
export default Coordinates;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import chai from 'chai';
|
|
2
2
|
import chaiAlmost from 'chai-almost';
|
|
3
3
|
|
|
4
|
-
import Coordinates from './Coordinates';
|
|
5
|
-
import Level from './Level';
|
|
6
|
-
import Constants from '../Constants';
|
|
4
|
+
import Coordinates from './Coordinates.js';
|
|
5
|
+
import Level from './Level.js';
|
|
6
|
+
import Constants from '../Constants.js';
|
|
7
7
|
|
|
8
8
|
const expect = chai.expect;
|
|
9
9
|
chai.use(chaiAlmost());
|
|
@@ -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,9 +1,12 @@
|
|
|
1
1
|
/* eslint-disable max-nested-callbacks */
|
|
2
|
-
import
|
|
2
|
+
import chai from 'chai';
|
|
3
3
|
|
|
4
|
-
import Level from './Level';
|
|
5
4
|
import Logger from '@wemap/logger';
|
|
6
5
|
|
|
6
|
+
import Level from './Level.js';
|
|
7
|
+
|
|
8
|
+
const { expect } = chai;
|
|
9
|
+
|
|
7
10
|
Logger.enable(false);
|
|
8
11
|
|
|
9
12
|
const checkSingle = (_level, _value) => {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import isFinite from 'lodash.isfinite';
|
|
3
|
-
|
|
4
|
-
import Constants from '../Constants';
|
|
1
|
+
import Constants from '../Constants.js';
|
|
5
2
|
|
|
6
3
|
class RelativePosition {
|
|
7
4
|
|
|
@@ -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,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import Coordinates from './Coordinates';
|
|
5
|
-
import Constants from '../Constants';
|
|
1
|
+
import Coordinates from './Coordinates.js';
|
|
2
|
+
import Constants from '../Constants.js';
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
5
|
* A Coordinates User Position is a Coordinates position with specific data related to user (bearing, time, accuracy)
|
|
@@ -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) {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import chai from 'chai';
|
|
3
3
|
import chaiAlmost from 'chai-almost';
|
|
4
4
|
|
|
5
|
-
import UserPosition from './UserPosition';
|
|
6
|
-
import Level from './Level';
|
|
7
|
-
import Coordinates from './Coordinates';
|
|
5
|
+
import UserPosition from './UserPosition.js';
|
|
6
|
+
import Level from './Level.js';
|
|
7
|
+
import Coordinates from './Coordinates.js';
|
|
8
8
|
|
|
9
9
|
const expect = chai.expect;
|
|
10
10
|
chai.use(chaiAlmost());
|
|
@@ -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,8 +1,6 @@
|
|
|
1
|
-
import isNumber from 'lodash.isnumber';
|
|
2
|
-
import isFinite from 'lodash.isfinite';
|
|
3
|
-
|
|
4
1
|
import { Quaternion } from '@wemap/maths';
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
import Attitude from './Attitude.js';
|
|
6
4
|
|
|
7
5
|
class AbsoluteHeading {
|
|
8
6
|
|
|
@@ -33,7 +31,7 @@ class AbsoluteHeading {
|
|
|
33
31
|
* @param {Number} heading
|
|
34
32
|
*/
|
|
35
33
|
set heading(heading) {
|
|
36
|
-
if (
|
|
34
|
+
if (typeof heading === 'number') {
|
|
37
35
|
this._heading = heading;
|
|
38
36
|
} else {
|
|
39
37
|
throw new Error('heading argument is not a number');
|
|
@@ -51,7 +49,7 @@ class AbsoluteHeading {
|
|
|
51
49
|
* @param {Number} time
|
|
52
50
|
*/
|
|
53
51
|
set time(time) {
|
|
54
|
-
if (
|
|
52
|
+
if (typeof time === 'number') {
|
|
55
53
|
this._time = time;
|
|
56
54
|
} else {
|
|
57
55
|
if (typeof time !== 'undefined' && time !== null) {
|
|
@@ -72,7 +70,7 @@ class AbsoluteHeading {
|
|
|
72
70
|
* @param {Number} accuracy
|
|
73
71
|
*/
|
|
74
72
|
set accuracy(accuracy) {
|
|
75
|
-
if (
|
|
73
|
+
if (typeof accuracy === 'number' && accuracy >= 0 && accuracy <= Math.PI) {
|
|
76
74
|
this._accuracy = accuracy;
|
|
77
75
|
} else {
|
|
78
76
|
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) {
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import chai from 'chai';
|
|
3
3
|
import chaiAlmost from 'chai-almost';
|
|
4
4
|
|
|
5
|
-
import Attitude from './Attitude';
|
|
6
5
|
import {
|
|
7
6
|
deg2rad, Quaternion, Utils
|
|
8
7
|
} from '@wemap/maths';
|
|
9
8
|
|
|
9
|
+
import Attitude from './Attitude.js';
|
|
10
|
+
|
|
10
11
|
const expect = chai.expect;
|
|
11
12
|
chai.use(chaiAlmost());
|
|
12
13
|
|
|
@@ -103,7 +104,6 @@ describe('Attitude', () => {
|
|
|
103
104
|
expect(() => new Attitude([1, 0, 0, 0], false)).throw(Error);
|
|
104
105
|
expect(() => new Attitude([1, 0, 0, 0], true)).throw(Error);
|
|
105
106
|
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
107
|
|
|
108
108
|
expect(() => new Attitude([1, 0, 0, 0], 10, deg2rad(10))).not.throw(Error);
|
|
109
109
|
expect(() => new Attitude([1, 0, 0, 0], 10, -1)).throw(Error);
|