@wemap/positioning 2.3.6 → 2.3.7
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 +1 -1
- package/src/PositioningHandler.js +58 -43
- package/src/PositioningHandler.spec.js +47 -27
- package/src/components/AbsoluteAttitudeComponent.jsx +2 -6
- package/src/components/ArCoreAbsoluteComponent.jsx +4 -11
- package/src/components/ArCoreComponent.jsx +4 -11
- package/src/components/GnssWifiComponent.jsx +2 -6
- package/src/components/GnssWifiPdrComponent.jsx +4 -11
- package/src/components/ImuComponent.jsx +4 -12
- package/src/components/InclinationComponent.jsx +2 -6
- package/src/components/PdrComponent.jsx +5 -12
- package/src/components/PoseComponent.jsx +4 -11
- package/src/components/PositioningInclinationComponent.jsx +5 -8
- package/src/components/PositioningPoseComponent.jsx +10 -15
- package/src/components/RelativeAttitudeComponent.jsx +3 -6
- package/src/errors/ContainsIgnoredProviderError.js +9 -0
- package/src/events/Availability.js +30 -0
- package/src/providers/Provider.js +50 -50
- package/src/providers/attitude/AbsoluteAttitudeProvider.js +11 -27
- package/src/providers/attitude/RelativeAttitudeProvider.js +2 -17
- package/src/providers/others/ImuProvider.js +11 -25
- package/src/providers/others/InclinationProvider.js +2 -17
- package/src/providers/pose/ArCoreAbsoluteProvider.js +4 -30
- package/src/providers/pose/ArCoreProvider.js +11 -8
- package/src/providers/pose/GnssWifiPdrProvider.js +4 -26
- package/src/providers/pose/PoseProvider.js +3 -29
- package/src/providers/pose/pdr/PdrProvider.js +8 -28
- package/src/providers/position/GnssWifiProvider.js +9 -16
- package/src/providers/position/IpProvider.js +1 -11
- package/src/events/ProviderError.js +0 -52
- package/src/providers/FakeAbsolutePositionProvider.js +0 -56
|
@@ -15,7 +15,6 @@ import RelativeAttitudeProvider from '../../attitude/RelativeAttitudeProvider';
|
|
|
15
15
|
import ImuProvider from '../../others/ImuProvider';
|
|
16
16
|
import EventType from '../../../events/EventType';
|
|
17
17
|
import MapMatchingProvider from '../../others/MapMatchingProvider';
|
|
18
|
-
import ProviderError from '../../../events/ProviderError';
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
const MM_PDR_ANGLE = 20;
|
|
@@ -41,18 +40,20 @@ class PdrProvider extends MapMatchingProvider {
|
|
|
41
40
|
* @override
|
|
42
41
|
*/
|
|
43
42
|
constructor(onEvent, onError, options) {
|
|
44
|
-
super(onEvent, onError, Object.assign(DEFAULT_OPTIONS, options
|
|
43
|
+
super(onEvent, onError, Object.assign({}, DEFAULT_OPTIONS, options));
|
|
45
44
|
|
|
46
45
|
// Input data providers
|
|
47
46
|
this.relativeAttitudeProvider = new RelativeAttitudeProvider(
|
|
48
47
|
e => this.onRelativeAttitudeEvent(e),
|
|
49
|
-
|
|
50
|
-
options
|
|
48
|
+
onError,
|
|
49
|
+
this.options
|
|
51
50
|
);
|
|
52
51
|
this.imuProvider = new ImuProvider(
|
|
53
52
|
e => this.onImuEvent(e),
|
|
54
|
-
|
|
55
|
-
Object.assign(
|
|
53
|
+
onError,
|
|
54
|
+
Object.assign({}, this.options,
|
|
55
|
+
{ require: [EventType.Acceleration, EventType.AngularRate] }
|
|
56
|
+
)
|
|
56
57
|
);
|
|
57
58
|
|
|
58
59
|
// Helpers for PDR
|
|
@@ -84,7 +85,7 @@ class PdrProvider extends MapMatchingProvider {
|
|
|
84
85
|
/**
|
|
85
86
|
* @override
|
|
86
87
|
*/
|
|
87
|
-
static
|
|
88
|
+
static getRequiredProviders() {
|
|
88
89
|
return [ImuProvider, RelativeAttitudeProvider];
|
|
89
90
|
}
|
|
90
91
|
|
|
@@ -240,27 +241,6 @@ class PdrProvider extends MapMatchingProvider {
|
|
|
240
241
|
this.notify(this.createEvent(EventType.AbsolutePosition, this.position));
|
|
241
242
|
}
|
|
242
243
|
|
|
243
|
-
onProviderError(errors) {
|
|
244
|
-
this.notifyError(...ProviderError.modifyArrayDataType(errors, EventType.AbsoluteAttitude));
|
|
245
|
-
this.notifyError(...ProviderError.modifyArrayDataType(errors, EventType.AbsolutePosition));
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* @override
|
|
250
|
-
*/
|
|
251
|
-
static checkAvailabilityErrors() {
|
|
252
|
-
const errors = super.checkAvailabilityErrors();
|
|
253
|
-
return ProviderError.modifyArrayDataType(
|
|
254
|
-
errors,
|
|
255
|
-
EventType.AbsolutePosition
|
|
256
|
-
).concat(
|
|
257
|
-
ProviderError.modifyArrayDataType(
|
|
258
|
-
errors,
|
|
259
|
-
EventType.AbsoluteAttitude
|
|
260
|
-
)
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
244
|
calculateNewPosition(previousPosition, timestamp, heading, stepSize) {
|
|
265
245
|
|
|
266
246
|
/**
|
|
@@ -7,6 +7,7 @@ import GeolocationApiMissingError from '../../errors/GeolocationApiMissingError'
|
|
|
7
7
|
import Provider from '../Provider';
|
|
8
8
|
import GeolocationPermissionDeniedError from '../../errors/GeolocationPermissionDeniedError';
|
|
9
9
|
import GeolocationPositionUnavailableError from '../../errors/GeolocationPositionUnavailableError';
|
|
10
|
+
import Availability from '../../events/Availability';
|
|
10
11
|
|
|
11
12
|
const POSITION_OPTIONS = {
|
|
12
13
|
enableHighAccuracy: true,
|
|
@@ -39,18 +40,13 @@ class GnssWifiProvider extends Provider {
|
|
|
39
40
|
/**
|
|
40
41
|
* @override
|
|
41
42
|
*/
|
|
42
|
-
static
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
GnssWifiProvider.createError(
|
|
50
|
-
EventType.AbsolutePosition,
|
|
51
|
-
new GeolocationApiMissingError()
|
|
52
|
-
)
|
|
53
|
-
];
|
|
43
|
+
static checkAvailability(options) {
|
|
44
|
+
return Availability.merge(
|
|
45
|
+
super.checkAvailability(options),
|
|
46
|
+
navigator && navigator.geolocation
|
|
47
|
+
? Availability.yes()
|
|
48
|
+
: Availability.no(new GeolocationApiMissingError())
|
|
49
|
+
);
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
/**
|
|
@@ -118,10 +114,7 @@ class GnssWifiProvider extends Provider {
|
|
|
118
114
|
}
|
|
119
115
|
|
|
120
116
|
if (customError) {
|
|
121
|
-
this.notifyError(
|
|
122
|
-
EventType.AbsolutePosition,
|
|
123
|
-
customError
|
|
124
|
-
));
|
|
117
|
+
this.notifyError(customError);
|
|
125
118
|
}
|
|
126
119
|
};
|
|
127
120
|
}
|
|
@@ -26,13 +26,6 @@ class IpProvider extends Provider {
|
|
|
26
26
|
return [EventType.AbsolutePosition];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* @override
|
|
31
|
-
*/
|
|
32
|
-
static checkAvailabilityErrors() {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
29
|
/**
|
|
37
30
|
* @override
|
|
38
31
|
*/
|
|
@@ -41,10 +34,7 @@ class IpProvider extends Provider {
|
|
|
41
34
|
fetch('https://ipinfo.io/geo?token=24a7ca2f3b489d')
|
|
42
35
|
.then((response) => {
|
|
43
36
|
if (!response) {
|
|
44
|
-
this.notifyError(
|
|
45
|
-
EventType.AbsolutePosition,
|
|
46
|
-
new IpResolveServerError()
|
|
47
|
-
));
|
|
37
|
+
this.notifyError(new IpResolveServerError());
|
|
48
38
|
return;
|
|
49
39
|
}
|
|
50
40
|
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import EventType from './EventType';
|
|
2
|
-
import ProviderEvent from './ProviderEvent';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A provider error is an error event which is triggered by device sensors
|
|
6
|
-
* in case of problem
|
|
7
|
-
*/
|
|
8
|
-
class ProviderError extends ProviderEvent {
|
|
9
|
-
|
|
10
|
-
error = null;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Create a Provider Error with the minimum information
|
|
14
|
-
* @param {String} providerName the provider name
|
|
15
|
-
* @param {EventType} dataType the type of event
|
|
16
|
-
* @param {Error} error the event error
|
|
17
|
-
*/
|
|
18
|
-
constructor(providerName, dataType, error) {
|
|
19
|
-
super(providerName, dataType, null);
|
|
20
|
-
this.error = error;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
clone() {
|
|
24
|
-
const evt = new ProviderError(this.providerName, this.dataType, this.error);
|
|
25
|
-
evt.timestamp = this.timestamp;
|
|
26
|
-
evt.isFromNative = this.isFromNative;
|
|
27
|
-
return evt;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Remove the same error in array
|
|
32
|
-
* @param {ProviderError[]} errorsArray
|
|
33
|
-
*/
|
|
34
|
-
static removeArrayDuplicates(errorsArray) {
|
|
35
|
-
return errorsArray.reduce((acc, current) => {
|
|
36
|
-
const found = acc.find(item => typeof item.error === typeof current.error && item.dataType === current.dataType);
|
|
37
|
-
return !found ? acc.concat([current]) : acc;
|
|
38
|
-
}, []);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static modifyArrayDataType(errorsArray, newDataType) {
|
|
42
|
-
const output = [];
|
|
43
|
-
errorsArray.forEach(error => {
|
|
44
|
-
const newError = error.clone();
|
|
45
|
-
newError.dataType = newDataType;
|
|
46
|
-
output.push(newError);
|
|
47
|
-
});
|
|
48
|
-
return ProviderError.removeArrayDuplicates(output);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default ProviderError;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WGS84, Attitude
|
|
3
|
-
} from '@wemap/geo';
|
|
4
|
-
import Provider from './Provider';
|
|
5
|
-
import EventType from '../events/EventType';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @private
|
|
10
|
-
*/
|
|
11
|
-
class FakeAbsolutePositionProvider extends Provider {
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @override
|
|
15
|
-
*/
|
|
16
|
-
static get displayName() {
|
|
17
|
-
return 'FakeAbsolutePosition';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @override
|
|
22
|
-
*/
|
|
23
|
-
static get eventsType() {
|
|
24
|
-
return [EventType.AbsoluteAttitude, EventType.AbsolutePosition];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @override
|
|
29
|
-
*/
|
|
30
|
-
startInternal() {
|
|
31
|
-
|
|
32
|
-
this.interval = setInterval(() => {
|
|
33
|
-
this.notify(
|
|
34
|
-
this.createEvent(EventType.AbsoluteAttitude, new Attitude([1, 0, 0, 0])),
|
|
35
|
-
this.createEvent(EventType.AbsolutePosition, new WGS84(45, 5))
|
|
36
|
-
);
|
|
37
|
-
}, 1000);
|
|
38
|
-
|
|
39
|
-
return Promise.resolve();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @override
|
|
44
|
-
*/
|
|
45
|
-
stopInternal() {
|
|
46
|
-
|
|
47
|
-
if (this.interval) {
|
|
48
|
-
clearInterval(this.interval);
|
|
49
|
-
this.interval = null;
|
|
50
|
-
}
|
|
51
|
-
return Promise.resolve();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default FakeAbsolutePositionProvider;
|