@wemap/providers 4.0.3 → 4.0.4
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/debug/src/Utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react'; // eslint-disable-line no-unused-vars
|
|
2
2
|
|
|
3
|
+
import { ItineraryInfo } from '@wemap/geo';
|
|
3
4
|
import { rad2deg } from '@wemap/maths';
|
|
4
5
|
import { OsrmUtils } from '@wemap/osm';
|
|
5
6
|
|
|
@@ -121,6 +122,9 @@ class Utils {
|
|
|
121
122
|
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
/**
|
|
126
|
+
* @param {ItineraryInfo} info
|
|
127
|
+
*/
|
|
124
128
|
static renderItineraryInfo(info) {
|
|
125
129
|
|
|
126
130
|
if (!info) {
|
package/package.json
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
"Guillaume Pannetier <guillaume.pannetier@getwemap.com>"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@wemap/geo": "^4.0.
|
|
11
|
+
"@wemap/geo": "^4.0.4",
|
|
12
12
|
"@wemap/geomagnetism": "^0.1.1",
|
|
13
13
|
"@wemap/logger": "^4.0.0",
|
|
14
|
-
"@wemap/map": "^4.0.
|
|
14
|
+
"@wemap/map": "^4.0.4",
|
|
15
15
|
"@wemap/maths": "^4.0.3",
|
|
16
16
|
"@wemap/utils": "^4.0.0"
|
|
17
17
|
},
|
|
18
18
|
"description": "A package using different geoloc systems",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@wemap/osm": "^4.0.
|
|
20
|
+
"@wemap/osm": "^4.0.4",
|
|
21
21
|
"mapbox-gl": "^1.11.1"
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/wemap/wemap-modules-js#readme",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"url": "git+https://github.com/wemap/wemap-modules-js.git"
|
|
40
40
|
},
|
|
41
41
|
"type": "module",
|
|
42
|
-
"version": "4.0.
|
|
43
|
-
"gitHead": "
|
|
42
|
+
"version": "4.0.4",
|
|
43
|
+
"gitHead": "8cb2140ad039f1e12b9834effb7cef467ade7549"
|
|
44
44
|
}
|
|
@@ -42,6 +42,9 @@ class MapMatchingHandler extends Provider {
|
|
|
42
42
|
/** @type {number} */
|
|
43
43
|
static MIN_STEPS_BETWEEN_ORIENTATION_MATCHING = 3;
|
|
44
44
|
|
|
45
|
+
/** @type {number} */
|
|
46
|
+
static MIN_STEPS_FOR_ORIENTATION_MATCHING = 5;
|
|
47
|
+
|
|
45
48
|
/** @type {MapMatching} */
|
|
46
49
|
_mapMatching;
|
|
47
50
|
|
|
@@ -262,6 +265,11 @@ class MapMatchingHandler extends Provider {
|
|
|
262
265
|
return;
|
|
263
266
|
}
|
|
264
267
|
|
|
268
|
+
// Detector to avoid big jumps in the wrong direction
|
|
269
|
+
if (thisWillBeAHugeJump && this._detectWrongBigJump(projectionWithBearing)) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
265
273
|
AbsolutePosition.notify(this.createEvent(
|
|
266
274
|
EventType.AbsolutePosition,
|
|
267
275
|
projectionWithBearing.projection,
|
|
@@ -298,6 +306,12 @@ class MapMatchingHandler extends Provider {
|
|
|
298
306
|
return;
|
|
299
307
|
}
|
|
300
308
|
|
|
309
|
+
// Detector to avoid big jumps in the wrong direction
|
|
310
|
+
if (thisWillBeAHugeJump && this._detectWrongBigJump(projection)) {
|
|
311
|
+
AbsolutePosition.notify(positionEvent);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
301
315
|
AbsolutePosition.notify(this.createEvent(
|
|
302
316
|
EventType.AbsolutePosition,
|
|
303
317
|
projection.projection,
|
|
@@ -343,6 +357,30 @@ class MapMatchingHandler extends Provider {
|
|
|
343
357
|
|
|
344
358
|
}
|
|
345
359
|
|
|
360
|
+
/**
|
|
361
|
+
* @param {Projection} projection
|
|
362
|
+
*/
|
|
363
|
+
_detectWrongBigJump(projection) {
|
|
364
|
+
|
|
365
|
+
if (this.network instanceof Itinerary && AbsolutePosition.lastEvent) {
|
|
366
|
+
const itinerary = this.network;
|
|
367
|
+
const infoPrevious = itinerary.getInfo(AbsolutePosition.lastEvent.data);
|
|
368
|
+
const infoProjection = itinerary.getInfo(projection.projection);
|
|
369
|
+
if (infoPrevious
|
|
370
|
+
&& infoProjection
|
|
371
|
+
&& infoPrevious.traveledDistance > infoProjection.traveledDistance
|
|
372
|
+
&& (infoPrevious.traveledDistance - infoProjection.traveledDistance) > projection.origin.accuracy
|
|
373
|
+
&& projection.distanceFromNearestElement > projection.origin.accuracy
|
|
374
|
+
&& projection.origin.distanceTo(AbsolutePosition.lastEvent.data) < projection.origin.accuracy + AbsolutePosition.lastEvent.data.accuracy) {
|
|
375
|
+
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
|
|
346
384
|
/**
|
|
347
385
|
* @param {Projection} projection
|
|
348
386
|
*/
|
|
@@ -353,7 +391,8 @@ class MapMatchingHandler extends Provider {
|
|
|
353
391
|
}
|
|
354
392
|
|
|
355
393
|
if (this.state !== ProviderState.STARTED
|
|
356
|
-
|| this._countStepsFromLastMatching < MapMatchingHandler.MIN_STEPS_BETWEEN_ORIENTATION_MATCHING
|
|
394
|
+
|| this._countStepsFromLastMatching < MapMatchingHandler.MIN_STEPS_BETWEEN_ORIENTATION_MATCHING
|
|
395
|
+
|| StraightLineDetector.numStepsDetectedFromLastTurn < MapMatchingHandler.MIN_STEPS_FOR_ORIENTATION_MATCHING) {
|
|
357
396
|
return;
|
|
358
397
|
}
|
|
359
398
|
|
|
@@ -6,7 +6,7 @@ import EventType from '../../events/EventType.js';
|
|
|
6
6
|
class StraightLineDetector extends Provider {
|
|
7
7
|
|
|
8
8
|
/** @type {number} */
|
|
9
|
-
static STEPS_CONSIDERED_FOR_STRAIGHT_LINE =
|
|
9
|
+
static STEPS_CONSIDERED_FOR_STRAIGHT_LINE = 2;
|
|
10
10
|
|
|
11
11
|
/** @type {number?} */
|
|
12
12
|
_turnDetectorProviderId = null;
|
|
@@ -75,6 +75,10 @@ class StraightLineDetector extends Provider {
|
|
|
75
75
|
isStraight() {
|
|
76
76
|
return this._countSteps >= StraightLineDetector.STEPS_CONSIDERED_FOR_STRAIGHT_LINE;
|
|
77
77
|
}
|
|
78
|
+
|
|
79
|
+
get numStepsDetectedFromLastTurn() {
|
|
80
|
+
return this._countSteps;
|
|
81
|
+
}
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
export default new StraightLineDetector();
|
|
@@ -5,7 +5,7 @@ import { deg2rad, diffAngle, Quaternion } from '@wemap/maths';
|
|
|
5
5
|
class AttitudeSmoother {
|
|
6
6
|
|
|
7
7
|
/** @type {number} in radians/s */
|
|
8
|
-
static ROTATION_SPEED_JUMP_THRESHOLD = deg2rad(
|
|
8
|
+
static ROTATION_SPEED_JUMP_THRESHOLD = deg2rad(180);
|
|
9
9
|
|
|
10
10
|
/** @type {number} in radians/s */
|
|
11
11
|
static ROTATION_SPEED_CONVERGENCE = deg2rad(10);
|