@wemap/positioning 2.7.13 → 14.0.0-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/README.md +51 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16582 -0
- package/dist/qr-scanner-worker.min-CdBZO1_x.js +2 -0
- package/dist/src/ILocationSource.d.ts +104 -0
- package/dist/src/ILocationSource.d.ts.map +1 -0
- package/dist/src/MapMatching.d.ts +83 -0
- package/dist/src/MapMatching.d.ts.map +1 -0
- package/dist/src/location-sources/GnssWifiLocationSource.d.ts +79 -0
- package/dist/src/location-sources/GnssWifiLocationSource.d.ts.map +1 -0
- package/dist/src/location-sources/LocationSource.d.ts +102 -0
- package/dist/src/location-sources/LocationSource.d.ts.map +1 -0
- package/dist/src/location-sources/VPSLocationSource.d.ts +107 -0
- package/dist/src/location-sources/VPSLocationSource.d.ts.map +1 -0
- package/dist/src/types.d.ts +65 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils/permissions.d.ts +29 -0
- package/dist/src/utils/permissions.d.ts.map +1 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/package.json +23 -59
- package/babel.config.js +0 -11
- package/config.json +0 -4
- package/debug/absolute-attitude.html +0 -16
- package/debug/arcore-absolute.html +0 -16
- package/debug/arcore.html +0 -16
- package/debug/components/AbsoluteAttitudeComponent.jsx +0 -100
- package/debug/components/ArCoreAbsoluteComponent.jsx +0 -104
- package/debug/components/ArCoreComponent.jsx +0 -69
- package/debug/components/GnssWifiComponent.jsx +0 -56
- package/debug/components/GnssWifiPdrComponent.jsx +0 -76
- package/debug/components/ImuComponent.jsx +0 -95
- package/debug/components/InclinationComponent.jsx +0 -52
- package/debug/components/MapComponent.jsx +0 -228
- package/debug/components/NavigationConfig.js +0 -92
- package/debug/components/PdrComponent.jsx +0 -75
- package/debug/components/PoseComponent.jsx +0 -77
- package/debug/components/PositioningComponent.jsx +0 -29
- package/debug/components/PositioningInclinationComponent.jsx +0 -82
- package/debug/components/PositioningPoseComponent.jsx +0 -117
- package/debug/components/RelativeAttitudeComponent.jsx +0 -82
- package/debug/components/StartStopComponent.jsx +0 -50
- package/debug/components/Utils.js +0 -128
- package/debug/components/index.js +0 -34
- package/debug/gnss-wifi-pdr.html +0 -16
- package/debug/gnss-wifi.html +0 -16
- package/debug/imu.html +0 -16
- package/debug/inclination.html +0 -16
- package/debug/pdr.html +0 -16
- package/debug/pose.html +0 -16
- package/debug/positioning.html +0 -16
- package/debug/relative-attitude.html +0 -16
- package/dist/wemap-positioning.min.js +0 -1
- package/index.js +0 -8
- package/src/PositioningHandler.js +0 -237
- package/src/PositioningHandler.spec.js +0 -294
- package/src/PositioningOptions.js +0 -34
- package/src/errors/AskImuOnDesktopError.js +0 -9
- package/src/errors/ContainsIgnoredProviderError.js +0 -9
- package/src/errors/GeolocationApiMissingError.js +0 -9
- package/src/errors/GeolocationPermissionDeniedError.js +0 -9
- package/src/errors/GeolocationPositionUnavailableError.js +0 -9
- package/src/errors/IpResolveServerError.js +0 -9
- package/src/errors/MissingAccelerometerError.js +0 -11
- package/src/errors/MissingArCoreError.js +0 -9
- package/src/errors/MissingGyroscopeError.js +0 -11
- package/src/errors/MissingMagnetometerError.js +0 -9
- package/src/errors/MissingNativeInterfaceError.js +0 -9
- package/src/errors/MissingSensorError.js +0 -14
- package/src/errors/NoProviderFoundError.js +0 -9
- package/src/events/Availability.js +0 -30
- package/src/events/EventType.js +0 -22
- package/src/events/ProviderEvent.js +0 -35
- package/src/providers/Constants.js +0 -5
- package/src/providers/Provider.js +0 -247
- package/src/providers/ProvidersList.js +0 -44
- package/src/providers/ProvidersLogger.js +0 -75
- package/src/providers/attitude/AbsoluteAttitudeProvider.js +0 -199
- package/src/providers/attitude/EkfAttitude.js +0 -238
- package/src/providers/attitude/EkfAttitude.spec.js +0 -116
- package/src/providers/attitude/RelativeAttitudeProvider.js +0 -121
- package/src/providers/others/ImuProvider.js +0 -179
- package/src/providers/others/InclinationProvider.js +0 -99
- package/src/providers/others/MapMatchingProvider.js +0 -65
- package/src/providers/pose/ArCoreAbsoluteProvider.js +0 -235
- package/src/providers/pose/ArCoreProvider.js +0 -191
- package/src/providers/pose/GnssWifiPdrProvider.js +0 -219
- package/src/providers/pose/PoseProvider.js +0 -71
- package/src/providers/pose/pdr/PdrProvider.js +0 -364
- package/src/providers/pose/pdr/helpers/HeadingUnlocker.js +0 -41
- package/src/providers/pose/pdr/helpers/HeadingUnlocker.spec.js +0 -26
- package/src/providers/pose/pdr/helpers/Smoother.js +0 -92
- package/src/providers/pose/pdr/helpers/Smoother.spec.js +0 -426
- package/src/providers/pose/pdr/helpers/ThugDetector.js +0 -37
- package/src/providers/pose/pdr/steps/StepDetection.js +0 -7
- package/src/providers/pose/pdr/steps/StepDetectionLadetto.js +0 -67
- package/src/providers/pose/pdr/steps/StepDetectionMinMaxPeaks.js +0 -80
- package/src/providers/pose/pdr/steps/StepDetectionMinMaxPeaks2.js +0 -108
- package/src/providers/position/GnssWifiProvider.js +0 -130
- package/src/providers/position/IpProvider.js +0 -74
- package/webpack/webpack.common.js +0 -20
- package/webpack/webpack.dev.js +0 -24
- package/webpack/webpack.prod.js +0 -15
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import Provider from '../Provider';
|
|
2
|
-
import EventType from '../../events/EventType';
|
|
3
|
-
import ImuProvider from './ImuProvider';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Inclination provider gives the inclination of the device using Imu Sensor
|
|
7
|
-
* For example, when the top of the device is pointing the sky, inclination = Math.PI/2
|
|
8
|
-
* when the device is layed on a table, inclination = 0
|
|
9
|
-
* This provider use window.orientation to return a result in function of screen orientation
|
|
10
|
-
*/
|
|
11
|
-
class InclinationProvider extends Provider {
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @override
|
|
15
|
-
*/
|
|
16
|
-
constructor(onEvent, onError, options) {
|
|
17
|
-
super(onEvent, onError, options);
|
|
18
|
-
|
|
19
|
-
this.imuProvider = new ImuProvider(
|
|
20
|
-
this.onImuEvent,
|
|
21
|
-
onError,
|
|
22
|
-
{ require: [EventType.Acceleration] }
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @override
|
|
28
|
-
*/
|
|
29
|
-
static get name() {
|
|
30
|
-
return 'Inclination';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @override
|
|
35
|
-
*/
|
|
36
|
-
static get displayName() {
|
|
37
|
-
return 'Inertial Measurement Unit';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @override
|
|
42
|
-
*/
|
|
43
|
-
static get eventsType() {
|
|
44
|
-
return [EventType.Inclination];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @override
|
|
49
|
-
*/
|
|
50
|
-
static getRequiredProviders() {
|
|
51
|
-
return [ImuProvider];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @override
|
|
56
|
-
*/
|
|
57
|
-
startInternal() {
|
|
58
|
-
return this.imuProvider.start();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @override
|
|
63
|
-
*/
|
|
64
|
-
stopInternal() {
|
|
65
|
-
return this.imuProvider.stop();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @private
|
|
70
|
-
*/
|
|
71
|
-
onImuEvent = imuEvent => {
|
|
72
|
-
const accelerationEvent = imuEvent[0];
|
|
73
|
-
const acc = accelerationEvent.data;
|
|
74
|
-
|
|
75
|
-
const screenOrientation = window.orientation || 0;
|
|
76
|
-
|
|
77
|
-
const sizeAcc = Math.sqrt(acc[0] * acc[0] + acc[1] * acc[1] + acc[2] * acc[2]);
|
|
78
|
-
const accNormalized = [acc[0] / sizeAcc, acc[1] / sizeAcc, acc[2] / sizeAcc];
|
|
79
|
-
|
|
80
|
-
const q = [accNormalized[2] + 1, accNormalized[1], -accNormalized[0], 0];
|
|
81
|
-
const qSize = Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2]);
|
|
82
|
-
const qNormalized = [q[0] / qSize, q[1] / qSize, q[2] / qSize, 0];
|
|
83
|
-
|
|
84
|
-
let inclination;
|
|
85
|
-
if (screenOrientation === 0) {
|
|
86
|
-
inclination = Math.asin(2 * qNormalized[1] * qNormalized[0]);
|
|
87
|
-
} else if (screenOrientation === 90) {
|
|
88
|
-
inclination = -Math.asin(2 * qNormalized[2] * qNormalized[0]);
|
|
89
|
-
} else if (screenOrientation === -90) {
|
|
90
|
-
inclination = Math.asin(2 * qNormalized[2] * qNormalized[0]);
|
|
91
|
-
} else if (screenOrientation === 180) {
|
|
92
|
-
inclination = -Math.asin(2 * qNormalized[1] * qNormalized[0]);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
this.notify(this.createEvent(EventType.Inclination, inclination));
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export default InclinationProvider;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import Provider from '../Provider';
|
|
2
|
-
import {
|
|
3
|
-
Itinerary, MapMatching, Network
|
|
4
|
-
} from '@wemap/graph';
|
|
5
|
-
|
|
6
|
-
class MapMatchingProvider extends Provider {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Enable mapmatching
|
|
10
|
-
* @param {*} network a network which will be used for map matching
|
|
11
|
-
* @param {*} maxDistance max distance between position and network to match. null disables maxDistance (default: null)
|
|
12
|
-
* @param {*} maxAngleBearing threshold to match a parallel segment for angle between position bearing and segment. null disables this threshold (default: null)
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
enableMapMatching(network, maxDistance, maxAngleBearing) {
|
|
16
|
-
this.mapMatching = new MapMatching();
|
|
17
|
-
this.mapMatching.maxDistance = maxDistance;
|
|
18
|
-
this.mapMatching.maxAngleBearing = maxAngleBearing;
|
|
19
|
-
|
|
20
|
-
if (network) {
|
|
21
|
-
this.setNetwork(network);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Update the network for mapmatching
|
|
27
|
-
* @param {Network} network a network instance
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
setNetwork(network) {
|
|
31
|
-
if (!this.mapMatching) {
|
|
32
|
-
throw new Error('MapMatching is not enabled');
|
|
33
|
-
}
|
|
34
|
-
this.mapMatching.network = network;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Is mapmatching activated?
|
|
39
|
-
* @returns is mapmatching activated
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
get hasMapMatching() {
|
|
43
|
-
return this.mapMatching !== null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Itinerary
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Update itinerary.
|
|
53
|
-
* Itinerary is different from network, it is not used for mapmatching. It can be used for others tricks like HeadingUnlocker
|
|
54
|
-
* @param {Itinerary} itinerary a given itinerary
|
|
55
|
-
* @public
|
|
56
|
-
*/
|
|
57
|
-
setItinerary(itinerary) {
|
|
58
|
-
if (!(itinerary instanceof Itinerary)) {
|
|
59
|
-
throw new TypeError(itinerary + ' is not an instance of Itinerary');
|
|
60
|
-
}
|
|
61
|
-
this.itinerary = itinerary;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default MapMatchingProvider;
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-statements */
|
|
2
|
-
import {
|
|
3
|
-
Attitude, WGS84UserPosition
|
|
4
|
-
} from '@wemap/geo';
|
|
5
|
-
|
|
6
|
-
import EventType from '../../events/EventType';
|
|
7
|
-
import ArCoreProvider from './ArCoreProvider';
|
|
8
|
-
import {
|
|
9
|
-
Quaternion, Vector3
|
|
10
|
-
} from '@wemap/maths';
|
|
11
|
-
import ImuProvider from '../others/ImuProvider';
|
|
12
|
-
import MapMatchingProvider from '../others/MapMatchingProvider';
|
|
13
|
-
import PdrProvider from './pdr/PdrProvider';
|
|
14
|
-
|
|
15
|
-
const MM_ARCORE_DIST = 5;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Pose provider is the provider used by the PositioningHandler. It uses the best fusion
|
|
19
|
-
* of what he can and provides an AbsoluteAttitude and an AbsolutePosition as an output.
|
|
20
|
-
*/
|
|
21
|
-
class ArCoreAbsoluteProvider extends MapMatchingProvider {
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @override
|
|
25
|
-
*/
|
|
26
|
-
constructor(onEvent, onError, options) {
|
|
27
|
-
super(onEvent, onError, options);
|
|
28
|
-
|
|
29
|
-
this.arCoreProvider = new ArCoreProvider(
|
|
30
|
-
e => this.onArCoreEvent(e),
|
|
31
|
-
onError,
|
|
32
|
-
options);
|
|
33
|
-
|
|
34
|
-
this.imuProvider = new ImuProvider(
|
|
35
|
-
this.onImuEvent,
|
|
36
|
-
onError,
|
|
37
|
-
Object.assign({}, options || {}, { require: [EventType.AngularRate] })
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
if (this.options.useMapMatching) {
|
|
41
|
-
this.enableMapMatching();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @override
|
|
47
|
-
*/
|
|
48
|
-
static get name() {
|
|
49
|
-
return 'ArCoreAbsolute';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @override
|
|
54
|
-
*/
|
|
55
|
-
static get displayName() {
|
|
56
|
-
return 'ArCore absolute provider';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @override
|
|
61
|
-
*/
|
|
62
|
-
static get eventsType() {
|
|
63
|
-
return [EventType.AbsoluteAttitude, EventType.AbsolutePosition];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Return the list of required providers
|
|
68
|
-
*/
|
|
69
|
-
static getRequiredProviders() {
|
|
70
|
-
return [ArCoreProvider, ImuProvider];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @override
|
|
75
|
-
*/
|
|
76
|
-
startInternal() {
|
|
77
|
-
this.arCoreProvider.start();
|
|
78
|
-
this.imuProvider.start();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @override
|
|
83
|
-
*/
|
|
84
|
-
stopInternal() {
|
|
85
|
-
this.arCoreProvider.stop();
|
|
86
|
-
this.imuProvider.stop();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
onArCoreEvent = events => {
|
|
90
|
-
|
|
91
|
-
const eventsForNotification = [];
|
|
92
|
-
|
|
93
|
-
events.forEach(event => {
|
|
94
|
-
if (event.dataType === EventType.RelativeAttitude) {
|
|
95
|
-
|
|
96
|
-
// const previousAttitude = this.relativeAttitude;
|
|
97
|
-
this.relativeAttitude = event.data;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The two following blocks cannot be called in the same call because this.waitingForceHeading
|
|
101
|
-
* if exists, is called before the first this.relativeAttitude assigment. So, this.waitingForceHeading
|
|
102
|
-
* and previousAttitude should not be defined in the same time.
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
if (typeof this.waitingForceHeading !== 'undefined') {
|
|
106
|
-
/**
|
|
107
|
-
* waitingForceHeading is set by setHeading() if this.relativeAttitude does not exist
|
|
108
|
-
* At this moment, this.relativeAttitude is defined, so we can call setHeading again
|
|
109
|
-
*/
|
|
110
|
-
this.setHeading(this.waitingForceHeading);
|
|
111
|
-
delete this.waitingForceHeading;
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// if (previousAttitude && this.absoluteAttitude) {
|
|
116
|
-
// /**
|
|
117
|
-
// * Sometimes ArCore has "orientation jumps" around z-axis.
|
|
118
|
-
// * Here we try to detect and remove them.
|
|
119
|
-
// */
|
|
120
|
-
// const dist = Quaternion.distance(event.data.quaternion, previousAttitude.quaternion);
|
|
121
|
-
// if (typeof this.angularRate !== 'undefined') {
|
|
122
|
-
// const velocity = Vector3.norm(this.angularRate);
|
|
123
|
-
// if (dist > deg2rad(10) && velocity < deg2rad(4)) {
|
|
124
|
-
// this.setHeading(this.absoluteAttitude.heading);
|
|
125
|
-
// }
|
|
126
|
-
// }
|
|
127
|
-
// }
|
|
128
|
-
|
|
129
|
-
if (this.offsetQuat) {
|
|
130
|
-
const absoluteQuaternion = Quaternion.multiply(this.offsetQuat, this.relativeAttitude.quaternion);
|
|
131
|
-
this.absoluteAttitude = new Attitude(absoluteQuaternion);
|
|
132
|
-
eventsForNotification.push(this.createEvent(EventType.AbsoluteAttitude, this.absoluteAttitude, event.timestamp));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (event.dataType === EventType.RelativePosition) {
|
|
137
|
-
|
|
138
|
-
if (this.oldRelativePos && this.offsetAngle
|
|
139
|
-
&& !ArCoreAbsoluteProvider.positionEquals(this.oldRelativePos, event.data)) {
|
|
140
|
-
|
|
141
|
-
const diffPos = Vector3.subtract(event.data, this.oldRelativePos);
|
|
142
|
-
const dist = Math.sqrt(diffPos[0] ** 2 + diffPos[2] ** 2);
|
|
143
|
-
const bearing = Math.atan2(diffPos[0], -diffPos[2]) - this.offsetAngle;
|
|
144
|
-
this.position = this.position.destinationPoint(dist, bearing, diffPos[1]);
|
|
145
|
-
|
|
146
|
-
if (this.absoluteAttitude) {
|
|
147
|
-
this.position.bearing = this.absoluteAttitude.heading;
|
|
148
|
-
this.updatePositionWithMapMatching();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
eventsForNotification.push(this.createEvent(EventType.AbsolutePosition, this.position, event.timestamp));
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
this.oldRelativePos = event.data;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (event.dataType === EventType.Barcode) {
|
|
158
|
-
eventsForNotification.push(event);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (eventsForNotification.length !== 0) {
|
|
162
|
-
this.notify(...eventsForNotification);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
static positionEquals(pos1, pos2) {
|
|
168
|
-
return pos1[0] === pos2[0] && pos1[1] === pos2[1] && pos1[2] === pos2[2];
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
onImuEvent = events => {
|
|
172
|
-
this.angularRate = events[0].data;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
setHeading(heading) {
|
|
176
|
-
|
|
177
|
-
if (!this.relativeAttitude) {
|
|
178
|
-
this.waitingForceHeading = heading;
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
this.offsetAngle = this.relativeAttitude.heading - heading;
|
|
183
|
-
this.offsetQuat = Quaternion.fromAxisAngle([0, 0, 1], this.offsetAngle);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
setPosition(position) {
|
|
187
|
-
this.position = WGS84UserPosition.fromWGS84(position);
|
|
188
|
-
this.position.provider = this.constructor.name;
|
|
189
|
-
this.notify(this.createEvent(EventType.AbsolutePosition, this.position));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @override
|
|
194
|
-
*/
|
|
195
|
-
static get useCameraNatively() {
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* MapMatching
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
enableMapMatching(network, maxDistance, maxAngleBearing) {
|
|
205
|
-
super.enableMapMatching(
|
|
206
|
-
network,
|
|
207
|
-
maxDistance || MM_ARCORE_DIST,
|
|
208
|
-
maxAngleBearing || PdrProvider.MM_PDR_ANGLE
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
updatePositionWithMapMatching() {
|
|
213
|
-
if (!this.mapMatching) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const projection = this.mapMatching.getProjection(this.position, true, true);
|
|
217
|
-
if (projection) {
|
|
218
|
-
if (projection.distanceFromNearestElement > 1) {
|
|
219
|
-
this.position.lat = projection.projection.lat;
|
|
220
|
-
this.position.lng = projection.projection.lng;
|
|
221
|
-
}
|
|
222
|
-
this.position.level = projection.projection.level;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
enableBarcodeScanner() {
|
|
227
|
-
this.arCoreProvider.enableBarcodeScanner();
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
disableBarcodeScanner() {
|
|
231
|
-
this.arCoreProvider.disableBarcodeScanner();
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export default ArCoreAbsoluteProvider;
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-bitwise */
|
|
2
|
-
import { Attitude } from '@wemap/geo';
|
|
3
|
-
|
|
4
|
-
import Provider from '../Provider';
|
|
5
|
-
import EventType from '../../events/EventType';
|
|
6
|
-
import MissingArCoreError from '../../errors/MissingArCoreError';
|
|
7
|
-
import MissingNativeInterfaceError from '../../errors/MissingNativeInterfaceError';
|
|
8
|
-
import Availability from '../../events/Availability';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const Payload = {
|
|
12
|
-
Pose: {
|
|
13
|
-
ref: 2 ** 0,
|
|
14
|
-
size: 7
|
|
15
|
-
},
|
|
16
|
-
Barcode: {
|
|
17
|
-
ref: 2 ** 1,
|
|
18
|
-
size: 1
|
|
19
|
-
},
|
|
20
|
-
ProjMat: {
|
|
21
|
-
ref: 2 ** 2,
|
|
22
|
-
size: 16
|
|
23
|
-
},
|
|
24
|
-
ImageRef: {
|
|
25
|
-
ref: 2 ** 3,
|
|
26
|
-
size: 1
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Pose provider is the provider used by the PositioningHandler. It uses the best fusion
|
|
32
|
-
* of what he can and provides an AbsoluteAttitude and an AbsolutePosition as an output.
|
|
33
|
-
*/
|
|
34
|
-
class ArCoreProvider extends Provider {
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @override
|
|
38
|
-
*/
|
|
39
|
-
static get name() {
|
|
40
|
-
return 'ArCore';
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @override
|
|
45
|
-
*/
|
|
46
|
-
static get displayName() {
|
|
47
|
-
return 'ArCore provider';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @override
|
|
52
|
-
*/
|
|
53
|
-
static get eventsType() {
|
|
54
|
-
return [EventType.RelativeAttitude, EventType.RelativePosition, EventType.Barcode];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Return the list of required providers
|
|
59
|
-
*/
|
|
60
|
-
static getRequiredProviders() {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @override
|
|
66
|
-
*/
|
|
67
|
-
startInternal() {
|
|
68
|
-
if (ArCoreProvider.nativeProvider) {
|
|
69
|
-
ArCoreProvider.nativeProvider.start();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
this.pullDataLoop();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @override
|
|
77
|
-
*/
|
|
78
|
-
stopInternal() {
|
|
79
|
-
if (ArCoreProvider.nativeProvider) {
|
|
80
|
-
ArCoreProvider.nativeProvider.stop();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
pullDataLoop = () => {
|
|
85
|
-
|
|
86
|
-
if (this.state !== Provider.State.STARTED) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const payload = JSON.parse(ArCoreProvider.nativeProvider.getInfo());
|
|
91
|
-
if (payload.length > 1) {
|
|
92
|
-
this.parsePayload(payload);
|
|
93
|
-
}
|
|
94
|
-
requestAnimationFrame(this.pullDataLoop);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
parsePayload(payload) {
|
|
98
|
-
|
|
99
|
-
const ref = payload[0];
|
|
100
|
-
let bufferIndex = 1;
|
|
101
|
-
|
|
102
|
-
const events = [];
|
|
103
|
-
|
|
104
|
-
if (ref & Payload.Pose.ref) {
|
|
105
|
-
const attitude = new Attitude(payload.slice(bufferIndex, bufferIndex + 4));
|
|
106
|
-
const position = payload.slice(bufferIndex + 4, bufferIndex + 7);
|
|
107
|
-
events.push(this.createEvent(EventType.RelativeAttitude, attitude));
|
|
108
|
-
events.push(this.createEvent(EventType.RelativePosition, position));
|
|
109
|
-
bufferIndex += Payload.Pose.size;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (ref & Payload.Barcode.ref) {
|
|
113
|
-
events.push(this.createEvent(EventType.Barcode, payload[bufferIndex]));
|
|
114
|
-
bufferIndex += Payload.Barcode.size;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (ref & Payload.ProjMat.ref) {
|
|
118
|
-
const projMatrix = payload.slice(bufferIndex, bufferIndex + Payload.ProjMat.size);
|
|
119
|
-
events.push(this.createEvent(EventType.ProjectionMatrix, projMatrix));
|
|
120
|
-
bufferIndex += Payload.ProjMat.size;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (events.length !== 0) {
|
|
124
|
-
this.notify(...events);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
static get nativeProvider() {
|
|
130
|
-
|
|
131
|
-
if (!this._nativeProvider) {
|
|
132
|
-
|
|
133
|
-
if (!this.nativeInterface) {
|
|
134
|
-
throw new MissingNativeInterfaceError();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
this._nativeProvider = this.nativeInterface.getArCoreProvider();
|
|
138
|
-
if (!this._nativeProvider) {
|
|
139
|
-
throw new MissingArCoreError();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return this._nativeProvider;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* @override
|
|
149
|
-
*/
|
|
150
|
-
static checkAvailability(options) {
|
|
151
|
-
|
|
152
|
-
const supAvailability = super.checkAvailability(options);
|
|
153
|
-
if (!supAvailability.isSupported) {
|
|
154
|
-
return supAvailability;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
try {
|
|
158
|
-
const nativeProvider = this.nativeProvider;
|
|
159
|
-
|
|
160
|
-
if (!nativeProvider.checkAvailability()) {
|
|
161
|
-
return Availability.no(new MissingArCoreError());
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
} catch (e) {
|
|
165
|
-
return Availability.no(e);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return Availability.yes();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
enableBarcodeScanner() {
|
|
172
|
-
if (ArCoreProvider.nativeProvider) {
|
|
173
|
-
ArCoreProvider.nativeProvider.enableBarcodeScanner();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
disableBarcodeScanner() {
|
|
178
|
-
if (ArCoreProvider.nativeProvider) {
|
|
179
|
-
ArCoreProvider.nativeProvider.disableBarcodeScanner();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @override
|
|
185
|
-
*/
|
|
186
|
-
static get useCameraNatively() {
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export default ArCoreProvider;
|