@aibee/crc-bmap 0.8.11 → 0.8.13
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.esm.js
CHANGED
|
@@ -3843,6 +3843,8 @@ var TaskQueue = class extends EventDispatcher2 {
|
|
|
3843
3843
|
const findTask = this._task.find((item) => item.meta.type === type);
|
|
3844
3844
|
if (findTask) {
|
|
3845
3845
|
return this.replace(findTask.tid, task);
|
|
3846
|
+
} else {
|
|
3847
|
+
return this.add(task);
|
|
3846
3848
|
}
|
|
3847
3849
|
}
|
|
3848
3850
|
}
|
|
@@ -10776,6 +10778,14 @@ var PositionNavigation = class extends EventDispatcher13 {
|
|
|
10776
10778
|
const path = [position, ...curRoutePathPoints.slice(pointIndex + 1)];
|
|
10777
10779
|
return getPathLength(path);
|
|
10778
10780
|
}
|
|
10781
|
+
getCurRouteToStartDistance() {
|
|
10782
|
+
const { curRoutePathPoints, pointIndex, position } = this;
|
|
10783
|
+
if (!curRoutePathPoints.length) {
|
|
10784
|
+
return 0;
|
|
10785
|
+
}
|
|
10786
|
+
const path = [...curRoutePathPoints.slice(0, pointIndex + 1), position];
|
|
10787
|
+
return getPathLength(path);
|
|
10788
|
+
}
|
|
10779
10789
|
// 计算剩余距离
|
|
10780
10790
|
getRemainDistance() {
|
|
10781
10791
|
const curPathRemainDistance = this.getCurRouteRemainDistance();
|
|
@@ -10792,28 +10802,46 @@ var PositionNavigation = class extends EventDispatcher13 {
|
|
|
10792
10802
|
return null;
|
|
10793
10803
|
}
|
|
10794
10804
|
const { pointIndex, curRoutePathPoints, position } = this;
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10805
|
+
let index = pointIndex;
|
|
10806
|
+
let dir = "front" /* FRONT */;
|
|
10807
|
+
let distance = 0;
|
|
10808
|
+
while (dir === "front" /* FRONT */ && distance < this.options.directionEmitThreshold) {
|
|
10809
|
+
const p1 = curRoutePathPoints[index];
|
|
10810
|
+
const p2 = curRoutePathPoints[index + 1];
|
|
10811
|
+
const p3 = curRoutePathPoints[index + 2];
|
|
10812
|
+
if (!p1 || !p2) {
|
|
10813
|
+
dir = "end" /* END */;
|
|
10814
|
+
} else {
|
|
10815
|
+
if (pointIndex === 0) {
|
|
10816
|
+
const l = getLength(p1, position);
|
|
10817
|
+
if (l < 5) {
|
|
10818
|
+
dir = "start" /* START */;
|
|
10819
|
+
}
|
|
10820
|
+
} else {
|
|
10821
|
+
distance += getLength(position, p2);
|
|
10822
|
+
if (!p3) {
|
|
10823
|
+
dir = "end" /* END */;
|
|
10824
|
+
} else {
|
|
10825
|
+
dir = calc_direction(p1, p2, p3);
|
|
10826
|
+
index += 1;
|
|
10827
|
+
}
|
|
10828
|
+
}
|
|
10806
10829
|
}
|
|
10807
10830
|
}
|
|
10808
|
-
if (
|
|
10809
|
-
return { dir
|
|
10831
|
+
if (dir === "end" /* END */ && distance <= this.options.directionEmitThreshold) {
|
|
10832
|
+
return { dir, distance };
|
|
10833
|
+
}
|
|
10834
|
+
const distanceToStart = this.getCurRouteToStartDistance();
|
|
10835
|
+
if (distanceToStart <= 5) {
|
|
10836
|
+
return { dir: "start" /* START */, distance };
|
|
10837
|
+
}
|
|
10838
|
+
if (distance >= this.options.directionEmitThreshold) {
|
|
10839
|
+
dir = "front" /* FRONT */;
|
|
10810
10840
|
}
|
|
10811
|
-
const dir = calc_direction(p1, p2, p3);
|
|
10812
10841
|
return { dir, distance };
|
|
10813
10842
|
}
|
|
10814
10843
|
getNavigationInfo() {
|
|
10815
10844
|
const { total: remainDistance, curRoute: curRouteRemainDistance } = this.getRemainDistance();
|
|
10816
|
-
console.log(remainDistance, curRouteRemainDistance, this.paths);
|
|
10817
10845
|
const nextDirInfo = this.getNextDirDistance();
|
|
10818
10846
|
if (!nextDirInfo) {
|
|
10819
10847
|
return null;
|
|
@@ -10822,9 +10850,6 @@ var PositionNavigation = class extends EventDispatcher13 {
|
|
|
10822
10850
|
if (dir === "end" /* END */ && nextDirDistance > 15) {
|
|
10823
10851
|
dir = "front" /* FRONT */;
|
|
10824
10852
|
}
|
|
10825
|
-
if (dir !== "start" /* START */ && nextDirDistance >= this.options.directionEmitThreshold) {
|
|
10826
|
-
dir = "front" /* FRONT */;
|
|
10827
|
-
}
|
|
10828
10853
|
if (curRouteRemainDistance <= 10) {
|
|
10829
10854
|
dir = "end" /* END */;
|
|
10830
10855
|
}
|