@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
package/package.json
CHANGED
|
@@ -7,10 +7,9 @@ import PositioningOptions from './PositioningOptions';
|
|
|
7
7
|
import InclinationProvider from './providers/others/InclinationProvider';
|
|
8
8
|
import Logger from '@wemap/logger';
|
|
9
9
|
import ArCoreAbsoluteProvider from './providers/pose/ArCoreAbsoluteProvider';
|
|
10
|
-
import ArCoreProvider from './providers/pose/ArCoreProvider';
|
|
11
10
|
import GnssWifiProvider from './providers/position/GnssWifiProvider';
|
|
12
11
|
import NoProviderFoundError from './errors/NoProviderFoundError';
|
|
13
|
-
import
|
|
12
|
+
import Availability from './events/Availability';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* @private
|
|
@@ -39,17 +38,17 @@ class PositioningHandler {
|
|
|
39
38
|
|
|
40
39
|
this.options = Object.assign({}, PositioningOptions, options);
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
try {
|
|
42
|
+
const providerClass = PositioningHandler.findProvider(eventsType, this.options);
|
|
43
|
+
const provider = Reflect.construct(providerClass, [onEvent, onError, this.options]);
|
|
44
|
+
this.providerInstances[provider.id] = provider;
|
|
45
|
+
provider.start();
|
|
46
|
+
|
|
47
|
+
return provider.id;
|
|
48
|
+
} catch (e) {
|
|
49
|
+
onError(e);
|
|
45
50
|
return null;
|
|
46
51
|
}
|
|
47
|
-
const provider = Reflect.construct(providerClass, [onEvent, onError, this.options]);
|
|
48
|
-
this.providerInstances[provider.id] = provider;
|
|
49
|
-
provider.start();
|
|
50
|
-
|
|
51
|
-
return provider.id;
|
|
52
|
-
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
/**
|
|
@@ -59,14 +58,10 @@ class PositioningHandler {
|
|
|
59
58
|
|
|
60
59
|
const options = Object.assign({}, PositioningOptions, _options);
|
|
61
60
|
|
|
62
|
-
let
|
|
63
|
-
const canUse = (provider
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
errors = provider.checkAvailabilityErrors();
|
|
69
|
-
return errors.length === 0;
|
|
61
|
+
let availability = Availability.yes();
|
|
62
|
+
const canUse = (provider) => {
|
|
63
|
+
availability = provider.checkAvailability(options);
|
|
64
|
+
return availability.isSupported;
|
|
70
65
|
};
|
|
71
66
|
|
|
72
67
|
const wantInclination = eventsType.length === 1
|
|
@@ -76,10 +71,7 @@ class PositioningHandler {
|
|
|
76
71
|
if (canUse(InclinationProvider)) {
|
|
77
72
|
return InclinationProvider;
|
|
78
73
|
}
|
|
79
|
-
|
|
80
|
-
return errors;
|
|
81
|
-
}
|
|
82
|
-
return [new ProviderError(null, EventType.Inclination, new NoProviderFoundError())];
|
|
74
|
+
throw availability.reason;
|
|
83
75
|
}
|
|
84
76
|
|
|
85
77
|
const wantPoseProvider = [EventType.AbsolutePosition, EventType.AbsoluteAttitude]
|
|
@@ -88,20 +80,17 @@ class PositioningHandler {
|
|
|
88
80
|
if (wantPoseProvider) {
|
|
89
81
|
|
|
90
82
|
if (options.waitInputPosition) {
|
|
91
|
-
if (canUse(ArCoreAbsoluteProvider
|
|
83
|
+
if (canUse(ArCoreAbsoluteProvider)) {
|
|
92
84
|
return ArCoreAbsoluteProvider;
|
|
93
85
|
}
|
|
94
86
|
if (canUse(PdrProvider)) {
|
|
95
87
|
return PdrProvider;
|
|
96
88
|
}
|
|
97
89
|
|
|
98
|
-
|
|
99
|
-
new ProviderError(null, EventType.AbsoluteAttitude, new NoProviderFoundError()),
|
|
100
|
-
new ProviderError(null, EventType.AbsolutePosition, new NoProviderFoundError())
|
|
101
|
-
];
|
|
90
|
+
throw availability.reason;
|
|
102
91
|
}
|
|
103
92
|
|
|
104
|
-
if (canUse(GnssWifiPdrProvider
|
|
93
|
+
if (canUse(GnssWifiPdrProvider)) {
|
|
105
94
|
return GnssWifiPdrProvider;
|
|
106
95
|
}
|
|
107
96
|
|
|
@@ -109,26 +98,18 @@ class PositioningHandler {
|
|
|
109
98
|
return PoseProvider;
|
|
110
99
|
}
|
|
111
100
|
|
|
112
|
-
if (options.optionalEvents.includes(EventType.AbsoluteAttitude)
|
|
113
|
-
|
|
114
|
-
return GnssWifiProvider;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (errors.length !== 0) {
|
|
118
|
-
return errors;
|
|
101
|
+
if (!options.optionalEvents.includes(EventType.AbsoluteAttitude)) {
|
|
102
|
+
throw availability.reason;
|
|
119
103
|
}
|
|
120
104
|
|
|
121
|
-
if (
|
|
122
|
-
return
|
|
105
|
+
if (canUse(GnssWifiProvider)) {
|
|
106
|
+
return GnssWifiProvider;
|
|
123
107
|
}
|
|
124
108
|
|
|
125
|
-
|
|
126
|
-
new ProviderError(null, EventType.AbsoluteAttitude, new NoProviderFoundError()),
|
|
127
|
-
new ProviderError(null, EventType.AbsolutePosition, new NoProviderFoundError())
|
|
128
|
-
];
|
|
109
|
+
throw availability.reason;
|
|
129
110
|
}
|
|
130
111
|
|
|
131
|
-
|
|
112
|
+
throw new NoProviderFoundError();
|
|
132
113
|
}
|
|
133
114
|
|
|
134
115
|
/**
|
|
@@ -149,6 +130,7 @@ class PositioningHandler {
|
|
|
149
130
|
}
|
|
150
131
|
if (!provider.setPosition) {
|
|
151
132
|
Logger.warn('Cannot set position to ' + provider.constructor.name);
|
|
133
|
+
return;
|
|
152
134
|
}
|
|
153
135
|
provider.setPosition(position);
|
|
154
136
|
}
|
|
@@ -163,6 +145,7 @@ class PositioningHandler {
|
|
|
163
145
|
}
|
|
164
146
|
if (!provider.setHeading) {
|
|
165
147
|
Logger.warn('Cannot set heading to ' + provider.constructor.name);
|
|
148
|
+
return;
|
|
166
149
|
}
|
|
167
150
|
provider.setHeading(heading);
|
|
168
151
|
}
|
|
@@ -177,10 +160,42 @@ class PositioningHandler {
|
|
|
177
160
|
}
|
|
178
161
|
if (!provider.setItinerary) {
|
|
179
162
|
Logger.warn('Cannot set itinerary to ' + provider.constructor.name);
|
|
163
|
+
return;
|
|
180
164
|
}
|
|
181
165
|
provider.setItinerary(itinerary);
|
|
182
166
|
}
|
|
183
167
|
|
|
168
|
+
/**
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
setNetwork(id, network) {
|
|
172
|
+
const provider = this.providerInstances[id];
|
|
173
|
+
if (!provider) {
|
|
174
|
+
throw new Error('Unknown provider');
|
|
175
|
+
}
|
|
176
|
+
if (!provider.setNetwork) {
|
|
177
|
+
Logger.warn('Cannot set network to ' + provider.constructor.name);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
provider.setNetwork(network);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
getItineraryInfo(id) {
|
|
188
|
+
const provider = this.providerInstances[id];
|
|
189
|
+
if (!provider) {
|
|
190
|
+
throw new Error('Unknown provider');
|
|
191
|
+
}
|
|
192
|
+
if (!provider.getItineraryInfo) {
|
|
193
|
+
Logger.warn('Cannot getItineraryInfo from ' + provider.constructor.name);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
provider.getItineraryInfo();
|
|
197
|
+
}
|
|
198
|
+
|
|
184
199
|
}
|
|
185
200
|
|
|
186
201
|
export default PositioningHandler;
|
|
@@ -10,8 +10,9 @@ import PdrProvider from './providers/pose/pdr/PdrProvider';
|
|
|
10
10
|
import ArCoreAbsoluteProvider from './providers/pose/ArCoreAbsoluteProvider';
|
|
11
11
|
import GnssWifiProvider from './providers/position/GnssWifiProvider';
|
|
12
12
|
import ArCoreProvider from './providers/pose/ArCoreProvider';
|
|
13
|
-
import ProviderError from './events/ProviderError';
|
|
14
13
|
import { ProvidersName } from './providers/ProvidersList';
|
|
14
|
+
import AskImuOnDesktopError from './errors/AskImuOnDesktopError';
|
|
15
|
+
import ContainsIgnoredProviderError from './errors/ContainsIgnoredProviderError';
|
|
15
16
|
|
|
16
17
|
const expect = chai.expect;
|
|
17
18
|
|
|
@@ -30,7 +31,7 @@ function fakeNativeInterface(arcore = true) {
|
|
|
30
31
|
|
|
31
32
|
function fakeGeolocation() {
|
|
32
33
|
navigator.__defineGetter__('geolocation', () => {
|
|
33
|
-
return {watchPosition: () => {}};
|
|
34
|
+
return { watchPosition: () => { } };
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -54,8 +55,10 @@ describe('PositioningHandler#findProvider', () => {
|
|
|
54
55
|
|
|
55
56
|
it('Inclination Desktop', () => {
|
|
56
57
|
config(CHROME_DESKTOP_USER_AGENT);
|
|
57
|
-
|
|
58
|
-
expect(
|
|
58
|
+
|
|
59
|
+
expect(
|
|
60
|
+
() => PositioningHandler.findProvider([EventType.Inclination])
|
|
61
|
+
).to.throw(AskImuOnDesktopError);
|
|
59
62
|
});
|
|
60
63
|
|
|
61
64
|
it('Inclination Mobile', () => {
|
|
@@ -66,32 +69,36 @@ describe('PositioningHandler#findProvider', () => {
|
|
|
66
69
|
|
|
67
70
|
it('Pose Desktop', () => {
|
|
68
71
|
config(CHROME_DESKTOP_USER_AGENT);
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
expect(
|
|
73
|
+
() => PositioningHandler.findProvider([EventType.AbsolutePosition, EventType.AbsoluteAttitude])
|
|
74
|
+
).to.throw(AskImuOnDesktopError);
|
|
71
75
|
});
|
|
72
76
|
|
|
73
77
|
it('Pose without PDR Desktop', () => {
|
|
74
78
|
config(CHROME_DESKTOP_USER_AGENT);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
expect(
|
|
80
|
+
() => PositioningHandler.findProvider(
|
|
81
|
+
[EventType.AbsolutePosition, EventType.AbsoluteAttitude],
|
|
82
|
+
{ ignoreProviders: [PdrProvider] }
|
|
83
|
+
)
|
|
84
|
+
).to.throw(AskImuOnDesktopError);
|
|
80
85
|
});
|
|
81
86
|
|
|
82
87
|
it('Pose without ArCore Desktop', () => {
|
|
83
88
|
config(CHROME_DESKTOP_USER_AGENT);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
expect(
|
|
90
|
+
() => PositioningHandler.findProvider(
|
|
91
|
+
[EventType.AbsolutePosition, EventType.AbsoluteAttitude],
|
|
92
|
+
{ ignoreProviders: [ArCoreProvider] }
|
|
93
|
+
)
|
|
94
|
+
).to.throw(AskImuOnDesktopError);
|
|
89
95
|
});
|
|
90
96
|
|
|
91
97
|
it('Pose with optional attitude Desktop', () => {
|
|
92
98
|
config(CHROME_DESKTOP_USER_AGENT);
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
expect(
|
|
100
|
+
() => PositioningHandler.findProvider([EventType.AbsolutePosition, EventType.AbsoluteAttitude])
|
|
101
|
+
).to.throw(AskImuOnDesktopError);
|
|
95
102
|
});
|
|
96
103
|
|
|
97
104
|
it('Pose with optional attitude without PDR Desktop', () => {
|
|
@@ -195,15 +202,15 @@ describe('PositioningHandler#findProvider', () => {
|
|
|
195
202
|
|
|
196
203
|
it('Pose with waitInputPosition without PDR Mobile Web', () => {
|
|
197
204
|
config(CHROME_ANDROID_USER_AGENT, false);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
expect(
|
|
206
|
+
() => PositioningHandler.findProvider(
|
|
207
|
+
[EventType.AbsolutePosition, EventType.AbsoluteAttitude],
|
|
208
|
+
{
|
|
209
|
+
waitInputPosition: true,
|
|
210
|
+
ignoreProviders: [ProvidersName.Pdr]
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
).to.throw(ContainsIgnoredProviderError);
|
|
207
214
|
});
|
|
208
215
|
|
|
209
216
|
it('Pose with waitInputPosition without ArCore Mobile Native', () => {
|
|
@@ -218,4 +225,17 @@ describe('PositioningHandler#findProvider', () => {
|
|
|
218
225
|
expect(provider).to.be.equals(PdrProvider);
|
|
219
226
|
});
|
|
220
227
|
|
|
228
|
+
it('Pose without GnssWifi Desktop', () => {
|
|
229
|
+
config(CHROME_DESKTOP_USER_AGENT, false);
|
|
230
|
+
expect(
|
|
231
|
+
() => PositioningHandler.findProvider(
|
|
232
|
+
[EventType.AbsolutePosition, EventType.AbsoluteAttitude],
|
|
233
|
+
{
|
|
234
|
+
ignoreProviders: [ProvidersName.GnssWifi],
|
|
235
|
+
optionalEvents: [EventType.AbsoluteAttitude]
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
).to.throw(ContainsIgnoredProviderError);
|
|
239
|
+
});
|
|
240
|
+
|
|
221
241
|
});
|
|
@@ -50,12 +50,8 @@ class AbsoluteAttitudeComponent extends React.Component {
|
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
onError =
|
|
54
|
-
|
|
55
|
-
if (event.dataType === EventType.AbsoluteAttitude) {
|
|
56
|
-
this.setState({ attitudeBrowser: event.error });
|
|
57
|
-
}
|
|
58
|
-
});
|
|
53
|
+
onError = error => {
|
|
54
|
+
this.setState({ attitudeBrowser: error });
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
render() {
|
|
@@ -61,18 +61,11 @@ class ArCoreAbsoluteComponent extends React.Component {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
onError =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
newState.position = event.error;
|
|
69
|
-
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
70
|
-
newState.attitude = event.error;
|
|
71
|
-
}
|
|
64
|
+
onError = error => {
|
|
65
|
+
this.setState({
|
|
66
|
+
position: error,
|
|
67
|
+
attitude: error
|
|
72
68
|
});
|
|
73
|
-
if (!isEmpty(newState)) {
|
|
74
|
-
this.setState(newState);
|
|
75
|
-
}
|
|
76
69
|
}
|
|
77
70
|
|
|
78
71
|
render() {
|
|
@@ -40,18 +40,11 @@ class ArCoreComponent extends React.Component {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
onError =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
newState.position = event.error;
|
|
48
|
-
} else if (event.dataType === EventType.RelativeAttitude) {
|
|
49
|
-
newState.attitude = event.error;
|
|
50
|
-
}
|
|
43
|
+
onError = error => {
|
|
44
|
+
this.setState({
|
|
45
|
+
position: error,
|
|
46
|
+
attitude: error
|
|
51
47
|
});
|
|
52
|
-
if (!isEmpty(newState)) {
|
|
53
|
-
this.setState(newState);
|
|
54
|
-
}
|
|
55
48
|
}
|
|
56
49
|
|
|
57
50
|
render() {
|
|
@@ -35,12 +35,8 @@ class GnssWifiComponent extends React.Component {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
onError =
|
|
39
|
-
|
|
40
|
-
if (event.dataType === EventType.AbsolutePosition) {
|
|
41
|
-
this.setState({ position: event.error });
|
|
42
|
-
}
|
|
43
|
-
});
|
|
38
|
+
onError = error => {
|
|
39
|
+
this.setState({ position: error });
|
|
44
40
|
}
|
|
45
41
|
|
|
46
42
|
render() {
|
|
@@ -56,18 +56,11 @@ class GnssWifiPdrComponent extends React.Component {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
onError =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
newState.position = event.error;
|
|
64
|
-
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
65
|
-
newState.attitude = event.error;
|
|
66
|
-
}
|
|
59
|
+
onError = error => {
|
|
60
|
+
this.setState({
|
|
61
|
+
position: error,
|
|
62
|
+
attitude: error
|
|
67
63
|
});
|
|
68
|
-
if (!isEmpty(newState)) {
|
|
69
|
-
this.setState(newState);
|
|
70
|
-
}
|
|
71
64
|
}
|
|
72
65
|
|
|
73
66
|
render() {
|
|
@@ -42,19 +42,11 @@ class ImuComponent extends React.Component {
|
|
|
42
42
|
this.setState(newState);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
onError =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (event.dataType === EventType.Acceleration) {
|
|
50
|
-
newState.acc = event.error;
|
|
51
|
-
}
|
|
52
|
-
if (event.dataType === EventType.AngularRate) {
|
|
53
|
-
newState.gyr = event.error;
|
|
54
|
-
}
|
|
45
|
+
onError = error => {
|
|
46
|
+
this.setState({
|
|
47
|
+
acc: error,
|
|
48
|
+
gyr: error
|
|
55
49
|
});
|
|
56
|
-
|
|
57
|
-
this.setState(newState);
|
|
58
50
|
}
|
|
59
51
|
|
|
60
52
|
render() {
|
|
@@ -30,12 +30,8 @@ class InclinationComponent extends React.Component {
|
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
onError =
|
|
34
|
-
|
|
35
|
-
if (event.dataType === EventType.Inclination) {
|
|
36
|
-
this.setState({ inclination: event.error });
|
|
37
|
-
}
|
|
38
|
-
});
|
|
33
|
+
onError = error => {
|
|
34
|
+
this.setState({ inclination: error });
|
|
39
35
|
}
|
|
40
36
|
|
|
41
37
|
render() {
|
|
@@ -27,13 +27,13 @@ class PdrComponent extends React.Component {
|
|
|
27
27
|
this.state = { position: null };
|
|
28
28
|
|
|
29
29
|
this.pdrProvider = new PdrProvider(this.onEvent, this.onError);
|
|
30
|
+
this.pdrProvider.enableMapMatching(ITINERARY);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
componentDidMount() {
|
|
34
35
|
this.pdrProvider.setPosition(INITIAL_POSITION);
|
|
35
36
|
this.pdrProvider.setHeading(INITIAL_HEADING);
|
|
36
|
-
this.pdrProvider.enableMapMatching(ITINERARY);
|
|
37
37
|
this.pdrProvider.start();
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -59,18 +59,11 @@ class PdrComponent extends React.Component {
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
onError =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
newState.position = event.error;
|
|
67
|
-
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
68
|
-
newState.attitude = event.error;
|
|
69
|
-
}
|
|
62
|
+
onError = error => {
|
|
63
|
+
this.setState({
|
|
64
|
+
position: error,
|
|
65
|
+
attitude: error
|
|
70
66
|
});
|
|
71
|
-
if (!isEmpty(newState)) {
|
|
72
|
-
this.setState(newState);
|
|
73
|
-
}
|
|
74
67
|
}
|
|
75
68
|
|
|
76
69
|
render() {
|
|
@@ -45,18 +45,11 @@ class PoseComponent extends React.Component {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
onError =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
newState.position = event.error;
|
|
53
|
-
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
54
|
-
newState.attitude = event.error;
|
|
55
|
-
}
|
|
48
|
+
onError = error => {
|
|
49
|
+
this.setState({
|
|
50
|
+
position: error,
|
|
51
|
+
attitude: error
|
|
56
52
|
});
|
|
57
|
-
if (!isEmpty(newState)) {
|
|
58
|
-
this.setState(newState);
|
|
59
|
-
}
|
|
60
53
|
}
|
|
61
54
|
|
|
62
55
|
render() {
|
|
@@ -24,7 +24,7 @@ class PositioningInclinationComponent extends React.Component {
|
|
|
24
24
|
this.id = this.props.positioningHandler.start(
|
|
25
25
|
[EventType.Inclination],
|
|
26
26
|
this.onEvents,
|
|
27
|
-
this.
|
|
27
|
+
this.onError
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -49,14 +49,11 @@ class PositioningInclinationComponent extends React.Component {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
newState.inclination = event.error;
|
|
57
|
-
}
|
|
52
|
+
onError = error => {
|
|
53
|
+
this.setState({
|
|
54
|
+
errorer: true,
|
|
55
|
+
inclination: error
|
|
58
56
|
});
|
|
59
|
-
this.setState(newState);
|
|
60
57
|
}
|
|
61
58
|
|
|
62
59
|
render() {
|
|
@@ -39,7 +39,7 @@ class PositioningPoseComponent extends React.Component {
|
|
|
39
39
|
this.id = this.props.positioningHandler.start(
|
|
40
40
|
[EventType.AbsolutePosition, EventType.AbsoluteAttitude],
|
|
41
41
|
this.onEvents,
|
|
42
|
-
this.
|
|
42
|
+
this.onError,
|
|
43
43
|
{
|
|
44
44
|
waitInputPosition: true,
|
|
45
45
|
useMapMatching: true
|
|
@@ -50,11 +50,10 @@ class PositioningPoseComponent extends React.Component {
|
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}, 3000);
|
|
53
|
+
this.props.positioningHandler.setItinerary(this.id, ITINERARY);
|
|
54
|
+
this.props.positioningHandler.setNetwork(this.id, ITINERARY);
|
|
55
|
+
this.props.positioningHandler.setPosition(this.id, INITIAL_POSITION);
|
|
56
|
+
this.props.positioningHandler.setHeading(this.id, INITIAL_HEADING);
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
|
|
@@ -85,16 +84,12 @@ class PositioningPoseComponent extends React.Component {
|
|
|
85
84
|
}
|
|
86
85
|
};
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
} else if (event.dataType === EventType.AbsoluteAttitude) {
|
|
94
|
-
newState.attitude = event.error;
|
|
95
|
-
}
|
|
87
|
+
onError = error => {
|
|
88
|
+
this.setState({
|
|
89
|
+
position: error,
|
|
90
|
+
attitude: error,
|
|
91
|
+
errored: false
|
|
96
92
|
});
|
|
97
|
-
this.setState(newState);
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
render() {
|
|
@@ -15,6 +15,7 @@ class RelativeAttitudeComponent extends React.Component {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
this.relativeAttitudeProvider = new RelativeAttitudeProvider(this.onEvent, this.onError);
|
|
18
|
+
this.setOffset(0);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
componentDidMount() {
|
|
@@ -35,12 +36,8 @@ class RelativeAttitudeComponent extends React.Component {
|
|
|
35
36
|
});
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
onError =
|
|
39
|
-
|
|
40
|
-
if (event.dataType === EventType.RelativeAttitude) {
|
|
41
|
-
this.setState({ attitude: event.error });
|
|
42
|
-
}
|
|
43
|
-
});
|
|
39
|
+
onError = error => {
|
|
40
|
+
this.setState({ attitude: error });
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
onDeviceOrientationEventListener = (e) => this.setState({ deviceorientation: e });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class Availability {
|
|
2
|
+
|
|
3
|
+
isSupported = false;
|
|
4
|
+
reason = null;
|
|
5
|
+
|
|
6
|
+
static no(reason) {
|
|
7
|
+
const availability = new Availability();
|
|
8
|
+
availability.reason = reason;
|
|
9
|
+
availability.isSupported = false;
|
|
10
|
+
return availability;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static yes() {
|
|
14
|
+
const availability = new Availability();
|
|
15
|
+
availability.isSupported = true;
|
|
16
|
+
return availability;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static merge(...availabilities) {
|
|
20
|
+
for (let i = 0; i < availabilities.length; i++) {
|
|
21
|
+
const availability = availabilities[i];
|
|
22
|
+
if (!availability.isSupported) {
|
|
23
|
+
return availability;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return Availability.yes();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default Availability;
|