@wemap/providers 6.1.0 → 6.1.1

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
@@ -40,6 +40,6 @@
40
40
  "url": "git+https://github.com/wemap/wemap-modules-js.git"
41
41
  },
42
42
  "type": "module",
43
- "version": "6.1.0",
44
- "gitHead": "367774b6d8cbfa864886d9cc3344244c7da20639"
43
+ "version": "6.1.1",
44
+ "gitHead": "b3cb15c80ce9428bcffa00c946d63fd71688a384"
45
45
  }
package/src/Providers.js CHANGED
@@ -32,7 +32,7 @@ export { default as GnssWifi } from './providers/position/absolute/GnssWifi.js';
32
32
  export { default as Ip } from './providers/position/absolute/Ip.js';
33
33
  export { default as AbsolutePosition } from './providers/position/absolute/AbsolutePosition.js';
34
34
 
35
- export { default as VisionRelocalization } from './providers/vision/VisionRelocalization.js';
35
+ export { default as Vps } from './providers/vision/Vps.js';
36
36
 
37
37
  export { default as Barcode } from './providers/others/Barcode.js';
38
38
  export { default as CameraNative } from './providers/others/CameraNative.js';
@@ -17,7 +17,7 @@ const ProvidersOptions = {
17
17
  * battery. They can be added to this list to be used
18
18
  * List of {@link Provider#pname}
19
19
  */
20
- optionalProviders: ['VisionRelocalization'],
20
+ optionalProviders: [],
21
21
 
22
22
  /**
23
23
  * Define the list of EventType that are optionals
@@ -34,7 +34,7 @@ const ProvidersOptions = {
34
34
  smoother: true,
35
35
 
36
36
  get hasVps() {
37
- return this.optionalProviders.includes('VisionRelocalization');
37
+ return this.optionalProviders.includes('Vps');
38
38
  }
39
39
  };
40
40
 
@@ -8,7 +8,7 @@ import MapMatchingHandler from '../../../mapmatching/MapMatchingHandler.js';
8
8
  import GnssWifi from './GnssWifi.js';
9
9
  import { default as GeoRelativePositionProvider } from '../relative/GeoRelativePosition.js';
10
10
  import ProvidersOptions from '../../../ProvidersOptions.js';
11
- import VisionRelocalization from '../../vision/VisionRelocalization.js';
11
+ import Vps from '../../vision/Vps.js';
12
12
 
13
13
  class AbsolutePosition extends Provider {
14
14
 
@@ -69,11 +69,12 @@ class AbsolutePosition extends Provider {
69
69
 
70
70
  if (ProvidersOptions.hasVps) {
71
71
 
72
- const vpsProviderId = VisionRelocalization.addEventListener(events => {
72
+ this._vpsProviderId = Vps.addEventListener(events => {
73
73
  for (const providerEvent of events) {
74
74
  if (providerEvent.dataType === EventType.AbsolutePosition) {
75
75
  this._onAbsolutePosition(providerEvent);
76
- VisionRelocalization.removeEventListener(vpsProviderId);
76
+ Vps.removeEventListener(this._vpsProviderId);
77
+ this._vpsProviderId = null;
77
78
  return;
78
79
  }
79
80
  }
@@ -101,8 +102,16 @@ class AbsolutePosition extends Provider {
101
102
  stop() {
102
103
  if (this._relativePositionProviderId) {
103
104
  GeoRelativePositionProvider.removeEventListener(this._relativePositionProviderId);
105
+ this._relativePositionProviderId = null;
106
+ }
107
+ if (this._gnssWifiProviderId) {
108
+ GnssWifi.removeEventListener(this._gnssWifiProviderId);
109
+ this._gnssWifiProviderId = null;
110
+ }
111
+ if (this._vpsProviderId) {
112
+ Vps.removeEventListener(this._vpsProviderId);
113
+ this._vpsProviderId = null;
104
114
  }
105
- GnssWifi.removeEventListener(this._gnssWifiProviderId);
106
115
 
107
116
  MapMatchingHandler.removeEventListener(this._mapMatchingHandlerId);
108
117
  }
@@ -10,7 +10,7 @@ import ProviderEvent from '../../events/ProviderEvent.js';
10
10
  import Provider from '../Provider.js';
11
11
  import ProviderState from '../ProviderState.js';
12
12
 
13
- class VisionRelocalization extends Provider {
13
+ class Vps extends Provider {
14
14
 
15
15
  // static SERVICE_URL = 'http://localhost:45678/';
16
16
  static SERVICE_URL = 'https://vps.maaap.it/';
@@ -30,7 +30,7 @@ class VisionRelocalization extends Provider {
30
30
  * @override
31
31
  */
32
32
  static get pname() {
33
- return 'VisionRelocalization';
33
+ return 'Vps';
34
34
  }
35
35
 
36
36
  /**
@@ -119,14 +119,14 @@ class VisionRelocalization extends Provider {
119
119
  while (this.state !== ProviderState.STOPPPED) {
120
120
 
121
121
  const diffTime = TimeUtils.preciseTime() - lastTimestamp;
122
- const timeToWait = Math.max(0, VisionRelocalization.MIN_TIME_BETWEEN_TWO_REQUESTS - diffTime);
122
+ const timeToWait = Math.max(0, Vps.MIN_TIME_BETWEEN_TWO_REQUESTS - diffTime);
123
123
  await new Promise(resolve => setTimeout(resolve, timeToWait));
124
124
 
125
125
  if (this.state === ProviderState.STOPPPED) {
126
126
  break;
127
127
  }
128
128
 
129
- const url = VisionRelocalization.SERVICE_URL + VisionRelocalization.MAP_ID;
129
+ const url = Vps.SERVICE_URL + Vps.MAP_ID;
130
130
 
131
131
  // 1. Prepare the request
132
132
  if (!this._camera || this._camera.state !== Camera.State.STARTED) {
@@ -222,7 +222,7 @@ class VisionRelocalization extends Provider {
222
222
  return [];
223
223
  }
224
224
 
225
- const { attitude, userPosition } = VisionRelocalization._parseJsonResponse(json, requestTime);
225
+ const { attitude, userPosition } = Vps._parseJsonResponse(json, requestTime);
226
226
 
227
227
  const events = [
228
228
  this.createEvent(EventType.AbsoluteAttitude, attitude),
@@ -269,4 +269,4 @@ class VisionRelocalization extends Provider {
269
269
  }
270
270
  }
271
271
 
272
- export default new VisionRelocalization();
272
+ export default new Vps();