@wemap/positioning 2.2.0 → 2.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/debug/arcore-absolute.html +16 -0
- package/package.json +1 -1
- package/src/PositioningHandler.js +19 -5
- package/src/components/AbsoluteAttitudeComponent.jsx +2 -2
- package/src/components/ArCoreAbsoluteComponent.jsx +100 -0
- package/src/components/ArCoreComponent.jsx +3 -3
- package/src/components/GnssWifiPdrComponent.jsx +2 -2
- package/src/components/MapComponent.jsx +29 -18
- package/src/components/PdrComponent.jsx +3 -3
- package/src/components/PositioningPoseComponent.jsx +3 -3
- package/src/components/index.js +2 -0
- package/src/providers/Provider.js +2 -2
- package/src/providers/ProviderOptions.js +1 -1
- package/src/providers/attitude/AbsoluteAttitudeProvider.js +6 -6
- package/src/providers/others/MapMatchingProvider.js +19 -19
- package/src/providers/pose/ArCoreAbsoluteProvider.js +186 -0
- package/src/providers/pose/ArCoreProvider.js +31 -43
- package/src/providers/pose/GnssWifiPdrProvider.js +20 -20
- package/src/providers/pose/PoseProvider.js +1 -1
- package/src/providers/pose/pdr/PdrProvider.js +38 -38
- package/src/providers/pose/pdr/helpers/Smoother.js +33 -33
- package/src/providers/pose/pdr/helpers/Smoother.spec.js +7 -7
- package/src/providers/position/GnssWifiProvider.js +5 -5
- package/src/providers/position/IpProvider.js +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint max-statements: ["error", 27]*/
|
|
2
2
|
import { WGS84UserPosition } from '@wemap/geo';
|
|
3
3
|
|
|
4
|
-
// Generated
|
|
4
|
+
// Generated positions by second
|
|
5
5
|
const GEN_FREQUENCY = 60;
|
|
6
6
|
|
|
7
7
|
// Min and max time for flyby (in second)
|
|
@@ -11,40 +11,40 @@ const MAX_FLYBY_TIME = 1;
|
|
|
11
11
|
class Smoother {
|
|
12
12
|
|
|
13
13
|
constructor() {
|
|
14
|
-
this.
|
|
14
|
+
this.positionsQueue = [];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Calculate smoothed positions for the next milliseconds given a new
|
|
18
|
+
* Calculate smoothed positions for the next milliseconds given a new position
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
generateNextPositions(_newPosition, flyby = false) {
|
|
21
21
|
|
|
22
|
-
if (!(
|
|
23
|
-
throw new TypeError('
|
|
22
|
+
if (!(_newPosition instanceof WGS84UserPosition)) {
|
|
23
|
+
throw new TypeError('newPosition is not instance of WGS84UserPosition');
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
28
|
-
throw new Error('
|
|
26
|
+
const newPosition = _newPosition.clone();
|
|
27
|
+
if (!newPosition.hasOwnProperty('time')) {
|
|
28
|
+
throw new Error('newPosition does not have time property');
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
if (!this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
31
|
+
if (!this.previousPosition) {
|
|
32
|
+
this.previousPosition = newPosition;
|
|
33
|
+
this.positionsQueue.push(this.previousPosition);
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const distance = this.
|
|
38
|
-
const azimuth = this.
|
|
37
|
+
const distance = this.previousPosition.distanceTo(newPosition);
|
|
38
|
+
const azimuth = this.previousPosition.bearingTo(newPosition);
|
|
39
39
|
|
|
40
|
-
let refTimestamp =
|
|
40
|
+
let refTimestamp = newPosition.time;
|
|
41
41
|
|
|
42
|
-
const queueLength = this.
|
|
42
|
+
const queueLength = this.positionsQueue.length;
|
|
43
43
|
if (queueLength) {
|
|
44
|
-
refTimestamp = Math.max(refTimestamp, this.
|
|
44
|
+
refTimestamp = Math.max(refTimestamp, this.positionsQueue[queueLength - 1].time);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
let diffTime =
|
|
47
|
+
let diffTime = newPosition.time - this.previousPosition.time;
|
|
48
48
|
|
|
49
49
|
if (flyby) {
|
|
50
50
|
diffTime = MAX_FLYBY_TIME;
|
|
@@ -55,34 +55,34 @@ class Smoother {
|
|
|
55
55
|
let i = 1;
|
|
56
56
|
while (i < nSamples + 1) {
|
|
57
57
|
i = Math.min(i, nSamples);
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
this.
|
|
58
|
+
const smoothedPosition = this.previousPosition.destinationPoint(distance * i / nSamples, azimuth);
|
|
59
|
+
smoothedPosition.time = refTimestamp + (i - 1) / GEN_FREQUENCY;
|
|
60
|
+
this.positionsQueue.push(smoothedPosition);
|
|
61
61
|
i++;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
this.
|
|
64
|
+
this.previousPosition = newPosition;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* Pull
|
|
69
|
-
* @param {*} timestamp
|
|
70
|
-
* @returns last known
|
|
68
|
+
* Pull positions until timestamp and return the last one.
|
|
69
|
+
* @param {*} timestamp position returned is the last before this timestamp
|
|
70
|
+
* @returns last known position before timestamp, undefined otherwise
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
pullPosition(timestamp) {
|
|
73
73
|
|
|
74
74
|
if ((typeof timestamp === 'undefined' || !timestamp)
|
|
75
|
-
&& this.
|
|
76
|
-
const output = this.
|
|
77
|
-
this.
|
|
75
|
+
&& this.positionsQueue.length > 0) {
|
|
76
|
+
const output = this.positionsQueue[this.positionsQueue.length - 1];
|
|
77
|
+
this.positionsQueue = [];
|
|
78
78
|
return output;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
let
|
|
82
|
-
while (this.
|
|
83
|
-
|
|
81
|
+
let position;
|
|
82
|
+
while (this.positionsQueue.length && this.positionsQueue[0].time <= timestamp) {
|
|
83
|
+
position = this.positionsQueue.shift();
|
|
84
84
|
}
|
|
85
|
-
return
|
|
85
|
+
return position;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
}
|
|
@@ -388,10 +388,10 @@ describe('validSmoother', () => {
|
|
|
388
388
|
for (let i = 0; i < positions.length; i++) {
|
|
389
389
|
const pos = new WGS84UserPosition(positions[i][1], positions[i][2]);
|
|
390
390
|
pos.time = positions[i][0];
|
|
391
|
-
smoother.
|
|
391
|
+
smoother.generateNextPositions(pos, positions[i][3]);
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
const predicted = smoother.
|
|
394
|
+
const predicted = smoother.positionsQueue;
|
|
395
395
|
expect(predicted.length).to.equal(expectations.length);
|
|
396
396
|
|
|
397
397
|
for (let i = 0; i < predicted.length; i++) {
|
|
@@ -401,8 +401,8 @@ describe('validSmoother', () => {
|
|
|
401
401
|
expect(timeDiff).to.almost.equal(0);
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
const
|
|
405
|
-
expect(
|
|
404
|
+
const positionAt10 = smoother.pullPosition(10);
|
|
405
|
+
expect(positionAt10.distanceTo(new WGS84(3.7669421260460435E-5, 2.5766995044818355E-5))).to.almost.equal(0);
|
|
406
406
|
});
|
|
407
407
|
});
|
|
408
408
|
|
|
@@ -413,12 +413,12 @@ describe('smoother return same value if unique', () => {
|
|
|
413
413
|
const smoother = new Smoother();
|
|
414
414
|
|
|
415
415
|
const pos = new WGS84UserPosition(positions[0][1], positions[0][2]);
|
|
416
|
-
smoother.
|
|
417
|
-
const posExpected = smoother.
|
|
416
|
+
smoother.generateNextPositions(pos);
|
|
417
|
+
const posExpected = smoother.pullPosition();
|
|
418
418
|
|
|
419
419
|
expect(posExpected).to.be.an.instanceof(WGS84UserPosition);
|
|
420
420
|
expect(posExpected.distanceTo(pos)).to.almost.equal(0);
|
|
421
|
-
expect(smoother.
|
|
421
|
+
expect(smoother.positionsQueue).to.be.an('array').that.is.empty;
|
|
422
422
|
});
|
|
423
423
|
});
|
|
424
424
|
|
|
@@ -78,8 +78,8 @@ class GnssWifiProvider extends Provider {
|
|
|
78
78
|
/**
|
|
79
79
|
* @private
|
|
80
80
|
*/
|
|
81
|
-
onNewPosition =
|
|
82
|
-
const { coords } =
|
|
81
|
+
onNewPosition = geolocation => {
|
|
82
|
+
const { coords } = geolocation;
|
|
83
83
|
if (!coords) {
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
@@ -89,9 +89,9 @@ class GnssWifiProvider extends Provider {
|
|
|
89
89
|
bearing = deg2rad(coords.heading);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
const timestamp = DateUtils.unixTimestampToPerformanceNow(
|
|
92
|
+
const timestamp = DateUtils.unixTimestampToPerformanceNow(geolocation.timestamp) / 1e3;
|
|
93
93
|
|
|
94
|
-
const
|
|
94
|
+
const position = new WGS84UserPosition(
|
|
95
95
|
coords.latitude,
|
|
96
96
|
coords.longitude,
|
|
97
97
|
coords.altitude,
|
|
@@ -101,7 +101,7 @@ class GnssWifiProvider extends Provider {
|
|
|
101
101
|
GnssWifiProvider.name);
|
|
102
102
|
|
|
103
103
|
this.notify(this.createEvent(
|
|
104
|
-
EventType.AbsolutePosition,
|
|
104
|
+
EventType.AbsolutePosition, position, timestamp
|
|
105
105
|
));
|
|
106
106
|
|
|
107
107
|
};
|
|
@@ -10,7 +10,7 @@ import IpResolveServerError from '../../errors/IpResolveServerError';
|
|
|
10
10
|
* by Wifi Fingerprinting algorithms or by GNSS. That is why the name is
|
|
11
11
|
* "GnssWifi".
|
|
12
12
|
*/
|
|
13
|
-
class
|
|
13
|
+
class IpProvider extends Provider {
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @override
|
|
@@ -72,4 +72,4 @@ class GnssWifiProvider extends Provider {
|
|
|
72
72
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export default
|
|
75
|
+
export default IpProvider;
|