@wemap/geo 7.2.1 → 7.3.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/index.js +1 -0
- package/package.json +2 -2
- package/src/coordinates/Coordinates.js +3 -3
- package/src/coordinates/GeoRef.js +39 -0
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * as Utils from './src/Utils.js';
|
|
|
4
4
|
/** Coordinates */
|
|
5
5
|
export { default as BoundingBox } from './src/coordinates/BoundingBox.js';
|
|
6
6
|
export { default as GeoRelativePosition } from './src/coordinates/GeoRelativePosition.js';
|
|
7
|
+
export { default as GeoRef } from './src/coordinates/GeoRef.js';
|
|
7
8
|
export { default as Level } from './src/coordinates/Level.js';
|
|
8
9
|
export { default as RelativePosition } from './src/coordinates/RelativePosition.js';
|
|
9
10
|
export { default as Coordinates } from './src/coordinates/Coordinates.js';
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/geo"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/geo",
|
|
15
|
-
"version": "7.
|
|
15
|
+
"version": "7.3.0",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"@wemap/logger": "^7.0.0",
|
|
31
31
|
"@wemap/maths": "^7.0.0"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "c79062ac53248f45aead5d4edd45b3efbc79755e"
|
|
34
34
|
}
|
|
@@ -38,10 +38,10 @@ class Coordinates {
|
|
|
38
38
|
/**
|
|
39
39
|
* @param {Number} lat
|
|
40
40
|
* @param {Number} lng
|
|
41
|
-
* @param {Number|null} alt
|
|
42
|
-
* @param {Level|null} level
|
|
41
|
+
* @param {?(Number|null)} alt
|
|
42
|
+
* @param {?(Level|null)} level
|
|
43
43
|
*/
|
|
44
|
-
constructor(lat, lng, alt, level) {
|
|
44
|
+
constructor(lat, lng, alt = null, level = null) {
|
|
45
45
|
this.lat = lat;
|
|
46
46
|
this.lng = lng;
|
|
47
47
|
this.alt = alt;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Quaternion, Vector3 } from '@wemap/maths';
|
|
2
|
+
|
|
3
|
+
import Coordinates from './Coordinates.js';
|
|
4
|
+
|
|
5
|
+
class GeoRef {
|
|
6
|
+
|
|
7
|
+
/** @type {!Coordinates} */
|
|
8
|
+
origin;
|
|
9
|
+
|
|
10
|
+
/** @type {number} */
|
|
11
|
+
scale;
|
|
12
|
+
|
|
13
|
+
/** @type {number} */
|
|
14
|
+
heading;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {number[]} localPosition in ENU frame
|
|
19
|
+
* @returns {Coordinates}
|
|
20
|
+
*/
|
|
21
|
+
localToWorld(localPosition) {
|
|
22
|
+
const ecefToEnuRotationOrigin = this.origin.ecefToEnuRotation;
|
|
23
|
+
const ecefTranslation = Quaternion.rotate(ecefToEnuRotationOrigin, localPosition);
|
|
24
|
+
const ecef = Vector3.add(this.origin.ecef, ecefTranslation);
|
|
25
|
+
return Coordinates.fromECEF(ecef);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {Coordinates} coords
|
|
30
|
+
* @returns {number[]} localPosition in ENU frame
|
|
31
|
+
*/
|
|
32
|
+
worldToLocal(coords) {
|
|
33
|
+
const enuToEcefRotationOrigin = this.origin.enuToEcefRotation;
|
|
34
|
+
const ecefTranslation = Vector3.subtract(coords.ecef, this.origin.ecef);
|
|
35
|
+
return Quaternion.rotate(enuToEcefRotationOrigin, ecefTranslation);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default GeoRef;
|