@wemap/providers 4.0.0 → 4.0.3
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/dist/index.html +1 -0
- package/debug/dist/turn-detection.html +19 -0
- package/debug/index.js +2 -0
- package/debug/src/AbsoluteAttitudeComponent.jsx +3 -10
- package/debug/src/StepDetectionComponent.jsx +3 -3
- package/debug/src/TurnDetectionComponent.jsx +47 -0
- package/debug/src/Utils.js +20 -0
- package/package.json +7 -9
- package/src/Providers.js +26 -81
- package/src/ProvidersInterface.js +5 -6
- package/src/errors/AskImuOnDesktopError.js +4 -3
- package/src/errors/ContainsIgnoredProviderError.js +4 -3
- package/src/errors/GeolocationApiMissingError.js +4 -3
- package/src/errors/GeolocationPermissionDeniedError.js +4 -3
- package/src/errors/GeolocationPositionUnavailableError.js +4 -3
- package/src/errors/IpResolveServerError.js +4 -3
- package/src/errors/MissingAccelerometerError.js +3 -3
- package/src/errors/MissingArCoreError.js +4 -3
- package/src/errors/MissingGyroscopeError.js +3 -3
- package/src/errors/MissingNativeInterfaceError.js +4 -3
- package/src/errors/MissingSensorError.js +4 -3
- package/src/errors/NoProviderFoundError.js +4 -3
- package/src/events/EventType.js +5 -1
- package/src/events/ProviderEvent.js +7 -0
- package/src/events/ProvidersLoggerOld.js +35 -34
- package/src/mapmatching/MapMatchingHandler.js +335 -69
- package/src/providers/FakeProvider.spec.js +15 -15
- package/src/providers/Provider.js +44 -27
- package/src/providers/Provider.spec.js +18 -29
- package/src/providers/attitude/TurnDectector.js +71 -0
- package/src/providers/attitude/absolute/AbsoluteAttitude.js +232 -0
- package/src/providers/attitude/absolute/{AbsoluteAttitudeFromBrowserProvider.js → AbsoluteAttitudeFromBrowser.js} +4 -4
- package/src/providers/attitude/relative/{RelativeAttitudeProvider.js → RelativeAttitude.js} +5 -8
- package/src/providers/attitude/relative/{RelativeAttitudeFromBrowserProvider.js → RelativeAttitudeFromBrowser.js} +4 -5
- package/src/providers/attitude/relative/{RelativeAttitudeFromEkfProvider.js → RelativeAttitudeFromEkf.js} +7 -8
- package/src/providers/attitude/relative/{RelativeAttitudeFromInertialProvider.js → RelativeAttitudeFromInertial.js} +24 -7
- package/src/providers/imu/{AccelerometerProvider.js → Accelerometer.js} +3 -3
- package/src/providers/imu/{GyroscopeProvider.js → Gyroscope.js} +3 -3
- package/src/providers/imu/HighRotationsDetector.js +62 -0
- package/src/providers/imu/{ImuProvider.js → Imu.js} +3 -3
- package/src/providers/inclination/{InclinationProvider.js → Inclination.js} +5 -6
- package/src/providers/inclination/{InclinationFromAccProvider.js → InclinationFromAcc.js} +4 -3
- package/src/providers/inclination/{InclinationFromRelativeAttitudeProvider.js → InclinationFromRelativeAttitude.js} +4 -3
- package/src/providers/legacy/helpers/ThugDetector.js +7 -7
- package/src/providers/others/{BarcodeProvider.js → Barcode.js} +3 -3
- package/src/providers/others/{CameraNativeProvider.js → CameraNative.js} +3 -3
- package/src/providers/others/{CameraProjectionMatrixProvider.js → CameraProjectionMatrix.js} +4 -4
- package/src/providers/position/absolute/AbsolutePosition.js +217 -0
- package/src/providers/position/absolute/{GnssWifiProvider.js → GnssWifi.js} +9 -8
- package/src/providers/position/absolute/{IpProvider.js → Ip.js} +2 -2
- package/src/providers/position/relative/{ArCoreProvider.js → ArCore.js} +28 -30
- package/src/providers/position/relative/{GeoRelativePositionProvider.js → GeoRelativePosition.js} +6 -6
- package/src/providers/position/relative/{GeoRelativePositionFromArCoreProvider.js → GeoRelativePositionFromArCore.js} +4 -5
- package/src/providers/position/relative/{PdrProvider.js → Pdr.js} +8 -8
- package/src/providers/steps/StepDetectionLadetto.js +12 -13
- package/src/providers/steps/StepDetectionMinMaxPeaks.js +19 -17
- package/src/providers/steps/StepDetectionMinMaxPeaks2.js +17 -18
- package/src/providers/steps/{StepDetectionProvider.js → StepDetector.js} +8 -7
- package/src/providers/steps/StraightLineDetector.js +80 -0
- package/src/smoothers/AttitudeSmoother.js +94 -59
- package/src/providers/MetaProvider.js +0 -44
- package/src/providers/attitude/absolute/AbsoluteAttitudeFromRelAttProvider.js +0 -132
- package/src/providers/attitude/absolute/AbsoluteAttitudeFusedProvider.js +0 -166
- package/src/providers/attitude/absolute/AbsoluteAttitudeProvider.js +0 -175
- package/src/providers/position/absolute/AbsolutePositionFromRelProvider.js +0 -107
- package/src/providers/position/absolute/AbsolutePositionProvider.js +0 -189
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AbsoluteHeading, Attitude
|
|
3
|
-
} from '@wemap/geo';
|
|
4
|
-
import { PromiseUtils } from '@wemap/utils';
|
|
5
|
-
|
|
6
|
-
import MetaProvider from '../../MetaProvider.js';
|
|
7
|
-
import EventType from '../../../events/EventType.js';
|
|
8
|
-
import {
|
|
9
|
-
AbsoluteAttitudeFromBrowser, AbsoluteAttitudeFromRelAtt, AbsoluteAttitudeFused
|
|
10
|
-
} from '../../../Providers.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Absolute attitude provider gives the device attitude in East-North-Up (ENU) frame
|
|
15
|
-
*/
|
|
16
|
-
class AbsoluteAttitudeProvider extends MetaProvider {
|
|
17
|
-
|
|
18
|
-
constructor() {
|
|
19
|
-
super();
|
|
20
|
-
|
|
21
|
-
this.attitudeFromBrowserErrored = false;
|
|
22
|
-
this.attitudeFromRelAttErrored = false;
|
|
23
|
-
this.attitudeFusedErrored = false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @override
|
|
28
|
-
*/
|
|
29
|
-
static get pname() {
|
|
30
|
-
return 'AbsoluteAttitude';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @override
|
|
35
|
-
*/
|
|
36
|
-
static get eventsType() {
|
|
37
|
-
return [EventType.AbsoluteAttitude];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @override
|
|
42
|
-
*/
|
|
43
|
-
get _availability() {
|
|
44
|
-
return PromiseUtils.any([
|
|
45
|
-
AbsoluteAttitudeFromBrowser.availability,
|
|
46
|
-
AbsoluteAttitudeFromRelAtt.availability,
|
|
47
|
-
AbsoluteAttitudeFused.availability
|
|
48
|
-
]);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @override
|
|
53
|
-
*/
|
|
54
|
-
start() {
|
|
55
|
-
|
|
56
|
-
this.fromBrowserProviderId = AbsoluteAttitudeFromBrowser.addEventListener(
|
|
57
|
-
events => this.onAttitudeFromBrowser(events[0]),
|
|
58
|
-
error => {
|
|
59
|
-
this.attitudeFromBrowserErrored = true;
|
|
60
|
-
this.onError(error);
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
this.fromRelAttProviderId = AbsoluteAttitudeFromRelAtt.addEventListener(
|
|
65
|
-
events => this.onAttitudeFromRelAtt(events[0]),
|
|
66
|
-
error => {
|
|
67
|
-
this.attitudeFromRelAttErrored = true;
|
|
68
|
-
this.onError(error);
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
this.fusedProviderId = AbsoluteAttitudeFused.addEventListener(
|
|
73
|
-
events => this.onAttitudeFused(events[0]),
|
|
74
|
-
error => {
|
|
75
|
-
this.attitudeFusedErrored = true;
|
|
76
|
-
this.onError(error);
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
onError(error) {
|
|
82
|
-
if (this.attitudeFromBrowserErrored
|
|
83
|
-
&& this.attitudeFromRelAttErrored
|
|
84
|
-
&& this.attitudeFusedErrored) {
|
|
85
|
-
this.notifyError(error);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
onAttitudeFromBrowser(event) {
|
|
90
|
-
this.eventFromBrowser = event;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (this.eventFromRelAtt && this.eventFromRelAtt.data.accuracy < event.data.accuracy) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (this.eventFromFused && this.eventFromFused.data.accuracy < event.data.accuracy) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
this.notify(event.clone());
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
onAttitudeFromRelAtt(event) {
|
|
103
|
-
this.eventFromRelAtt = event;
|
|
104
|
-
|
|
105
|
-
if (this.eventFromBrowser && this.eventFromBrowser.data.accuracy < event.data.accuracy) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (this.eventFromFused && this.eventFromFused.data.accuracy < event.data.accuracy) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
this.notify(event.clone());
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
onAttitudeFused(event) {
|
|
115
|
-
this.eventFromFused = event;
|
|
116
|
-
|
|
117
|
-
if (this.eventFromBrowser && this.eventFromBrowser.data.accuracy < event.data.accuracy) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (this.eventFromRelAtt && this.eventFromRelAtt.data.accuracy < event.data.accuracy) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
this.notify(event.clone());
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @override
|
|
128
|
-
*/
|
|
129
|
-
stop() {
|
|
130
|
-
AbsoluteAttitudeFromBrowser.removeEventListener(this.fromBrowserProviderId);
|
|
131
|
-
AbsoluteAttitudeFromRelAtt.removeEventListener(this.fromRelAttProviderId);
|
|
132
|
-
AbsoluteAttitudeFused.removeEventListener(this.fusedProviderId);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @override
|
|
137
|
-
* @param {AbsoluteHeading|Attitude} data
|
|
138
|
-
*/
|
|
139
|
-
feed(data) {
|
|
140
|
-
|
|
141
|
-
if (data instanceof AbsoluteHeading) {
|
|
142
|
-
|
|
143
|
-
if (data.time === null) {
|
|
144
|
-
throw Error('the time of the absolute heading is not defined');
|
|
145
|
-
}
|
|
146
|
-
if (data.accuracy === null) {
|
|
147
|
-
throw Error('the accuracy of the absolute heading is not defined');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
this.notify(this.createEvent(
|
|
151
|
-
EventType.AbsoluteAttitude,
|
|
152
|
-
data.toAttitude()
|
|
153
|
-
));
|
|
154
|
-
|
|
155
|
-
} else if (data instanceof Attitude) {
|
|
156
|
-
|
|
157
|
-
if (data.time === null) {
|
|
158
|
-
throw Error('the time of the attitude is not defined');
|
|
159
|
-
}
|
|
160
|
-
if (data.accuracy === null) {
|
|
161
|
-
throw Error('the accuracy of the attitude is not defined');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
this.notify(this.createEvent(
|
|
165
|
-
EventType.AbsoluteAttitude,
|
|
166
|
-
data
|
|
167
|
-
));
|
|
168
|
-
|
|
169
|
-
} else {
|
|
170
|
-
throw new Error('data is nor an AbsoluteHeading or an Attitude object');
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export default AbsoluteAttitudeProvider;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import Provider from '../../Provider.js';
|
|
2
|
-
import EventType from '../../../events/EventType.js';
|
|
3
|
-
import ProviderEvent from '../../../events/ProviderEvent.js';
|
|
4
|
-
import {
|
|
5
|
-
AbsolutePosition, GeoRelativePosition
|
|
6
|
-
} from '../../../Providers.js';
|
|
7
|
-
|
|
8
|
-
class AbsolutePositionFromRelProvider extends Provider {
|
|
9
|
-
|
|
10
|
-
position = null;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @override
|
|
14
|
-
*/
|
|
15
|
-
static get pname() {
|
|
16
|
-
return 'AbsolutePositionFromRel';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @override
|
|
21
|
-
*/
|
|
22
|
-
static get eventsType() {
|
|
23
|
-
return [EventType.AbsolutePosition];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @override
|
|
28
|
-
*/
|
|
29
|
-
get _availability() {
|
|
30
|
-
return GeoRelativePosition.availability;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @override
|
|
36
|
-
*/
|
|
37
|
-
start() {
|
|
38
|
-
|
|
39
|
-
this.providerId = GeoRelativePosition.addEventListener(
|
|
40
|
-
events => this.onRelativePositionEvent(events[0]),
|
|
41
|
-
error => this.notifyError(error)
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
this.onAbsolutePositionEvent(AbsolutePosition.lastEvent);
|
|
45
|
-
this.absolutePositionProviderId = AbsolutePosition.addEventListener(
|
|
46
|
-
events => this.onAbsolutePositionEvent(events[0]),
|
|
47
|
-
error => this.notifyError(error),
|
|
48
|
-
false
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @override
|
|
56
|
-
*/
|
|
57
|
-
stop() {
|
|
58
|
-
GeoRelativePosition.removeEventListener(this.providerId);
|
|
59
|
-
AbsolutePosition.removeEventListener(this.absolutePositionProviderId);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
onAbsolutePositionEvent(absolutePositionEvent) {
|
|
63
|
-
|
|
64
|
-
if (!absolutePositionEvent) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Use absolute position events only when they are not from this provider
|
|
70
|
-
*/
|
|
71
|
-
if (absolutePositionEvent.data === this.position) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
this.position = absolutePositionEvent.data;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @param {ProviderEvent} event
|
|
81
|
-
*/
|
|
82
|
-
onRelativePositionEvent(event) {
|
|
83
|
-
|
|
84
|
-
if (this.position) {
|
|
85
|
-
|
|
86
|
-
const offsetPos = event.data;
|
|
87
|
-
|
|
88
|
-
const dist = Math.sqrt(offsetPos.x ** 2 + offsetPos.y ** 2);
|
|
89
|
-
const bearing = Math.atan2(offsetPos.x, offsetPos.y);
|
|
90
|
-
const alt = this.position.alt !== null ? offsetPos.z : null;
|
|
91
|
-
|
|
92
|
-
this.position = this.position.destinationPoint(dist, bearing, alt);
|
|
93
|
-
this.position.bearing = offsetPos.bearing;
|
|
94
|
-
this.position.time = offsetPos.time;
|
|
95
|
-
this.position.accuracy += offsetPos.accuracy;
|
|
96
|
-
|
|
97
|
-
this.notify(this.createEvent(
|
|
98
|
-
EventType.AbsolutePosition,
|
|
99
|
-
this.position,
|
|
100
|
-
[event]
|
|
101
|
-
));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export default AbsolutePositionFromRelProvider;
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash.noop';
|
|
2
|
-
|
|
3
|
-
import { UserPosition } from '@wemap/geo';
|
|
4
|
-
import { PromiseUtils } from '@wemap/utils';
|
|
5
|
-
|
|
6
|
-
import MetaProvider from '../../MetaProvider.js';
|
|
7
|
-
import EventType from '../../../events/EventType.js';
|
|
8
|
-
import ProviderEvent from '../../../events/ProviderEvent.js';
|
|
9
|
-
import {
|
|
10
|
-
AbsolutePositionFromRel, GnssWifi
|
|
11
|
-
} from '../../../Providers.js';
|
|
12
|
-
import MapMatchingHandler from '../../../mapmatching/MapMatchingHandler.js';
|
|
13
|
-
|
|
14
|
-
// Position accuracy uncertainty ratio
|
|
15
|
-
const ACCURACY_NEW_POS_EPS_RATIO = 1.5;
|
|
16
|
-
const ACCURACY_RELOC_RATIO = 2;
|
|
17
|
-
const MM_MIN_TIME = 0.4;
|
|
18
|
-
|
|
19
|
-
class AbsolutePositionProvider extends MetaProvider {
|
|
20
|
-
|
|
21
|
-
/** @type {number} */
|
|
22
|
-
lastMMAttempt = -Infinity;
|
|
23
|
-
|
|
24
|
-
constructor() {
|
|
25
|
-
super();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @override
|
|
30
|
-
*/
|
|
31
|
-
static get pname() {
|
|
32
|
-
return 'AbsolutePosition';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @override
|
|
37
|
-
*/
|
|
38
|
-
static get eventsType() {
|
|
39
|
-
return [EventType.AbsolutePosition];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @override
|
|
44
|
-
*/
|
|
45
|
-
get _availability() {
|
|
46
|
-
return PromiseUtils.any([
|
|
47
|
-
AbsolutePositionFromRel.availability,
|
|
48
|
-
GnssWifi.availability
|
|
49
|
-
]);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @override
|
|
55
|
-
*/
|
|
56
|
-
start() {
|
|
57
|
-
AbsolutePositionFromRel.availability
|
|
58
|
-
.then(() => {
|
|
59
|
-
this.fromRelPosProviderId = AbsolutePositionFromRel.addEventListener(
|
|
60
|
-
events => this.onAbsolutePositionFromRel(events[0]),
|
|
61
|
-
noop
|
|
62
|
-
);
|
|
63
|
-
})
|
|
64
|
-
.catch(() => {
|
|
65
|
-
// do nothing
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
this.gnssWifiProviderId = GnssWifi.addEventListener(
|
|
69
|
-
events => {
|
|
70
|
-
// bearing from GnssWifi is not reliable for our usecase
|
|
71
|
-
events[0].data.bearing = null;
|
|
72
|
-
this.onAbsolutePosition(events[0], false);
|
|
73
|
-
},
|
|
74
|
-
noop
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @override
|
|
82
|
-
*/
|
|
83
|
-
stop() {
|
|
84
|
-
if (this.fromRelPosProviderId) {
|
|
85
|
-
AbsolutePositionFromRel.removeEventListener(this.fromRelPosProviderId);
|
|
86
|
-
}
|
|
87
|
-
GnssWifi.removeEventListener(this.gnssWifiProviderId);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @param {ProviderEvent} newPositionEvent
|
|
92
|
-
* @param {boolean} canContainLevel
|
|
93
|
-
*/
|
|
94
|
-
onAbsolutePosition(newPositionEvent, canContainLevel = true) {
|
|
95
|
-
|
|
96
|
-
if (!this._useNewAbsolutePosition(newPositionEvent.data)) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const newPosition = newPositionEvent.data.clone();
|
|
101
|
-
|
|
102
|
-
if (this.lastEvent && !canContainLevel) {
|
|
103
|
-
newPosition.level = this.lastEvent.data.level;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// If the new position does not have a bearing, retrieve the bearing from the last position
|
|
107
|
-
if (newPosition.bearing === null && this.lastEvent !== null) {
|
|
108
|
-
newPosition.bearing = this.lastEvent.data.bearing;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const shouldTryMmOnNodes = !newPositionEvent.providersStack.includes(AbsolutePositionFromRel.pname);
|
|
112
|
-
const position = MapMatchingHandler.calcProjection(newPosition, shouldTryMmOnNodes) || newPosition;
|
|
113
|
-
|
|
114
|
-
this.notify(this.createEvent(
|
|
115
|
-
EventType.AbsolutePosition,
|
|
116
|
-
position,
|
|
117
|
-
[newPositionEvent]
|
|
118
|
-
));
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @param {ProviderEvent} newPositionEvent
|
|
124
|
-
*/
|
|
125
|
-
onAbsolutePositionFromRel(newPositionEvent) {
|
|
126
|
-
|
|
127
|
-
let position = newPositionEvent.data;
|
|
128
|
-
|
|
129
|
-
if (newPositionEvent.data.time - this.lastMMAttempt > MM_MIN_TIME) {
|
|
130
|
-
position = MapMatchingHandler.calcProjection(position) || position;
|
|
131
|
-
this.lastMMAttempt = newPositionEvent.data.time;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (position === newPositionEvent.data) {
|
|
135
|
-
position = position.clone();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
this.notify(this.createEvent(
|
|
139
|
-
EventType.AbsolutePosition,
|
|
140
|
-
position,
|
|
141
|
-
[newPositionEvent]
|
|
142
|
-
));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
_useNewAbsolutePosition(newPosition) {
|
|
146
|
-
|
|
147
|
-
if (!this.lastEvent) {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const lastPosition = this.lastEvent.data;
|
|
152
|
-
|
|
153
|
-
if (newPosition.accuracy <= newPosition.distanceTo(lastPosition) / ACCURACY_NEW_POS_EPS_RATIO) {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (newPosition.accuracy <= lastPosition.accuracy / ACCURACY_RELOC_RATIO) {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return false;
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* @override
|
|
167
|
-
* @param {UserPosition} data
|
|
168
|
-
*/
|
|
169
|
-
feed(data) {
|
|
170
|
-
if (data instanceof UserPosition) {
|
|
171
|
-
const position = data;
|
|
172
|
-
if (position.time === null) {
|
|
173
|
-
throw Error('the time of the position is not defined');
|
|
174
|
-
}
|
|
175
|
-
if (position.accuracy === null) {
|
|
176
|
-
throw Error('the accuracy of the position is not defined');
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
this.onAbsolutePosition(this.createEvent(
|
|
180
|
-
EventType.AbsolutePosition, position
|
|
181
|
-
));
|
|
182
|
-
} else {
|
|
183
|
-
throw new Error('Unknown feed object');
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export default AbsolutePositionProvider;
|