@wemap/positioning 2.7.2 → 2.7.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/package.json CHANGED
@@ -71,6 +71,6 @@
71
71
  "lint": "eslint --ext .js,.jsx --quiet src",
72
72
  "test": "mocha -r esm \"src/**/*.spec.js\""
73
73
  },
74
- "version": "2.7.2",
75
- "gitHead": "ec928b7890e3c37be2a32b1ba1c108aeba9e15b7"
74
+ "version": "2.7.3",
75
+ "gitHead": "e4f4ccdfdb5a2aaa1f8d4ab2c062f1ff3a740a43"
76
76
  }
@@ -10,6 +10,8 @@ import ArCoreAbsoluteProvider from './providers/pose/ArCoreAbsoluteProvider';
10
10
  import GnssWifiProvider from './providers/position/GnssWifiProvider';
11
11
  import NoProviderFoundError from './errors/NoProviderFoundError';
12
12
  import Availability from './events/Availability';
13
+ import RelativeAttitudeProvider from './providers/attitude/RelativeAttitudeProvider';
14
+ import AbsoluteAttitudeProvider from './providers/attitude/AbsoluteAttitudeProvider';
13
15
 
14
16
  /**
15
17
  * @private
@@ -113,6 +115,30 @@ class PositioningHandler {
113
115
  throw availability.reason;
114
116
  }
115
117
 
118
+ const wantAbsoluteAttitude = eventsType.length === 1
119
+ && eventsType.includes(EventType.AbsoluteAttitude);
120
+
121
+ if (wantAbsoluteAttitude) {
122
+ if (canUse(AbsoluteAttitudeProvider)) {
123
+ return AbsoluteAttitudeProvider;
124
+ }
125
+ throw availability.reason;
126
+ }
127
+
128
+
129
+ const wantRelativeAttitude = eventsType.length === 1
130
+ && eventsType.includes(EventType.RelativeAttitude);
131
+
132
+ if (wantRelativeAttitude) {
133
+ if (!options.waitInputHeading) {
134
+ throw new NoProviderFoundError();
135
+ }
136
+ if (canUse(RelativeAttitudeProvider)) {
137
+ return RelativeAttitudeProvider;
138
+ }
139
+ throw availability.reason;
140
+ }
141
+
116
142
  throw new NoProviderFoundError();
117
143
  }
118
144
 
@@ -13,6 +13,9 @@ import ArCoreProvider from './providers/pose/ArCoreProvider';
13
13
  import { ProvidersName } from './providers/ProvidersList';
14
14
  import AskImuOnDesktopError from './errors/AskImuOnDesktopError';
15
15
  import ContainsIgnoredProviderError from './errors/ContainsIgnoredProviderError';
16
+ import AbsoluteAttitudeProvider from './providers/attitude/AbsoluteAttitudeProvider';
17
+ import NoProviderFoundError from './errors/NoProviderFoundError';
18
+ import RelativeAttitudeProvider from './providers/attitude/RelativeAttitudeProvider';
16
19
 
17
20
  const expect = chai.expect;
18
21
 
@@ -238,4 +241,51 @@ describe('PositioningHandler#findProvider', () => {
238
241
  ).to.throw(ContainsIgnoredProviderError);
239
242
  });
240
243
 
244
+ it('Absolute Attitude Desktop', () => {
245
+ config(CHROME_DESKTOP_USER_AGENT);
246
+ expect(
247
+ () => PositioningHandler.findProvider([EventType.AbsoluteAttitude])
248
+ ).to.throw(AskImuOnDesktopError);
249
+ });
250
+
251
+
252
+ it('Absolute Attitude Web', () => {
253
+ config(CHROME_ANDROID_USER_AGENT);
254
+ const provider = PositioningHandler.findProvider([EventType.AbsoluteAttitude]);
255
+ expect(provider).to.be.equals(AbsoluteAttitudeProvider);
256
+ });
257
+
258
+
259
+ it('Relative Attitude Desktop without waitInputHeading', () => {
260
+ config(CHROME_DESKTOP_USER_AGENT);
261
+ expect(
262
+ () => PositioningHandler.findProvider([EventType.RelativeAttitude])
263
+ ).to.throw(NoProviderFoundError);
264
+ });
265
+
266
+ it('Relative Attitude Desktop', () => {
267
+ config(CHROME_DESKTOP_USER_AGENT);
268
+ expect(() => PositioningHandler.findProvider(
269
+ [EventType.RelativeAttitude],
270
+ { waitInputHeading: true })
271
+ ).to.throw(AskImuOnDesktopError);
272
+ });
273
+
274
+ it('Relative Attitude Web without waitInputHeading', () => {
275
+ config(CHROME_ANDROID_USER_AGENT);
276
+ expect(
277
+ () => PositioningHandler.findProvider([EventType.RelativeAttitude])
278
+ ).to.throw(NoProviderFoundError);
279
+ });
280
+
281
+
282
+ it('Relative Attitude Web', () => {
283
+ config(CHROME_ANDROID_USER_AGENT);
284
+ const provider = PositioningHandler.findProvider(
285
+ [EventType.RelativeAttitude],
286
+ { waitInputHeading: true }
287
+ );
288
+ expect(provider).to.be.equals(RelativeAttitudeProvider);
289
+ });
290
+
241
291
  });