@wemap/providers 6.1.5 → 6.2.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.
|
@@ -42,7 +42,9 @@ var EventType = {
|
|
|
42
42
|
CameraNative: 'CAMERA_NATIVE',
|
|
43
43
|
|
|
44
44
|
Itinerary: 'ITINERARY',
|
|
45
|
-
Network: 'NETWORK'
|
|
45
|
+
Network: 'NETWORK',
|
|
46
|
+
|
|
47
|
+
ForceVps: 'FORCE_VPS'
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
/**
|
|
@@ -3775,7 +3777,7 @@ class Vps extends Provider {
|
|
|
3775
3777
|
camera.on('started', this._internalStart);
|
|
3776
3778
|
camera.on('stopped', this._internalStop);
|
|
3777
3779
|
|
|
3778
|
-
if (camera.
|
|
3780
|
+
if (camera.state === Camera.State.STARTED) {
|
|
3779
3781
|
this._internalStart();
|
|
3780
3782
|
}
|
|
3781
3783
|
}
|
|
@@ -3785,13 +3787,13 @@ class Vps extends Provider {
|
|
|
3785
3787
|
|
|
3786
3788
|
this._serverError = false;
|
|
3787
3789
|
|
|
3788
|
-
let lastTimestamp = -1;
|
|
3789
|
-
|
|
3790
3790
|
while (this.state !== ProviderState.STOPPPED) {
|
|
3791
3791
|
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3792
|
+
if (this.lastEvent) {
|
|
3793
|
+
const diffTime = preciseTime() - this.lastEvent.data.time * 1e3;
|
|
3794
|
+
const timeToWait = Math.max(0, Vps.MIN_TIME_BETWEEN_TWO_REQUESTS - diffTime);
|
|
3795
|
+
await new Promise(resolve => setTimeout(resolve, timeToWait));
|
|
3796
|
+
}
|
|
3795
3797
|
|
|
3796
3798
|
if (this.state === ProviderState.STOPPPED) {
|
|
3797
3799
|
break;
|
|
@@ -3830,8 +3832,6 @@ class Vps extends Provider {
|
|
|
3830
3832
|
if (events.length) {
|
|
3831
3833
|
this.notify(...events);
|
|
3832
3834
|
}
|
|
3833
|
-
|
|
3834
|
-
lastTimestamp = preciseTime();
|
|
3835
3835
|
}
|
|
3836
3836
|
|
|
3837
3837
|
if (this.state !== ProviderState.STOPPPED) {
|
|
@@ -3853,7 +3853,7 @@ class Vps extends Provider {
|
|
|
3853
3853
|
|
|
3854
3854
|
// Retrieve the image
|
|
3855
3855
|
const image = await camera.currentImage;
|
|
3856
|
-
const time = preciseTime();
|
|
3856
|
+
const time = preciseTime() / 1e3;
|
|
3857
3857
|
// TODO: move the grayscale conversion in the currentImage getter
|
|
3858
3858
|
CameraUtils.convertToGrayscale(image);
|
|
3859
3859
|
const reducedImage = CameraUtils.reduceImageSize(image, 1280);
|
|
@@ -3960,6 +3960,9 @@ class AbsolutePosition extends Provider {
|
|
|
3960
3960
|
/** @type {number?} */
|
|
3961
3961
|
_mapMatchingHandlerId
|
|
3962
3962
|
|
|
3963
|
+
/** @type {boolean?} */
|
|
3964
|
+
_waitUntilNextVpsPosition = false;
|
|
3965
|
+
|
|
3963
3966
|
/**
|
|
3964
3967
|
* @override
|
|
3965
3968
|
*/
|
|
@@ -4002,14 +4005,9 @@ class AbsolutePosition extends Provider {
|
|
|
4002
4005
|
if (ProvidersOptions.hasVps) {
|
|
4003
4006
|
|
|
4004
4007
|
this._vpsProviderId = Vps$1.addEventListener(events => {
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
Vps$1.removeEventListener(this._vpsProviderId);
|
|
4009
|
-
this._vpsProviderId = null;
|
|
4010
|
-
return;
|
|
4011
|
-
}
|
|
4012
|
-
}
|
|
4008
|
+
this._onAbsolutePosition(events.find(event => event.dataType === EventType.AbsolutePosition));
|
|
4009
|
+
Vps$1.removeEventListener(this._vpsProviderId);
|
|
4010
|
+
this._vpsProviderId = null;
|
|
4013
4011
|
});
|
|
4014
4012
|
|
|
4015
4013
|
} else {
|
|
@@ -4060,7 +4058,7 @@ class AbsolutePosition extends Provider {
|
|
|
4060
4058
|
if (lastPosition) {
|
|
4061
4059
|
|
|
4062
4060
|
// Is the new position accuracy is better enough than the last position accuracy
|
|
4063
|
-
const isBetterEnough = newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO
|
|
4061
|
+
const isBetterEnough = newPosition.accuracy * AbsolutePosition.ACCURACY_RELOC_RATIO <= lastPosition.accuracy;
|
|
4064
4062
|
|
|
4065
4063
|
// Is the new position is far from the new one (regarding accuracy)
|
|
4066
4064
|
// This is important if the person put the current page in the background during a while
|
|
@@ -4102,7 +4100,7 @@ class AbsolutePosition extends Provider {
|
|
|
4102
4100
|
*/
|
|
4103
4101
|
_onRelativePosition(relativeEvent) {
|
|
4104
4102
|
|
|
4105
|
-
if (!this.lastEvent) {
|
|
4103
|
+
if (!this.lastEvent || this._waitUntilNextVpsPosition) {
|
|
4106
4104
|
return;
|
|
4107
4105
|
}
|
|
4108
4106
|
|
|
@@ -4139,12 +4137,28 @@ class AbsolutePosition extends Provider {
|
|
|
4139
4137
|
/**
|
|
4140
4138
|
* @override
|
|
4141
4139
|
* @param {UserPosition|ProviderEvent} data
|
|
4140
|
+
* @param {EventType} eventType
|
|
4142
4141
|
*/
|
|
4143
|
-
feed(data) {
|
|
4142
|
+
feed(data, eventType) {
|
|
4144
4143
|
|
|
4145
4144
|
/** @type {ProviderEvent<UserPosition>} */
|
|
4146
4145
|
let newPositionEvent;
|
|
4147
4146
|
|
|
4147
|
+
if (eventType === EventType.ForceVps) {
|
|
4148
|
+
if (!this._vpsProviderId && this.state === ProviderState.STARTED) {
|
|
4149
|
+
this._waitUntilNextVpsPosition = true;
|
|
4150
|
+
this._vpsProviderId = Vps$1.addEventListener(events => {
|
|
4151
|
+
this._waitUntilNextVpsPosition = false;
|
|
4152
|
+
this._onAbsolutePosition(events.find(event => event.dataType === EventType.AbsolutePosition));
|
|
4153
|
+
Vps$1.removeEventListener(this._vpsProviderId);
|
|
4154
|
+
this._vpsProviderId = null;
|
|
4155
|
+
});
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
return;
|
|
4159
|
+
|
|
4160
|
+
}
|
|
4161
|
+
|
|
4148
4162
|
if (data instanceof UserPosition) {
|
|
4149
4163
|
|
|
4150
4164
|
if (data.time === null) {
|
|
@@ -5375,6 +5389,7 @@ class ProvidersInterface {
|
|
|
5375
5389
|
return AbsoluteAttitude$1;
|
|
5376
5390
|
|
|
5377
5391
|
case EventType.AbsolutePosition:
|
|
5392
|
+
case EventType.ForceVps:
|
|
5378
5393
|
return AbsolutePosition$1;
|
|
5379
5394
|
|
|
5380
5395
|
case EventType.RelativeAttitude:
|
|
@@ -5430,6 +5445,8 @@ class ProvidersInterface {
|
|
|
5430
5445
|
throw errorFn('Itinerary');
|
|
5431
5446
|
}
|
|
5432
5447
|
break;
|
|
5448
|
+
case EventType.ForceVps:
|
|
5449
|
+
break;
|
|
5433
5450
|
default:
|
|
5434
5451
|
throw new Error(`Unable to deal with this event type: ${eventType}`);
|
|
5435
5452
|
}
|