@wemap/providers 14.6.0-beta.4 → 14.6.0
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/dist/index.js +940 -927
- package/dist/src/events/AbsolutePosition.d.ts +13 -0
- package/dist/src/events/AbsolutePosition.d.ts.map +1 -0
- package/dist/src/events/Types.d.ts +2 -3
- package/dist/src/events/Types.d.ts.map +1 -1
- package/dist/src/mapmatching/MapMatchingHandler.d.ts +0 -4
- package/dist/src/mapmatching/MapMatchingHandler.d.ts.map +1 -1
- package/dist/src/providers/Provider.d.ts +6 -0
- package/dist/src/providers/Provider.d.ts.map +1 -1
- package/dist/src/providers/position/absolute/AbsolutePositionProvider.d.ts +18 -2
- package/dist/src/providers/position/absolute/AbsolutePositionProvider.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import { AbsoluteHeading, Attitude, Constants, GeoRelativePosition, Level, RelativePosition, UserPosition } from "@wemap/geo";
|
|
2
|
-
import { Matrix, Matrix3, Matrix4, Quaternion, Rotations, Vector, Vector3, deg2rad, diffAngle, diffAngleLines, rad2deg, std } from "@wemap/maths";
|
|
3
|
-
import { Edge, ItineraryInfoManager } from "@wemap/routers";
|
|
4
|
-
import { Browser, BrowserUtils, TimeUtils, UserAgentUtils } from "@wemap/utils";
|
|
5
|
-
import { Camera, SharedCameras, base64ToCanvas, canvasToBase64, reduceImageSize } from "@wemap/camera";
|
|
6
|
-
|
|
1
|
+
import { AbsoluteHeading as e, Attitude as t, Constants as n, GeoRelativePosition as r, Level as i, RelativePosition as a, UserPosition as o } from "@wemap/geo";
|
|
2
|
+
import { Matrix as s, Matrix3 as c, Matrix4 as l, Quaternion as u, Rotations as d, Vector as f, Vector3 as p, deg2rad as m, diffAngle as h, diffAngleLines as g, rad2deg as _, std as v } from "@wemap/maths";
|
|
3
|
+
import { Edge as y, ItineraryInfoManager as b } from "@wemap/routers";
|
|
4
|
+
import { Browser as x, BrowserUtils as S, TimeUtils as C, UserAgentUtils as w } from "@wemap/utils";
|
|
5
|
+
import { Camera as ee, SharedCameras as T, base64ToCanvas as E, canvasToBase64 as te, reduceImageSize as ne } from "@wemap/camera";
|
|
6
|
+
//#region src/events/AbsolutePosition.ts
|
|
7
|
+
var re = class e extends o {
|
|
8
|
+
source;
|
|
9
|
+
static fromUserPosition(t, n) {
|
|
10
|
+
let r = new e(t.lat, t.lng, t.alt, t.level, t.time, t.accuracy, t.bearing);
|
|
11
|
+
return r.source = n, r;
|
|
12
|
+
}
|
|
13
|
+
clone() {
|
|
14
|
+
return e.fromUserPosition(super.clone(), this.source);
|
|
15
|
+
}
|
|
16
|
+
}, ie = class extends t {}, ae = class extends t {}, D = {
|
|
7
17
|
useMapMatching: !0,
|
|
8
18
|
ignoreProviders: [],
|
|
9
19
|
optionalProviders: [],
|
|
@@ -12,12 +22,12 @@ var RelativeAttitude = class extends Attitude {}, AbsoluteAttitude = class exten
|
|
|
12
22
|
get hasPoleStar() {
|
|
13
23
|
return this.optionalProviders.includes("PoleStar");
|
|
14
24
|
}
|
|
15
|
-
},
|
|
25
|
+
}, oe = Object.defineProperty, se = (e, t, n) => t in e ? oe(e, t, {
|
|
16
26
|
enumerable: !0,
|
|
17
27
|
configurable: !0,
|
|
18
28
|
writable: !0,
|
|
19
|
-
value:
|
|
20
|
-
}) : e[
|
|
29
|
+
value: n
|
|
30
|
+
}) : e[t] = n, O = (e, t, n) => (se(e, typeof t == "symbol" ? t : t + "", n), n), ce = [
|
|
21
31
|
"error",
|
|
22
32
|
"ok",
|
|
23
33
|
"warn",
|
|
@@ -27,101 +37,101 @@ var RelativeAttitude = class extends Attitude {}, AbsoluteAttitude = class exten
|
|
|
27
37
|
"log",
|
|
28
38
|
"debug"
|
|
29
39
|
];
|
|
30
|
-
function
|
|
40
|
+
function le(e) {
|
|
31
41
|
return "wemap" in e;
|
|
32
42
|
}
|
|
33
|
-
var
|
|
34
|
-
static enable(
|
|
35
|
-
e.ENABLED = !!
|
|
43
|
+
var k = class e {
|
|
44
|
+
static enable(t) {
|
|
45
|
+
e.ENABLED = !!t;
|
|
36
46
|
}
|
|
37
|
-
static level(
|
|
38
|
-
return arguments.length && (e.LOG_LEVEL =
|
|
47
|
+
static level(t) {
|
|
48
|
+
return arguments.length && (e.LOG_LEVEL = t), e.LOG_LEVEL;
|
|
39
49
|
}
|
|
40
50
|
static clearHistory() {
|
|
41
51
|
e.HISTORY = [];
|
|
42
52
|
}
|
|
43
|
-
static _canUseLog(
|
|
44
|
-
let
|
|
45
|
-
return
|
|
53
|
+
static _canUseLog(t) {
|
|
54
|
+
let n = ce.indexOf(t), r = ce.indexOf(e.LOG_LEVEL);
|
|
55
|
+
return r !== -1 && n <= r;
|
|
46
56
|
}
|
|
47
57
|
static _getColorByType(e) {
|
|
48
|
-
let
|
|
58
|
+
let t = null;
|
|
49
59
|
switch (e) {
|
|
50
60
|
case "flux":
|
|
51
|
-
|
|
61
|
+
t = "background-color: #0083E0; color: #FFFFFF;";
|
|
52
62
|
break;
|
|
53
63
|
case "ok":
|
|
54
|
-
|
|
64
|
+
t = "background-color: #00FF22; color: #272727;";
|
|
55
65
|
break;
|
|
56
66
|
case "deprecated":
|
|
57
|
-
|
|
67
|
+
t = "background-color: #CA0AFA; color: #FFFFFF;";
|
|
58
68
|
break;
|
|
59
69
|
case "error":
|
|
60
|
-
|
|
70
|
+
t = "background-color: #CC0000; color: #FFFFFF;";
|
|
61
71
|
break;
|
|
62
72
|
case "warn":
|
|
63
|
-
|
|
73
|
+
t = "background-color: #DD7908; color: #FFFFFF;";
|
|
64
74
|
break;
|
|
65
75
|
case "debug":
|
|
66
|
-
|
|
76
|
+
t = "background-color: #999999; color: #FFFFFF;";
|
|
67
77
|
break;
|
|
68
78
|
case "info":
|
|
69
|
-
|
|
79
|
+
t = "background-color: #DCFF4E; color: #000000;";
|
|
70
80
|
break;
|
|
71
81
|
default:
|
|
72
|
-
|
|
82
|
+
t = "background-color: #F4F4F4; color: #999999;";
|
|
73
83
|
break;
|
|
74
84
|
}
|
|
75
|
-
return
|
|
85
|
+
return t;
|
|
76
86
|
}
|
|
77
|
-
static _getOriginByType(e,
|
|
78
|
-
let
|
|
87
|
+
static _getOriginByType(e, t) {
|
|
88
|
+
let n = null, r = null, i = t;
|
|
79
89
|
if (arguments.length < 2) return "";
|
|
80
90
|
try {
|
|
81
|
-
for (
|
|
82
|
-
return
|
|
91
|
+
for (n = "", r = e.stack && e.stack.length ? e.stack.split("\n").splice(3) : [], (i < 0 || i >= r.length) && (i = r.length); i;) n += "\r\n " + r[0].trim(), r = r.splice(1), i--;
|
|
92
|
+
return n;
|
|
83
93
|
} catch {
|
|
84
94
|
return "";
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
|
-
static _log(
|
|
88
|
-
let
|
|
89
|
-
if (
|
|
97
|
+
static _log(t, n, r) {
|
|
98
|
+
let i = "color: auto;", a = "color: #6A6A6A;", o = typeof window < "u", s, c = null, l = null, u = null, d = null, f = "", p = !1;
|
|
99
|
+
if (c = t, d = Error(n), o && (l = e._getColorByType(t)), u = e._getOriginByType(d, r), c === "deprecated" && (c = "warn", p = "deprecated"), o && (u = e._COLOR_TOKEN + u), s = (o ? e._COLOR_TOKEN : "") + " " + d.message, f = o ? e._COLOR_TOKEN : "", f += e._TYPE_PREFIX, f += p || t, f += e._TYPE_SUFFIX, typeof window < "u" && le(window)) {
|
|
90
100
|
let e = performance && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime();
|
|
91
|
-
|
|
101
|
+
f += "[" + Math.round(e - window.wemap.startTime) + "ms]";
|
|
92
102
|
}
|
|
93
|
-
return
|
|
103
|
+
return s = f + s, e.SHOW_ORIGIN && (s += u), e.HISTORY.push(s), !this._canUseLog(t) || arguments.length < 2 || !e.ENABLED ? !1 : (o ? console && t !== "ok" && t !== "flux" && t !== "deprecated" && console[t] && ce.indexOf(t) <= ce.indexOf("info") ? console[t](s, l, i, a) : console.log(s, l, i, a) : console.log(s), !0);
|
|
94
104
|
}
|
|
95
105
|
static external(e) {
|
|
96
106
|
return console.log("LIVEMAP :: " + e);
|
|
97
107
|
}
|
|
98
|
-
static flux(
|
|
99
|
-
return e._log("flux",
|
|
108
|
+
static flux(t) {
|
|
109
|
+
return e._log("flux", t, 0);
|
|
100
110
|
}
|
|
101
|
-
static ok(
|
|
102
|
-
return e._log("ok",
|
|
111
|
+
static ok(t) {
|
|
112
|
+
return e._log("ok", t, 1);
|
|
103
113
|
}
|
|
104
|
-
static error(
|
|
105
|
-
return e._log("error",
|
|
114
|
+
static error(t, n = -1) {
|
|
115
|
+
return e._log("error", t, n);
|
|
106
116
|
}
|
|
107
|
-
static warn(
|
|
108
|
-
return e._log("warn",
|
|
117
|
+
static warn(t, n = 2) {
|
|
118
|
+
return e._log("warn", t, n);
|
|
109
119
|
}
|
|
110
|
-
static deprecated(
|
|
111
|
-
return e._log("deprecated",
|
|
120
|
+
static deprecated(t, n = 2) {
|
|
121
|
+
return e._log("deprecated", t, n);
|
|
112
122
|
}
|
|
113
|
-
static debug(
|
|
114
|
-
return e._log("debug",
|
|
123
|
+
static debug(t, n = -1) {
|
|
124
|
+
return e._log("debug", t, n);
|
|
115
125
|
}
|
|
116
|
-
static info(
|
|
117
|
-
return e._log("info",
|
|
126
|
+
static info(t, n = 0) {
|
|
127
|
+
return e._log("info", t, n);
|
|
118
128
|
}
|
|
119
|
-
static log(
|
|
120
|
-
return e._log("log",
|
|
129
|
+
static log(t, n = 1) {
|
|
130
|
+
return e._log("log", t, n);
|
|
121
131
|
}
|
|
122
132
|
};
|
|
123
|
-
|
|
124
|
-
for (var
|
|
133
|
+
O(k, "LOG_LEVEL", "debug"), O(k, "SHOW_ORIGIN", !0), O(k, "ENABLED", !0), O(k, "HISTORY", []), O(k, "_COLOR_TOKEN", "%c"), O(k, "_TYPE_PREFIX", "<<<< "), O(k, "_TYPE_SUFFIX", " >>>>");
|
|
134
|
+
for (var A = k, ue = new class {
|
|
125
135
|
_enabled = !1;
|
|
126
136
|
currentId = 0;
|
|
127
137
|
objectsIdMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -137,30 +147,30 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
|
|
|
137
147
|
}
|
|
138
148
|
initializeInterval() {
|
|
139
149
|
this.interval ||= window.setInterval(() => {
|
|
140
|
-
for (let [e,
|
|
150
|
+
for (let [e, t] of Object.entries(this.pushEvents)) A.debug("Received " + t + " notifications from " + this.pushEventsRef[Number(e)].getName() + " last second");
|
|
141
151
|
this.pushEvents = {}, this.pushEventsRef = {};
|
|
142
152
|
}, 1e3);
|
|
143
153
|
}
|
|
144
154
|
getObjectId(e) {
|
|
145
155
|
return this.objectsIdMap.has(e) || this.objectsIdMap.set(e, ++this.currentId), this.objectsIdMap.get(e);
|
|
146
156
|
}
|
|
147
|
-
addEvent(e,
|
|
157
|
+
addEvent(e, t) {
|
|
148
158
|
if (!this.enabled) return;
|
|
149
159
|
this.initDate ||= Date.now(), this.initializeInterval();
|
|
150
|
-
let
|
|
151
|
-
|
|
160
|
+
let n = this.getObjectId(e), r = e.getName();
|
|
161
|
+
A.debug(r + "[" + n + "]." + t);
|
|
152
162
|
}
|
|
153
163
|
incrementNotifications(e) {
|
|
154
164
|
if (!this.enabled) return;
|
|
155
|
-
let
|
|
156
|
-
|
|
165
|
+
let t = this.getObjectId(e), n = this.pushEvents[t];
|
|
166
|
+
n || (n = 0, this.pushEventsRef[t] = e), this.pushEvents[t] = n + 1;
|
|
157
167
|
}
|
|
158
|
-
}(),
|
|
168
|
+
}(), de = class e extends Error {
|
|
159
169
|
static DEFAULT_MESSAGE = "Contains ignored provider";
|
|
160
|
-
constructor(
|
|
161
|
-
super(
|
|
170
|
+
constructor(t) {
|
|
171
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
162
172
|
}
|
|
163
|
-
},
|
|
173
|
+
}, j = class e {
|
|
164
174
|
static _callbackUniqueId = 0;
|
|
165
175
|
static _uniqueId = 1;
|
|
166
176
|
id;
|
|
@@ -169,10 +179,10 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
|
|
|
169
179
|
_eventsCallbacks = [];
|
|
170
180
|
_monitoringCallbacks = [];
|
|
171
181
|
constructor() {
|
|
172
|
-
this.id = e._uniqueId++,
|
|
182
|
+
this.id = e._uniqueId++, ue.addEvent(this, "constructor");
|
|
173
183
|
}
|
|
174
184
|
getAvailability() {
|
|
175
|
-
return
|
|
185
|
+
return D.ignoreProviders.includes(this.getName()) ? Promise.resolve(new de()) : this.availability();
|
|
176
186
|
}
|
|
177
187
|
get hasNativeInterface() {
|
|
178
188
|
return !!this.nativeInterface;
|
|
@@ -186,69 +196,73 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
|
|
|
186
196
|
get useCameraNatively() {
|
|
187
197
|
return !1;
|
|
188
198
|
}
|
|
189
|
-
addEventListener(
|
|
190
|
-
let
|
|
199
|
+
addEventListener(t = null, n = null, r = !0) {
|
|
200
|
+
let i = ++e._callbackUniqueId;
|
|
191
201
|
if (this._eventsCallbacks.push({
|
|
192
|
-
id:
|
|
193
|
-
onEvent:
|
|
194
|
-
onError:
|
|
195
|
-
optional: !
|
|
196
|
-
}), !
|
|
202
|
+
id: i,
|
|
203
|
+
onEvent: t || (() => {}),
|
|
204
|
+
onError: n || (() => {}),
|
|
205
|
+
optional: !r
|
|
206
|
+
}), !r || this.state !== "stopped") return i;
|
|
197
207
|
this.state = "starting";
|
|
198
|
-
let
|
|
199
|
-
return
|
|
200
|
-
let e = await
|
|
208
|
+
let a = Promise.resolve();
|
|
209
|
+
return D.checkAvailabilityOnStart && (a = this.getAvailability()), (async () => {
|
|
210
|
+
let e = await a;
|
|
201
211
|
if (e) {
|
|
202
212
|
this.state = "stopped", this.notifyError(e);
|
|
203
213
|
return;
|
|
204
214
|
}
|
|
205
|
-
|
|
206
|
-
})(),
|
|
215
|
+
ue.addEvent(this, "start"), this.start(), this.state = "started", this._monitoringCallbacks.forEach((e) => e.onStarted?.());
|
|
216
|
+
})(), i;
|
|
207
217
|
}
|
|
208
218
|
removeEventListener(e) {
|
|
209
|
-
let
|
|
210
|
-
|
|
219
|
+
let t = this._eventsCallbacks.find((t) => t.id === e);
|
|
220
|
+
t && (this._eventsCallbacks = this._eventsCallbacks.filter((e) => e !== t), !t.optional && (this._eventsCallbacks.find((e) => !e.optional) || this.state !== "stopped" && (ue.addEvent(this, "stop"), this.stop(), this.state = "stopped", this._monitoringCallbacks.forEach((e) => e.onStopped?.()))));
|
|
211
221
|
}
|
|
212
|
-
addMonitoringListener(
|
|
213
|
-
let
|
|
222
|
+
addMonitoringListener(t, n) {
|
|
223
|
+
let r = e._callbackUniqueId++;
|
|
214
224
|
return this._monitoringCallbacks.push({
|
|
215
|
-
id:
|
|
216
|
-
onStarted:
|
|
217
|
-
onStopped:
|
|
218
|
-
}),
|
|
225
|
+
id: r,
|
|
226
|
+
onStarted: t || null,
|
|
227
|
+
onStopped: n || null
|
|
228
|
+
}), r;
|
|
219
229
|
}
|
|
220
230
|
removeMonitoringListener(e) {
|
|
221
|
-
this._monitoringCallbacks = this._monitoringCallbacks.filter((
|
|
231
|
+
this._monitoringCallbacks = this._monitoringCallbacks.filter((t) => t.id !== e);
|
|
222
232
|
}
|
|
223
233
|
notify = (e) => {
|
|
224
|
-
|
|
234
|
+
let t = this._adaptBeforeNotify(e);
|
|
235
|
+
ue.incrementNotifications(this), this._eventsCallbacks.forEach((e) => e.onEvent?.(t)), this._lastEvent = t;
|
|
225
236
|
};
|
|
237
|
+
_adaptBeforeNotify(e) {
|
|
238
|
+
return e;
|
|
239
|
+
}
|
|
226
240
|
notifyError = (e) => {
|
|
227
|
-
this._eventsCallbacks.forEach(({ id:
|
|
228
|
-
|
|
241
|
+
this._eventsCallbacks.forEach(({ id: t, onError: n }) => {
|
|
242
|
+
D.stopOnError && this.removeEventListener(t), n?.(e);
|
|
229
243
|
});
|
|
230
244
|
};
|
|
231
245
|
get lastEvent() {
|
|
232
246
|
return this._lastEvent;
|
|
233
247
|
}
|
|
234
|
-
},
|
|
248
|
+
}, M = class {
|
|
235
249
|
static async every(e) {
|
|
236
|
-
for (let
|
|
237
|
-
let e = await
|
|
250
|
+
for (let t of e) {
|
|
251
|
+
let e = await t;
|
|
238
252
|
if (e) return e;
|
|
239
253
|
}
|
|
240
254
|
return null;
|
|
241
255
|
}
|
|
242
256
|
static async some(e) {
|
|
243
|
-
let
|
|
244
|
-
for (let
|
|
245
|
-
let e = await
|
|
246
|
-
if (e)
|
|
257
|
+
let t;
|
|
258
|
+
for (let n of e) {
|
|
259
|
+
let e = await n;
|
|
260
|
+
if (e) t ||= e;
|
|
247
261
|
else return null;
|
|
248
262
|
}
|
|
249
|
-
return
|
|
263
|
+
return t || null;
|
|
250
264
|
}
|
|
251
|
-
},
|
|
265
|
+
}, fe = [
|
|
252
266
|
[
|
|
253
267
|
0,
|
|
254
268
|
0,
|
|
@@ -444,7 +458,7 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
|
|
|
444
458
|
-1.1,
|
|
445
459
|
-.3
|
|
446
460
|
]
|
|
447
|
-
],
|
|
461
|
+
], pe = [
|
|
448
462
|
[
|
|
449
463
|
0,
|
|
450
464
|
0,
|
|
@@ -640,7 +654,7 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
|
|
|
640
654
|
0,
|
|
641
655
|
.5
|
|
642
656
|
]
|
|
643
|
-
],
|
|
657
|
+
], me = [
|
|
644
658
|
[
|
|
645
659
|
0,
|
|
646
660
|
0,
|
|
@@ -836,7 +850,7 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
|
|
|
836
850
|
0,
|
|
837
851
|
-.1
|
|
838
852
|
]
|
|
839
|
-
],
|
|
853
|
+
], he = [
|
|
840
854
|
[
|
|
841
855
|
0,
|
|
842
856
|
0,
|
|
@@ -1032,88 +1046,88 @@ for (var Logger = _Logger, ProvidersLoggerOld_default = new class {
|
|
|
1032
1046
|
0,
|
|
1033
1047
|
-.1
|
|
1034
1048
|
]
|
|
1035
|
-
],
|
|
1049
|
+
], N = {
|
|
1036
1050
|
a: 6378.137,
|
|
1037
1051
|
b: 6356.7523142,
|
|
1038
1052
|
r0: 6371.2
|
|
1039
|
-
},
|
|
1053
|
+
}, ge = function(e, t) {
|
|
1040
1054
|
return Array(e).fill("").map(function(e) {
|
|
1041
|
-
return Array(
|
|
1055
|
+
return Array(t).fill(0);
|
|
1042
1056
|
});
|
|
1043
|
-
},
|
|
1057
|
+
}, _e = function() {
|
|
1044
1058
|
return (new Date(Date.now()).valueOf() / 864e5 + 2440587.5 - 2458850) / 365.25;
|
|
1045
|
-
},
|
|
1046
|
-
return Number(Math.round(Number(e + "e+" +
|
|
1047
|
-
},
|
|
1059
|
+
}, ve = function(e, t) {
|
|
1060
|
+
return Number(Math.round(Number(e + "e+" + t)) + "e-" + t);
|
|
1061
|
+
}, ye = function(e) {
|
|
1048
1062
|
return e > 90 ? e - 180 : e < -90 ? e + 180 : e;
|
|
1049
|
-
},
|
|
1063
|
+
}, be = function(e) {
|
|
1050
1064
|
return e * .017453292519943295;
|
|
1051
|
-
},
|
|
1065
|
+
}, xe = function(e) {
|
|
1052
1066
|
return e * 57.29577951308232;
|
|
1053
|
-
}, P =
|
|
1067
|
+
}, P = ge(13, 13), F = ge(13, 13), Se = ge(13, 13), Ce = ge(13, 13), we = Array(13).fill(0), Te = Array(13).fill(0), Ee = Array(13).fill(0), De = ge(13, 13).map(function(e) {
|
|
1054
1068
|
return e.map(function(e) {
|
|
1055
1069
|
return [0, 0];
|
|
1056
1070
|
});
|
|
1057
|
-
}),
|
|
1058
|
-
for (var
|
|
1059
|
-
var
|
|
1060
|
-
|
|
1061
|
-
var
|
|
1062
|
-
P[0][0] = 1, P[1][1] =
|
|
1063
|
-
for (var
|
|
1064
|
-
for (var
|
|
1065
|
-
for (var
|
|
1066
|
-
for (var
|
|
1067
|
-
for (var
|
|
1068
|
-
for (var
|
|
1069
|
-
var
|
|
1070
|
-
|
|
1071
|
+
}), I = 2; I <= 12; I++) Ee[I] = Math.sqrt((2 * I - 1) / (2 * I));
|
|
1072
|
+
for (var L = 0; L <= 12; L++) for (var Oe = L * L, I = Math.max(L + 1, 2); I <= 12; I++) De[L][I][0] = Math.sqrt((I - 1) * (I - 1) - Oe), De[L][I][1] = 1 / Math.sqrt(I * I - Oe);
|
|
1073
|
+
var ke = function(e, t, n) {
|
|
1074
|
+
n === void 0 && (n = 0);
|
|
1075
|
+
var r = Math.cos(be(e)), i = Math.sin(be(e)), a = Math.sqrt(N.a ** 2 * r ** 2 + N.b ** 2 * i ** 2), o = Math.atan2(r * (n * a + N.a ** 2), i * (n * a + N.b ** 2)), s = Math.sqrt(n ** 2 + 2 * n * a + (N.a ** 4 - (N.a ** 4 - N.b ** 4) * i ** 2) / (N.a ** 2 - (N.a ** 2 - N.b ** 2) * i ** 2)), c = Math.cos(o), l = Math.sin(o), u = 1 / (l + (l === 0 ? 1e-8 : 0));
|
|
1076
|
+
P[0][0] = 1, P[1][1] = l, P[1][0] = c, F[1][0] = -l, F[1][1] = c;
|
|
1077
|
+
for (var d = 2; d <= 12; d++) P[d][d] = P[d - 1][d - 1] * l * Ee[d], F[d][d] = (F[d - 1][d - 1] * l + P[d - 1][d - 1] * c) * Ee[d];
|
|
1078
|
+
for (var f = 0; f <= 12; f++) for (var d = Math.max(f + 1, 2); d <= 12; d++) P[d][f] = (P[d - 1][f] * c * (2 * d - 1) - P[d - 2][f] * De[f][d][0]) * De[f][d][1], F[d][f] = ((F[d - 1][f] * c - P[d - 1][f] * l) * (2 * d - 1) - F[d - 2][f] * De[f][d][0]) * De[f][d][1];
|
|
1079
|
+
for (var p = _e(), d = 1; d <= 12; d++) for (var f = 0; f <= 12; f++) Se[d][f] = fe[d][f] + p * me[d][f], Ce[d][f] = pe[d][f] + p * he[d][f];
|
|
1080
|
+
for (var f = 0; f <= 12; f++) we[f] = Math.sin(f * be(t)), Te[f] = Math.cos(f * be(t));
|
|
1081
|
+
for (var m = 0, h = 0, g = 0, _ = N.r0 / s, v = _ ** 2, d = 1; d <= 12; d++) {
|
|
1082
|
+
for (var y = 0, b = 0, x = 0, f = 0; f <= d; f++) {
|
|
1083
|
+
var S = Se[d][f] * Te[f] + Ce[d][f] * we[f];
|
|
1084
|
+
y += S * P[d][f], b += S * F[d][f], x += f * (Se[d][f] * we[f] - Ce[d][f] * Te[f]) * P[d][f];
|
|
1071
1085
|
}
|
|
1072
|
-
|
|
1086
|
+
v *= _, m += (d + 1) * y * v, h -= b * v, g += x * v * u;
|
|
1073
1087
|
}
|
|
1074
|
-
var
|
|
1088
|
+
var C = o - (Math.PI / 2 - be(e)), w = Math.sin(C), ee = Math.cos(C), T = -h * ee - m * w, E = g, te = h * w - m * ee, ne = T !== 0 || E !== 0 ? ve(xe(Math.atan2(E, T)), 2) : 0, re = E !== 0 || T !== 0 && te !== 0 ? ye(xe(Math.atan2(te * Math.sin(Math.atan2(E, T)), E))) : 0;
|
|
1075
1089
|
return {
|
|
1076
|
-
declination:
|
|
1077
|
-
inclination:
|
|
1078
|
-
intensity: Math.round(Math.sqrt(
|
|
1079
|
-
northIntensity: Math.round(
|
|
1080
|
-
eastIntensity: Math.round(
|
|
1081
|
-
verticalIntensity: Math.round(
|
|
1082
|
-
horizontalIntensity: Math.round(Math.sqrt(
|
|
1090
|
+
declination: ve(ne, 2),
|
|
1091
|
+
inclination: ve(re, 2),
|
|
1092
|
+
intensity: Math.round(Math.sqrt(T ** 2 + E ** 2 + te ** 2)),
|
|
1093
|
+
northIntensity: Math.round(T),
|
|
1094
|
+
eastIntensity: Math.round(E),
|
|
1095
|
+
verticalIntensity: Math.round(te),
|
|
1096
|
+
horizontalIntensity: Math.round(Math.sqrt(T ** 2 + E ** 2))
|
|
1083
1097
|
};
|
|
1084
|
-
},
|
|
1098
|
+
}, Ae = class e extends Error {
|
|
1085
1099
|
static DEFAULT_MESSAGE = "It seems that you ask for IMU events on a desktop browser";
|
|
1086
|
-
constructor(
|
|
1087
|
-
super(
|
|
1100
|
+
constructor(t) {
|
|
1101
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
1088
1102
|
}
|
|
1089
|
-
},
|
|
1103
|
+
}, R = class e extends Error {
|
|
1090
1104
|
static DEFAULT_MESSAGE = "Impossible to retrieve events, a sensor is missing";
|
|
1091
|
-
constructor(
|
|
1092
|
-
super(
|
|
1105
|
+
constructor(t) {
|
|
1106
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
1093
1107
|
}
|
|
1094
1108
|
from(e) {
|
|
1095
1109
|
return this.message += " from " + e, this;
|
|
1096
1110
|
}
|
|
1097
|
-
},
|
|
1111
|
+
}, je = class extends R {
|
|
1098
1112
|
constructor(e) {
|
|
1099
1113
|
super(e);
|
|
1100
1114
|
}
|
|
1101
|
-
},
|
|
1115
|
+
}, Me = class e extends Error {
|
|
1102
1116
|
static DEFAULT_MESSAGE = "Geolocation api is missing";
|
|
1103
|
-
constructor(
|
|
1104
|
-
super(
|
|
1117
|
+
constructor(t) {
|
|
1118
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
1105
1119
|
}
|
|
1106
|
-
},
|
|
1120
|
+
}, Ne = class e extends Error {
|
|
1107
1121
|
static DEFAULT_MESSAGE = "Geolocation permission denied";
|
|
1108
|
-
constructor(
|
|
1109
|
-
super(
|
|
1122
|
+
constructor(t) {
|
|
1123
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
1110
1124
|
}
|
|
1111
|
-
},
|
|
1125
|
+
}, Pe = class e extends Error {
|
|
1112
1126
|
static DEFAULT_MESSAGE = "Geolocation position unavailable";
|
|
1113
|
-
constructor(
|
|
1114
|
-
super(
|
|
1127
|
+
constructor(t) {
|
|
1128
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
1115
1129
|
}
|
|
1116
|
-
},
|
|
1130
|
+
}, Fe = { DEFAULT_ALTITUDE: 1.6 }, Ie = new class e extends j {
|
|
1117
1131
|
static DEFAULT_DISCARD_POSITIONS_ABOVE = 50;
|
|
1118
1132
|
discardPositionsAbove = e.DEFAULT_DISCARD_POSITIONS_ABOVE;
|
|
1119
1133
|
enableHighAccuracy = !0;
|
|
@@ -1127,7 +1141,7 @@ var field = function(e, C, w) {
|
|
|
1127
1141
|
};
|
|
1128
1142
|
}
|
|
1129
1143
|
availability() {
|
|
1130
|
-
return typeof navigator == "object" && navigator.geolocation ? Promise.resolve() : Promise.resolve(new
|
|
1144
|
+
return typeof navigator == "object" && navigator.geolocation ? Promise.resolve() : Promise.resolve(new Me());
|
|
1131
1145
|
}
|
|
1132
1146
|
start() {
|
|
1133
1147
|
navigator.geolocation.getCurrentPosition(this.onNewPosition, this.onPositionError, this.positionOptions), setTimeout(() => {
|
|
@@ -1138,38 +1152,38 @@ var field = function(e, C, w) {
|
|
|
1138
1152
|
this.geoLocationId !== void 0 && navigator.geolocation.clearWatch(this.geoLocationId);
|
|
1139
1153
|
}
|
|
1140
1154
|
onNewPosition = (e) => {
|
|
1141
|
-
let { coords:
|
|
1142
|
-
if (!
|
|
1143
|
-
let
|
|
1144
|
-
|
|
1145
|
-
let
|
|
1146
|
-
this.enableHighAccuracy && typeof this.discardPositionsAbove == "number" &&
|
|
1155
|
+
let { coords: t } = e;
|
|
1156
|
+
if (!t) return;
|
|
1157
|
+
let n;
|
|
1158
|
+
t.heading && (n = m(t.heading));
|
|
1159
|
+
let r = C.unixTimestampToPreciseTime(e.timestamp) / 1e3, i = new o(t.latitude, t.longitude, Fe.DEFAULT_ALTITUDE, null, r, t.accuracy, n);
|
|
1160
|
+
this.enableHighAccuracy && typeof this.discardPositionsAbove == "number" && t.accuracy > this.discardPositionsAbove || this.notify(i);
|
|
1147
1161
|
};
|
|
1148
1162
|
onPositionError = (e) => {
|
|
1149
|
-
|
|
1150
|
-
let
|
|
1163
|
+
A.warn(`[Providers] watchPosition error: [${e.code}] ${e.message}`);
|
|
1164
|
+
let t;
|
|
1151
1165
|
switch (e.code) {
|
|
1152
1166
|
case 1:
|
|
1153
|
-
|
|
1167
|
+
t = new Ne(e.message);
|
|
1154
1168
|
break;
|
|
1155
1169
|
case 2:
|
|
1156
|
-
|
|
1170
|
+
t = new Pe(e.message);
|
|
1157
1171
|
break;
|
|
1158
|
-
default:
|
|
1172
|
+
default: t = Error(e.message);
|
|
1159
1173
|
}
|
|
1160
|
-
this.notifyError(
|
|
1174
|
+
this.notifyError(t);
|
|
1161
1175
|
};
|
|
1162
|
-
}(),
|
|
1176
|
+
}(), Le = class e extends Error {
|
|
1163
1177
|
static DEFAULT_MESSAGE = "ARCore is missing";
|
|
1164
|
-
constructor(
|
|
1165
|
-
super(
|
|
1178
|
+
constructor(t) {
|
|
1179
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
1166
1180
|
}
|
|
1167
|
-
},
|
|
1181
|
+
}, Re = class e extends Error {
|
|
1168
1182
|
static DEFAULT_MESSAGE = "Native interface is missing. You are maybe trying to execute a code which is not available in a web browser";
|
|
1169
|
-
constructor(
|
|
1170
|
-
super(
|
|
1183
|
+
constructor(t) {
|
|
1184
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
1171
1185
|
}
|
|
1172
|
-
},
|
|
1186
|
+
}, z = new class e extends j {
|
|
1173
1187
|
static Payload = {
|
|
1174
1188
|
Pose: {
|
|
1175
1189
|
ref: 1,
|
|
@@ -1188,7 +1202,7 @@ var field = function(e, C, w) {
|
|
|
1188
1202
|
size: 1
|
|
1189
1203
|
}
|
|
1190
1204
|
};
|
|
1191
|
-
static RELATIVE_ATTITUDE_DRIFT =
|
|
1205
|
+
static RELATIVE_ATTITUDE_DRIFT = m(3) / 60;
|
|
1192
1206
|
_nativeProvider;
|
|
1193
1207
|
previousPosition = [
|
|
1194
1208
|
0,
|
|
@@ -1198,7 +1212,7 @@ var field = function(e, C, w) {
|
|
|
1198
1212
|
getName = () => "ArCore";
|
|
1199
1213
|
availability() {
|
|
1200
1214
|
try {
|
|
1201
|
-
if (!this.nativeProvider.checkAvailability()) return Promise.resolve(new
|
|
1215
|
+
if (!this.nativeProvider.checkAvailability()) return Promise.resolve(new Le());
|
|
1202
1216
|
} catch (e) {
|
|
1203
1217
|
return Promise.resolve(e);
|
|
1204
1218
|
}
|
|
@@ -1215,28 +1229,28 @@ var field = function(e, C, w) {
|
|
|
1215
1229
|
let e = JSON.parse(this.nativeProvider.getInfo());
|
|
1216
1230
|
e.length > 1 && this.parsePayload(e), requestAnimationFrame(this.pullDataLoop);
|
|
1217
1231
|
};
|
|
1218
|
-
parsePayload(
|
|
1219
|
-
let
|
|
1220
|
-
if (
|
|
1221
|
-
|
|
1222
|
-
let
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1232
|
+
parsePayload(t) {
|
|
1233
|
+
let n = t[0], r = 1, i, o, s, c, l = C.preciseTime() / 1e3;
|
|
1234
|
+
if (n & e.Payload.Pose.ref) {
|
|
1235
|
+
i = new ie(t.slice(r, r + 4), l, e.RELATIVE_ATTITUDE_DRIFT);
|
|
1236
|
+
let n = [
|
|
1237
|
+
t[r + 4],
|
|
1238
|
+
t[r + 5],
|
|
1239
|
+
t[r + 6]
|
|
1226
1240
|
];
|
|
1227
|
-
|
|
1241
|
+
o = new a(n[0] - this.previousPosition[0], n[1] - this.previousPosition[1], n[2] - this.previousPosition[2], l, 1e-4), this.previousPosition = n, r += e.Payload.Pose.size;
|
|
1228
1242
|
}
|
|
1229
|
-
|
|
1230
|
-
relativePosition:
|
|
1231
|
-
relativeAttitude:
|
|
1232
|
-
...
|
|
1233
|
-
...
|
|
1243
|
+
n & e.Payload.Barcode.ref && (c = t[r], r += e.Payload.Barcode.size), n & e.Payload.ProjMat.ref && (s = t.slice(r, r + e.Payload.ProjMat.size), r += e.Payload.ProjMat.size), this.notify({
|
|
1244
|
+
relativePosition: o,
|
|
1245
|
+
relativeAttitude: i,
|
|
1246
|
+
...c && { barcode: c },
|
|
1247
|
+
...s && { cameraProjection: s }
|
|
1234
1248
|
});
|
|
1235
1249
|
}
|
|
1236
1250
|
get nativeProvider() {
|
|
1237
1251
|
if (!this._nativeProvider) {
|
|
1238
|
-
if (!this.nativeInterface) throw new
|
|
1239
|
-
if (this._nativeProvider = this.nativeInterface.getArCoreProvider(), !this._nativeProvider) throw new
|
|
1252
|
+
if (!this.nativeInterface) throw new Re();
|
|
1253
|
+
if (this._nativeProvider = this.nativeInterface.getArCoreProvider(), !this._nativeProvider) throw new Le();
|
|
1240
1254
|
}
|
|
1241
1255
|
return this._nativeProvider;
|
|
1242
1256
|
}
|
|
@@ -1257,36 +1271,36 @@ var field = function(e, C, w) {
|
|
|
1257
1271
|
get useCameraNatively() {
|
|
1258
1272
|
return !0;
|
|
1259
1273
|
}
|
|
1260
|
-
}(),
|
|
1274
|
+
}(), ze = new class extends j {
|
|
1261
1275
|
absoluteAttitudeProviderId;
|
|
1262
1276
|
arCoreProviderId;
|
|
1263
1277
|
absoluteAttitudeEvent;
|
|
1264
1278
|
getName = () => "GeoRelativePositionFromArCore";
|
|
1265
1279
|
availability() {
|
|
1266
|
-
return
|
|
1280
|
+
return M.every([z.getAvailability(), X.getAvailability()]);
|
|
1267
1281
|
}
|
|
1268
1282
|
start() {
|
|
1269
|
-
this.arCoreProviderId =
|
|
1283
|
+
this.arCoreProviderId = z.addEventListener(this.onArCoreEvents, this.notifyError), this.absoluteAttitudeProviderId = X.addEventListener((e) => this.absoluteAttitudeEvent = e, this.notifyError);
|
|
1270
1284
|
}
|
|
1271
1285
|
stop() {
|
|
1272
|
-
|
|
1286
|
+
z.removeEventListener(this.arCoreProviderId), X.removeEventListener(this.absoluteAttitudeProviderId);
|
|
1273
1287
|
}
|
|
1274
1288
|
onArCoreEvents = (e) => {
|
|
1275
|
-
let
|
|
1276
|
-
|
|
1289
|
+
let t = e.relativeAttitude, n = e.relativePosition;
|
|
1290
|
+
t && n && this.absoluteAttitudeEvent && this.compute(n, t, this.absoluteAttitudeEvent);
|
|
1277
1291
|
};
|
|
1278
|
-
compute(e,
|
|
1279
|
-
let
|
|
1280
|
-
this.notify(
|
|
1292
|
+
compute(e, t, n) {
|
|
1293
|
+
let i = n.heading - t.heading, a = Math.cos(i) * e.x - Math.sin(i) * e.z, o = -Math.sin(i) * e.x - Math.cos(i) * e.z, s = e.y, c = new r(a, o, s, e.time, 0, n.heading);
|
|
1294
|
+
this.notify(c);
|
|
1281
1295
|
}
|
|
1282
|
-
}(),
|
|
1296
|
+
}(), Be = {
|
|
1283
1297
|
acc: .5,
|
|
1284
1298
|
gyr: .3
|
|
1285
|
-
},
|
|
1299
|
+
}, Ve = {
|
|
1286
1300
|
acc: .5,
|
|
1287
1301
|
gyr: .3,
|
|
1288
1302
|
yc: 2
|
|
1289
|
-
},
|
|
1303
|
+
}, He = class {
|
|
1290
1304
|
P;
|
|
1291
1305
|
accRef;
|
|
1292
1306
|
cRef;
|
|
@@ -1296,26 +1310,26 @@ var field = function(e, C, w) {
|
|
|
1296
1310
|
0,
|
|
1297
1311
|
0,
|
|
1298
1312
|
1
|
|
1299
|
-
],
|
|
1313
|
+
], t = [
|
|
1300
1314
|
-1,
|
|
1301
1315
|
0,
|
|
1302
1316
|
0
|
|
1303
1317
|
]) {
|
|
1304
|
-
this.accRef = e, this.cRef =
|
|
1318
|
+
this.accRef = e, this.cRef = t, this.P = l.fromDiagVector([
|
|
1305
1319
|
,
|
|
1306
1320
|
,
|
|
1307
1321
|
,
|
|
1308
1322
|
,
|
|
1309
|
-
].fill(.1 ** 2)), this.quaternion = null, this.noises = {}, this.setRelativeNoises(
|
|
1323
|
+
].fill(.1 ** 2)), this.quaternion = null, this.noises = {}, this.setRelativeNoises(Be), this.setAbsoluteNoises(Ve);
|
|
1310
1324
|
}
|
|
1311
1325
|
setRelativeNoises(e) {
|
|
1312
1326
|
this.noises.relative = {
|
|
1313
|
-
acc:
|
|
1327
|
+
acc: c.diag([
|
|
1314
1328
|
,
|
|
1315
1329
|
,
|
|
1316
1330
|
,
|
|
1317
1331
|
].fill(e.acc ** 2)),
|
|
1318
|
-
gyr:
|
|
1332
|
+
gyr: c.diag([
|
|
1319
1333
|
,
|
|
1320
1334
|
,
|
|
1321
1335
|
,
|
|
@@ -1324,90 +1338,90 @@ var field = function(e, C, w) {
|
|
|
1324
1338
|
}
|
|
1325
1339
|
setAbsoluteNoises(e) {
|
|
1326
1340
|
this.noises.absolute = {
|
|
1327
|
-
acc:
|
|
1341
|
+
acc: c.diag([
|
|
1328
1342
|
,
|
|
1329
1343
|
,
|
|
1330
1344
|
,
|
|
1331
1345
|
].fill(e.acc ** 2)),
|
|
1332
|
-
gyr:
|
|
1346
|
+
gyr: c.diag([
|
|
1333
1347
|
,
|
|
1334
1348
|
,
|
|
1335
1349
|
,
|
|
1336
1350
|
].fill(e.gyr ** 2)),
|
|
1337
|
-
yc:
|
|
1351
|
+
yc: c.diag([
|
|
1338
1352
|
,
|
|
1339
1353
|
,
|
|
1340
1354
|
,
|
|
1341
1355
|
].fill(e.yc ** 2))
|
|
1342
1356
|
};
|
|
1343
1357
|
}
|
|
1344
|
-
tryInitialize(e,
|
|
1345
|
-
let
|
|
1346
|
-
if (
|
|
1347
|
-
let e =
|
|
1358
|
+
tryInitialize(e, t) {
|
|
1359
|
+
let n = p.normalize(e);
|
|
1360
|
+
if (t) {
|
|
1361
|
+
let e = p.normalize(t), r = p.normalize(p.cross(e, n)), i = p.cross(n, r), a = [
|
|
1348
1362
|
[
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1363
|
+
r[0],
|
|
1364
|
+
i[0],
|
|
1365
|
+
n[0]
|
|
1352
1366
|
],
|
|
1353
1367
|
[
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1368
|
+
r[1],
|
|
1369
|
+
i[1],
|
|
1370
|
+
n[1]
|
|
1357
1371
|
],
|
|
1358
1372
|
[
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1373
|
+
r[2],
|
|
1374
|
+
i[2],
|
|
1375
|
+
n[2]
|
|
1362
1376
|
]
|
|
1363
1377
|
];
|
|
1364
|
-
this.quaternion =
|
|
1378
|
+
this.quaternion = u.fromMatrix3Matlab(a);
|
|
1365
1379
|
} else {
|
|
1366
|
-
let e =
|
|
1380
|
+
let e = p.dot(n, this.accRef) + 1, t = p.cross(n, this.accRef), r = [
|
|
1367
1381
|
e,
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1382
|
+
t[0],
|
|
1383
|
+
t[1],
|
|
1384
|
+
t[2]
|
|
1371
1385
|
];
|
|
1372
|
-
|
|
1386
|
+
r = u.normalize(r), this.quaternion = r;
|
|
1373
1387
|
}
|
|
1374
1388
|
return this.quaternion;
|
|
1375
1389
|
}
|
|
1376
|
-
update(e,
|
|
1377
|
-
if (!this.quaternion) return this.tryInitialize(
|
|
1378
|
-
let
|
|
1390
|
+
update(e, t, n, r) {
|
|
1391
|
+
if (!this.quaternion) return this.tryInitialize(t, r);
|
|
1392
|
+
let i = this.quaternion, a = i, o = p.multiplyScalar(n, .5 * e), d = this.computeC([
|
|
1379
1393
|
1,
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
]),
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
]),
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
]),
|
|
1392
|
-
-1 *
|
|
1393
|
-
-1 *
|
|
1394
|
-
-1 *
|
|
1395
|
-
],
|
|
1396
|
-
if (
|
|
1397
|
-
let e =
|
|
1398
|
-
|
|
1399
|
-
let
|
|
1400
|
-
|
|
1401
|
-
let
|
|
1402
|
-
|
|
1394
|
+
o[0],
|
|
1395
|
+
o[1],
|
|
1396
|
+
o[2]
|
|
1397
|
+
]), m = l.multiplyVector(d, i), h = c.diag([
|
|
1398
|
+
a[0],
|
|
1399
|
+
a[0],
|
|
1400
|
+
a[0]
|
|
1401
|
+
]), g = c.skew([
|
|
1402
|
+
a[1],
|
|
1403
|
+
a[2],
|
|
1404
|
+
a[3]
|
|
1405
|
+
]), _ = [
|
|
1406
|
+
-1 * a[1],
|
|
1407
|
+
-1 * a[2],
|
|
1408
|
+
-1 * a[3]
|
|
1409
|
+
], v = s.concatRow([_], c.sum(g, h)), y = l.multiplyScalar(s.multiply(s.multiply(v, this.noises[r ? "absolute" : "relative"].gyr), s.transpose(v)), (e / 2) ** 2), b = l.sum(l.multiply(l.multiply(d, this.P), l.transpose(d)), y), x = p.normalize(t), S, C, w;
|
|
1410
|
+
if (r) {
|
|
1411
|
+
let e = p.normalize(r), t = p.cross(x, e), n = p.normalize(t), i = p.subtract(n, u.rotateMatlab(m, this.cRef)), a = p.subtract(x, u.rotateMatlab(m, this.accRef));
|
|
1412
|
+
S = f.concat(i, a);
|
|
1413
|
+
let o = this.jacobianES(m, this.cRef), l = this.jacobianES(m, this.accRef);
|
|
1414
|
+
w = s.concatRow(o, l);
|
|
1415
|
+
let d = s.concatLine(this.noises.absolute.yc, c.zeros), h = s.concatLine(c.zeros, this.noises.absolute.acc), g = s.concatRow(d, h);
|
|
1416
|
+
C = s.multiply(s.multiply(b, s.transpose(w)), s.inverse(s.sum(s.multiply(s.multiply(w, b), s.transpose(w)), g)));
|
|
1403
1417
|
} else {
|
|
1404
|
-
|
|
1418
|
+
S = p.subtract(x, u.rotateMatlab(m, this.accRef)), w = this.jacobianES(m, this.accRef);
|
|
1405
1419
|
let e = this.noises.relative.acc;
|
|
1406
|
-
|
|
1420
|
+
C = s.multiply(s.multiply(b, s.transpose(w)), c.inverse(c.sum(s.multiply(s.multiply(w, b), s.transpose(w)), e)));
|
|
1407
1421
|
}
|
|
1408
|
-
|
|
1409
|
-
let
|
|
1410
|
-
return
|
|
1422
|
+
i = u.sum(m, s.multiplyVector(C, S));
|
|
1423
|
+
let ee = l.multiply(l.subtract(l.identity, s.multiply(C, w)), b);
|
|
1424
|
+
return i = u.normalize(i), this.quaternion = i, this.P = ee, i;
|
|
1411
1425
|
}
|
|
1412
1426
|
computeC(e) {
|
|
1413
1427
|
return [
|
|
@@ -1437,38 +1451,38 @@ var field = function(e, C, w) {
|
|
|
1437
1451
|
]
|
|
1438
1452
|
];
|
|
1439
1453
|
}
|
|
1440
|
-
jacobianES(e,
|
|
1441
|
-
let [
|
|
1454
|
+
jacobianES(e, t) {
|
|
1455
|
+
let [n, r, i, a] = e, [o, s, c] = t;
|
|
1442
1456
|
return [
|
|
1443
1457
|
[
|
|
1444
|
-
2 *
|
|
1445
|
-
2 *
|
|
1446
|
-
2 *
|
|
1447
|
-
2 *
|
|
1458
|
+
2 * a * s - 2 * i * c,
|
|
1459
|
+
2 * i * s + 2 * a * c,
|
|
1460
|
+
2 * r * s - 2 * n * c - 4 * i * o,
|
|
1461
|
+
2 * n * s + 2 * r * c - 4 * a * o
|
|
1448
1462
|
],
|
|
1449
1463
|
[
|
|
1450
|
-
2 *
|
|
1451
|
-
2 *
|
|
1452
|
-
2 *
|
|
1453
|
-
2 *
|
|
1464
|
+
2 * r * c - 2 * a * o,
|
|
1465
|
+
2 * n * c - 4 * r * s + 2 * i * o,
|
|
1466
|
+
2 * r * o + 2 * a * c,
|
|
1467
|
+
2 * i * c - 2 * n * o - 4 * a * s
|
|
1454
1468
|
],
|
|
1455
1469
|
[
|
|
1456
|
-
2 *
|
|
1457
|
-
2 *
|
|
1458
|
-
2 *
|
|
1459
|
-
2 *
|
|
1470
|
+
2 * i * o - 2 * r * s,
|
|
1471
|
+
2 * a * o - 4 * r * c - 2 * n * s,
|
|
1472
|
+
2 * n * o - 4 * i * c + 2 * a * s,
|
|
1473
|
+
2 * r * o + 2 * i * s
|
|
1460
1474
|
]
|
|
1461
1475
|
];
|
|
1462
1476
|
}
|
|
1463
|
-
},
|
|
1477
|
+
}, B = new class extends j {
|
|
1464
1478
|
getName = () => "IMU";
|
|
1465
1479
|
availability() {
|
|
1466
|
-
return
|
|
1480
|
+
return S.isMobile ? Promise.resolve() : Promise.resolve(new Ae());
|
|
1467
1481
|
}
|
|
1468
1482
|
start() {
|
|
1469
|
-
let e = () => window.addEventListener("devicemotion", this.parseDeviceMotionEvent, !0),
|
|
1470
|
-
|
|
1471
|
-
if (
|
|
1483
|
+
let e = () => window.addEventListener("devicemotion", this.parseDeviceMotionEvent, !0), t = DeviceMotionEvent.requestPermission || void 0;
|
|
1484
|
+
t ? t().then((t) => {
|
|
1485
|
+
if (t !== "granted") throw Error("Permission not granted");
|
|
1472
1486
|
e();
|
|
1473
1487
|
}).catch(this.notifyError) : e();
|
|
1474
1488
|
}
|
|
@@ -1476,174 +1490,174 @@ var field = function(e, C, w) {
|
|
|
1476
1490
|
window.removeEventListener("devicemotion", this.parseDeviceMotionEvent, !0);
|
|
1477
1491
|
}
|
|
1478
1492
|
parseDeviceMotionEvent = (e) => {
|
|
1479
|
-
let
|
|
1493
|
+
let t = e.timeStamp / 1e3, n;
|
|
1480
1494
|
if (e.accelerationIncludingGravity) {
|
|
1481
|
-
let { x:
|
|
1482
|
-
typeof
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
], (
|
|
1495
|
+
let { x: t, y: r, z: i } = e.accelerationIncludingGravity;
|
|
1496
|
+
typeof t == "number" && typeof r == "number" && typeof i == "number" && (n = [
|
|
1497
|
+
t,
|
|
1498
|
+
r,
|
|
1499
|
+
i
|
|
1500
|
+
], (S.getName() === x.SAFARI || S.getName() === x.IOS_WEBVIEW) && (n[0] *= -1, n[1] *= -1, n[2] *= -1));
|
|
1487
1501
|
}
|
|
1488
|
-
let
|
|
1502
|
+
let r;
|
|
1489
1503
|
if (e.rotationRate) {
|
|
1490
|
-
let { alpha:
|
|
1491
|
-
typeof
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1504
|
+
let { alpha: t, beta: n, gamma: i } = e.rotationRate;
|
|
1505
|
+
typeof t == "number" && typeof n == "number" && typeof i == "number" && (r = [
|
|
1506
|
+
m(t),
|
|
1507
|
+
m(n),
|
|
1508
|
+
m(i)
|
|
1495
1509
|
]);
|
|
1496
1510
|
}
|
|
1497
|
-
(
|
|
1498
|
-
...
|
|
1499
|
-
timestamp:
|
|
1500
|
-
values:
|
|
1511
|
+
(n || r) && this.notify({
|
|
1512
|
+
...n && { acceleration: {
|
|
1513
|
+
timestamp: t,
|
|
1514
|
+
values: n
|
|
1501
1515
|
} },
|
|
1502
|
-
...
|
|
1503
|
-
timestamp:
|
|
1504
|
-
values:
|
|
1516
|
+
...r && { angularRate: {
|
|
1517
|
+
timestamp: t,
|
|
1518
|
+
values: r
|
|
1505
1519
|
} }
|
|
1506
1520
|
});
|
|
1507
1521
|
};
|
|
1508
|
-
}(),
|
|
1522
|
+
}(), Ue = class e extends R {
|
|
1509
1523
|
static DEFAULT_MESSAGE = "Impossible to retrieve Acceleration data";
|
|
1510
|
-
constructor(
|
|
1511
|
-
super(
|
|
1524
|
+
constructor(t) {
|
|
1525
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
1512
1526
|
}
|
|
1513
|
-
},
|
|
1527
|
+
}, V = new class extends j {
|
|
1514
1528
|
imuProviderId;
|
|
1515
1529
|
getName = () => "Accelerometer";
|
|
1516
|
-
availability = () =>
|
|
1530
|
+
availability = () => B.getAvailability();
|
|
1517
1531
|
start() {
|
|
1518
|
-
this.imuProviderId =
|
|
1519
|
-
e.acceleration ? this.notify(e.acceleration) : this.notifyError(new
|
|
1532
|
+
this.imuProviderId = B.addEventListener((e) => {
|
|
1533
|
+
e.acceleration ? this.notify(e.acceleration) : this.notifyError(new Ue().from("devicemotion"));
|
|
1520
1534
|
}, this.notifyError);
|
|
1521
1535
|
}
|
|
1522
1536
|
stop() {
|
|
1523
|
-
|
|
1537
|
+
B.removeEventListener(this.imuProviderId);
|
|
1524
1538
|
}
|
|
1525
|
-
}(),
|
|
1539
|
+
}(), We = class extends R {
|
|
1526
1540
|
static DEFAULT_MESSAGE = "Impossible to retrieve Angular Rate data";
|
|
1527
1541
|
constructor(e) {
|
|
1528
|
-
super(e ||
|
|
1542
|
+
super(e || R.DEFAULT_MESSAGE);
|
|
1529
1543
|
}
|
|
1530
|
-
},
|
|
1544
|
+
}, H = new class extends j {
|
|
1531
1545
|
imuProviderId;
|
|
1532
1546
|
getName = () => "Gyroscope";
|
|
1533
|
-
availability = () =>
|
|
1547
|
+
availability = () => B.getAvailability();
|
|
1534
1548
|
start() {
|
|
1535
|
-
this.imuProviderId =
|
|
1536
|
-
e.angularRate ? this.notify(e.angularRate) : this.notifyError(new
|
|
1549
|
+
this.imuProviderId = B.addEventListener((e) => {
|
|
1550
|
+
e.angularRate ? this.notify(e.angularRate) : this.notifyError(new We().from("devicemotion"));
|
|
1537
1551
|
}, this.notifyError);
|
|
1538
1552
|
}
|
|
1539
1553
|
stop() {
|
|
1540
|
-
|
|
1554
|
+
B.removeEventListener(this.imuProviderId);
|
|
1541
1555
|
}
|
|
1542
|
-
}(),
|
|
1543
|
-
static DEFAULT_DRIFT =
|
|
1556
|
+
}(), Ge = new class e extends j {
|
|
1557
|
+
static DEFAULT_DRIFT = m(5) / 60;
|
|
1544
1558
|
accelerometerProviderId;
|
|
1545
|
-
ekfAttitude = new
|
|
1559
|
+
ekfAttitude = new He();
|
|
1546
1560
|
gyroscopeEvent;
|
|
1547
1561
|
gyroscopeProviderId;
|
|
1548
1562
|
lastTimestamp = 0;
|
|
1549
1563
|
getName = () => "RelativeAttitudeFromEkf";
|
|
1550
1564
|
availability() {
|
|
1551
|
-
return
|
|
1565
|
+
return M.every([V.getAvailability(), H.getAvailability()]);
|
|
1552
1566
|
}
|
|
1553
1567
|
start() {
|
|
1554
|
-
this.accelerometerProviderId =
|
|
1568
|
+
this.accelerometerProviderId = V.addEventListener((e) => this.onAccelerometerEvent(e), (e) => this.notifyError(e)), this.gyroscopeProviderId = H.addEventListener((e) => this.gyroscopeEvent = e, (e) => this.notifyError(e));
|
|
1555
1569
|
}
|
|
1556
1570
|
stop() {
|
|
1557
|
-
|
|
1571
|
+
V.removeEventListener(this.accelerometerProviderId), H.removeEventListener(this.gyroscopeProviderId);
|
|
1558
1572
|
}
|
|
1559
|
-
onAccelerometerEvent = (
|
|
1573
|
+
onAccelerometerEvent = (t) => {
|
|
1560
1574
|
if (!this.gyroscopeEvent) return;
|
|
1561
|
-
let { values:
|
|
1575
|
+
let { values: n, timestamp: r } = t;
|
|
1562
1576
|
if (this.lastTimestamp === 0) {
|
|
1563
|
-
this.lastTimestamp =
|
|
1577
|
+
this.lastTimestamp = r;
|
|
1564
1578
|
return;
|
|
1565
1579
|
}
|
|
1566
|
-
let
|
|
1567
|
-
this.lastTimestamp =
|
|
1568
|
-
let
|
|
1569
|
-
if (
|
|
1570
|
-
let
|
|
1571
|
-
this.notify(
|
|
1580
|
+
let i = r - this.lastTimestamp;
|
|
1581
|
+
this.lastTimestamp = r;
|
|
1582
|
+
let a = this.ekfAttitude.update(i, n, this.gyroscopeEvent.values);
|
|
1583
|
+
if (a) {
|
|
1584
|
+
let t = new ie(a, r, e.DEFAULT_DRIFT);
|
|
1585
|
+
this.notify(t);
|
|
1572
1586
|
}
|
|
1573
1587
|
};
|
|
1574
|
-
}(),
|
|
1575
|
-
static DEFAULT_DRIFT =
|
|
1588
|
+
}(), Ke = new class e extends j {
|
|
1589
|
+
static DEFAULT_DRIFT = m(5) / 60;
|
|
1576
1590
|
getName = () => "RelativeAttitudeFromBrowser";
|
|
1577
1591
|
availability() {
|
|
1578
|
-
return
|
|
1592
|
+
return S.isMobile ? Promise.resolve() : Promise.resolve(new Ae());
|
|
1579
1593
|
}
|
|
1580
1594
|
start() {
|
|
1581
|
-
let e = () => window.addEventListener("deviceorientation", this.onDeviceOrientationEvent, !0),
|
|
1582
|
-
|
|
1583
|
-
if (
|
|
1595
|
+
let e = () => window.addEventListener("deviceorientation", this.onDeviceOrientationEvent, !0), t = DeviceOrientationEvent.requestPermission || void 0;
|
|
1596
|
+
t ? t().then((t) => {
|
|
1597
|
+
if (t !== "granted") throw Error("Permission not granted");
|
|
1584
1598
|
e();
|
|
1585
1599
|
}).catch((e) => this.notifyError(e)) : e();
|
|
1586
1600
|
}
|
|
1587
1601
|
stop() {
|
|
1588
1602
|
window.removeEventListener("deviceorientation", this.onDeviceOrientationEvent, !0);
|
|
1589
1603
|
}
|
|
1590
|
-
onDeviceOrientationEvent = (
|
|
1591
|
-
if (typeof
|
|
1592
|
-
this.notifyError(new
|
|
1604
|
+
onDeviceOrientationEvent = (t) => {
|
|
1605
|
+
if (typeof t.alpha != "number" || typeof t.beta != "number" || typeof t.gamma != "number") {
|
|
1606
|
+
this.notifyError(new R().from("deviceorientation"));
|
|
1593
1607
|
return;
|
|
1594
1608
|
}
|
|
1595
|
-
let
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
]),
|
|
1600
|
-
this.notify(
|
|
1609
|
+
let n = new ie(d.eulerToQuaternionZXYDegrees([
|
|
1610
|
+
t.alpha,
|
|
1611
|
+
t.beta,
|
|
1612
|
+
t.gamma
|
|
1613
|
+
]), t.timeStamp / 1e3, e.DEFAULT_DRIFT);
|
|
1614
|
+
this.notify(n);
|
|
1601
1615
|
};
|
|
1602
|
-
}(),
|
|
1616
|
+
}(), U = new class e extends j {
|
|
1603
1617
|
static THRESHOLD = 10;
|
|
1604
1618
|
static DELAY_CONSIDERATION = 3;
|
|
1605
1619
|
gyroscopeProviderId;
|
|
1606
1620
|
getName = () => "HighRotationsProvider";
|
|
1607
|
-
availability = () =>
|
|
1621
|
+
availability = () => H.getAvailability();
|
|
1608
1622
|
start() {
|
|
1609
|
-
this.gyroscopeProviderId =
|
|
1623
|
+
this.gyroscopeProviderId = H.addEventListener(this._parseGyroscopeEvent, this.notifyError);
|
|
1610
1624
|
}
|
|
1611
1625
|
stop() {
|
|
1612
|
-
|
|
1626
|
+
H.removeEventListener(this.gyroscopeProviderId);
|
|
1613
1627
|
}
|
|
1614
1628
|
isInProgress() {
|
|
1615
|
-
return !this.lastEvent || !
|
|
1629
|
+
return !this.lastEvent || !H.lastEvent ? !1 : H.lastEvent.timestamp - this.lastEvent.timestamp < e.DELAY_CONSIDERATION;
|
|
1616
1630
|
}
|
|
1617
|
-
_parseGyroscopeEvent = (
|
|
1618
|
-
let { values:
|
|
1619
|
-
|
|
1631
|
+
_parseGyroscopeEvent = (t) => {
|
|
1632
|
+
let { values: n, timestamp: r } = t;
|
|
1633
|
+
p.norm(n) > e.THRESHOLD && this.notify({ timestamp: r });
|
|
1620
1634
|
};
|
|
1621
|
-
}(),
|
|
1622
|
-
static DEFAULT_DRIFT =
|
|
1635
|
+
}(), W = new class e extends j {
|
|
1636
|
+
static DEFAULT_DRIFT = m(5) / 60;
|
|
1623
1637
|
_highRotationsProviderId;
|
|
1624
1638
|
listenerId;
|
|
1625
1639
|
provider;
|
|
1626
1640
|
getName = () => "RelativeAttitudeFromInertial";
|
|
1627
1641
|
availability() {
|
|
1628
|
-
return
|
|
1642
|
+
return M.some([Ge.getAvailability(), Ke.getAvailability()]);
|
|
1629
1643
|
}
|
|
1630
1644
|
start() {
|
|
1631
|
-
|
|
1632
|
-
this.provider = e ?
|
|
1645
|
+
Ge.getAvailability().then((e) => {
|
|
1646
|
+
this.provider = e ? Ke : Ge, this.listenerId = this.provider.addEventListener((e) => this._parseEvent(e), this.notifyError), this._highRotationsProviderId = U.addEventListener(null, this.notifyError);
|
|
1633
1647
|
});
|
|
1634
1648
|
}
|
|
1635
|
-
_parseEvent(
|
|
1636
|
-
let
|
|
1637
|
-
if (
|
|
1638
|
-
let
|
|
1639
|
-
|
|
1649
|
+
_parseEvent(t) {
|
|
1650
|
+
let n = t.clone();
|
|
1651
|
+
if (U.isInProgress()) {
|
|
1652
|
+
let t = (n.accuracy || 0) + e.DEFAULT_DRIFT * 100;
|
|
1653
|
+
t = Math.min(t, Math.PI), n.accuracy = t;
|
|
1640
1654
|
}
|
|
1641
|
-
this.notify(
|
|
1655
|
+
this.notify(n);
|
|
1642
1656
|
}
|
|
1643
1657
|
stop() {
|
|
1644
|
-
this.provider && (this.provider.removeEventListener(this.listenerId), delete this.provider),
|
|
1658
|
+
this.provider && (this.provider.removeEventListener(this.listenerId), delete this.provider), U.removeEventListener(this._highRotationsProviderId);
|
|
1645
1659
|
}
|
|
1646
|
-
}(),
|
|
1660
|
+
}(), qe = class e {
|
|
1647
1661
|
static MIN_TIME_BETWEEN_STEPS = .4;
|
|
1648
1662
|
static MAX_FRENQUENCY = 4;
|
|
1649
1663
|
static MIN_FRENQUENCY = 1;
|
|
@@ -1652,15 +1666,15 @@ var field = function(e, C, w) {
|
|
|
1652
1666
|
lastVerticalAcc = 0;
|
|
1653
1667
|
maxAcceleration = 0;
|
|
1654
1668
|
lastStepTimestamp = -e.MIN_TIME_BETWEEN_STEPS;
|
|
1655
|
-
compute(
|
|
1656
|
-
let
|
|
1657
|
-
if (
|
|
1658
|
-
else if (this.maxAcceleration > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD &&
|
|
1669
|
+
compute(t, n) {
|
|
1670
|
+
let r = !1, i = n[2], a = t - this.lastStepTimestamp;
|
|
1671
|
+
if (i > this.lastVerticalAcc) i > this.maxAcceleration && (this.maxAcceleration = i);
|
|
1672
|
+
else if (this.maxAcceleration > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && a > e.MIN_TIME_BETWEEN_STEPS) {
|
|
1659
1673
|
this.maxAcceleration = 0;
|
|
1660
|
-
let
|
|
1661
|
-
this.frequency = Math.min(Math.max(1 /
|
|
1674
|
+
let n = t - this.lastStepTimestamp;
|
|
1675
|
+
this.frequency = Math.min(Math.max(1 / n, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), r = !0, this.lastStepTimestamp = t;
|
|
1662
1676
|
} else this.maxAcceleration = 0;
|
|
1663
|
-
return this.lastVerticalAcc =
|
|
1677
|
+
return this.lastVerticalAcc = i, r;
|
|
1664
1678
|
}
|
|
1665
1679
|
get lastStepSize() {
|
|
1666
1680
|
return this.frequency ? .45 + .2 * this.frequency : 0;
|
|
@@ -1668,7 +1682,7 @@ var field = function(e, C, w) {
|
|
|
1668
1682
|
get speed() {
|
|
1669
1683
|
return this.lastStepTimestamp ? this.lastStepSize * this.frequency : 0;
|
|
1670
1684
|
}
|
|
1671
|
-
},
|
|
1685
|
+
}, Je = class e {
|
|
1672
1686
|
static WINDOW_TIME = .3;
|
|
1673
1687
|
static MIN_TIME_BETWEEN_STEPS = .4;
|
|
1674
1688
|
static MAX_FRENQUENCY = 4;
|
|
@@ -1678,17 +1692,17 @@ var field = function(e, C, w) {
|
|
|
1678
1692
|
frequency = 0;
|
|
1679
1693
|
lastStepTimestamp = -e.MIN_TIME_BETWEEN_STEPS;
|
|
1680
1694
|
slidingWindow = [];
|
|
1681
|
-
compute(
|
|
1682
|
-
if (this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS >
|
|
1683
|
-
let
|
|
1684
|
-
if (this.slidingWindow.forEach((e,
|
|
1685
|
-
e.timestamp <
|
|
1695
|
+
compute(t, n) {
|
|
1696
|
+
if (this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS > t) return !1;
|
|
1697
|
+
let r = -(2 ** 53 - 1), i = 2 ** 53 - 1, a = e.WINDOW_TIME;
|
|
1698
|
+
if (this.slidingWindow.forEach((e, n, o) => {
|
|
1699
|
+
e.timestamp < t - a ? o.splice(n, 1) : (r = Math.max(e.verticalAcc, r), i = Math.min(e.verticalAcc, i));
|
|
1686
1700
|
}), this.slidingWindow.push({
|
|
1687
|
-
timestamp:
|
|
1688
|
-
verticalAcc:
|
|
1689
|
-
}),
|
|
1690
|
-
let
|
|
1691
|
-
return this.frequency = Math.min(Math.max(1 /
|
|
1701
|
+
timestamp: t,
|
|
1702
|
+
verticalAcc: n[2]
|
|
1703
|
+
}), r > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && i < e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
|
|
1704
|
+
let n = this.lastStepTimestamp ? t - this.lastStepTimestamp : 1;
|
|
1705
|
+
return this.frequency = Math.min(Math.max(1 / n, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), this.lastStepTimestamp = t, !0;
|
|
1692
1706
|
}
|
|
1693
1707
|
return !1;
|
|
1694
1708
|
}
|
|
@@ -1698,7 +1712,7 @@ var field = function(e, C, w) {
|
|
|
1698
1712
|
get speed() {
|
|
1699
1713
|
return this.lastStepTimestamp ? this.lastStepSize * this.frequency : 0;
|
|
1700
1714
|
}
|
|
1701
|
-
},
|
|
1715
|
+
}, Ye = class e {
|
|
1702
1716
|
static WINDOW_TIME = .3;
|
|
1703
1717
|
static MIN_TIME_BETWEEN_STEPS = .4;
|
|
1704
1718
|
static MAX_FRENQUENCY = 4;
|
|
@@ -1710,18 +1724,18 @@ var field = function(e, C, w) {
|
|
|
1710
1724
|
slidingWindow = [];
|
|
1711
1725
|
lastStepTimestamp = -e.MIN_TIME_BETWEEN_STEPS;
|
|
1712
1726
|
previousVerticalAcc = 0;
|
|
1713
|
-
compute(
|
|
1714
|
-
let
|
|
1715
|
-
if (this.previousVerticalAcc =
|
|
1716
|
-
let
|
|
1717
|
-
if (this.slidingWindow.forEach((
|
|
1718
|
-
|
|
1727
|
+
compute(t, n, r) {
|
|
1728
|
+
let i = this.influence * (n[2] * 2) + (1 - this.influence) * this.previousVerticalAcc;
|
|
1729
|
+
if (this.previousVerticalAcc = i, Math.sqrt(r[0] ** 2 + r[1] ** 2 + r[2] ** 2) > .75 || this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS > t) return !1;
|
|
1730
|
+
let a = -(2 ** 53 - 1), o = 2 ** 53 - 1;
|
|
1731
|
+
if (this.slidingWindow.forEach((n, r, i) => {
|
|
1732
|
+
n.timestamp < t - e.WINDOW_TIME ? i.splice(r, 1) : (a = Math.max(n.verticalAcc, a), o = Math.min(n.verticalAcc, o));
|
|
1719
1733
|
}), this.slidingWindow.push({
|
|
1720
|
-
timestamp:
|
|
1721
|
-
verticalAcc:
|
|
1722
|
-
}),
|
|
1723
|
-
let
|
|
1724
|
-
return this.frequency = Math.min(Math.max(1 /
|
|
1734
|
+
timestamp: t,
|
|
1735
|
+
verticalAcc: i
|
|
1736
|
+
}), a > e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && o < e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
|
|
1737
|
+
let n = this.lastStepTimestamp ? t - this.lastStepTimestamp : 1;
|
|
1738
|
+
return this.frequency = Math.min(Math.max(1 / n, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), this.lastStepTimestamp = t, !0;
|
|
1725
1739
|
}
|
|
1726
1740
|
return !1;
|
|
1727
1741
|
}
|
|
@@ -1732,16 +1746,16 @@ var field = function(e, C, w) {
|
|
|
1732
1746
|
return this.lastStepSize && this.frequency ? this.lastStepSize * this.frequency : 0;
|
|
1733
1747
|
}
|
|
1734
1748
|
mean(e) {
|
|
1735
|
-
let
|
|
1736
|
-
for (let
|
|
1737
|
-
return
|
|
1749
|
+
let t = 0, n = 0;
|
|
1750
|
+
for (let n = 0; n < e.length; ++n) t += e[n].verticalAcc;
|
|
1751
|
+
return n = t / e.length, n;
|
|
1738
1752
|
}
|
|
1739
1753
|
stddev(e) {
|
|
1740
|
-
let
|
|
1741
|
-
for (let
|
|
1742
|
-
return Math.sqrt(
|
|
1754
|
+
let t = this.mean(e), n = 0;
|
|
1755
|
+
for (let r = 0; r < e.length; ++r) n += (e[r].verticalAcc - t) ** 2;
|
|
1756
|
+
return Math.sqrt(n / e.length);
|
|
1743
1757
|
}
|
|
1744
|
-
},
|
|
1758
|
+
}, Xe = class e {
|
|
1745
1759
|
static WINDOW_TIME = .6;
|
|
1746
1760
|
static MIN_TIME_BETWEEN_STEPS = .6;
|
|
1747
1761
|
static MAX_FRENQUENCY = 4;
|
|
@@ -1754,33 +1768,33 @@ var field = function(e, C, w) {
|
|
|
1754
1768
|
lastStepTimestamp = -e.MIN_TIME_BETWEEN_STEPS;
|
|
1755
1769
|
previousVerticalAcc = 0;
|
|
1756
1770
|
previousHorizontalAcc = 0;
|
|
1757
|
-
compute(
|
|
1758
|
-
let
|
|
1759
|
-
if (this.previousVerticalAcc =
|
|
1760
|
-
timestamp:
|
|
1761
|
-
verticalAcc:
|
|
1762
|
-
}), this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS >
|
|
1763
|
-
let
|
|
1764
|
-
if (this.slidingWindow.forEach((
|
|
1765
|
-
|
|
1766
|
-
}), !
|
|
1767
|
-
let
|
|
1768
|
-
for (let
|
|
1769
|
-
let
|
|
1770
|
-
if (
|
|
1771
|
-
|
|
1771
|
+
compute(t, n) {
|
|
1772
|
+
let r = this.influence * n[2] + (1 - this.influence) * this.previousVerticalAcc;
|
|
1773
|
+
if (this.previousVerticalAcc = r, this.slidingWindow = this.slidingWindow.filter((n) => n.timestamp >= t - e.WINDOW_TIME), this.slidingWindow.push({
|
|
1774
|
+
timestamp: t,
|
|
1775
|
+
verticalAcc: r
|
|
1776
|
+
}), this.lastStepTimestamp && this.lastStepTimestamp + e.MIN_TIME_BETWEEN_STEPS > t) return !1;
|
|
1777
|
+
let i = Number.MIN_VALUE, a = -1, o = !1;
|
|
1778
|
+
if (this.slidingWindow.forEach((t, n) => {
|
|
1779
|
+
t.verticalAcc > i && t.verticalAcc >= e.VERTICAL_ACC_POSITIVE_PEAK_THRESHOLD && (i = t.verticalAcc, a = n, o = !0);
|
|
1780
|
+
}), !o) return !1;
|
|
1781
|
+
let s = !1, c = Number.MAX_VALUE;
|
|
1782
|
+
for (let t = 0; t < a; t++) {
|
|
1783
|
+
let n = this.slidingWindow[t].verticalAcc;
|
|
1784
|
+
if (c = Math.min(c, n), n < e.VERTICAL_ACC_NEGATIVE_PEAK_THRESHOLD) {
|
|
1785
|
+
s = !0;
|
|
1772
1786
|
break;
|
|
1773
1787
|
}
|
|
1774
1788
|
}
|
|
1775
|
-
if (!
|
|
1776
|
-
let
|
|
1777
|
-
for (let e =
|
|
1778
|
-
|
|
1789
|
+
if (!s) return !1;
|
|
1790
|
+
let l = i - c, u = i - .5 * l, d = !1;
|
|
1791
|
+
for (let e = a + 1; e < this.slidingWindow.length; e++) if (this.slidingWindow[e].verticalAcc <= u) {
|
|
1792
|
+
d = !0;
|
|
1779
1793
|
break;
|
|
1780
1794
|
}
|
|
1781
|
-
if (!
|
|
1782
|
-
let
|
|
1783
|
-
return this.frequency = Math.min(Math.max(1 /
|
|
1795
|
+
if (!d) return !1;
|
|
1796
|
+
let f = this.lastStepTimestamp ? t - this.lastStepTimestamp : 1;
|
|
1797
|
+
return this.frequency = Math.min(Math.max(1 / f, e.MIN_FRENQUENCY), e.MAX_FRENQUENCY), this.lastStepTimestamp = t, !0;
|
|
1784
1798
|
}
|
|
1785
1799
|
get lastStepSize() {
|
|
1786
1800
|
return this.frequency ? .45 + .2 * this.frequency : 0;
|
|
@@ -1789,16 +1803,16 @@ var field = function(e, C, w) {
|
|
|
1789
1803
|
return this.lastStepSize && this.frequency ? this.lastStepSize * this.frequency : 0;
|
|
1790
1804
|
}
|
|
1791
1805
|
mean(e) {
|
|
1792
|
-
let
|
|
1793
|
-
for (let
|
|
1794
|
-
return
|
|
1806
|
+
let t = 0, n = 0;
|
|
1807
|
+
for (let n = 0; n < e.length; ++n) t += e[n];
|
|
1808
|
+
return n = t / e.length, n;
|
|
1795
1809
|
}
|
|
1796
1810
|
stddev(e) {
|
|
1797
|
-
let
|
|
1798
|
-
for (let
|
|
1799
|
-
return Math.sqrt(
|
|
1811
|
+
let t = this.mean(e), n = 0;
|
|
1812
|
+
for (let r = 0; r < e.length; ++r) n += (e[r] - t) ** 2;
|
|
1813
|
+
return Math.sqrt(n / e.length);
|
|
1800
1814
|
}
|
|
1801
|
-
},
|
|
1815
|
+
}, G = new class e extends j {
|
|
1802
1816
|
static DEFAULT_STEP_SIZE_MULTIPLIER = 1;
|
|
1803
1817
|
static DEFAULT_ALGORITHM = "minMaxPeaks3";
|
|
1804
1818
|
accelerometerProviderId;
|
|
@@ -1816,22 +1830,22 @@ var field = function(e, C, w) {
|
|
|
1816
1830
|
}
|
|
1817
1831
|
getName = () => "StepDetector";
|
|
1818
1832
|
availability() {
|
|
1819
|
-
return
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1833
|
+
return M.every([
|
|
1834
|
+
V.getAvailability(),
|
|
1835
|
+
H.getAvailability(),
|
|
1836
|
+
W.getAvailability()
|
|
1823
1837
|
]);
|
|
1824
1838
|
}
|
|
1825
1839
|
start() {
|
|
1826
|
-
this.numOfSteps = 0, this.accelerometerProviderId =
|
|
1840
|
+
this.numOfSteps = 0, this.accelerometerProviderId = V.addEventListener(this.onAccelerometerEvent, this.notifyError), this.gyroscopeProviderId = H.addEventListener((e) => this.angularRateEvent = e, this.notifyError), this.attitudeProviderId = W.addEventListener((e) => this.attitudeEvent = e, this.notifyError);
|
|
1827
1841
|
}
|
|
1828
1842
|
stop() {
|
|
1829
|
-
|
|
1843
|
+
V.removeEventListener(this.accelerometerProviderId), H.removeEventListener(this.gyroscopeProviderId), W.removeEventListener(this.attitudeProviderId);
|
|
1830
1844
|
}
|
|
1831
|
-
onAccelerometerEvent = (
|
|
1845
|
+
onAccelerometerEvent = (t) => {
|
|
1832
1846
|
if (!this.attitudeEvent || !this.angularRateEvent) return;
|
|
1833
|
-
let { values:
|
|
1834
|
-
if (this.stepDetector.compute(
|
|
1847
|
+
let { values: n, timestamp: r } = t, i = e.computeLinearAcceleration(this.attitudeEvent.quaternion, n);
|
|
1848
|
+
if (this.stepDetector.compute(r, i, this.angularRateEvent.values)) {
|
|
1835
1849
|
let e = this.stepDetector.lastStepSize * this._stepSizeMultiplier;
|
|
1836
1850
|
this.numOfSteps++, this.notify({
|
|
1837
1851
|
size: e,
|
|
@@ -1839,9 +1853,9 @@ var field = function(e, C, w) {
|
|
|
1839
1853
|
});
|
|
1840
1854
|
}
|
|
1841
1855
|
};
|
|
1842
|
-
static computeLinearAcceleration(e,
|
|
1843
|
-
let
|
|
1844
|
-
return
|
|
1856
|
+
static computeLinearAcceleration(e, t) {
|
|
1857
|
+
let r = u.rotateMatlab(u.inverse(e), t);
|
|
1858
|
+
return r[2] -= n.EARTH_GRAVITY, r;
|
|
1845
1859
|
}
|
|
1846
1860
|
set stepSizeMultiplier(e) {
|
|
1847
1861
|
this._stepSizeMultiplier = e;
|
|
@@ -1852,17 +1866,16 @@ var field = function(e, C, w) {
|
|
|
1852
1866
|
set algorithm(e) {
|
|
1853
1867
|
switch (e) {
|
|
1854
1868
|
case "ladetto":
|
|
1855
|
-
this.stepDetector = new
|
|
1869
|
+
this.stepDetector = new qe();
|
|
1856
1870
|
break;
|
|
1857
1871
|
case "minMaxPeaks":
|
|
1858
|
-
this.stepDetector = new
|
|
1872
|
+
this.stepDetector = new Je();
|
|
1859
1873
|
break;
|
|
1860
1874
|
case "minMaxPeaks2":
|
|
1861
|
-
this.stepDetector = new
|
|
1875
|
+
this.stepDetector = new Ye();
|
|
1862
1876
|
break;
|
|
1863
|
-
case "minMaxPeaks3":
|
|
1864
1877
|
default:
|
|
1865
|
-
e = "minMaxPeaks3", this.stepDetector = new
|
|
1878
|
+
e = "minMaxPeaks3", this.stepDetector = new Xe();
|
|
1866
1879
|
break;
|
|
1867
1880
|
}
|
|
1868
1881
|
this._algorithm = e;
|
|
@@ -1870,42 +1883,43 @@ var field = function(e, C, w) {
|
|
|
1870
1883
|
get algorithm() {
|
|
1871
1884
|
return this._algorithm;
|
|
1872
1885
|
}
|
|
1873
|
-
}(),
|
|
1886
|
+
}(), Ze = new class extends j {
|
|
1874
1887
|
absoluteAttitudeProviderId;
|
|
1875
1888
|
stepDetectionProviderId;
|
|
1876
1889
|
attitudeEvent;
|
|
1877
|
-
misalignmentError =
|
|
1890
|
+
misalignmentError = m(3);
|
|
1878
1891
|
getName = () => "Pdr";
|
|
1879
1892
|
availability() {
|
|
1880
|
-
return
|
|
1893
|
+
return M.every([G.getAvailability(), X.getAvailability()]);
|
|
1881
1894
|
}
|
|
1882
1895
|
start() {
|
|
1883
|
-
this.stepDetectionProviderId =
|
|
1896
|
+
this.stepDetectionProviderId = G.addEventListener(this.onStepEvent, this.notifyError), this.absoluteAttitudeProviderId = X.addEventListener((e) => this.attitudeEvent = e, this.notifyError);
|
|
1884
1897
|
}
|
|
1885
1898
|
stop() {
|
|
1886
|
-
|
|
1899
|
+
G.removeEventListener(this.stepDetectionProviderId), X.removeEventListener(this.absoluteAttitudeProviderId);
|
|
1887
1900
|
}
|
|
1888
1901
|
onStepEvent = (e) => {
|
|
1889
1902
|
if (!this.attitudeEvent) return;
|
|
1890
|
-
let
|
|
1891
|
-
this.notify(
|
|
1903
|
+
let t = e.size, n = this.attitudeEvent, i = n.heading, a = n.accuracy + this.misalignmentError, o = t / 2 * Math.sin(a / 2), s = n.time, c = new r(t * Math.sin(i), t * Math.cos(i), 0, s, o, i);
|
|
1904
|
+
this.notify(c);
|
|
1892
1905
|
};
|
|
1893
|
-
}(),
|
|
1906
|
+
}(), Qe = new class extends j {
|
|
1894
1907
|
providerId;
|
|
1895
1908
|
geoRelativeProvider;
|
|
1896
1909
|
getName = () => "GeoRelativePosition";
|
|
1897
1910
|
availability() {
|
|
1898
|
-
return
|
|
1911
|
+
return M.some([Ze.getAvailability(), ze.getAvailability()]);
|
|
1899
1912
|
}
|
|
1900
1913
|
async start() {
|
|
1901
|
-
|
|
1914
|
+
let e = await ze.getAvailability();
|
|
1915
|
+
this.geoRelativeProvider = e ? Ze : ze, this.providerId = this.geoRelativeProvider.addEventListener(this.notify, this.notifyError);
|
|
1902
1916
|
}
|
|
1903
1917
|
stop() {
|
|
1904
1918
|
this.geoRelativeProvider?.removeEventListener(this.providerId), delete this.geoRelativeProvider;
|
|
1905
1919
|
}
|
|
1906
|
-
}(),
|
|
1920
|
+
}(), $e = {
|
|
1907
1921
|
name: "@wemap/providers",
|
|
1908
|
-
version: "14.6.0-beta.
|
|
1922
|
+
version: "14.6.0-beta.5",
|
|
1909
1923
|
description: "Sensor, positioning and VPS providers for the Wemap SDK.",
|
|
1910
1924
|
license: "UNLICENSED",
|
|
1911
1925
|
author: "Wemap SAS",
|
|
@@ -1933,88 +1947,88 @@ var field = function(e, C, w) {
|
|
|
1933
1947
|
sideEffects: !1,
|
|
1934
1948
|
files: ["dist"],
|
|
1935
1949
|
dependencies: {
|
|
1936
|
-
"@wemap/camera": "14.6.0-beta.
|
|
1937
|
-
"@wemap/core": "14.6.0-beta.
|
|
1938
|
-
"@wemap/geo": "14.6.0-beta.
|
|
1939
|
-
"@wemap/maths": "14.6.0-beta.
|
|
1940
|
-
"@wemap/osm": "14.6.0-beta.
|
|
1941
|
-
"@wemap/routers": "14.6.0-beta.
|
|
1942
|
-
"@wemap/utils": "14.6.0-beta.
|
|
1950
|
+
"@wemap/camera": "14.6.0-beta.5",
|
|
1951
|
+
"@wemap/core": "14.6.0-beta.5",
|
|
1952
|
+
"@wemap/geo": "14.6.0-beta.5",
|
|
1953
|
+
"@wemap/maths": "14.6.0-beta.5",
|
|
1954
|
+
"@wemap/osm": "14.6.0-beta.5",
|
|
1955
|
+
"@wemap/routers": "14.6.0-beta.5",
|
|
1956
|
+
"@wemap/utils": "14.6.0-beta.5"
|
|
1943
1957
|
},
|
|
1944
1958
|
devDependencies: {
|
|
1945
1959
|
"@wemap/logger-legacy": "^13.3.0",
|
|
1946
1960
|
geomag: "^1.0.0"
|
|
1947
1961
|
}
|
|
1948
|
-
},
|
|
1962
|
+
}, et = new class extends j {
|
|
1949
1963
|
providerId;
|
|
1950
1964
|
getName = () => "InclinationFromAcc";
|
|
1951
|
-
availability = () =>
|
|
1965
|
+
availability = () => V.getAvailability();
|
|
1952
1966
|
start() {
|
|
1953
|
-
this.providerId =
|
|
1967
|
+
this.providerId = V.addEventListener(this.onAccelerometerEvent, this.notifyError);
|
|
1954
1968
|
}
|
|
1955
1969
|
stop() {
|
|
1956
|
-
|
|
1970
|
+
V.removeEventListener(this.providerId);
|
|
1957
1971
|
}
|
|
1958
1972
|
onAccelerometerEvent = (e) => {
|
|
1959
|
-
let
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
],
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
-
|
|
1973
|
+
let t = e.values, n = window.orientation || 0, r = Math.sqrt(t[0] * t[0] + t[1] * t[1] + t[2] * t[2]), i = [
|
|
1974
|
+
t[0] / r,
|
|
1975
|
+
t[1] / r,
|
|
1976
|
+
t[2] / r
|
|
1977
|
+
], a = [
|
|
1978
|
+
i[2] + 1,
|
|
1979
|
+
i[1],
|
|
1980
|
+
-i[0],
|
|
1967
1981
|
0
|
|
1968
|
-
],
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1982
|
+
], o = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]), s = [
|
|
1983
|
+
a[0] / o,
|
|
1984
|
+
a[1] / o,
|
|
1985
|
+
a[2] / o,
|
|
1972
1986
|
0
|
|
1973
|
-
],
|
|
1974
|
-
|
|
1987
|
+
], c;
|
|
1988
|
+
c = n === 0 ? Math.asin(2 * s[1] * s[0]) : n === 90 ? -Math.asin(2 * s[2] * s[0]) : n === -90 ? Math.asin(2 * s[2] * s[0]) : -Math.asin(2 * s[1] * s[0]), this.notify(c);
|
|
1975
1989
|
};
|
|
1976
|
-
}(),
|
|
1990
|
+
}(), tt = new class extends j {
|
|
1977
1991
|
providerId;
|
|
1978
1992
|
getName = () => "InclinationFromRelativeAttitude";
|
|
1979
|
-
availability = () =>
|
|
1993
|
+
availability = () => W.getAvailability();
|
|
1980
1994
|
start() {
|
|
1981
|
-
this.providerId =
|
|
1982
|
-
let
|
|
1983
|
-
this.notify(
|
|
1995
|
+
this.providerId = W.addEventListener((e) => {
|
|
1996
|
+
let t = this.enuQuatToInclination(e.quaternion);
|
|
1997
|
+
this.notify(t);
|
|
1984
1998
|
}, this.notifyError);
|
|
1985
1999
|
}
|
|
1986
2000
|
stop() {
|
|
1987
|
-
|
|
2001
|
+
W.removeEventListener(this.providerId);
|
|
1988
2002
|
}
|
|
1989
2003
|
enuQuatToInclination(e) {
|
|
1990
|
-
let
|
|
1991
|
-
return
|
|
2004
|
+
let t = window.orientation || 0;
|
|
2005
|
+
return t === 0 ? Math.asin(2 * (e[2] * e[3] + e[1] * e[0])) : t === 90 ? Math.asin(2 * (e[1] * e[3] - e[2] * e[0])) : t === -90 ? Math.asin(2 * (e[2] * e[0] - e[1] * e[3])) : -Math.asin(2 * (e[2] * e[3] + e[1] * e[0]));
|
|
1992
2006
|
}
|
|
1993
|
-
}(),
|
|
2007
|
+
}(), K = new class extends j {
|
|
1994
2008
|
provider;
|
|
1995
2009
|
providerId;
|
|
1996
2010
|
getName = () => "Inclination";
|
|
1997
2011
|
availability() {
|
|
1998
|
-
return
|
|
2012
|
+
return M.some([et.getAvailability(), tt.getAvailability()]);
|
|
1999
2013
|
}
|
|
2000
2014
|
async start() {
|
|
2001
2015
|
let e = () => {
|
|
2002
|
-
this.provider =
|
|
2016
|
+
this.provider = et, this.providerId = this.provider.addEventListener(this.notify, this.notifyError);
|
|
2003
2017
|
};
|
|
2004
|
-
await
|
|
2005
|
-
|
|
2018
|
+
await tt.getAvailability() ? (this.provider = tt, this.providerId = this.provider.addEventListener(this.notify, () => {
|
|
2019
|
+
tt.removeEventListener(this.providerId), e();
|
|
2006
2020
|
})) : e();
|
|
2007
2021
|
}
|
|
2008
2022
|
stop() {
|
|
2009
2023
|
this.provider && this.provider.removeEventListener(this.providerId);
|
|
2010
2024
|
}
|
|
2011
|
-
}(),
|
|
2025
|
+
}(), nt = class e {
|
|
2012
2026
|
size;
|
|
2013
2027
|
calibration;
|
|
2014
2028
|
coarse;
|
|
2015
2029
|
device;
|
|
2016
|
-
constructor(e,
|
|
2017
|
-
this.size = e, this.calibration =
|
|
2030
|
+
constructor(e, t = null, n = null, r = null) {
|
|
2031
|
+
this.size = e, this.calibration = t, this.coarse = n, this.device = r;
|
|
2018
2032
|
}
|
|
2019
2033
|
toJson() {
|
|
2020
2034
|
return {
|
|
@@ -2027,47 +2041,47 @@ var field = function(e, C, w) {
|
|
|
2027
2041
|
...this.device !== null && { device: this.device }
|
|
2028
2042
|
};
|
|
2029
2043
|
}
|
|
2030
|
-
static fromJson(
|
|
2044
|
+
static fromJson(n) {
|
|
2031
2045
|
return new e({
|
|
2032
|
-
width:
|
|
2033
|
-
height:
|
|
2034
|
-
},
|
|
2035
|
-
...
|
|
2036
|
-
...
|
|
2037
|
-
},
|
|
2038
|
-
}
|
|
2039
|
-
},
|
|
2046
|
+
width: n.size[0],
|
|
2047
|
+
height: n.size[1]
|
|
2048
|
+
}, n.calibration, {
|
|
2049
|
+
...n.coarse?.position && { position: o.fromJson(n.coarse.position) },
|
|
2050
|
+
...n.coarse?.attitude && { attitude: t.fromJson(n.coarse.attitude) }
|
|
2051
|
+
}, n.device);
|
|
2052
|
+
}
|
|
2053
|
+
}, rt = class e {
|
|
2040
2054
|
metadata;
|
|
2041
2055
|
image;
|
|
2042
2056
|
imageQuality;
|
|
2043
2057
|
localPose;
|
|
2044
|
-
constructor(e,
|
|
2045
|
-
this.metadata = e, this.image =
|
|
2058
|
+
constructor(e, t, n = .8, r = null) {
|
|
2059
|
+
this.metadata = e, this.image = t, this.imageQuality = n, this.localPose = r;
|
|
2046
2060
|
}
|
|
2047
2061
|
toJson() {
|
|
2048
2062
|
return {
|
|
2049
|
-
image:
|
|
2063
|
+
image: te(this.image, "image/jpeg", this.imageQuality),
|
|
2050
2064
|
...this.localPose && { local_pose: this.localPose },
|
|
2051
2065
|
...this.metadata.toJson()
|
|
2052
2066
|
};
|
|
2053
2067
|
}
|
|
2054
|
-
static fromJson(
|
|
2055
|
-
return new e(
|
|
2068
|
+
static fromJson(t) {
|
|
2069
|
+
return new e(nt.fromJson(t), E(t.image));
|
|
2056
2070
|
}
|
|
2057
2071
|
toFormData() {
|
|
2058
|
-
let e = this.image.toDataURL("image/jpeg", this.imageQuality).split(",")[1] || "",
|
|
2059
|
-
for (let e = 0; e <
|
|
2060
|
-
let
|
|
2061
|
-
|
|
2062
|
-
let
|
|
2063
|
-
return
|
|
2064
|
-
}
|
|
2065
|
-
},
|
|
2072
|
+
let e = this.image.toDataURL("image/jpeg", this.imageQuality).split(",")[1] || "", t = atob(e), n = new Uint8Array(t.length);
|
|
2073
|
+
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
2074
|
+
let r = new FormData();
|
|
2075
|
+
r.append("image", new Blob([n], { type: "image/jpeg" }), "image.jpg");
|
|
2076
|
+
let i = this.metadata.toJson();
|
|
2077
|
+
return i.calibration && r.append("calibration", JSON.stringify(i.calibration)), i.coarse && r.append("coarse", JSON.stringify(i.coarse)), i.device && r.append("device", JSON.stringify(i.device)), this.localPose && r.append("local_pose", JSON.stringify(this.localPose)), r;
|
|
2078
|
+
}
|
|
2079
|
+
}, it = class e {
|
|
2066
2080
|
success;
|
|
2067
2081
|
attitude;
|
|
2068
2082
|
position;
|
|
2069
|
-
constructor(e,
|
|
2070
|
-
this.success = e, this.attitude =
|
|
2083
|
+
constructor(e, t = null, n = null) {
|
|
2084
|
+
this.success = e, this.attitude = t, this.position = n;
|
|
2071
2085
|
}
|
|
2072
2086
|
toJson() {
|
|
2073
2087
|
return {
|
|
@@ -2076,100 +2090,100 @@ var field = function(e, C, w) {
|
|
|
2076
2090
|
position: this.position?.toJson()
|
|
2077
2091
|
};
|
|
2078
2092
|
}
|
|
2079
|
-
static fromJson(
|
|
2080
|
-
let
|
|
2081
|
-
|
|
2082
|
-
let
|
|
2083
|
-
return
|
|
2084
|
-
}
|
|
2085
|
-
},
|
|
2086
|
-
static _prepareRequest(e,
|
|
2087
|
-
let
|
|
2088
|
-
return
|
|
2089
|
-
width:
|
|
2090
|
-
height:
|
|
2091
|
-
},
|
|
2092
|
-
}
|
|
2093
|
-
static async relocalize(e,
|
|
2094
|
-
let
|
|
2093
|
+
static fromJson(n, r = null) {
|
|
2094
|
+
let i = null;
|
|
2095
|
+
n.attitude && (i = t.fromJson(n.attitude), i.time = r);
|
|
2096
|
+
let a = null;
|
|
2097
|
+
return n.position && (a = o.fromJson(n.position), a.time = r), new e(n.success, i, a);
|
|
2098
|
+
}
|
|
2099
|
+
}, at = class {
|
|
2100
|
+
static _prepareRequest(e, t = null, n = null, r = null, i = null) {
|
|
2101
|
+
let a = ne(e, 720, 720), o = w.getDeviceFromUserAgent() || {};
|
|
2102
|
+
return r && (o.session_id = r.session_id, o.installation_id = r.installation_id, o.attempt_id = r.attempt_id, o.caller = r.caller), new rt(new nt({
|
|
2103
|
+
width: a.width,
|
|
2104
|
+
height: a.height
|
|
2105
|
+
}, t, n, o), a, .8, i);
|
|
2106
|
+
}
|
|
2107
|
+
static async relocalize(e, t, n = null, r = null, i = null, a = null, o = null) {
|
|
2108
|
+
let s = C.preciseTime() / 1e3, c = this._prepareRequest(t, n, r, i, a), l;
|
|
2095
2109
|
try {
|
|
2096
|
-
let
|
|
2097
|
-
|
|
2110
|
+
let t = c.toFormData();
|
|
2111
|
+
l = await fetch(e, {
|
|
2098
2112
|
method: "POST",
|
|
2099
|
-
body:
|
|
2100
|
-
headers: Object.assign({ Accept: "application/vnd.geopose+json; version=1" },
|
|
2113
|
+
body: t,
|
|
2114
|
+
headers: Object.assign({ Accept: "application/vnd.geopose+json; version=1" }, o || {})
|
|
2101
2115
|
});
|
|
2102
2116
|
} catch {
|
|
2103
|
-
return
|
|
2117
|
+
return A.debug("[VPS] Server respond error"), null;
|
|
2104
2118
|
}
|
|
2105
|
-
if (
|
|
2106
|
-
let
|
|
2107
|
-
return
|
|
2119
|
+
if (l.status !== 200) return A.debug("[VPS] Server respond error"), null;
|
|
2120
|
+
let u = await l.json(), d = it.fromJson(u, s);
|
|
2121
|
+
return A.debug(`[VPS] Server respond ${d.success ? "success" : "not found"}`), d;
|
|
2108
2122
|
}
|
|
2109
2123
|
static getHeadingFromQuaternion(e) {
|
|
2110
|
-
let [
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2124
|
+
let [t, n, r, i] = e, a = Math.sqrt(2) / 2, o = [
|
|
2125
|
+
a * (t - n),
|
|
2126
|
+
a * (t + n),
|
|
2127
|
+
a * (r + i),
|
|
2128
|
+
a * (i - r)
|
|
2115
2129
|
];
|
|
2116
|
-
return -Math.atan2(2 *
|
|
2130
|
+
return -Math.atan2(2 * o[3] * o[0] - 2 * o[2] * o[1], 1 - 2 * o[1] ** 2 - 2 * o[3] ** 2);
|
|
2117
2131
|
}
|
|
2118
|
-
},
|
|
2132
|
+
}, q = new class extends j {
|
|
2119
2133
|
arCoreMonitoringId;
|
|
2120
2134
|
arCoreProviderId;
|
|
2121
2135
|
inertialProviderId;
|
|
2122
2136
|
getName = () => "RelativeAttitude";
|
|
2123
|
-
availability = () =>
|
|
2137
|
+
availability = () => W.getAvailability();
|
|
2124
2138
|
start() {
|
|
2125
|
-
this.arCoreMonitoringId =
|
|
2139
|
+
this.arCoreMonitoringId = z.addMonitoringListener(() => {
|
|
2126
2140
|
this.listenArCore(), this.unlistenInertial();
|
|
2127
2141
|
}, () => {
|
|
2128
2142
|
this.unlistenArCore(), this.listenInertial();
|
|
2129
|
-
}),
|
|
2143
|
+
}), z.state === "started" ? this.listenArCore() : this.listenInertial();
|
|
2130
2144
|
}
|
|
2131
2145
|
stop() {
|
|
2132
|
-
|
|
2146
|
+
z.removeMonitoringListener(this.arCoreMonitoringId), this.unlistenArCore(), this.unlistenInertial();
|
|
2133
2147
|
}
|
|
2134
2148
|
listenInertial = () => {
|
|
2135
|
-
this.inertialProviderId =
|
|
2149
|
+
this.inertialProviderId = W.addEventListener(this.notify, this.notifyError);
|
|
2136
2150
|
};
|
|
2137
2151
|
unlistenInertial = () => {
|
|
2138
|
-
|
|
2152
|
+
W.removeEventListener(this.inertialProviderId);
|
|
2139
2153
|
};
|
|
2140
2154
|
listenArCore = () => {
|
|
2141
|
-
this.arCoreProviderId =
|
|
2155
|
+
this.arCoreProviderId = z.addEventListener((e) => this.notify(e.relativeAttitude), null, !1);
|
|
2142
2156
|
};
|
|
2143
2157
|
unlistenArCore = () => {
|
|
2144
|
-
|
|
2158
|
+
z.removeEventListener(this.arCoreProviderId);
|
|
2145
2159
|
};
|
|
2146
|
-
}(),
|
|
2160
|
+
}(), ot = class {
|
|
2147
2161
|
_providerId;
|
|
2148
2162
|
_isRunning = !1;
|
|
2149
2163
|
_dataOnStart = null;
|
|
2150
2164
|
tickStart() {
|
|
2151
|
-
this._dataOnStart = null, !this._isRunning && (this._isRunning = !0, this._providerId =
|
|
2165
|
+
this._dataOnStart = null, !this._isRunning && (this._isRunning = !0, this._providerId = Ke.addEventListener((e) => {
|
|
2152
2166
|
this._dataOnStart ||= e;
|
|
2153
2167
|
}));
|
|
2154
2168
|
}
|
|
2155
2169
|
tickEnd() {
|
|
2156
|
-
if (!this._isRunning) return
|
|
2157
|
-
if (this._internalStop(), !this._dataOnStart) return
|
|
2158
|
-
let e =
|
|
2159
|
-
return
|
|
2170
|
+
if (!this._isRunning) return A.warn("You have to call tickStart before tickEnd"), null;
|
|
2171
|
+
if (this._internalStop(), !this._dataOnStart) return A.warn("Delay was too short between tickStart and tickEnd or RelativeAttitudeProvider cannot be retrieved."), null;
|
|
2172
|
+
let e = Ke.lastEvent;
|
|
2173
|
+
return t.diff(this._dataOnStart, e);
|
|
2160
2174
|
}
|
|
2161
2175
|
_internalStop() {
|
|
2162
|
-
|
|
2176
|
+
Ke.removeEventListener(this._providerId), delete this._providerId, this._isRunning = !1;
|
|
2163
2177
|
}
|
|
2164
2178
|
release() {
|
|
2165
2179
|
this._isRunning && this._internalStop();
|
|
2166
2180
|
}
|
|
2167
|
-
},
|
|
2181
|
+
}, st = class e extends Error {
|
|
2168
2182
|
static DEFAULT_MESSAGE = "PoleStar is missing";
|
|
2169
|
-
constructor(
|
|
2170
|
-
super(
|
|
2183
|
+
constructor(t) {
|
|
2184
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
2171
2185
|
}
|
|
2172
|
-
},
|
|
2186
|
+
}, ct = new class extends j {
|
|
2173
2187
|
getName = () => "PoleStar";
|
|
2174
2188
|
constructor() {
|
|
2175
2189
|
super(), this.addMethodsToNativeJsProvider();
|
|
@@ -2191,32 +2205,32 @@ var field = function(e, C, w) {
|
|
|
2191
2205
|
this.nativeProvider.stop();
|
|
2192
2206
|
}
|
|
2193
2207
|
get nativeProvider() {
|
|
2194
|
-
if (!this.nativeInterface) throw new
|
|
2208
|
+
if (!this.nativeInterface) throw new Re();
|
|
2195
2209
|
let e = this.nativeInterface.getPoleStarProvider();
|
|
2196
|
-
if (!e) throw new
|
|
2210
|
+
if (!e) throw new st();
|
|
2197
2211
|
return e;
|
|
2198
2212
|
}
|
|
2199
2213
|
addMethodsToNativeJsProvider() {
|
|
2200
2214
|
this.nativeJsInterface && (this.nativeJsInterface.polestar = {
|
|
2201
2215
|
callbackError: (e) => this.notifyError(Error(e)),
|
|
2202
2216
|
callbackPosition: (e) => {
|
|
2203
|
-
let
|
|
2204
|
-
this.notify(
|
|
2217
|
+
let t = JSON.parse(e), n = C.unixTimestampToPreciseTime(t.time) / 1e3, r = new re(t.lat, t.lng, Fe.DEFAULT_ALTITUDE, t.alt / 5, n, t.accuracy, m(t.bearing));
|
|
2218
|
+
this.notify(r);
|
|
2205
2219
|
}
|
|
2206
2220
|
});
|
|
2207
2221
|
}
|
|
2208
|
-
}(),
|
|
2222
|
+
}(), J = new class e extends j {
|
|
2209
2223
|
static MIN_TIME_BETWEEN_TWO_REQUESTS = 1e3;
|
|
2210
|
-
static DEFAULT_MIN_INCLINATION_FOR_REQUEST =
|
|
2224
|
+
static DEFAULT_MIN_INCLINATION_FOR_REQUEST = m(60);
|
|
2211
2225
|
static DEFAULT_WAIT_TIME_MIN_INCLINATION_FOR_REQUEST = 200;
|
|
2212
2226
|
static DEFAULT_USE_COARSE_POSE = !0;
|
|
2213
|
-
static DEFAULT_REQUEST_CALLER = `@wemap/providers(VpsProvider) ${
|
|
2214
|
-
static CAMERA_TO_SMARTPHONE_ROT =
|
|
2227
|
+
static DEFAULT_REQUEST_CALLER = `@wemap/providers(VpsProvider) ${$e.version}`;
|
|
2228
|
+
static CAMERA_TO_SMARTPHONE_ROT = u.fromAxisAngle([
|
|
2215
2229
|
1,
|
|
2216
2230
|
0,
|
|
2217
2231
|
0
|
|
2218
2232
|
], Math.PI);
|
|
2219
|
-
static ENU_TO_ARCORE_ROT =
|
|
2233
|
+
static ENU_TO_ARCORE_ROT = u.fromAxisAngle([
|
|
2220
2234
|
1,
|
|
2221
2235
|
0,
|
|
2222
2236
|
0
|
|
@@ -2240,18 +2254,18 @@ var field = function(e, C, w) {
|
|
|
2240
2254
|
super(), this._sessionId = this._generateUuid();
|
|
2241
2255
|
}
|
|
2242
2256
|
getName = () => "Vps";
|
|
2243
|
-
availability = () =>
|
|
2257
|
+
availability = () => ee.checkAvailability();
|
|
2244
2258
|
start() {
|
|
2245
|
-
this._inclinationProviderId =
|
|
2259
|
+
this._inclinationProviderId = K.addEventListener(), this._relativeRotationCalc = new ot(), T.on("added", this._onCameraDetected), T.on("removed", this._onCameraRemoved), T.list.length && (T.list.length > 1 && A.warn("It seems that more than 1 camera has been detected for VPS. Taking the first..."), this._useCamera(T.list[0].camera));
|
|
2246
2260
|
}
|
|
2247
2261
|
stop() {
|
|
2248
|
-
|
|
2262
|
+
K.removeEventListener(this._inclinationProviderId), this._relativeRotationCalc?.release(), T.off("added", this._onCameraDetected), T.off("removed", this._onCameraRemoved), this._camera = null;
|
|
2249
2263
|
}
|
|
2250
2264
|
_onCameraDetected = ({ camera: e }) => {
|
|
2251
|
-
this._camera &&
|
|
2265
|
+
this._camera && A.warn("It seems that more than 1 camera has been detected for VPS. Taking the first..."), this._useCamera(e);
|
|
2252
2266
|
};
|
|
2253
2267
|
_onCameraRemoved = () => {
|
|
2254
|
-
this._camera ? (this._camera.off("started", this._internalStart), this._camera.off("stopped", this._internalStop)) :
|
|
2268
|
+
this._camera ? (this._camera.off("started", this._internalStart), this._camera.off("stopped", this._internalStop)) : A.warn("There is no previously detected camera but once has stopped"), this._camera = null;
|
|
2255
2269
|
};
|
|
2256
2270
|
_useCamera(e) {
|
|
2257
2271
|
this._camera = e, e.on("started", this._internalStart), e.on("stopped", this._internalStop), e.state === "started" && this._internalStart();
|
|
@@ -2261,41 +2275,41 @@ var field = function(e, C, w) {
|
|
|
2261
2275
|
this.notifyError(/* @__PURE__ */ Error("VPS endpoint has not been set before calling start()"));
|
|
2262
2276
|
return;
|
|
2263
2277
|
}
|
|
2264
|
-
let
|
|
2265
|
-
for (; !
|
|
2266
|
-
if (
|
|
2267
|
-
let
|
|
2268
|
-
await new Promise((e) => setTimeout(e,
|
|
2278
|
+
let n = null, r = () => this.state === "stopped";
|
|
2279
|
+
for (; !r();) {
|
|
2280
|
+
if (n !== null) {
|
|
2281
|
+
let t = C.preciseTime() - n, r = Math.max(0, e.MIN_TIME_BETWEEN_TWO_REQUESTS - t);
|
|
2282
|
+
await new Promise((e) => setTimeout(e, r));
|
|
2269
2283
|
}
|
|
2270
|
-
if (
|
|
2271
|
-
let
|
|
2272
|
-
if (
|
|
2284
|
+
if (n = C.preciseTime(), r() || !this._camera || this._camera.state !== "started") break;
|
|
2285
|
+
let i = K.lastEvent ? K.lastEvent : null;
|
|
2286
|
+
if (i !== null && i < this._minInclinationForRequest) {
|
|
2273
2287
|
await new Promise((e) => setTimeout(e, this._waitTimeMinInclinationForRequest));
|
|
2274
2288
|
continue;
|
|
2275
2289
|
}
|
|
2276
2290
|
this._relativeRotationCalc?.tickStart();
|
|
2277
|
-
let
|
|
2278
|
-
if (!
|
|
2279
|
-
let
|
|
2280
|
-
this._useCoarsePose && (
|
|
2281
|
-
...
|
|
2282
|
-
...
|
|
2291
|
+
let a = await this._camera.currentImage;
|
|
2292
|
+
if (!a) continue;
|
|
2293
|
+
let o = null, s = Y.getBestPositionEvent(Ie.lastEvent, ct.lastEvent);
|
|
2294
|
+
this._useCoarsePose && (s || X.lastEvent) && (o = {
|
|
2295
|
+
...s && { position: s },
|
|
2296
|
+
...X.lastEvent && { attitude: X.lastEvent }
|
|
2283
2297
|
}), this._currentAttemptId === null && (this._attemptIdCounter += 1, this._currentAttemptId = this._attemptIdCounter);
|
|
2284
|
-
let
|
|
2285
|
-
position:
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2298
|
+
let c = q.lastEvent, l = Qe.lastEvent, d = c && l ? {
|
|
2299
|
+
position: u.rotate(e.ENU_TO_ARCORE_ROT, [
|
|
2300
|
+
l.x,
|
|
2301
|
+
l.y,
|
|
2302
|
+
l.z
|
|
2289
2303
|
]),
|
|
2290
|
-
orientation:
|
|
2291
|
-
} : null,
|
|
2304
|
+
orientation: u.multiply(e.ENU_TO_ARCORE_ROT, c.quaternion)
|
|
2305
|
+
} : null, f = await at.relocalize(this._endpoint, a, null, o, {
|
|
2292
2306
|
session_id: this._sessionId,
|
|
2293
2307
|
installation_id: null,
|
|
2294
2308
|
...this._currentAttemptId !== null && { attempt_id: this._currentAttemptId },
|
|
2295
2309
|
caller: this._requestCaller
|
|
2296
|
-
},
|
|
2297
|
-
if (!
|
|
2298
|
-
this._scanFailureCallbacks.forEach(({ id: e, callback:
|
|
2310
|
+
}, d);
|
|
2311
|
+
if (!f || !f.success) {
|
|
2312
|
+
this._scanFailureCallbacks.forEach(({ id: e, callback: t }) => t({
|
|
2299
2313
|
listenerId: e,
|
|
2300
2314
|
sessionId: this._sessionId,
|
|
2301
2315
|
attemptId: this._currentAttemptId
|
|
@@ -2303,39 +2317,39 @@ var field = function(e, C, w) {
|
|
|
2303
2317
|
continue;
|
|
2304
2318
|
}
|
|
2305
2319
|
this._currentAttemptId = null;
|
|
2306
|
-
let
|
|
2320
|
+
let p = f.attitude.quaternion, h = u.multiply(p, e.CAMERA_TO_SMARTPHONE_ROT), g = u.multiply(u.fromAxisAngle([
|
|
2307
2321
|
0,
|
|
2308
2322
|
0,
|
|
2309
2323
|
1
|
|
2310
|
-
],
|
|
2324
|
+
], m(window.orientation || 0)), h), _ = this._relativeRotationCalc?.tickEnd() || new t([
|
|
2311
2325
|
1,
|
|
2312
2326
|
0,
|
|
2313
2327
|
0,
|
|
2314
2328
|
0
|
|
2315
|
-
]),
|
|
2316
|
-
if (
|
|
2329
|
+
]), v = new ae(u.multiply(g, _.quaternion), f.attitude.time, f.attitude.accuracy), y = f.position.clone();
|
|
2330
|
+
if (y.accuracy === null && (y.accuracy = 5), r()) break;
|
|
2317
2331
|
this.notify({
|
|
2318
|
-
absoluteAttitude:
|
|
2319
|
-
absolutePosition:
|
|
2332
|
+
absoluteAttitude: v,
|
|
2333
|
+
absolutePosition: y
|
|
2320
2334
|
});
|
|
2321
2335
|
}
|
|
2322
2336
|
};
|
|
2323
2337
|
_internalStop = () => {};
|
|
2324
2338
|
_generateUuid() {
|
|
2325
2339
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
2326
|
-
let
|
|
2327
|
-
return (e === "x" ?
|
|
2340
|
+
let t = Math.random() * 16 | 0;
|
|
2341
|
+
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
2328
2342
|
});
|
|
2329
2343
|
}
|
|
2330
|
-
addScanFailureListener(
|
|
2331
|
-
let
|
|
2344
|
+
addScanFailureListener(t) {
|
|
2345
|
+
let n = ++e._scanFailureCallbackUniqueId;
|
|
2332
2346
|
return this._scanFailureCallbacks.push({
|
|
2333
|
-
id:
|
|
2334
|
-
callback:
|
|
2335
|
-
}),
|
|
2347
|
+
id: n,
|
|
2348
|
+
callback: t
|
|
2349
|
+
}), n;
|
|
2336
2350
|
}
|
|
2337
2351
|
removeScanFailureListener(e) {
|
|
2338
|
-
this._scanFailureCallbacks = this._scanFailureCallbacks.filter(({ id:
|
|
2352
|
+
this._scanFailureCallbacks = this._scanFailureCallbacks.filter(({ id: t }) => t !== e);
|
|
2339
2353
|
}
|
|
2340
2354
|
resetCurrentAttempt() {
|
|
2341
2355
|
this._currentAttemptId = null;
|
|
@@ -2370,7 +2384,7 @@ var field = function(e, C, w) {
|
|
|
2370
2384
|
set requestCaller(e) {
|
|
2371
2385
|
this._requestCaller = e;
|
|
2372
2386
|
}
|
|
2373
|
-
}(),
|
|
2387
|
+
}(), Y = new class e extends j {
|
|
2374
2388
|
static ACCURACY_RELOC_RATIO = 1;
|
|
2375
2389
|
static USE_MM_FOR_FEED = !0;
|
|
2376
2390
|
_polestarProviderId;
|
|
@@ -2382,75 +2396,81 @@ var field = function(e, C, w) {
|
|
|
2382
2396
|
_waitUntilNextVpsPosition = !1;
|
|
2383
2397
|
_lastPolestarFix = null;
|
|
2384
2398
|
ignoreGnssWifi = !1;
|
|
2399
|
+
_lastKnownLevel = null;
|
|
2385
2400
|
getName = () => "AbsolutePosition";
|
|
2401
|
+
_adaptBeforeNotify(e) {
|
|
2402
|
+
return e.level === null ? e.level = this._lastKnownLevel : this._lastKnownLevel = e.level, e;
|
|
2403
|
+
}
|
|
2386
2404
|
availability() {
|
|
2387
|
-
return
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
...
|
|
2391
|
-
|
|
2405
|
+
return M.some([
|
|
2406
|
+
Qe.getAvailability(),
|
|
2407
|
+
Ie.getAvailability(),
|
|
2408
|
+
...D.hasPoleStar ? [ct.getAvailability()] : [],
|
|
2409
|
+
J.getAvailability()
|
|
2392
2410
|
]);
|
|
2393
2411
|
}
|
|
2394
2412
|
start() {
|
|
2395
|
-
|
|
2396
|
-
e || (this._relativePositionProviderId =
|
|
2397
|
-
}), this._gnssWifiProviderId =
|
|
2413
|
+
Qe.getAvailability().then((e) => {
|
|
2414
|
+
e || (this._relativePositionProviderId = Qe.addEventListener((e) => this._onRelativePosition(e)));
|
|
2415
|
+
}), this._gnssWifiProviderId = Ie.addEventListener((e) => {
|
|
2398
2416
|
if (this.ignoreGnssWifi) return;
|
|
2399
|
-
let
|
|
2400
|
-
|
|
2401
|
-
}), this._vpsProviderId =
|
|
2402
|
-
if (this._lastPolestarFix =
|
|
2403
|
-
let
|
|
2404
|
-
|
|
2417
|
+
let t = e.clone();
|
|
2418
|
+
t.bearing = null, this._onAbsolutePosition(t, "gnss-wifi", !1);
|
|
2419
|
+
}), this._vpsProviderId = J.addEventListener((e) => this._onAbsolutePosition(e.absolutePosition, "vps"), this.notifyError, !1), D.hasPoleStar && (this._polestarProviderId = ct.addEventListener((e) => {
|
|
2420
|
+
if (this._lastPolestarFix = C.preciseTime(), !this._onAbsolutePosition(e, "polestar") && this.lastEvent?.level === null) {
|
|
2421
|
+
let t = this.lastEvent.clone();
|
|
2422
|
+
t.level = e.level, this.notify(t);
|
|
2405
2423
|
}
|
|
2406
|
-
})), this._mapMatchingHandlerId =
|
|
2424
|
+
})), this._mapMatchingHandlerId = $.addEventListener();
|
|
2407
2425
|
}
|
|
2408
2426
|
stop() {
|
|
2409
|
-
this._relativePositionProviderId && (
|
|
2410
|
-
}
|
|
2411
|
-
_shouldTakeIntoAccountNewAbsolutePosition(
|
|
2412
|
-
let
|
|
2413
|
-
if (!
|
|
2414
|
-
let
|
|
2415
|
-
if (
|
|
2416
|
-
let
|
|
2417
|
-
if (
|
|
2418
|
-
let
|
|
2419
|
-
return !!(
|
|
2420
|
-
}
|
|
2421
|
-
_onAbsolutePosition(e,
|
|
2422
|
-
if (!this._shouldTakeIntoAccountNewAbsolutePosition(e,
|
|
2423
|
-
let
|
|
2424
|
-
return
|
|
2427
|
+
this._relativePositionProviderId && (Qe.removeEventListener(this._relativePositionProviderId), delete this._relativePositionProviderId), this._gnssWifiProviderId && (Ie.removeEventListener(this._gnssWifiProviderId), delete this._gnssWifiProviderId), this._vpsProviderId && (J.removeEventListener(this._vpsProviderId), delete this._vpsProviderId), this._polestarProviderId && (ct.removeEventListener(this._polestarProviderId), delete this._polestarProviderId), $.removeEventListener(this._mapMatchingHandlerId);
|
|
2428
|
+
}
|
|
2429
|
+
_shouldTakeIntoAccountNewAbsolutePosition(t, n = !0) {
|
|
2430
|
+
let r = t, a = this.lastEvent || null;
|
|
2431
|
+
if (!a) return !0;
|
|
2432
|
+
let o = r.accuracy * e.ACCURACY_RELOC_RATIO <= a.accuracy;
|
|
2433
|
+
if (o) return !0;
|
|
2434
|
+
let s = a.distanceTo(r) > a.accuracy + r.accuracy;
|
|
2435
|
+
if (s) return !0;
|
|
2436
|
+
let c = s && r.accuracy <= a.accuracy;
|
|
2437
|
+
return !!(o && c || n && !i.equals(r.level, a.level));
|
|
2438
|
+
}
|
|
2439
|
+
_onAbsolutePosition(e, t, n = !0) {
|
|
2440
|
+
if (!this._shouldTakeIntoAccountNewAbsolutePosition(e, n) && !this.useAllAbsolutePositions) return !1;
|
|
2441
|
+
let r = re.fromUserPosition(e, t), i = this.lastEvent ? this.lastEvent : null;
|
|
2442
|
+
return i && (n || (r.level = i.level), r.bearing === null && (r.bearing = i.bearing)), $.canUseMapMatching() ? $.notifyPositionFromAbsolute(r) : (this.notify(r), !0);
|
|
2425
2443
|
}
|
|
2426
2444
|
_onRelativePosition(e) {
|
|
2427
2445
|
if (!this.lastEvent || this._waitUntilNextVpsPosition) return !1;
|
|
2428
|
-
let
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2446
|
+
let t = this.lastEvent, n = e, r = Math.sqrt(n.x ** 2 + n.y ** 2), i = Math.atan2(n.x, n.y), a = t.alt === null ? null : n.z, o = t.destinationPoint(r, i, a);
|
|
2447
|
+
o.bearing = n.bearing, o.time = n.time, o.accuracy += n.accuracy;
|
|
2448
|
+
let s = re.fromUserPosition(o, "relative");
|
|
2449
|
+
return $.canUseMapMatching() ? $.notifyPositionFromRelative(s) : (this.notify(s), !0);
|
|
2450
|
+
}
|
|
2451
|
+
feed(t) {
|
|
2452
|
+
let n;
|
|
2453
|
+
if (t instanceof o) {
|
|
2454
|
+
if (t.time === null) throw Error("the time of the position is not defined");
|
|
2455
|
+
if (t.accuracy === null) throw Error("the accuracy of the position is not defined");
|
|
2456
|
+
n = re.fromUserPosition(t, t.source ?? "feed");
|
|
2437
2457
|
} else throw Error("data is nor an UserPosition or an AbsolutePositionEvent");
|
|
2438
|
-
if (!e.USE_MM_FOR_FEED ||
|
|
2439
|
-
this.notify(
|
|
2458
|
+
if (!e.USE_MM_FOR_FEED || !$.canUseMapMatching()) {
|
|
2459
|
+
this.notify(n);
|
|
2440
2460
|
return;
|
|
2441
2461
|
}
|
|
2442
|
-
|
|
2462
|
+
$.notifyPositionFromFeed(n);
|
|
2443
2463
|
}
|
|
2444
2464
|
getBestPositionEvent(...e) {
|
|
2445
|
-
return e.reduce((e,
|
|
2446
|
-
if (!e) return
|
|
2447
|
-
if (!
|
|
2448
|
-
let { accuracy:
|
|
2449
|
-
return
|
|
2465
|
+
return e.reduce((e, t) => {
|
|
2466
|
+
if (!e) return t;
|
|
2467
|
+
if (!t || t.accuracy === null || t.time === null) return e;
|
|
2468
|
+
let { accuracy: n, time: r } = t, { accuracy: i, time: a } = e;
|
|
2469
|
+
return n < i + 1.3888 * (r - a) ? t : e;
|
|
2450
2470
|
}, null);
|
|
2451
2471
|
}
|
|
2452
|
-
}(),
|
|
2453
|
-
DEFAULT_ACCURACY =
|
|
2472
|
+
}(), lt = new class e extends j {
|
|
2473
|
+
DEFAULT_ACCURACY = m(15);
|
|
2454
2474
|
absolutePositionProviderId;
|
|
2455
2475
|
absolutePositionEvent;
|
|
2456
2476
|
declinationQuaternion;
|
|
@@ -2460,102 +2480,102 @@ var field = function(e, C, w) {
|
|
|
2460
2480
|
iosIsSkyMode = null;
|
|
2461
2481
|
getName = () => "AbsoluteAttitudeFromBrowser";
|
|
2462
2482
|
availability() {
|
|
2463
|
-
return
|
|
2483
|
+
return S.isMobile ? Promise.resolve() : Promise.resolve(new Ae());
|
|
2464
2484
|
}
|
|
2465
2485
|
start() {
|
|
2466
2486
|
let e = () => {
|
|
2467
|
-
switch (
|
|
2468
|
-
case
|
|
2487
|
+
switch (S.getName()) {
|
|
2488
|
+
case x.CHROME:
|
|
2469
2489
|
window.addEventListener("deviceorientationabsolute", this.onDeviceOrientationChromeEvent, !0);
|
|
2470
2490
|
break;
|
|
2471
|
-
case
|
|
2472
|
-
case
|
|
2491
|
+
case x.SAFARI:
|
|
2492
|
+
case x.IOS_WEBVIEW:
|
|
2473
2493
|
window.addEventListener("deviceorientation", this.onDeviceOrientationSafariEvent, !0);
|
|
2474
2494
|
break;
|
|
2475
2495
|
}
|
|
2476
|
-
},
|
|
2477
|
-
|
|
2478
|
-
if (
|
|
2496
|
+
}, t = DeviceOrientationEvent.requestPermission || void 0;
|
|
2497
|
+
t ? t().then((t) => {
|
|
2498
|
+
if (t !== "granted") throw Error("Permission not granted");
|
|
2479
2499
|
e();
|
|
2480
2500
|
}).catch(this.notifyError) : e();
|
|
2481
|
-
let
|
|
2482
|
-
|
|
2501
|
+
let n = Y.lastEvent;
|
|
2502
|
+
n ? this.onAbsolutePositionEvent(n) : this.absolutePositionProviderId = Y.addEventListener(this.onAbsolutePositionEvent, this.notifyError, !1);
|
|
2483
2503
|
}
|
|
2484
2504
|
stop() {
|
|
2485
|
-
switch (
|
|
2486
|
-
case
|
|
2505
|
+
switch (S.getName()) {
|
|
2506
|
+
case x.CHROME:
|
|
2487
2507
|
window.removeEventListener("deviceorientationabsolute", this.onDeviceOrientationChromeEvent, !0);
|
|
2488
2508
|
break;
|
|
2489
|
-
case
|
|
2490
|
-
case
|
|
2509
|
+
case x.SAFARI:
|
|
2510
|
+
case x.IOS_WEBVIEW:
|
|
2491
2511
|
window.removeEventListener("deviceorientation", this.onDeviceOrientationSafariEvent, !0);
|
|
2492
2512
|
break;
|
|
2493
2513
|
}
|
|
2494
|
-
|
|
2514
|
+
Y.removeEventListener(this.absolutePositionProviderId);
|
|
2495
2515
|
}
|
|
2496
2516
|
onDeviceOrientationChromeEvent = (e) => {
|
|
2497
2517
|
if (this.magQuaternionTimestamp = e.timeStamp / 1e3, typeof e.alpha != "number" || typeof e.beta != "number" || typeof e.gamma != "number") {
|
|
2498
|
-
this.notifyError(new
|
|
2518
|
+
this.notifyError(new R().from("deviceorientationabsolute"));
|
|
2499
2519
|
return;
|
|
2500
2520
|
}
|
|
2501
|
-
this.magQuaternion =
|
|
2521
|
+
this.magQuaternion = d.eulerToQuaternionZXYDegrees([
|
|
2502
2522
|
e.alpha,
|
|
2503
2523
|
e.beta,
|
|
2504
2524
|
e.gamma
|
|
2505
2525
|
]), this.compute();
|
|
2506
2526
|
};
|
|
2507
|
-
onDeviceOrientationSafariEvent = (
|
|
2508
|
-
if (this.magQuaternionTimestamp =
|
|
2509
|
-
this.notifyError(new
|
|
2527
|
+
onDeviceOrientationSafariEvent = (t) => {
|
|
2528
|
+
if (this.magQuaternionTimestamp = t.timeStamp / 1e3, typeof t.beta != "number" || typeof t.gamma != "number") {
|
|
2529
|
+
this.notifyError(new R().from("deviceorientation"));
|
|
2510
2530
|
return;
|
|
2511
2531
|
}
|
|
2512
|
-
if (typeof
|
|
2513
|
-
this.notifyError(new
|
|
2532
|
+
if (typeof t.webkitCompassHeading != "number") {
|
|
2533
|
+
this.notifyError(new je().from("deviceorientation"));
|
|
2514
2534
|
return;
|
|
2515
2535
|
}
|
|
2516
|
-
let
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
]),
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2536
|
+
let n, [r, i, a, o] = d.eulerToQuaternionZXYDegrees([
|
|
2537
|
+
t.webkitCompassHeading,
|
|
2538
|
+
t.beta,
|
|
2539
|
+
t.gamma
|
|
2540
|
+
]), s = _(Math.acos(r ** 2 - i ** 2 - a ** 2 + o ** 2)), c = null;
|
|
2541
|
+
s > 136 ? c = !0 : s < 134 ? c = !1 : this.iosPreviousQuat && this.iosIsSkyMode !== null && (c = u.distance([
|
|
2542
|
+
r,
|
|
2543
|
+
i,
|
|
2544
|
+
a,
|
|
2545
|
+
o
|
|
2526
2546
|
], this.iosPreviousQuat) < .5 ? this.iosIsSkyMode : !this.iosIsSkyMode), this.iosPreviousQuat = [
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
], this.iosIsSkyMode =
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2547
|
+
r,
|
|
2548
|
+
i,
|
|
2549
|
+
a,
|
|
2550
|
+
o
|
|
2551
|
+
], this.iosIsSkyMode = c, c !== void 0 && (n = c ? 180 - t.webkitCompassHeading : e.webkitCompassToHeading(t.webkitCompassHeading, t.beta, t.gamma), this.magQuaternion = d.eulerToQuaternionZXYDegrees([
|
|
2552
|
+
n,
|
|
2553
|
+
t.beta,
|
|
2554
|
+
t.gamma
|
|
2535
2555
|
]), this.compute());
|
|
2536
2556
|
};
|
|
2537
2557
|
compute() {
|
|
2538
2558
|
if (!this.declinationQuaternion || !this.magQuaternion || !this.absolutePositionEvent) return;
|
|
2539
|
-
let e = new
|
|
2559
|
+
let e = new ae(u.multiply(this.declinationQuaternion, this.magQuaternion), this.magQuaternionTimestamp, this.DEFAULT_ACCURACY);
|
|
2540
2560
|
this.notify(e);
|
|
2541
2561
|
}
|
|
2542
2562
|
onAbsolutePositionEvent = (e) => {
|
|
2543
2563
|
this.absolutePositionEvent = e;
|
|
2544
|
-
let
|
|
2545
|
-
this.declinationQuaternion =
|
|
2564
|
+
let t = ke(e.lat, e.lng);
|
|
2565
|
+
this.declinationQuaternion = u.fromAxisAngle([
|
|
2546
2566
|
0,
|
|
2547
2567
|
0,
|
|
2548
2568
|
1
|
|
2549
|
-
], -
|
|
2569
|
+
], -m(t.declination)), Y.removeEventListener(this.absolutePositionProviderId), delete this.absolutePositionProviderId, this.compute();
|
|
2550
2570
|
};
|
|
2551
|
-
static webkitCompassToHeading(e,
|
|
2552
|
-
let
|
|
2553
|
-
return
|
|
2571
|
+
static webkitCompassToHeading(e, t, n) {
|
|
2572
|
+
let r = m(e), i = m(t), a = m(n), o = Math.cos(r / 2), s = Math.cos(i / 2), c = Math.cos(a / 2), l = Math.sin(r / 2), u = Math.sin(i / 2), d = Math.sin(a / 2), f = o * s * c - l * u * d, p = l * s * c + o * u * d;
|
|
2573
|
+
return _(-2 * Math.atan(p / f));
|
|
2554
2574
|
}
|
|
2555
|
-
}(),
|
|
2556
|
-
static REL_ABS_DIVERGENCE_ANGLE_THRESHOLD =
|
|
2575
|
+
}(), X = new class n extends j {
|
|
2576
|
+
static REL_ABS_DIVERGENCE_ANGLE_THRESHOLD = m(25);
|
|
2557
2577
|
static REL_ABS_DIVERGENCE_TIME_THRESHOLD = 2.5;
|
|
2558
|
-
static REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD =
|
|
2578
|
+
static REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD = m(15);
|
|
2559
2579
|
_absAttitudeFromBrowser;
|
|
2560
2580
|
_vpsProviderId;
|
|
2561
2581
|
fromBrowserProviderId;
|
|
@@ -2573,17 +2593,17 @@ var field = function(e, C, w) {
|
|
|
2573
2593
|
_callbackMagCalibration;
|
|
2574
2594
|
getName = () => "AbsoluteAttitude";
|
|
2575
2595
|
availability() {
|
|
2576
|
-
return
|
|
2596
|
+
return M.some([lt.getAvailability(), q.getAvailability()]);
|
|
2577
2597
|
}
|
|
2578
2598
|
start() {
|
|
2579
|
-
this.fromBrowserProviderId =
|
|
2599
|
+
this.fromBrowserProviderId = lt.addEventListener(this._onAttitudeFromBrowser, (e) => {
|
|
2580
2600
|
this._attitudeFromBrowserErrored = !0, this._onError(e);
|
|
2581
|
-
}), this._vpsProviderId =
|
|
2601
|
+
}), this._vpsProviderId = J.addEventListener((e) => this._onAttitudeFromVps(e.absoluteAttitude), (e) => this.notifyError(e), !1), this.relativeAttitudeProviderId = q.addEventListener(this._onRelativeAttitudeEvent, (e) => {
|
|
2582
2602
|
this._attitudeFromRelativeErrored = !0, this._onError(e);
|
|
2583
|
-
}), this.inclinationProviderId =
|
|
2603
|
+
}), this.inclinationProviderId = K.addEventListener(), this.highRotationProviderId = U.addEventListener();
|
|
2584
2604
|
}
|
|
2585
2605
|
stop() {
|
|
2586
|
-
|
|
2606
|
+
lt.removeEventListener(this.fromBrowserProviderId), q.removeEventListener(this.relativeAttitudeProviderId), K.removeEventListener(this.inclinationProviderId), U.removeEventListener(this.highRotationProviderId), J.removeEventListener(this._vpsProviderId);
|
|
2587
2607
|
}
|
|
2588
2608
|
_setCallbackMagCalibration(e) {
|
|
2589
2609
|
this._callbackMagCalibration = e;
|
|
@@ -2593,37 +2613,37 @@ var field = function(e, C, w) {
|
|
|
2593
2613
|
};
|
|
2594
2614
|
_forceHeadingForRelative = (e) => {
|
|
2595
2615
|
if (this.lastEvent && e.accuracy > this.lastEvent.accuracy) return;
|
|
2596
|
-
let
|
|
2597
|
-
let
|
|
2598
|
-
this._relAbsQuat =
|
|
2616
|
+
let t = (t) => {
|
|
2617
|
+
let n = t.heading;
|
|
2618
|
+
this._relAbsQuat = u.fromAxisAngle([
|
|
2599
2619
|
0,
|
|
2600
2620
|
0,
|
|
2601
2621
|
1
|
|
2602
|
-
],
|
|
2622
|
+
], n - e.heading), this._relativeAccuracy = 0, this._lastForcedHeadingEvent = e;
|
|
2603
2623
|
};
|
|
2604
2624
|
if (this._relativeAttitude) {
|
|
2605
|
-
|
|
2625
|
+
t(this._relativeAttitude);
|
|
2606
2626
|
return;
|
|
2607
2627
|
}
|
|
2608
|
-
let
|
|
2609
|
-
|
|
2628
|
+
let n = q.addEventListener((e) => {
|
|
2629
|
+
t(e), q.removeEventListener(n);
|
|
2610
2630
|
});
|
|
2611
2631
|
};
|
|
2612
2632
|
_onRelativeAttitudeEvent = (e) => {
|
|
2613
|
-
let { quaternion:
|
|
2614
|
-
if (this._relativeAttitude && (this._relativeAccuracy += (
|
|
2615
|
-
let
|
|
2633
|
+
let { quaternion: r, accuracy: i, time: a } = e;
|
|
2634
|
+
if (this._relativeAttitude && (this._relativeAccuracy += (a - this._relativeAttitude.time) * i), this._relativeAttitude = e, !this._lastForcedHeadingEvent || !this._relAbsQuat) return;
|
|
2635
|
+
let o = Math.min((this._lastForcedHeadingEvent.accuracy || 0) + this._relativeAccuracy, Math.PI), s = U.isInProgress(), c = !1;
|
|
2616
2636
|
if (this._absAttitudeFromBrowser) {
|
|
2617
|
-
let { accuracy: e, heading:
|
|
2618
|
-
if (this._wasHighRotationInProgress && !
|
|
2619
|
-
else if (e <
|
|
2620
|
-
let e = new
|
|
2621
|
-
|
|
2637
|
+
let { accuracy: e, heading: i } = this._absAttitudeFromBrowser;
|
|
2638
|
+
if (this._wasHighRotationInProgress && !s) this._forceHeadingForRelative(this._absAttitudeFromBrowser);
|
|
2639
|
+
else if (e < o) {
|
|
2640
|
+
let e = new t(u.multiply(this._relAbsQuat, r)), o = Math.abs(h(e.heading, i)), s = K.lastEvent;
|
|
2641
|
+
o > n.REL_ABS_DIVERGENCE_ANGLE_THRESHOLD && s !== null && Math.abs(s - Math.PI / 4) > n.REL_ABS_DIVERGENCE_INCLINATION_THRESHOLD && (c = !0, this._timeFirstDivergence !== null && a - this._timeFirstDivergence > n.REL_ABS_DIVERGENCE_TIME_THRESHOLD ? (this._forceHeadingForRelative(this._absAttitudeFromBrowser), this._callbackMagCalibration?.({ angle: o }), this._timeFirstDivergence = null) : this._timeFirstDivergence === null && (this._timeFirstDivergence = a));
|
|
2622
2642
|
}
|
|
2623
2643
|
}
|
|
2624
|
-
|
|
2625
|
-
let
|
|
2626
|
-
this.notify(
|
|
2644
|
+
c || (this._timeFirstDivergence = null), this._wasHighRotationInProgress = s;
|
|
2645
|
+
let l = new ae(u.multiply(this._relAbsQuat, r), a, o);
|
|
2646
|
+
this.notify(l);
|
|
2627
2647
|
};
|
|
2628
2648
|
_onAttitudeFromBrowser = (e) => {
|
|
2629
2649
|
if (this._absAttitudeFromBrowser = e, !this._lastForcedHeadingEvent) {
|
|
@@ -2634,39 +2654,39 @@ var field = function(e, C, w) {
|
|
|
2634
2654
|
_onAttitudeFromVps = (e) => {
|
|
2635
2655
|
this._forceHeadingForRelative(e);
|
|
2636
2656
|
};
|
|
2637
|
-
feed(
|
|
2638
|
-
if (
|
|
2639
|
-
if (
|
|
2640
|
-
if (
|
|
2641
|
-
this._forceHeadingForRelative(
|
|
2642
|
-
} else if (
|
|
2643
|
-
if (
|
|
2644
|
-
if (
|
|
2645
|
-
this._forceHeadingForRelative(
|
|
2657
|
+
feed(t) {
|
|
2658
|
+
if (t instanceof e) {
|
|
2659
|
+
if (t.time === null) throw Error("the time of the absolute heading is not defined");
|
|
2660
|
+
if (t.accuracy === null) throw Error("the accuracy of the absolute heading is not defined");
|
|
2661
|
+
this._forceHeadingForRelative(t);
|
|
2662
|
+
} else if (t instanceof ae) {
|
|
2663
|
+
if (t.time === null) throw Error("the time of the attitude is not defined");
|
|
2664
|
+
if (t.accuracy === null) throw Error("the accuracy of the attitude is not defined");
|
|
2665
|
+
this._forceHeadingForRelative(t);
|
|
2646
2666
|
} else throw Error("data is nor an AbsoluteHeading or an Attitude object");
|
|
2647
2667
|
}
|
|
2648
|
-
}(),
|
|
2668
|
+
}(), Z = new class e extends j {
|
|
2649
2669
|
static SLIDING_WINDOW_TIME = .3;
|
|
2650
2670
|
static STD_THRESHOLD = .075;
|
|
2651
2671
|
static CONSIDER_TURN_UNTIL = 1;
|
|
2652
2672
|
providerId;
|
|
2653
2673
|
slidingWindow = [];
|
|
2654
2674
|
getName = () => "Turn";
|
|
2655
|
-
availability = () =>
|
|
2675
|
+
availability = () => q.getAvailability();
|
|
2656
2676
|
start() {
|
|
2657
|
-
this.providerId =
|
|
2677
|
+
this.providerId = q.addEventListener(this._parseRelativeAttitude, this.notifyError);
|
|
2658
2678
|
}
|
|
2659
2679
|
stop() {
|
|
2660
|
-
|
|
2680
|
+
q.removeEventListener(this.providerId);
|
|
2661
2681
|
}
|
|
2662
2682
|
isTurning() {
|
|
2663
|
-
return !this.lastEvent || !
|
|
2683
|
+
return !this.lastEvent || !q.lastEvent ? !1 : q.lastEvent.time - this.lastEvent.timestamp < e.CONSIDER_TURN_UNTIL;
|
|
2664
2684
|
}
|
|
2665
|
-
_parseRelativeAttitude = (
|
|
2666
|
-
let { heading:
|
|
2667
|
-
this.slidingWindow = this.slidingWindow.filter((
|
|
2685
|
+
_parseRelativeAttitude = (t) => {
|
|
2686
|
+
let { heading: n } = t, r = t.time;
|
|
2687
|
+
this.slidingWindow = this.slidingWindow.filter((t) => t[0] >= r - e.SLIDING_WINDOW_TIME), this.slidingWindow.push([r, n]), v(this.slidingWindow.map((e) => e[1])) > e.STD_THRESHOLD && this.notify({ timestamp: r });
|
|
2668
2688
|
};
|
|
2669
|
-
}(),
|
|
2689
|
+
}(), Q = new class e extends j {
|
|
2670
2690
|
static DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE = 2;
|
|
2671
2691
|
_turnProviderId;
|
|
2672
2692
|
_stepProviderId;
|
|
@@ -2674,13 +2694,13 @@ var field = function(e, C, w) {
|
|
|
2674
2694
|
_stepsConsideredForStraightLine = e.DEFAULT_STEPS_CONSIDERED_FOR_STRAIGHT_LINE;
|
|
2675
2695
|
getName = () => "StraightLine";
|
|
2676
2696
|
availability() {
|
|
2677
|
-
return
|
|
2697
|
+
return M.every([Z.getAvailability(), G.getAvailability()]);
|
|
2678
2698
|
}
|
|
2679
2699
|
start() {
|
|
2680
|
-
this._turnProviderId =
|
|
2700
|
+
this._turnProviderId = Z.addEventListener(this._onTurn), this._stepProviderId = G.addEventListener(this._onStep);
|
|
2681
2701
|
}
|
|
2682
2702
|
stop() {
|
|
2683
|
-
|
|
2703
|
+
Z.removeEventListener(this._turnProviderId), G.removeEventListener(this._stepProviderId);
|
|
2684
2704
|
}
|
|
2685
2705
|
_onTurn = () => {
|
|
2686
2706
|
this._countSteps >= this._stepsConsideredForStraightLine && this.notify(!1), this._countSteps = 0;
|
|
@@ -2700,10 +2720,9 @@ var field = function(e, C, w) {
|
|
|
2700
2720
|
set stepsConsideredForStraightLine(e) {
|
|
2701
2721
|
this._stepsConsideredForStraightLine = e;
|
|
2702
2722
|
}
|
|
2703
|
-
}(),
|
|
2704
|
-
static DEFAULT_MM_MAX_ANGLE =
|
|
2723
|
+
}(), $ = new class t extends j {
|
|
2724
|
+
static DEFAULT_MM_MAX_ANGLE = m(30);
|
|
2705
2725
|
static DEFAULT_MM_MAX_DIST = 30;
|
|
2706
|
-
static DEFAULT_MM_MIN_DIST = 0;
|
|
2707
2726
|
static DEFAULT_USE_ITINERARY_START_AS_POSITION = !1;
|
|
2708
2727
|
static DEFAULT_USE_ORIENTATION_MATCHING = !0;
|
|
2709
2728
|
static DEFAULT_MM_HUGE_JUMP_DISTANCE = 3;
|
|
@@ -2711,20 +2730,19 @@ var field = function(e, C, w) {
|
|
|
2711
2730
|
static DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING = 3;
|
|
2712
2731
|
static DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING = 5;
|
|
2713
2732
|
static DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE = 3;
|
|
2714
|
-
static DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD =
|
|
2733
|
+
static DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD = m(3);
|
|
2715
2734
|
static DEFAULT_USE_STRICT = !1;
|
|
2716
|
-
_mapMatchingMaxDistance =
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
_useStrict = C.DEFAULT_USE_STRICT;
|
|
2735
|
+
_mapMatchingMaxDistance = t.DEFAULT_MM_MAX_DIST;
|
|
2736
|
+
_mapMatchingMaxAngleBearing = t.DEFAULT_MM_MAX_ANGLE;
|
|
2737
|
+
_useItineraryStartAsPosition = t.DEFAULT_USE_ITINERARY_START_AS_POSITION;
|
|
2738
|
+
_useOrientationMatching = t.DEFAULT_USE_ORIENTATION_MATCHING;
|
|
2739
|
+
_hugeJumpDistance = t.DEFAULT_MM_HUGE_JUMP_DISTANCE;
|
|
2740
|
+
_disableMMCloseToATurnDistance = t.DEFAULT_DISABLE_MM_CLOSE_TO_A_TURN_DISTANCE;
|
|
2741
|
+
_minStepsBetweenOrientationMatching = t.DEFAULT_MIN_STEPS_BETWEEN_ORIENTATION_MATCHING;
|
|
2742
|
+
_minStepsForOrientationMatching = t.DEFAULT_MIN_STEPS_FOR_ORIENTATION_MATCHING;
|
|
2743
|
+
_lastProjectionsWindowSize = t.DEFAULT_LAST_PROJECTIONS_WINDOW_SIZE;
|
|
2744
|
+
_lastProjectionsEdgeAngleThreshold = t.DEFAULT_LAST_PROJECTIONS_EDGE_ANGLE_THRESHOLD;
|
|
2745
|
+
_useStrict = t.DEFAULT_USE_STRICT;
|
|
2728
2746
|
_graph = null;
|
|
2729
2747
|
_internalProvidersStarted = !1;
|
|
2730
2748
|
_straightLineProviderId;
|
|
@@ -2746,13 +2764,13 @@ var field = function(e, C, w) {
|
|
|
2746
2764
|
this.graph && !this._internalProvidersStarted ? this._startInternalProviders() : !this.graph && this._internalProvidersStarted && this._stopInternalProviders();
|
|
2747
2765
|
};
|
|
2748
2766
|
_startInternalProviders() {
|
|
2749
|
-
this.enabled && this._internalProvidersStarted || (this._straightLineProviderId =
|
|
2767
|
+
this.enabled && this._internalProvidersStarted || (this._straightLineProviderId = Q.addEventListener(), this._turnProviderId = Z.addEventListener(), this._stepProviderId = G.addEventListener(() => this._countStepsFromLastMatching++), this._internalProvidersStarted = !0);
|
|
2750
2768
|
}
|
|
2751
2769
|
_stopInternalProviders() {
|
|
2752
|
-
this.enabled && !this._internalProvidersStarted || (
|
|
2770
|
+
this.enabled && !this._internalProvidersStarted || (Q.removeEventListener(this._straightLineProviderId), Z.removeEventListener(this._turnProviderId), G.removeEventListener(this._stepProviderId), this._internalProvidersStarted = !1);
|
|
2753
2771
|
}
|
|
2754
2772
|
get enabled() {
|
|
2755
|
-
return
|
|
2773
|
+
return D.useMapMatching;
|
|
2756
2774
|
}
|
|
2757
2775
|
get graph() {
|
|
2758
2776
|
return this._graph;
|
|
@@ -2761,96 +2779,96 @@ var field = function(e, C, w) {
|
|
|
2761
2779
|
this._graph = e, this._itineraryInfoManager = null, this.notify({ ...e && { graph: e } }), this._manageStartStop(), this.canUseMapMatching();
|
|
2762
2780
|
}
|
|
2763
2781
|
set itinerary(e) {
|
|
2764
|
-
this._graph = e ? e.toGraph() : null, this._itineraryInfoManager = new
|
|
2782
|
+
this._graph = e ? e.toGraph() : null, this._itineraryInfoManager = new b(e), this.notify({ ...e && { itinerary: e } }), this._manageStartStop(), this.canUseMapMatching() && e && this._notifyPositionFromItineraryInput(e);
|
|
2765
2783
|
}
|
|
2766
2784
|
canUseMapMatching() {
|
|
2767
2785
|
return this.enabled && this.graph;
|
|
2768
2786
|
}
|
|
2769
2787
|
_notifyPositionFromItineraryInput(e) {
|
|
2770
2788
|
if (!this._useItineraryStartAsPosition || !e.origin) return;
|
|
2771
|
-
let
|
|
2772
|
-
if (
|
|
2773
|
-
else if (e.coords.length >= 2)
|
|
2789
|
+
let t = Y.lastEvent || null, n = o.fromCoordinates(e.origin);
|
|
2790
|
+
if (t) n.alt = t.alt, n.time = t.time, n.accuracy = t.accuracy + n.distanceTo(t), n.bearing = t.bearing;
|
|
2791
|
+
else if (e.coords.length >= 2) n.alt = Fe.DEFAULT_ALTITUDE, n.time = C.preciseTime(), n.accuracy = 0, n.bearing = e.coords[0].bearingTo(e.coords[1]);
|
|
2774
2792
|
else return;
|
|
2775
|
-
let
|
|
2776
|
-
|
|
2793
|
+
let r = this.getProjection(n, !0);
|
|
2794
|
+
r ? Y.notify(r.coords) : Y.notify(n);
|
|
2777
2795
|
}
|
|
2778
2796
|
notifyPositionFromFeed(e) {
|
|
2779
|
-
let
|
|
2780
|
-
if (this._useStrict &&
|
|
2781
|
-
|
|
2797
|
+
let t = this.getProjection(e, !0, !1);
|
|
2798
|
+
if (this._useStrict && t) {
|
|
2799
|
+
Y.notify(t.coords);
|
|
2782
2800
|
return;
|
|
2783
2801
|
}
|
|
2784
|
-
if (!
|
|
2785
|
-
|
|
2802
|
+
if (!t) {
|
|
2803
|
+
Y.notify(e);
|
|
2786
2804
|
return;
|
|
2787
2805
|
}
|
|
2788
|
-
|
|
2806
|
+
Y.notify(t.coords);
|
|
2789
2807
|
}
|
|
2790
2808
|
notifyPositionFromAbsolute(e) {
|
|
2791
2809
|
if (this._useStrict) {
|
|
2792
|
-
let
|
|
2793
|
-
if (
|
|
2810
|
+
let t = this.getProjection(e);
|
|
2811
|
+
if (t) return Y.notify(t.coords), !0;
|
|
2794
2812
|
}
|
|
2795
|
-
let
|
|
2796
|
-
if (e.bearing !== null && (
|
|
2797
|
-
let
|
|
2798
|
-
return
|
|
2813
|
+
let t = null;
|
|
2814
|
+
if (e.bearing !== null && (t = this.getProjection(e, !0, !0)), !t) return Y.notify(e), !0;
|
|
2815
|
+
let n = t.distanceFromNearestElement > this._hugeJumpDistance;
|
|
2816
|
+
return n && !Q.isStraight() || n && this._detectWrongBigJump(t) ? !1 : (Y.notify(t.coords), this.tryOrientationMatching(t), !0);
|
|
2799
2817
|
}
|
|
2800
2818
|
notifyPositionFromRelative(e) {
|
|
2801
|
-
let
|
|
2802
|
-
if (this._useStrict &&
|
|
2803
|
-
if (
|
|
2804
|
-
if (
|
|
2805
|
-
this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections.push(
|
|
2806
|
-
let
|
|
2807
|
-
return
|
|
2819
|
+
let t = this.getProjection(e, !0, !0);
|
|
2820
|
+
if (this._useStrict && t) return Y.notify(t.coords), !0;
|
|
2821
|
+
if (Z.isTurning()) return this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections = [], Y.notify(e), !0;
|
|
2822
|
+
if (t) {
|
|
2823
|
+
this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections.push(t), this._lastProjections.length > this._lastProjectionsWindowSize && this._lastProjections.shift();
|
|
2824
|
+
let n = t.distanceFromNearestElement > this._hugeJumpDistance;
|
|
2825
|
+
return n && !Q.isStraight() || n && this._detectWrongBigJump(t) || !this._areLastProjectionsInTheSameDirection() || this._disableMMCloseToATurnDistance > 0 && this._hasTurnInCircle(t.coords, this._disableMMCloseToATurnDistance) ? (Y.notify(e), !0) : (Y.notify(t.coords), this.tryOrientationMatching(t), !0);
|
|
2808
2826
|
}
|
|
2809
|
-
if (
|
|
2810
|
-
let
|
|
2811
|
-
|
|
2812
|
-
let
|
|
2813
|
-
if (
|
|
2827
|
+
if (Q.isStraight()) {
|
|
2828
|
+
let t = e.clone();
|
|
2829
|
+
t.bearing = lt.lastEvent?.heading || null;
|
|
2830
|
+
let n = this.getProjection(t, !0, !0);
|
|
2831
|
+
if (n) return this._projectionsWithAbsAndWithoutRelAttitudeInARow.push(n), this._projectionsWithAbsAndWithoutRelAttitudeInARow.length < 3 || (this._lastProjections.push(n), this._lastProjections.length > this._lastProjectionsWindowSize && this._lastProjections.shift(), !this._areLastProjectionsInTheSameDirection()) ? (Y.notify(e), !0) : (Y.notify(n.coords), this.tryOrientationMatching(n), !0);
|
|
2814
2832
|
}
|
|
2815
|
-
return this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections = [],
|
|
2833
|
+
return this._projectionsWithAbsAndWithoutRelAttitudeInARow = [], this._lastProjections = [], Y.notify(e), !0;
|
|
2816
2834
|
}
|
|
2817
2835
|
_detectWrongBigJump(e) {
|
|
2818
|
-
if (this._itineraryInfoManager &&
|
|
2819
|
-
let
|
|
2820
|
-
if (
|
|
2836
|
+
if (this._itineraryInfoManager && Y.lastEvent) {
|
|
2837
|
+
let t = this._itineraryInfoManager.getInfo(Y.lastEvent), n = this._itineraryInfoManager.getInfo(e.coords);
|
|
2838
|
+
if (t && n && t.traveledDistance > n.traveledDistance && t.traveledDistance - n.traveledDistance > e.origin.accuracy && e.distanceFromNearestElement > e.origin.accuracy && e.origin.distanceTo(Y.lastEvent) < e.origin.accuracy + Y.lastEvent.accuracy) return !0;
|
|
2821
2839
|
}
|
|
2822
2840
|
return !1;
|
|
2823
2841
|
}
|
|
2824
2842
|
_areLastProjectionsInTheSameDirection() {
|
|
2825
2843
|
if (this._lastProjections.length === 0) return !1;
|
|
2826
2844
|
let e = this._lastProjections[0];
|
|
2827
|
-
return !this._lastProjections.some((
|
|
2845
|
+
return !this._lastProjections.some((t) => !(t.nearestElement instanceof y) || !(e.nearestElement instanceof y) || g(t.nearestElement.bearing, e.nearestElement.bearing) > this._lastProjectionsEdgeAngleThreshold);
|
|
2828
2846
|
}
|
|
2829
2847
|
_nodeHasTurn(e) {
|
|
2830
2848
|
if (!this._graph) return;
|
|
2831
|
-
let
|
|
2832
|
-
for (let e = 0; e <
|
|
2849
|
+
let n = this._graph.edges.filter((t) => t.vertex1 === e || t.vertex2 === e);
|
|
2850
|
+
for (let e = 0; e < n.length; e++) for (let r = e + 1; r < n.length; r++) if (g(n[e].bearing, n[r].bearing) > t.DEFAULT_MM_MAX_ANGLE) return !0;
|
|
2833
2851
|
return !1;
|
|
2834
2852
|
}
|
|
2835
|
-
_hasTurnInCircle(e,
|
|
2836
|
-
let
|
|
2837
|
-
return
|
|
2838
|
-
}
|
|
2839
|
-
tryOrientationMatching(
|
|
2840
|
-
if (!this._useOrientationMatching || this.state !== "started" || this._countStepsFromLastMatching < this._minStepsBetweenOrientationMatching ||
|
|
2841
|
-
let { nearestElement:
|
|
2842
|
-
if (!(
|
|
2843
|
-
let
|
|
2844
|
-
|
|
2845
|
-
let
|
|
2846
|
-
|
|
2847
|
-
}
|
|
2848
|
-
getProjection(e,
|
|
2849
|
-
let
|
|
2850
|
-
...
|
|
2851
|
-
...
|
|
2853
|
+
_hasTurnInCircle(e, t) {
|
|
2854
|
+
let n = this._graph;
|
|
2855
|
+
return n ? n.vertices.filter((n) => n.coords.distanceTo(e) <= t && i.intersect(n.coords.level, e.level)).some((e) => this._nodeHasTurn(e)) : !1;
|
|
2856
|
+
}
|
|
2857
|
+
tryOrientationMatching(t) {
|
|
2858
|
+
if (!this._useOrientationMatching || this.state !== "started" || this._countStepsFromLastMatching < this._minStepsBetweenOrientationMatching || Q.numStepsDetectedFromLastTurn < this._minStepsForOrientationMatching) return;
|
|
2859
|
+
let { nearestElement: n, origin: r } = t;
|
|
2860
|
+
if (!(n instanceof y)) return;
|
|
2861
|
+
let i, a = h(n.bearing, r.bearing), o = h(n.bearing + Math.PI, r.bearing);
|
|
2862
|
+
i = Math.abs(a) < Math.abs(o) ? n.bearing : (n.bearing + Math.PI) % (2 * Math.PI);
|
|
2863
|
+
let s = new e(i, r.time, 0);
|
|
2864
|
+
X._forceHeadingForRelative(s), this._countStepsFromLastMatching = 0;
|
|
2865
|
+
}
|
|
2866
|
+
getProjection(e, t, n) {
|
|
2867
|
+
let r = {
|
|
2868
|
+
...t && !this._useStrict && { maxDistance: this._mapMatchingMaxDistance },
|
|
2869
|
+
...n && !this._useStrict && { maxBearingAngle: this._mapMatchingMaxAngleBearing }
|
|
2852
2870
|
};
|
|
2853
|
-
return this._graph?.getProjection(e,
|
|
2871
|
+
return this._graph?.getProjection(e, r);
|
|
2854
2872
|
}
|
|
2855
2873
|
get maxDistance() {
|
|
2856
2874
|
return this._mapMatchingMaxDistance;
|
|
@@ -2858,12 +2876,6 @@ var field = function(e, C, w) {
|
|
|
2858
2876
|
set maxDistance(e) {
|
|
2859
2877
|
this._mapMatchingMaxDistance = e;
|
|
2860
2878
|
}
|
|
2861
|
-
get minDistance() {
|
|
2862
|
-
return this._mapMatchingMinDistance;
|
|
2863
|
-
}
|
|
2864
|
-
set minDistance(e) {
|
|
2865
|
-
this._mapMatchingMinDistance = e;
|
|
2866
|
-
}
|
|
2867
2879
|
get maxAngleBearing() {
|
|
2868
2880
|
return this._mapMatchingMaxAngleBearing;
|
|
2869
2881
|
}
|
|
@@ -2924,7 +2936,7 @@ var field = function(e, C, w) {
|
|
|
2924
2936
|
set useStrict(e) {
|
|
2925
2937
|
this._useStrict = e;
|
|
2926
2938
|
}
|
|
2927
|
-
}(),
|
|
2939
|
+
}(), ut = class e {
|
|
2928
2940
|
static DEFAULT_FREQUENCY = 60;
|
|
2929
2941
|
static DEFAULT_FLYBY_TIME = 1;
|
|
2930
2942
|
positionsQueue = [];
|
|
@@ -2932,22 +2944,22 @@ var field = function(e, C, w) {
|
|
|
2932
2944
|
timeoutNotify;
|
|
2933
2945
|
callback;
|
|
2934
2946
|
frequency;
|
|
2935
|
-
constructor(
|
|
2936
|
-
this.callback =
|
|
2937
|
-
}
|
|
2938
|
-
feed(
|
|
2939
|
-
if (!(
|
|
2940
|
-
if (
|
|
2941
|
-
let
|
|
2942
|
-
if (this.positionsQueue.length === 0 ?
|
|
2943
|
-
let e =
|
|
2944
|
-
for (;
|
|
2945
|
-
let
|
|
2946
|
-
|
|
2947
|
+
constructor(t, n = e.DEFAULT_FREQUENCY) {
|
|
2948
|
+
this.callback = t, this.frequency = n;
|
|
2949
|
+
}
|
|
2950
|
+
feed(t, n = e.DEFAULT_FLYBY_TIME) {
|
|
2951
|
+
if (!(t instanceof o)) throw TypeError("newPosition is not instance of UserPosition");
|
|
2952
|
+
if (t.time === null) throw Error("newPosition does not have time property");
|
|
2953
|
+
let r;
|
|
2954
|
+
if (this.positionsQueue.length === 0 ? r = this.previousPosition : (r = this.positionsQueue[0], this.positionsQueue = []), r) {
|
|
2955
|
+
let e = t.time, a = r.distanceTo(t), o = r.bearingTo(t), s = 1, c = this.frequency * n + 1, l = i.clone(t.level);
|
|
2956
|
+
for (; s < c + 1;) {
|
|
2957
|
+
let n = r.destinationPoint(a * s / c, o);
|
|
2958
|
+
n.time = e + (s - 1) / this.frequency, n.level = l, n.bearing = t.bearing, n.accuracy = Math.max(n.accuracy + (t.accuracy - n.accuracy) * s / c, 0), this.positionsQueue.push(n), s++;
|
|
2947
2959
|
}
|
|
2948
2960
|
this.timeoutNotify && clearTimeout(this.timeoutNotify);
|
|
2949
|
-
} else this.positionsQueue.push(
|
|
2950
|
-
this.previousPosition =
|
|
2961
|
+
} else this.positionsQueue.push(t.clone());
|
|
2962
|
+
this.previousPosition = t, this._notifyNext();
|
|
2951
2963
|
}
|
|
2952
2964
|
_notifyNext = () => {
|
|
2953
2965
|
this.positionsQueue.length && (this.callback?.(this.positionsQueue.shift()), this.positionsQueue.length === 0 ? delete this.timeoutNotify : this.timeoutNotify = setTimeout(this._notifyNext, 1e3 / this.frequency));
|
|
@@ -2955,78 +2967,78 @@ var field = function(e, C, w) {
|
|
|
2955
2967
|
clear() {
|
|
2956
2968
|
clearTimeout(this.timeoutNotify), delete this.timeoutNotify, this.positionsQueue = [];
|
|
2957
2969
|
}
|
|
2958
|
-
},
|
|
2959
|
-
static ROTATION_SPEED_JUMP_THRESHOLD =
|
|
2960
|
-
static ROTATION_SPEED_CONVERGENCE =
|
|
2961
|
-
static HIGH_JUMP_THRESHOLD =
|
|
2962
|
-
static ROTATION_SPEED_HIGH_JUMP_CONVERGENCE =
|
|
2963
|
-
static PITCH_UNCERTAINITY_HEADING_THRESHOLD =
|
|
2970
|
+
}, dt = class e {
|
|
2971
|
+
static ROTATION_SPEED_JUMP_THRESHOLD = m(180);
|
|
2972
|
+
static ROTATION_SPEED_CONVERGENCE = m(10);
|
|
2973
|
+
static HIGH_JUMP_THRESHOLD = m(20);
|
|
2974
|
+
static ROTATION_SPEED_HIGH_JUMP_CONVERGENCE = m(100);
|
|
2975
|
+
static PITCH_UNCERTAINITY_HEADING_THRESHOLD = m(5);
|
|
2964
2976
|
_previousAttitude;
|
|
2965
2977
|
_smoothing = null;
|
|
2966
2978
|
callback;
|
|
2967
2979
|
constructor(e) {
|
|
2968
2980
|
this.callback = e;
|
|
2969
2981
|
}
|
|
2970
|
-
feed(
|
|
2971
|
-
if (
|
|
2972
|
-
let { _previousAttitude:
|
|
2973
|
-
if (this._previousAttitude =
|
|
2974
|
-
this.callback(
|
|
2982
|
+
feed(n) {
|
|
2983
|
+
if (n.time === null) throw Error("newAttitude does not have time property");
|
|
2984
|
+
let { _previousAttitude: r } = this;
|
|
2985
|
+
if (this._previousAttitude = n, !r) {
|
|
2986
|
+
this.callback(n);
|
|
2975
2987
|
return;
|
|
2976
2988
|
}
|
|
2977
|
-
if (e.isJump(
|
|
2978
|
-
let
|
|
2989
|
+
if (e.isJump(r, n)) {
|
|
2990
|
+
let i = this._smoothing === null ? r : this._smoothing.interpAttitude(r), a = i.heading, o = n.heading, s = h(o, a), c = Math.abs(s) < e.HIGH_JUMP_THRESHOLD ? e.ROTATION_SPEED_CONVERGENCE : e.ROTATION_SPEED_HIGH_JUMP_CONVERGENCE, l = i.time, d = Math.abs(s) / c, f = s < 0 ? -1 : 1;
|
|
2979
2991
|
this._smoothing = {
|
|
2980
|
-
toTime:
|
|
2992
|
+
toTime: l + d,
|
|
2981
2993
|
interpAttitude: (e) => {
|
|
2982
|
-
let
|
|
2994
|
+
let n = c * (e.time - l), r = a + n * f, i = u.fromAxisAngle([
|
|
2983
2995
|
0,
|
|
2984
2996
|
0,
|
|
2985
2997
|
1
|
|
2986
|
-
],
|
|
2987
|
-
return new
|
|
2998
|
+
], o - r);
|
|
2999
|
+
return new t(u.multiply(i, e.quaternion), e.time, e.accuracy);
|
|
2988
3000
|
}
|
|
2989
3001
|
};
|
|
2990
3002
|
}
|
|
2991
|
-
if (this._smoothing !== null) if (
|
|
3003
|
+
if (this._smoothing !== null) if (n.time >= this._smoothing.toTime) this._smoothing = null;
|
|
2992
3004
|
else {
|
|
2993
|
-
let e = this._smoothing.interpAttitude(
|
|
3005
|
+
let e = this._smoothing.interpAttitude(n);
|
|
2994
3006
|
this.callback(e);
|
|
2995
3007
|
return;
|
|
2996
3008
|
}
|
|
2997
|
-
this.callback(
|
|
3009
|
+
this.callback(n);
|
|
2998
3010
|
}
|
|
2999
|
-
static isJump(
|
|
3000
|
-
let
|
|
3001
|
-
return Math.abs(Math.asin(2 * (
|
|
3011
|
+
static isJump(t, n) {
|
|
3012
|
+
let r = t.heading, i = n.heading, a = h(i, r), o = n.time - t.time, [s, c, l, u] = n.quaternion;
|
|
3013
|
+
return Math.abs(Math.asin(2 * (s * c + l * u)) - Math.PI / 4) < e.PITCH_UNCERTAINITY_HEADING_THRESHOLD ? !1 : Math.abs(a) > e.ROTATION_SPEED_JUMP_THRESHOLD * o;
|
|
3002
3014
|
}
|
|
3003
|
-
},
|
|
3015
|
+
}, ft = new class extends j {
|
|
3004
3016
|
getName = () => "MagnetometerCalibrationProvider";
|
|
3005
|
-
availability = () =>
|
|
3017
|
+
availability = () => X.getAvailability();
|
|
3006
3018
|
constructor() {
|
|
3007
|
-
super(),
|
|
3019
|
+
super(), X._setCallbackMagCalibration((e) => this.state === "started" && this.notify(e));
|
|
3008
3020
|
}
|
|
3009
3021
|
start() {}
|
|
3010
3022
|
stop() {}
|
|
3011
|
-
}(),
|
|
3023
|
+
}(), pt = class e extends Error {
|
|
3012
3024
|
static DEFAULT_MESSAGE = "IP Resolver failed";
|
|
3013
|
-
constructor(
|
|
3014
|
-
super(
|
|
3025
|
+
constructor(t) {
|
|
3026
|
+
super(t || e.DEFAULT_MESSAGE);
|
|
3015
3027
|
}
|
|
3016
|
-
},
|
|
3028
|
+
}, mt = new class extends j {
|
|
3017
3029
|
getName = () => "Ip";
|
|
3018
3030
|
availability = () => Promise.resolve();
|
|
3019
3031
|
async start() {
|
|
3020
3032
|
let e = await fetch("https://ipinfo.io/geo?token=24a7ca2f3b489d");
|
|
3021
3033
|
if (!e) {
|
|
3022
|
-
this.notifyError(new
|
|
3034
|
+
this.notifyError(new pt());
|
|
3023
3035
|
return;
|
|
3024
3036
|
}
|
|
3025
|
-
let
|
|
3026
|
-
this.notify(
|
|
3037
|
+
let t = C.preciseTime() / 1e3, n = (await e.json()).loc.split(","), r = new o(parseFloat(n[0]), parseFloat(n[1]), null, null, t, 1e5);
|
|
3038
|
+
this.notify(r);
|
|
3027
3039
|
}
|
|
3028
3040
|
stop() {}
|
|
3029
|
-
}(),
|
|
3041
|
+
}(), ht = class e {
|
|
3030
3042
|
static MAX_CONSECUTIVE_FAILURES = 10;
|
|
3031
3043
|
intervalMs;
|
|
3032
3044
|
enabled;
|
|
@@ -3039,8 +3051,8 @@ var field = function(e, C, w) {
|
|
|
3039
3051
|
statusCallbacks = /* @__PURE__ */ new Set();
|
|
3040
3052
|
onResult;
|
|
3041
3053
|
onError;
|
|
3042
|
-
constructor(e,
|
|
3043
|
-
this.onResult =
|
|
3054
|
+
constructor(e, t, n) {
|
|
3055
|
+
this.onResult = t, this.onError = n, this.intervalMs = e.intervalMs ?? 3e4, this.enabled = e.enabled ?? !1, this._status = this.enabled ? "idle" : "disabled";
|
|
3044
3056
|
}
|
|
3045
3057
|
get status() {
|
|
3046
3058
|
return this._status;
|
|
@@ -3062,10 +3074,10 @@ var field = function(e, C, w) {
|
|
|
3062
3074
|
}, this.intervalMs), this.setStatus("scheduled"));
|
|
3063
3075
|
}
|
|
3064
3076
|
async cancelRunningScan() {
|
|
3065
|
-
this.isBackgroundScanRunning && (this.listenerId !== null && (
|
|
3077
|
+
this.isBackgroundScanRunning && (this.listenerId !== null && (J.removeEventListener(this.listenerId), this.listenerId = null, J.stop()), this.scanFailureListenerId !== null && (J.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled"));
|
|
3066
3078
|
}
|
|
3067
3079
|
clear() {
|
|
3068
|
-
this.clearTimeoutOnly(), this.listenerId !== null && (
|
|
3080
|
+
this.clearTimeoutOnly(), this.listenerId !== null && (J.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (J.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), this.isBackgroundScanRunning = !1, this.setStatus(this.enabled ? "idle" : "disabled");
|
|
3069
3081
|
}
|
|
3070
3082
|
runNow() {
|
|
3071
3083
|
this.enabled && (this.clearTimeoutOnly(), this.startBackgroundScan());
|
|
@@ -3075,60 +3087,61 @@ var field = function(e, C, w) {
|
|
|
3075
3087
|
}
|
|
3076
3088
|
async startBackgroundScan() {
|
|
3077
3089
|
if (!this.enabled || this.isBackgroundScanRunning || this.listenerId !== null) return;
|
|
3078
|
-
let
|
|
3079
|
-
if (
|
|
3080
|
-
this.onError(
|
|
3090
|
+
let t = await J.getAvailability();
|
|
3091
|
+
if (t instanceof Error) {
|
|
3092
|
+
this.onError(t), this.setStatus("idle");
|
|
3081
3093
|
return;
|
|
3082
3094
|
}
|
|
3083
|
-
this.isBackgroundScanRunning = !0, this.setStatus("scanning"), this.scanFailureListenerId =
|
|
3084
|
-
!this.isBackgroundScanRunning || this.scanFailureListenerId === null ||
|
|
3085
|
-
}), this.listenerId =
|
|
3095
|
+
this.isBackgroundScanRunning = !0, this.setStatus("scanning"), this.scanFailureListenerId = J.addScanFailureListener((t) => {
|
|
3096
|
+
!this.isBackgroundScanRunning || this.scanFailureListenerId === null || t.listenerId !== this.scanFailureListenerId || (this.consecutiveFailures += 1, this.consecutiveFailures >= e.MAX_CONSECUTIVE_FAILURES && (this.consecutiveFailures = 0, J.resetCurrentAttempt(), this.cleanupListener(), this.schedule()));
|
|
3097
|
+
}), this.listenerId = J.addEventListener((e) => {
|
|
3086
3098
|
this.consecutiveFailures = 0, this.cleanupListener(), this.onResult(e), this.schedule();
|
|
3087
3099
|
}, (e) => {
|
|
3088
3100
|
this.cleanupListener(), this.onError(e), this.schedule();
|
|
3089
3101
|
});
|
|
3090
3102
|
}
|
|
3091
3103
|
cleanupListener() {
|
|
3092
|
-
this.listenerId !== null && (
|
|
3104
|
+
this.listenerId !== null && (J.removeEventListener(this.listenerId), this.listenerId = null), this.scanFailureListenerId !== null && (J.removeScanFailureListener(this.scanFailureListenerId), this.scanFailureListenerId = null), J.stop(), this.isBackgroundScanRunning = !1, this.enabled ? this.setStatus("idle") : this.setStatus("disabled");
|
|
3093
3105
|
}
|
|
3094
3106
|
setStatus(e) {
|
|
3095
|
-
this._status !== e && (this._status = e, this.statusCallbacks.forEach((
|
|
3107
|
+
this._status !== e && (this._status = e, this.statusCallbacks.forEach((t) => {
|
|
3096
3108
|
try {
|
|
3097
|
-
|
|
3109
|
+
t(e);
|
|
3098
3110
|
} catch (e) {
|
|
3099
3111
|
console.error("[VpsBackgroundScanner] Error in status listener", e);
|
|
3100
3112
|
}
|
|
3101
3113
|
}));
|
|
3102
3114
|
}
|
|
3103
|
-
},
|
|
3115
|
+
}, gt = new class extends j {
|
|
3104
3116
|
providerId;
|
|
3105
3117
|
getName = () => "Barcode";
|
|
3106
|
-
availability = () =>
|
|
3118
|
+
availability = () => z.getAvailability();
|
|
3107
3119
|
start() {
|
|
3108
|
-
|
|
3120
|
+
z.enableBarcodeScanner(), this.providerId = z.addEventListener((e) => e.barcode && this.notify(e.barcode), this.notifyError);
|
|
3109
3121
|
}
|
|
3110
3122
|
stop() {
|
|
3111
|
-
|
|
3123
|
+
z.disableBarcodeScanner(), z.removeEventListener(this.providerId);
|
|
3112
3124
|
}
|
|
3113
|
-
}(),
|
|
3125
|
+
}(), _t = new class extends j {
|
|
3114
3126
|
providerId;
|
|
3115
3127
|
getName = () => "CameraNative";
|
|
3116
3128
|
availability = () => Promise.resolve();
|
|
3117
3129
|
start() {
|
|
3118
|
-
|
|
3130
|
+
z.state !== "stopped" && this.notify("started"), this.providerId = z.addMonitoringListener(() => this.notify("started"), () => this.notify("stopped"));
|
|
3119
3131
|
}
|
|
3120
3132
|
stop() {
|
|
3121
|
-
|
|
3133
|
+
z.removeMonitoringListener(this.providerId);
|
|
3122
3134
|
}
|
|
3123
|
-
}(),
|
|
3135
|
+
}(), vt = new class extends j {
|
|
3124
3136
|
providerId;
|
|
3125
3137
|
getName = () => "CameraProjectionMatrix";
|
|
3126
|
-
availability = () =>
|
|
3138
|
+
availability = () => z.getAvailability();
|
|
3127
3139
|
start() {
|
|
3128
|
-
this.providerId =
|
|
3140
|
+
this.providerId = z.addEventListener((e) => e.cameraProjection && this.notify(e.cameraProjection), this.notifyError);
|
|
3129
3141
|
}
|
|
3130
3142
|
stop() {
|
|
3131
|
-
|
|
3143
|
+
z.removeEventListener(this.providerId);
|
|
3132
3144
|
}
|
|
3133
3145
|
}();
|
|
3134
|
-
|
|
3146
|
+
//#endregion
|
|
3147
|
+
export { ae as AbsoluteAttitude, lt as AbsoluteAttitudeFromBrowserProvider, X as AbsoluteAttitudeProvider, re as AbsolutePosition, Y as AbsolutePositionProvider, V as AccelerometerProvider, z as ArCoreProvider, dt as AttitudeSmoother, gt as BarcodeProvider, _t as CameraNativeProvider, vt as CameraProjectionMatrixProvider, Fe as Constants, ze as GeoRelativePositionFromArCoreProvider, Qe as GeoRelativePositionProvider, Ie as GnssWifiProvider, H as GyroscopeProvider, U as HighRotationsProvider, at as ImageRelocalization, B as ImuProvider, et as InclinationFromAccProvider, tt as InclinationFromRelativeAttitudeProvider, K as InclinationProvider, mt as IpProvider, ft as MagnetometerCalibrationProvider, $ as MapMatchingHandler, Ze as PdrProvider, ct as PoleStarProvider, ut as PositionSmoother, ue as ProvidersLoggerOld, D as ProvidersOptions, ie as RelativeAttitude, Ke as RelativeAttitudeFromBrowserProvider, Ge as RelativeAttitudeFromEkfProvider, W as RelativeAttitudeFromInertialProvider, q as RelativeAttitudeProvider, ot as RelativeRotationCalc, Ye as StepDetectionMinMaxPeaks2, Xe as StepDetectionMinMaxPeaks3, G as StepProvider, Q as StraightLineProvider, Z as TurnProvider, ht as VpsBackgroundScanner, nt as VpsMetadata, J as VpsProvider, rt as VpsRequest, it as VpsResponse };
|