@aibee/crc-bmap 0.8.40 → 0.8.41
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/lib/bmap.cjs.min.js +9 -9
- package/lib/bmap.esm.js +32 -7
- package/lib/bmap.esm.min.js +9 -9
- package/lib/bmap.min.js +9 -9
- package/lib/src/plugins/car-inertial-position/compass.js +7 -1
- package/lib/src/plugins/car-inertial-position/utils.js +7 -0
- package/lib/src/plugins/navigation/navigation.d.ts +2 -2
- package/lib/src/plugins/navigation/position-navigation.d.ts +7 -5
- package/lib/src/plugins/navigation/position-navigation.js +13 -5
- package/lib/src/utils/road2.d.ts +8 -0
- package/lib/src/utils/road2.js +4 -0
- package/package.json +1 -1
|
@@ -17,6 +17,9 @@ import { removeOutliers } from "./utils";
|
|
|
17
17
|
* @param compass
|
|
18
18
|
* @param time
|
|
19
19
|
*/ setAbsoluteCompass(compass, time) {
|
|
20
|
+
if (!this.delta) {
|
|
21
|
+
this.emitCompass(compass);
|
|
22
|
+
}
|
|
20
23
|
if (!this.compassData.length) {
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
@@ -41,10 +44,13 @@ import { removeOutliers } from "./utils";
|
|
|
41
44
|
const delta = compass - curCompass.res;
|
|
42
45
|
this.deltas.push(delta);
|
|
43
46
|
const deltas = removeOutliers(this.deltas);
|
|
44
|
-
|
|
47
|
+
if (deltas.length) {
|
|
48
|
+
this.delta = deltas.reduce((sum, cur)=>sum + cur, 0) / deltas.length;
|
|
49
|
+
}
|
|
45
50
|
}
|
|
46
51
|
emitCompass(compass) {
|
|
47
52
|
// 把 compass 限制在 0 ~ 360
|
|
53
|
+
console.log("compass delta", this.delta, compass);
|
|
48
54
|
this.dispatchEvent({
|
|
49
55
|
type: "compass",
|
|
50
56
|
value: (compass + this.delta + 360) % 360
|
|
@@ -63,7 +63,9 @@ import { Vector2 } from "three";
|
|
|
63
63
|
* @param timeIntervalMs
|
|
64
64
|
* @returns
|
|
65
65
|
*/ export function predictFutureSpeed(positions, timeIntervalMs) {
|
|
66
|
+
console.log("timeIntervalMs", timeIntervalMs);
|
|
66
67
|
const speeds = calculateInstantaneousSpeed(positions);
|
|
68
|
+
console.log("speeds", speeds);
|
|
67
69
|
const n = speeds.length;
|
|
68
70
|
if (n === 0) {
|
|
69
71
|
return 0; // 如果没有速度数据,返回0
|
|
@@ -75,8 +77,13 @@ import { Vector2 } from "three";
|
|
|
75
77
|
if (n > 1) {
|
|
76
78
|
const speedDifferences = speeds.slice(1).map((speed, index)=>speed - speeds[index]);
|
|
77
79
|
const time = positions.slice(1).reduce((sum, cur, index)=>sum + (cur.time - positions[index].time), 0);
|
|
80
|
+
console.log("time", time);
|
|
81
|
+
if (!time) {
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
78
84
|
acceleration = speedDifferences.reduce((sum, value)=>sum + value, 0) / time;
|
|
79
85
|
}
|
|
86
|
+
console.log("acceleration", acceleration);
|
|
80
87
|
// 预测未来速度 m/ms
|
|
81
88
|
const futureSpeed = Math.max(currentSpeed + acceleration * timeIntervalMs, 0);
|
|
82
89
|
return futureSpeed;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BMap } from "../../bmap";
|
|
2
2
|
import { Plugin } from "../base";
|
|
3
3
|
import { Path, PathConfig } from "./path";
|
|
4
|
-
import { PathData2, TweenUtil,
|
|
4
|
+
import { PathData2, TweenUtil, RoadData2 } from "../../utils";
|
|
5
5
|
import { Floor, Poi2, PoiOptions2 } from "../../elements";
|
|
6
6
|
import { Tween } from "@tweenjs/tween.js";
|
|
7
7
|
import { type NavigationProcessInfo, PositionNavigation, type PositionNavigationConfig } from "./position-navigation";
|
|
@@ -24,7 +24,7 @@ interface EventMap {
|
|
|
24
24
|
info: NavigationProcessInfo;
|
|
25
25
|
};
|
|
26
26
|
"add-path": {
|
|
27
|
-
paths: PathData2
|
|
27
|
+
paths: PathData2;
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
export interface NavigationConfig {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventDispatcher } from "three";
|
|
2
2
|
import { Navigation } from "./navigation";
|
|
3
|
-
import {
|
|
3
|
+
import { PathData2, PathDirection, RoadData2, Timer, TweenUtil } from "../../utils";
|
|
4
4
|
import { Tween } from "@tweenjs/tween.js";
|
|
5
5
|
import { DebouncedFuncLeading } from 'lodash';
|
|
6
6
|
export interface PositionNavigationConfig {
|
|
@@ -16,6 +16,7 @@ export interface NavigationProcessInfo {
|
|
|
16
16
|
dir: PathDirection;
|
|
17
17
|
pos: [number, number];
|
|
18
18
|
routeIndex: number;
|
|
19
|
+
crossName: string;
|
|
19
20
|
offset: boolean;
|
|
20
21
|
reset: boolean;
|
|
21
22
|
}
|
|
@@ -31,7 +32,7 @@ export declare class PositionNavigation extends EventDispatcher<PositionNavigati
|
|
|
31
32
|
position: [number, number];
|
|
32
33
|
routeIndex: number;
|
|
33
34
|
pointIndex: number;
|
|
34
|
-
paths:
|
|
35
|
+
paths: PathData2;
|
|
35
36
|
options: PositionNavigationConfig;
|
|
36
37
|
timer: Timer;
|
|
37
38
|
resetTimer: number | null;
|
|
@@ -41,15 +42,15 @@ export declare class PositionNavigation extends EventDispatcher<PositionNavigati
|
|
|
41
42
|
roadData: RoadData2[];
|
|
42
43
|
paused: boolean;
|
|
43
44
|
constructor(navigation: Navigation, options: Partial<PositionNavigationConfig>, roadData: RoadData2[]);
|
|
44
|
-
get curRoutePath():
|
|
45
|
+
get curRoutePath(): PathData2[0] | null;
|
|
45
46
|
get curRoutePathPoints(): [number, number][];
|
|
46
47
|
registryEvent(): void;
|
|
47
48
|
unRegistryEvent(): void;
|
|
48
49
|
onAddPaths: ({ paths }: {
|
|
49
|
-
paths:
|
|
50
|
+
paths: PathData2;
|
|
50
51
|
}) => void;
|
|
51
52
|
onUpdate: () => void;
|
|
52
|
-
resetStatus(paths:
|
|
53
|
+
resetStatus(paths: PathData2): void;
|
|
53
54
|
emitNavigationStatus(): void;
|
|
54
55
|
adsorb(floor: string, _position: [number, number]): {
|
|
55
56
|
distance: number;
|
|
@@ -72,6 +73,7 @@ export declare class PositionNavigation extends EventDispatcher<PositionNavigati
|
|
|
72
73
|
getNextDirDistance(): {
|
|
73
74
|
dir: PathDirection;
|
|
74
75
|
distance: number;
|
|
76
|
+
crossName: string;
|
|
75
77
|
} | null;
|
|
76
78
|
private getNavigationInfo;
|
|
77
79
|
dispose(): void;
|
|
@@ -249,12 +249,14 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
249
249
|
}
|
|
250
250
|
// 计算下一个拐弯点的方向和距离
|
|
251
251
|
getNextDirDistance() {
|
|
252
|
+
var _curRoutePath_pointInfos_index;
|
|
252
253
|
if (!this.position) {
|
|
253
254
|
return null;
|
|
254
255
|
}
|
|
255
|
-
const { pointIndex, curRoutePathPoints, position } = this;
|
|
256
|
+
const { pointIndex, curRoutePathPoints, position, curRoutePath } = this;
|
|
256
257
|
let index = pointIndex;
|
|
257
258
|
let dir = PathDirection.FRONT;
|
|
259
|
+
let crossName = (curRoutePath == null ? void 0 : (_curRoutePath_pointInfos_index = curRoutePath.pointInfos[index]) == null ? void 0 : _curRoutePath_pointInfos_index.crossName) || "";
|
|
258
260
|
let distance = 0;
|
|
259
261
|
let t = Date.now(); // 循环控制在5ms内,防止死循环
|
|
260
262
|
while(dir === PathDirection.FRONT && distance < this.options.directionEmitThreshold && Date.now() - t < 5){
|
|
@@ -276,6 +278,8 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
276
278
|
dir = PathDirection.END;
|
|
277
279
|
} else {
|
|
278
280
|
dir = calc_direction(p1, p2, p3);
|
|
281
|
+
var _curRoutePath_pointInfos__crossName;
|
|
282
|
+
crossName = (_curRoutePath_pointInfos__crossName = curRoutePath == null ? void 0 : curRoutePath.pointInfos[index + 1].crossName) != null ? _curRoutePath_pointInfos__crossName : "";
|
|
279
283
|
index += 1;
|
|
280
284
|
}
|
|
281
285
|
}
|
|
@@ -285,7 +289,8 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
285
289
|
if (dir === PathDirection.END && distance <= this.options.directionEmitThreshold) {
|
|
286
290
|
return {
|
|
287
291
|
dir,
|
|
288
|
-
distance
|
|
292
|
+
distance,
|
|
293
|
+
crossName
|
|
289
294
|
};
|
|
290
295
|
}
|
|
291
296
|
// 其他情况下判断距离起点的距离,如果是 <= 5米 就是start
|
|
@@ -293,7 +298,8 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
293
298
|
if (distanceToStart <= 5) {
|
|
294
299
|
return {
|
|
295
300
|
dir: PathDirection.START,
|
|
296
|
-
distance
|
|
301
|
+
distance,
|
|
302
|
+
crossName
|
|
297
303
|
};
|
|
298
304
|
}
|
|
299
305
|
// 其他情况根据拐弯距离判断是不是直行
|
|
@@ -302,7 +308,8 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
302
308
|
}
|
|
303
309
|
return {
|
|
304
310
|
dir,
|
|
305
|
-
distance
|
|
311
|
+
distance,
|
|
312
|
+
crossName
|
|
306
313
|
};
|
|
307
314
|
}
|
|
308
315
|
getNavigationInfo() {
|
|
@@ -314,7 +321,7 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
314
321
|
if (!nextDirInfo) {
|
|
315
322
|
return null;
|
|
316
323
|
}
|
|
317
|
-
let { dir, distance: nextDirDistance } = nextDirInfo;
|
|
324
|
+
let { dir, distance: nextDirDistance, crossName } = nextDirInfo;
|
|
318
325
|
if (dir === PathDirection.END && nextDirDistance > 15) {
|
|
319
326
|
// 请直行
|
|
320
327
|
dir = PathDirection.FRONT;
|
|
@@ -330,6 +337,7 @@ export class PositionNavigation extends EventDispatcher {
|
|
|
330
337
|
dir,
|
|
331
338
|
pos: this.position,
|
|
332
339
|
routeIndex: this.routeIndex,
|
|
340
|
+
crossName,
|
|
333
341
|
offset: this.offset,
|
|
334
342
|
reset: this.reset
|
|
335
343
|
};
|
package/lib/src/utils/road2.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface RoadData2 {
|
|
|
30
30
|
endTime?: string;
|
|
31
31
|
permission?: number;
|
|
32
32
|
relatedId?: string;
|
|
33
|
+
crossName?: string;
|
|
33
34
|
}>;
|
|
34
35
|
}
|
|
35
36
|
export interface Facility {
|
|
@@ -74,6 +75,7 @@ export type RouteType2 = "" | "escalator" | "straightLadder" | "forward";
|
|
|
74
75
|
export type PathData2 = {
|
|
75
76
|
floor: string;
|
|
76
77
|
points: [number, number][];
|
|
78
|
+
pointInfos: RoadData2['points'];
|
|
77
79
|
endType: string;
|
|
78
80
|
destId: string;
|
|
79
81
|
distance: number;
|
|
@@ -101,6 +103,7 @@ export declare class RoadNetwork2 {
|
|
|
101
103
|
endTime?: string;
|
|
102
104
|
permission?: number;
|
|
103
105
|
relatedId?: string;
|
|
106
|
+
crossName?: string;
|
|
104
107
|
}>;
|
|
105
108
|
nodeMap: Map<string, string>;
|
|
106
109
|
facilityMap: Map<string, {
|
|
@@ -121,6 +124,7 @@ export declare class RoadNetwork2 {
|
|
|
121
124
|
endTime?: string;
|
|
122
125
|
permission?: number;
|
|
123
126
|
relatedId?: string;
|
|
127
|
+
crossName?: string;
|
|
124
128
|
}[]>;
|
|
125
129
|
straightLadderMap: Map<string, {
|
|
126
130
|
id: string;
|
|
@@ -140,6 +144,7 @@ export declare class RoadNetwork2 {
|
|
|
140
144
|
endTime?: string;
|
|
141
145
|
permission?: number;
|
|
142
146
|
relatedId?: string;
|
|
147
|
+
crossName?: string;
|
|
143
148
|
}[]>;
|
|
144
149
|
escalatorMap: Map<string, {
|
|
145
150
|
start?: RoadData2["points"][0];
|
|
@@ -167,6 +172,7 @@ export declare class RoadNetwork2 {
|
|
|
167
172
|
endTime?: string;
|
|
168
173
|
permission?: number;
|
|
169
174
|
relatedId?: string;
|
|
175
|
+
crossName?: string;
|
|
170
176
|
}[]>;
|
|
171
177
|
connectionPointMap: Map<string, {
|
|
172
178
|
id: string;
|
|
@@ -186,6 +192,7 @@ export declare class RoadNetwork2 {
|
|
|
186
192
|
endTime?: string;
|
|
187
193
|
permission?: number;
|
|
188
194
|
relatedId?: string;
|
|
195
|
+
crossName?: string;
|
|
189
196
|
}[]>;
|
|
190
197
|
parkingMap: Map<string, {
|
|
191
198
|
id: string;
|
|
@@ -205,6 +212,7 @@ export declare class RoadNetwork2 {
|
|
|
205
212
|
endTime?: string;
|
|
206
213
|
permission?: number;
|
|
207
214
|
relatedId?: string;
|
|
215
|
+
crossName?: string;
|
|
208
216
|
}>;
|
|
209
217
|
lineMap: Map<string, Map<string, number>>;
|
|
210
218
|
baseRoute: Graph;
|
package/lib/src/utils/road2.js
CHANGED
|
@@ -738,6 +738,7 @@ export class RoadNetwork2 {
|
|
|
738
738
|
if (((_arr_ = arr[arr.length - 1]) == null ? void 0 : _arr_.floor) === floor) {
|
|
739
739
|
const pathData = arr[arr.length - 1];
|
|
740
740
|
pathData.points.push(point.cds);
|
|
741
|
+
pathData.pointInfos.push(point);
|
|
741
742
|
// type: normal | graph | escalator(扶梯) | straightLadder(直梯) | staircase(楼梯) | facility(设备) | connectionPoint(路网连接点)
|
|
742
743
|
pathData.endType = endType;
|
|
743
744
|
pathData.destId = point.nodeId;
|
|
@@ -748,6 +749,9 @@ export class RoadNetwork2 {
|
|
|
748
749
|
points: [
|
|
749
750
|
point.cds
|
|
750
751
|
],
|
|
752
|
+
pointInfos: [
|
|
753
|
+
point
|
|
754
|
+
],
|
|
751
755
|
endType: endType,
|
|
752
756
|
destId: point.nodeId,
|
|
753
757
|
distance: 0,
|