@wemap/positioning 2.7.5 → 2.7.6

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
@@ -8,18 +8,21 @@
8
8
  "Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
9
9
  ],
10
10
  "dependencies": {
11
- "@wemap/geo": "^2.7.4",
12
- "@wemap/graph": "^2.7.4",
11
+ "@wemap/geo": "^2.7.6",
12
+ "@wemap/graph": "^2.7.6",
13
13
  "@wemap/logger": "^2.7.0",
14
14
  "@wemap/maths": "^2.7.2",
15
- "@wemap/osm": "^2.7.5",
16
- "@wemap/utils": "^2.7.0",
15
+ "@wemap/osm": "^2.7.6",
16
+ "@wemap/utils": "^2.7.6",
17
17
  "geomagnetism": "^0.1.0",
18
18
  "lodash.isempty": "^4.4.0",
19
19
  "lodash.isnumber": "^3.0.3",
20
20
  "lodash.noop": "^3.0.1"
21
21
  },
22
22
  "description": "A package using different geoloc systems",
23
+ "devDependencies": {
24
+ "webpack-dev-server": "^3.9.0"
25
+ },
23
26
  "homepage": "https://github.com/wemap/wemap-modules-js#readme",
24
27
  "keywords": [
25
28
  "wemap",
@@ -43,6 +46,6 @@
43
46
  "lint": "eslint --ext .js,.jsx --quiet src",
44
47
  "test": "mocha -r esm \"src/**/*.spec.js\""
45
48
  },
46
- "version": "2.7.5",
47
- "gitHead": "5d60aa9ae789520ef5adeb34a8e4d3e5973ed0b2"
49
+ "version": "2.7.6",
50
+ "gitHead": "46ba2de050542dacd2b0fd9a0e07cb03f1aedbc7"
48
51
  }
@@ -1,5 +1,4 @@
1
1
  import chai from 'chai';
2
- import 'jsdom-global/register';
3
2
 
4
3
  import PositioningHandler from './PositioningHandler';
5
4
  import EventType from './events/EventType';
@@ -20,16 +19,18 @@ import RelativeAttitudeProvider from './providers/attitude/RelativeAttitudeProvi
20
19
  const expect = chai.expect;
21
20
 
22
21
  function fakeUserAgent(userAgent) {
23
- navigator.__defineGetter__('userAgent', () => userAgent);
22
+ global.navigator = { userAgent };
24
23
  }
25
24
 
26
25
  function fakeNativeInterface(arcore = true) {
27
26
  // We have to clear the cache here
28
27
  ArCoreProvider._nativeProvider = null;
29
28
 
30
- global.WemapProvidersAndroid = {getArCoreProvider: () => {
31
- return { checkAvailability: () => arcore };
32
- }};
29
+ global.WemapProvidersAndroid = {
30
+ getArCoreProvider: () => {
31
+ return { checkAvailability: () => arcore };
32
+ }
33
+ };
33
34
  }
34
35
 
35
36
  function fakeGeolocation() {
@@ -289,3 +290,5 @@ describe('PositioningHandler#findProvider', () => {
289
290
  });
290
291
 
291
292
  });
293
+
294
+ delete global.navigator;
@@ -12,6 +12,8 @@ import ImuProvider from '../others/ImuProvider';
12
12
  import MapMatchingProvider from '../others/MapMatchingProvider';
13
13
  import PdrProvider from './pdr/PdrProvider';
14
14
 
15
+ const MM_ARCORE_DIST = 5;
16
+
15
17
  /**
16
18
  * Pose provider is the provider used by the PositioningHandler. It uses the best fusion
17
19
  * of what he can and provides an AbsoluteAttitude and an AbsolutePosition as an output.
@@ -140,7 +142,7 @@ class ArCoreAbsoluteProvider extends MapMatchingProvider {
140
142
 
141
143
  if (this.absoluteAttitude) {
142
144
  this.position.bearing = this.absoluteAttitude.heading;
143
- this.updateLevel(this.position);
145
+ this.updatePositionWithMapMatching();
144
146
  }
145
147
 
146
148
  this.notify(this.createEvent(EventType.AbsolutePosition, this.position, event.timestamp));
@@ -191,17 +193,22 @@ class ArCoreAbsoluteProvider extends MapMatchingProvider {
191
193
  enableMapMatching(network, maxDistance, maxAngleBearing) {
192
194
  super.enableMapMatching(
193
195
  network,
194
- maxDistance || PdrProvider.MM_PDR_DIST,
196
+ maxDistance || MM_ARCORE_DIST,
195
197
  maxAngleBearing || PdrProvider.MM_PDR_ANGLE
196
198
  );
197
199
  }
198
200
 
199
- updateLevel(position) {
200
- if (this.mapMatching) {
201
- const projection = this.mapMatching.getProjection(position, true);
202
- if (projection) {
203
- position.level = projection.projection.level;
201
+ updatePositionWithMapMatching() {
202
+ if (!this.mapMatching) {
203
+ return;
204
+ }
205
+ const projection = this.mapMatching.getProjection(this.position, true, true);
206
+ if (projection) {
207
+ if (projection.distanceFromNearestElement > 1) {
208
+ this.position.lat = projection.projection.lat;
209
+ this.position.lng = projection.projection.lng;
204
210
  }
211
+ this.position.level = projection.projection.level;
205
212
  }
206
213
  }
207
214
  }