@wemap/providers 6.2.1 → 6.2.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.
@@ -0,0 +1,63 @@
1
+ import { Evented } from 'mapbox-gl';
2
+ import {
3
+ PositionSmoother, ProvidersInterface, EventType
4
+ } from '@wemap/providers';
5
+
6
+ export default class CustomMapProvider extends Evented {
7
+
8
+ attitudeProviderId = null;
9
+ positionProviderId = null;
10
+ smoother = null;
11
+
12
+ start() {
13
+
14
+ /**
15
+ * Attitude
16
+ */
17
+ this.attitudeProviderId = ProvidersInterface.addEventListener(
18
+ EventType.AbsoluteAttitude,
19
+ attitude => this.fire('heading.changed', { heading: attitude.headingDegrees })
20
+ );
21
+
22
+ // There is no sense to show the last known attitude on the map
23
+ // this.fire('heading.changed' : { heading: ProvidersInterface.getLastKnown(EventType.AbsoluteAttitude)});
24
+
25
+
26
+ /**
27
+ * Position
28
+ */
29
+
30
+ this.smoother = new PositionSmoother(position => {
31
+ this.fire('position.changed', { position });
32
+ });
33
+
34
+ this.positionProviderId = ProvidersInterface.addEventListener(
35
+ EventType.AbsolutePosition,
36
+ position => this.smoother.feed(position)
37
+ );
38
+
39
+ const lastKnownPosition = ProvidersInterface.getLastKnown(EventType.AbsolutePosition);
40
+ if (lastKnownPosition) {
41
+ this.fire('position.changed', { position: lastKnownPosition });
42
+ }
43
+ }
44
+
45
+ stop() {
46
+
47
+ /**
48
+ * Attitude
49
+ */
50
+
51
+ ProvidersInterface.removeEventListener(this.attitudeProviderId);
52
+
53
+
54
+ /**
55
+ * Position
56
+ */
57
+
58
+ ProvidersInterface.removeEventListener(this.positionProviderId);
59
+
60
+ this.smoother.clear();
61
+ this.smoother = null;
62
+ }
63
+ }
package/package.json CHANGED
@@ -9,16 +9,17 @@
9
9
  ],
10
10
  "dependencies": {
11
11
  "@wemap/camera": "^6.1.0",
12
- "@wemap/geo": "^6.0.0",
12
+ "@wemap/geo": "^6.2.3",
13
13
  "@wemap/geomagnetism": "^0.1.1",
14
14
  "@wemap/logger": "^6.0.0",
15
- "@wemap/map": "^6.1.2",
15
+ "@wemap/map": "^6.2.3",
16
16
  "@wemap/maths": "^6.0.0",
17
- "@wemap/osm": "^6.0.0",
17
+ "@wemap/osm": "^6.2.3",
18
18
  "@wemap/utils": "^6.0.0"
19
19
  },
20
20
  "description": "A package using different geoloc systems",
21
21
  "devDependencies": {
22
+ "map-gl-geolocation": "^0.3.0",
22
23
  "mapbox-gl": "^1.11.1"
23
24
  },
24
25
  "homepage": "https://github.com/wemap/wemap-modules-js#readme",
@@ -40,6 +41,6 @@
40
41
  "url": "git+https://github.com/wemap/wemap-modules-js.git"
41
42
  },
42
43
  "type": "module",
43
- "version": "6.2.1",
44
- "gitHead": "0d2771fd12d66b079ff5467d3f8d9064091a0c30"
44
+ "version": "6.2.3",
45
+ "gitHead": "e88b0f15de31c30588aaacdadcbad2da46f9673d"
45
46
  }
@@ -1,5 +1,3 @@
1
- import { Vector3 } from '@wemap/maths';
2
-
3
1
  class StepDetectionMinMaxPeaks2 {
4
2
 
5
3
  // in seconds
@@ -16,11 +14,6 @@ class StepDetectionMinMaxPeaks2 {
16
14
  static VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD = 0.75;
17
15
  static VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD = -0.3;
18
16
 
19
- // in rad.s-1
20
- static HIGH_ROTATION_THRESHOLD = 1.35
21
- // in seconds
22
- static HIGH_ROTATION_DURATION = 0.3
23
-
24
17
 
25
18
  constructor() {
26
19
  this.slidingWindow = [];
@@ -30,22 +23,14 @@ class StepDetectionMinMaxPeaks2 {
30
23
  this.influence = 0.2;
31
24
  }
32
25
 
33
- _parseGyroscope(values, timestamp) {
34
- const rotationSpeed = Vector3.norm(values);
35
- if (rotationSpeed > StepDetectionMinMaxPeaks2.HIGH_ROTATION_THRESHOLD) {
36
- this.lastHighRotation = timestamp;
37
- }
38
- }
39
26
 
40
27
  compute(timestamp, linearAcc, angularRate) {
41
28
 
42
- this._parseGyroscope(angularRate, timestamp);
43
-
44
29
  const verticalAcc = this.influence * (linearAcc[2] * 2) + (1 - this.influence) * this.previousVerticalAcc;
45
30
  this.previousVerticalAcc = verticalAcc;
46
31
 
47
32
 
48
- if (timestamp - this.lastHighRotation < StepDetectionMinMaxPeaks2.HIGH_ROTATION_DURATION) {
33
+ if (Math.sqrt(angularRate[0] ** 2 + angularRate[1] ** 2 + angularRate[2] ** 2) > 0.75) {
49
34
  return false;
50
35
  }
51
36