@wemap/geo 0.1.3 → 0.1.4
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 +2 -2
- package/src/coordinates/WGS84.js +16 -6
- package/src/graph/MapMatching.js +4 -2
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/geo"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/geo",
|
|
15
|
-
"version": "0.1.
|
|
15
|
+
"version": "0.1.4",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-utils-js/issues"
|
|
18
18
|
},
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"wemap"
|
|
27
27
|
],
|
|
28
28
|
"license": "ISC",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "991a53f06eed6adb872fad2cbd70a4edf7ee9cf9"
|
|
30
30
|
}
|
package/src/coordinates/WGS84.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Utils, Vector3, Quaternion
|
|
3
|
+
} from '@wemap/maths';
|
|
2
4
|
import Constants from '../Constants';
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
class WGS84 {
|
|
6
8
|
|
|
7
|
-
constructor(lat, lng, alt
|
|
9
|
+
constructor(lat, lng, alt) {
|
|
8
10
|
this._lat = lat;
|
|
9
11
|
this._lng = lng;
|
|
10
12
|
this._alt = alt;
|
|
@@ -208,12 +210,20 @@ class WGS84 {
|
|
|
208
210
|
|
|
209
211
|
const G = Vector3.cross(a, b);
|
|
210
212
|
const F = Vector3.cross(c, G);
|
|
211
|
-
|
|
213
|
+
const t = Vector3.normalize(Vector3.cross(G, F));
|
|
212
214
|
|
|
213
|
-
|
|
215
|
+
const posECEF = Vector3.multiplyScalar(t, this.getEarthRadiusAtPosition());
|
|
216
|
+
const poseWGS84 = WGS84.fromECEF(posECEF);
|
|
217
|
+
|
|
218
|
+
// poseWGS84.alt is not 0 here due to the ECEF transformation residual.
|
|
219
|
+
// So if p1.alt and p2.alt are defined we take the middle elevation between p1 and p2.
|
|
220
|
+
// Otherwise we remove alt from projection because the residual has no sense.
|
|
221
|
+
let alt;
|
|
222
|
+
if (typeof p1.alt !== 'undefined' && typeof p2.alt !== 'undefined') {
|
|
223
|
+
alt = (p1.alt + p2.alt) / 2;
|
|
224
|
+
}
|
|
225
|
+
const projection = new WGS84(poseWGS84.lat, poseWGS84.lng, alt);
|
|
214
226
|
|
|
215
|
-
const projection = WGS84.fromECEF(t);
|
|
216
|
-
projection.alt = p1.alt && p2.alt ? (p1.alt + p2.alt) / 2 : 0;
|
|
217
227
|
if (Math.abs((p1.distanceTo(p2) - p1.distanceTo(projection) - p2.distanceTo(projection))) > 1e-6) {
|
|
218
228
|
return null;
|
|
219
229
|
}
|
package/src/graph/MapMatching.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* eslint complexity: ["error",
|
|
1
|
+
/* eslint complexity: ["error", 22]*/
|
|
2
2
|
/* eslint max-statements: ["error", 45]*/
|
|
3
3
|
|
|
4
|
-
import { Utils as MathUtils} from '@wemap/maths';
|
|
4
|
+
import { Utils as MathUtils } from '@wemap/maths';
|
|
5
5
|
import Network from './Network';
|
|
6
6
|
|
|
7
7
|
const rad2deg = MathUtils.rad2deg;
|
|
@@ -97,6 +97,8 @@ class MapMatching {
|
|
|
97
97
|
|
|
98
98
|
if (!projection.projection) {
|
|
99
99
|
return null;
|
|
100
|
+
} else if (typeof projection.projection.alt === 'undefined') {
|
|
101
|
+
projection.projection.alt = location.alt;
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
return projection;
|