@heycar/heycars-map 2.8.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +1 -1
- package/dist/v2/business-components/TrafficDrivingLine/TrafficDrivingLine.js +37 -13
- package/dist/v2/hooks/useDeviationCorrectionDrivingRoute.js +6 -2
- package/dist/v2/types/interface.d.ts +4 -1
- package/dist/v2/utils/compatibleDrivingRoute.js +11 -3
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/transform.d.ts +1 -0
- package/dist/v2/utils/transform.js +4 -0
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +1 -1
- package/dist/v3/business-components/TrafficDrivingLine/TrafficDrivingLine.js +37 -13
- package/dist/v3/hooks/useDeviationCorrectionDrivingRoute.js +6 -2
- package/dist/v3/types/interface.d.ts +4 -1
- package/dist/v3/utils/compatibleDrivingRoute.js +11 -3
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/transform.d.ts +1 -0
- package/dist/v3/utils/transform.js +4 -0
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ import { WalkingRoute } from "../WalkingRoute/WalkingRoute.js";
|
|
|
20
20
|
import { WaveCircle } from "../WaveCircle/WaveCircle.js";
|
|
21
21
|
const IS_ENABLE_AUXILIARY_GRASP_ROAD = apiGetAuxiliaryGrapStatus();
|
|
22
22
|
const PASSENGER_DISTANCE_MAX = 2e3;
|
|
23
|
-
const PASSENGER_DISTANCE_MIN =
|
|
23
|
+
const PASSENGER_DISTANCE_MIN = 20;
|
|
24
24
|
const AUTO_FIT_VIEW_INTERVAL = IS_ENABLE_AUXILIARY_GRASP_ROAD ? 24 * 3600 * 1e3 : 15e3;
|
|
25
25
|
const carDurationWithinMinDistance = (distance) => Math.floor(distance / 5);
|
|
26
26
|
const SectionDispatching = defineSetup("SectionDispatching", function(props) {
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { h } from "vue";
|
|
2
2
|
import { defineSetup } from "../../types/helper.js";
|
|
3
|
-
import { stringifyPoint } from "../../utils/transform.js";
|
|
3
|
+
import { stringifyPoint, isPointExactEqual } from "../../utils/transform.js";
|
|
4
4
|
import { DrivingLine } from "../DrivingLine/DrivingLine.js";
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const toHalfPath = (path, isFromStart = true) => {
|
|
6
|
+
if (path.length < 2)
|
|
7
|
+
return path;
|
|
8
|
+
const [[x0, y0], [x1, y1]] = path;
|
|
9
|
+
const mid = [(x0 + x1) / 2, (y0 + y1) / 2];
|
|
10
|
+
return isFromStart ? [[x0, y0], mid] : [mid, [x1, y1]];
|
|
11
|
+
};
|
|
12
|
+
const isSlowOrJam = (status) => {
|
|
13
|
+
return status === "SLOW" || status === "TRAFFIC_JAM" || status === "HEAVY_TRAFFIC_JAM";
|
|
14
|
+
};
|
|
15
|
+
const justifyFirstPointStatus = (firstPointStatus, secondPointBeforeStatus) => {
|
|
16
|
+
return (firstPointStatus === void 0 || firstPointStatus === "UNKNOWN") && !!secondPointBeforeStatus && secondPointBeforeStatus !== "UNKNOWN" ? secondPointBeforeStatus : firstPointStatus != null ? firstPointStatus : "UNKNOWN";
|
|
7
17
|
};
|
|
8
18
|
const createMulitpleLineByTrafficJams = (path, trafficJams) => {
|
|
9
|
-
var _a;
|
|
19
|
+
var _a, _b, _c, _d;
|
|
10
20
|
if (!trafficJams)
|
|
11
21
|
return [{
|
|
12
22
|
path,
|
|
@@ -18,12 +28,13 @@ const createMulitpleLineByTrafficJams = (path, trafficJams) => {
|
|
|
18
28
|
const multipleLines = [];
|
|
19
29
|
let line = {
|
|
20
30
|
path: [firstPoint],
|
|
21
|
-
status: justifyFirstPointStatus(trafficJams[stringifyPoint(firstPoint)], trafficJams[stringifyPoint(path[1])])
|
|
31
|
+
status: justifyFirstPointStatus((_a = trafficJams[stringifyPoint(firstPoint)]) == null ? void 0 : _a.after, (_b = trafficJams[stringifyPoint(path[1])]) == null ? void 0 : _b.before)
|
|
22
32
|
};
|
|
23
|
-
for (let idx =
|
|
33
|
+
for (let idx = 1; idx < path.length; idx++) {
|
|
24
34
|
const point = path[idx];
|
|
25
|
-
const traffic = (
|
|
26
|
-
|
|
35
|
+
const traffic = (_d = (_c = trafficJams[stringifyPoint(point)]) == null ? void 0 : _c.after) != null ? _d : "UNKNOWN";
|
|
36
|
+
if (!isPointExactEqual(point, path[idx - 1]))
|
|
37
|
+
line.path.push(point);
|
|
27
38
|
if (traffic === line.status)
|
|
28
39
|
continue;
|
|
29
40
|
multipleLines.push(line);
|
|
@@ -48,27 +59,41 @@ const beautifyMultipleLines = (lines) => {
|
|
|
48
59
|
status: "NORMAL",
|
|
49
60
|
lineCap: "round"
|
|
50
61
|
};
|
|
51
|
-
const
|
|
62
|
+
const roundCoveredLines = [];
|
|
63
|
+
const buttCoveredLines = [];
|
|
52
64
|
for (const line of lines) {
|
|
53
65
|
const {
|
|
54
66
|
path,
|
|
55
67
|
status
|
|
56
68
|
} = line;
|
|
57
|
-
if (status
|
|
69
|
+
if (!isSlowOrJam(status))
|
|
58
70
|
continue;
|
|
59
|
-
|
|
71
|
+
buttCoveredLines.push({
|
|
60
72
|
status,
|
|
61
73
|
path,
|
|
62
74
|
lineCap: "butt"
|
|
63
75
|
});
|
|
64
76
|
}
|
|
65
77
|
const first = lines[0];
|
|
78
|
+
const last = lines[lines.length - 1];
|
|
66
79
|
const ignoredLine = {
|
|
67
80
|
status: first.status,
|
|
68
81
|
path: first.path.slice(0, 2),
|
|
69
82
|
lineCap: "butt"
|
|
70
83
|
};
|
|
71
|
-
|
|
84
|
+
if (isSlowOrJam(first.status))
|
|
85
|
+
roundCoveredLines.push({
|
|
86
|
+
status: first.status,
|
|
87
|
+
path: toHalfPath(first.path.slice(0, 2)),
|
|
88
|
+
lineCap: "round"
|
|
89
|
+
});
|
|
90
|
+
if (isSlowOrJam(last.status))
|
|
91
|
+
roundCoveredLines.push({
|
|
92
|
+
status: last.status,
|
|
93
|
+
path: toHalfPath(last.path.slice(-2), false),
|
|
94
|
+
lineCap: "round"
|
|
95
|
+
});
|
|
96
|
+
return [ignoredLine, totalLine, ...roundCoveredLines, ...buttCoveredLines];
|
|
72
97
|
};
|
|
73
98
|
const TrafficDrivingLine = defineSetup("TrafficDrivingLine", function(props) {
|
|
74
99
|
return () => {
|
|
@@ -77,7 +102,6 @@ const TrafficDrivingLine = defineSetup("TrafficDrivingLine", function(props) {
|
|
|
77
102
|
trafficJams
|
|
78
103
|
} = props;
|
|
79
104
|
const multipleLines = createMulitpleLineByTrafficJams(path, trafficJams);
|
|
80
|
-
console.log("multipleLines = ", multipleLines);
|
|
81
105
|
const beautifiedLines = beautifyMultipleLines(multipleLines);
|
|
82
106
|
return h("div", [beautifiedLines.map((line) => h(DrivingLine, {
|
|
83
107
|
"attrs": {
|
|
@@ -134,7 +134,12 @@ const createSubRouteByPoint = (route, point, distanceOfLineFn) => {
|
|
|
134
134
|
count += step.path.length;
|
|
135
135
|
if (count <= index)
|
|
136
136
|
continue;
|
|
137
|
-
|
|
137
|
+
if (step.path.length + index - count + 1 < 0) {
|
|
138
|
+
console.error(
|
|
139
|
+
"`MyError: createSubRouteByPoint unexpected condition: step.path.length + index - count + 1 < 0"
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
const firstStepPath = [point, ...step.path.slice(step.path.length + index - count + 1)];
|
|
138
143
|
const totalStepDistanceByMeasure = distanceOfLineFn(step.path);
|
|
139
144
|
const stepDistanceByMeasure = (_a = distanceOfLineFn(firstStepPath)) != null ? _a : 0;
|
|
140
145
|
const firstStepDistance = totalStepDistanceByMeasure ? step.distance * stepDistanceByMeasure / totalStepDistanceByMeasure : stepDistanceByMeasure;
|
|
@@ -153,7 +158,6 @@ const createSubRouteByPoint = (route, point, distanceOfLineFn) => {
|
|
|
153
158
|
distance += step.distance;
|
|
154
159
|
duration += step.duration;
|
|
155
160
|
}
|
|
156
|
-
console.log("point, index, distance, steps, route = ", point, index, distance, steps, route);
|
|
157
161
|
return { path, duration, distance, steps, index, baseRoute: route };
|
|
158
162
|
};
|
|
159
163
|
const createEmptySubRoute = () => {
|
|
@@ -107,4 +107,7 @@ export type ProxyServiceError = {
|
|
|
107
107
|
msg: string;
|
|
108
108
|
};
|
|
109
109
|
export type TrafficStatus = "UNKNOWN" | "NORMAL" | "SLOW" | "TRAFFIC_JAM" | "HEAVY_TRAFFIC_JAM";
|
|
110
|
-
export type TrafficJams = Record<`${number},${number}`,
|
|
110
|
+
export type TrafficJams = Record<`${number},${number}`, {
|
|
111
|
+
before: TrafficStatus;
|
|
112
|
+
after: TrafficStatus;
|
|
113
|
+
}>;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { apiGaodeDirectionDriving } from "../api/gaodeDirectionDriving.js";
|
|
2
2
|
import { apiGoogleDirections } from "../api/googleDirections.js";
|
|
3
|
-
import {
|
|
3
|
+
import { amapTraffic2trafficStatus, stringifyPoint } from "./transform.js";
|
|
4
4
|
const amapTmcs2trafficJams = (tmcs) => {
|
|
5
5
|
const trafficJams = {};
|
|
6
|
+
let prevStatus = "UNKNOWN";
|
|
6
7
|
for (const tmc of tmcs) {
|
|
7
8
|
const { path } = tmc;
|
|
8
9
|
if (!path)
|
|
9
10
|
continue;
|
|
10
11
|
for (const { lng, lat } of path) {
|
|
11
|
-
|
|
12
|
+
const status = amapTraffic2trafficStatus(tmc.status);
|
|
13
|
+
trafficJams[stringifyPoint([lng, lat])] = {
|
|
14
|
+
before: prevStatus,
|
|
15
|
+
after: status
|
|
16
|
+
};
|
|
17
|
+
prevStatus = status;
|
|
12
18
|
}
|
|
13
19
|
}
|
|
14
20
|
return trafficJams;
|
|
@@ -24,6 +30,7 @@ function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
|
24
30
|
switch (status) {
|
|
25
31
|
case "complete": {
|
|
26
32
|
let path = [];
|
|
33
|
+
let tmcs = [];
|
|
27
34
|
const drivingResult = result;
|
|
28
35
|
const routeSteps = [];
|
|
29
36
|
const firstRoute = drivingResult.routes[0];
|
|
@@ -33,13 +40,14 @@ function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
|
33
40
|
const basicStep = step;
|
|
34
41
|
const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
|
|
35
42
|
path = path.concat(stepPath);
|
|
36
|
-
|
|
43
|
+
tmcs = tmcs.concat(basicStep.tmcs);
|
|
37
44
|
routeSteps.push({
|
|
38
45
|
path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
|
|
39
46
|
duration: basicStep.time,
|
|
40
47
|
distance: basicStep.distance
|
|
41
48
|
});
|
|
42
49
|
}
|
|
50
|
+
Object.assign(trafficJams, amapTmcs2trafficJams(tmcs));
|
|
43
51
|
return resolve({
|
|
44
52
|
path,
|
|
45
53
|
distance: firstRoute.distance,
|
package/dist/v2/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.8.
|
|
3
|
+
const pkgVersion = "2.8.1";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
|
@@ -25,6 +25,7 @@ export declare const pipeAsync: <P extends any[]>(fn?: ((...args: P) => any) | u
|
|
|
25
25
|
export declare const pipeDefer: <P extends any[], R>(fn: (...args: P) => R) => (...args: P) => Promise<R>;
|
|
26
26
|
export declare const pipeOnlyLastEffect: <P extends any[], R>(fn: (...arg: P) => Promise<R>) => (...args: P) => Promise<R>;
|
|
27
27
|
export declare const isPlaceEqual: (p1: Place, p2?: Place) => boolean;
|
|
28
|
+
export declare const isPointExactEqual: (p1: Point, p2?: Point) => boolean;
|
|
28
29
|
export declare const isPointEqual: (p1: Point, p2?: Point) => boolean;
|
|
29
30
|
export declare const isGeoPositionEqual: (p1: GeolocationPosition, p2?: GeolocationPosition) => boolean;
|
|
30
31
|
export declare const isZoneEqual: (z1: Zone, z2?: Zone) => boolean;
|
|
@@ -96,6 +96,9 @@ const pipeOnlyLastEffect = (fn) => {
|
|
|
96
96
|
const isPlaceEqual = (p1, p2) => {
|
|
97
97
|
return isAccuryEqual(p1.lng, p2 == null ? void 0 : p2.lng) && isAccuryEqual(p1.lat, p2 == null ? void 0 : p2.lat);
|
|
98
98
|
};
|
|
99
|
+
const isPointExactEqual = (p1, p2) => {
|
|
100
|
+
return p1[0] === (p2 == null ? void 0 : p2[0]) && p1[1] === (p2 == null ? void 0 : p2[1]);
|
|
101
|
+
};
|
|
99
102
|
const isPointEqual = (p1, p2) => {
|
|
100
103
|
return isAccuryEqual(p1[0], p2 == null ? void 0 : p2[0]) && isAccuryEqual(p1[1], p2 == null ? void 0 : p2[1]);
|
|
101
104
|
};
|
|
@@ -323,6 +326,7 @@ export {
|
|
|
323
326
|
isGeoPositionEqual,
|
|
324
327
|
isPlaceEqual,
|
|
325
328
|
isPointEqual,
|
|
329
|
+
isPointExactEqual,
|
|
326
330
|
isZoneEqual,
|
|
327
331
|
lnglat2point,
|
|
328
332
|
maybeFunctionToFunction,
|
|
@@ -20,7 +20,7 @@ import { WalkingRoute } from "../WalkingRoute/WalkingRoute.js";
|
|
|
20
20
|
import { WaveCircle } from "../WaveCircle/WaveCircle.js";
|
|
21
21
|
const IS_ENABLE_AUXILIARY_GRASP_ROAD = apiGetAuxiliaryGrapStatus();
|
|
22
22
|
const PASSENGER_DISTANCE_MAX = 2e3;
|
|
23
|
-
const PASSENGER_DISTANCE_MIN =
|
|
23
|
+
const PASSENGER_DISTANCE_MIN = 20;
|
|
24
24
|
const AUTO_FIT_VIEW_INTERVAL = IS_ENABLE_AUXILIARY_GRASP_ROAD ? 24 * 3600 * 1e3 : 15e3;
|
|
25
25
|
const carDurationWithinMinDistance = (distance) => Math.floor(distance / 5);
|
|
26
26
|
const SectionDispatching = defineSetup("SectionDispatching", function(props) {
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { createVNode } from "vue";
|
|
2
2
|
import { defineSetup } from "../../types/helper.js";
|
|
3
|
-
import { stringifyPoint } from "../../utils/transform.js";
|
|
3
|
+
import { stringifyPoint, isPointExactEqual } from "../../utils/transform.js";
|
|
4
4
|
import { DrivingLine } from "../DrivingLine/DrivingLine.js";
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const toHalfPath = (path, isFromStart = true) => {
|
|
6
|
+
if (path.length < 2)
|
|
7
|
+
return path;
|
|
8
|
+
const [[x0, y0], [x1, y1]] = path;
|
|
9
|
+
const mid = [(x0 + x1) / 2, (y0 + y1) / 2];
|
|
10
|
+
return isFromStart ? [[x0, y0], mid] : [mid, [x1, y1]];
|
|
11
|
+
};
|
|
12
|
+
const isSlowOrJam = (status) => {
|
|
13
|
+
return status === "SLOW" || status === "TRAFFIC_JAM" || status === "HEAVY_TRAFFIC_JAM";
|
|
14
|
+
};
|
|
15
|
+
const justifyFirstPointStatus = (firstPointStatus, secondPointBeforeStatus) => {
|
|
16
|
+
return (firstPointStatus === void 0 || firstPointStatus === "UNKNOWN") && !!secondPointBeforeStatus && secondPointBeforeStatus !== "UNKNOWN" ? secondPointBeforeStatus : firstPointStatus != null ? firstPointStatus : "UNKNOWN";
|
|
7
17
|
};
|
|
8
18
|
const createMulitpleLineByTrafficJams = (path, trafficJams) => {
|
|
9
|
-
var _a;
|
|
19
|
+
var _a, _b, _c, _d;
|
|
10
20
|
if (!trafficJams)
|
|
11
21
|
return [{
|
|
12
22
|
path,
|
|
@@ -18,12 +28,13 @@ const createMulitpleLineByTrafficJams = (path, trafficJams) => {
|
|
|
18
28
|
const multipleLines = [];
|
|
19
29
|
let line = {
|
|
20
30
|
path: [firstPoint],
|
|
21
|
-
status: justifyFirstPointStatus(trafficJams[stringifyPoint(firstPoint)], trafficJams[stringifyPoint(path[1])])
|
|
31
|
+
status: justifyFirstPointStatus((_a = trafficJams[stringifyPoint(firstPoint)]) == null ? void 0 : _a.after, (_b = trafficJams[stringifyPoint(path[1])]) == null ? void 0 : _b.before)
|
|
22
32
|
};
|
|
23
|
-
for (let idx =
|
|
33
|
+
for (let idx = 1; idx < path.length; idx++) {
|
|
24
34
|
const point = path[idx];
|
|
25
|
-
const traffic = (
|
|
26
|
-
|
|
35
|
+
const traffic = (_d = (_c = trafficJams[stringifyPoint(point)]) == null ? void 0 : _c.after) != null ? _d : "UNKNOWN";
|
|
36
|
+
if (!isPointExactEqual(point, path[idx - 1]))
|
|
37
|
+
line.path.push(point);
|
|
27
38
|
if (traffic === line.status)
|
|
28
39
|
continue;
|
|
29
40
|
multipleLines.push(line);
|
|
@@ -48,27 +59,41 @@ const beautifyMultipleLines = (lines) => {
|
|
|
48
59
|
status: "NORMAL",
|
|
49
60
|
lineCap: "round"
|
|
50
61
|
};
|
|
51
|
-
const
|
|
62
|
+
const roundCoveredLines = [];
|
|
63
|
+
const buttCoveredLines = [];
|
|
52
64
|
for (const line of lines) {
|
|
53
65
|
const {
|
|
54
66
|
path,
|
|
55
67
|
status
|
|
56
68
|
} = line;
|
|
57
|
-
if (status
|
|
69
|
+
if (!isSlowOrJam(status))
|
|
58
70
|
continue;
|
|
59
|
-
|
|
71
|
+
buttCoveredLines.push({
|
|
60
72
|
status,
|
|
61
73
|
path,
|
|
62
74
|
lineCap: "butt"
|
|
63
75
|
});
|
|
64
76
|
}
|
|
65
77
|
const first = lines[0];
|
|
78
|
+
const last = lines[lines.length - 1];
|
|
66
79
|
const ignoredLine = {
|
|
67
80
|
status: first.status,
|
|
68
81
|
path: first.path.slice(0, 2),
|
|
69
82
|
lineCap: "butt"
|
|
70
83
|
};
|
|
71
|
-
|
|
84
|
+
if (isSlowOrJam(first.status))
|
|
85
|
+
roundCoveredLines.push({
|
|
86
|
+
status: first.status,
|
|
87
|
+
path: toHalfPath(first.path.slice(0, 2)),
|
|
88
|
+
lineCap: "round"
|
|
89
|
+
});
|
|
90
|
+
if (isSlowOrJam(last.status))
|
|
91
|
+
roundCoveredLines.push({
|
|
92
|
+
status: last.status,
|
|
93
|
+
path: toHalfPath(last.path.slice(-2), false),
|
|
94
|
+
lineCap: "round"
|
|
95
|
+
});
|
|
96
|
+
return [ignoredLine, totalLine, ...roundCoveredLines, ...buttCoveredLines];
|
|
72
97
|
};
|
|
73
98
|
const TrafficDrivingLine = defineSetup("TrafficDrivingLine", function(props) {
|
|
74
99
|
return () => {
|
|
@@ -77,7 +102,6 @@ const TrafficDrivingLine = defineSetup("TrafficDrivingLine", function(props) {
|
|
|
77
102
|
trafficJams
|
|
78
103
|
} = props;
|
|
79
104
|
const multipleLines = createMulitpleLineByTrafficJams(path, trafficJams);
|
|
80
|
-
console.log("multipleLines = ", multipleLines);
|
|
81
105
|
const beautifiedLines = beautifyMultipleLines(multipleLines);
|
|
82
106
|
return createVNode("div", null, [beautifiedLines.map((line) => createVNode(DrivingLine, {
|
|
83
107
|
"path": line.path,
|
|
@@ -134,7 +134,12 @@ const createSubRouteByPoint = (route, point, distanceOfLineFn) => {
|
|
|
134
134
|
count += step.path.length;
|
|
135
135
|
if (count <= index)
|
|
136
136
|
continue;
|
|
137
|
-
|
|
137
|
+
if (step.path.length + index - count + 1 < 0) {
|
|
138
|
+
console.error(
|
|
139
|
+
"`MyError: createSubRouteByPoint unexpected condition: step.path.length + index - count + 1 < 0"
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
const firstStepPath = [point, ...step.path.slice(step.path.length + index - count + 1)];
|
|
138
143
|
const totalStepDistanceByMeasure = distanceOfLineFn(step.path);
|
|
139
144
|
const stepDistanceByMeasure = (_a = distanceOfLineFn(firstStepPath)) != null ? _a : 0;
|
|
140
145
|
const firstStepDistance = totalStepDistanceByMeasure ? step.distance * stepDistanceByMeasure / totalStepDistanceByMeasure : stepDistanceByMeasure;
|
|
@@ -153,7 +158,6 @@ const createSubRouteByPoint = (route, point, distanceOfLineFn) => {
|
|
|
153
158
|
distance += step.distance;
|
|
154
159
|
duration += step.duration;
|
|
155
160
|
}
|
|
156
|
-
console.log("point, index, distance, steps, route = ", point, index, distance, steps, route);
|
|
157
161
|
return { path, duration, distance, steps, index, baseRoute: route };
|
|
158
162
|
};
|
|
159
163
|
const createEmptySubRoute = () => {
|
|
@@ -107,4 +107,7 @@ export type ProxyServiceError = {
|
|
|
107
107
|
msg: string;
|
|
108
108
|
};
|
|
109
109
|
export type TrafficStatus = "UNKNOWN" | "NORMAL" | "SLOW" | "TRAFFIC_JAM" | "HEAVY_TRAFFIC_JAM";
|
|
110
|
-
export type TrafficJams = Record<`${number},${number}`,
|
|
110
|
+
export type TrafficJams = Record<`${number},${number}`, {
|
|
111
|
+
before: TrafficStatus;
|
|
112
|
+
after: TrafficStatus;
|
|
113
|
+
}>;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { apiGaodeDirectionDriving } from "../api/gaodeDirectionDriving.js";
|
|
2
2
|
import { apiGoogleDirections } from "../api/googleDirections.js";
|
|
3
|
-
import {
|
|
3
|
+
import { amapTraffic2trafficStatus, stringifyPoint } from "./transform.js";
|
|
4
4
|
const amapTmcs2trafficJams = (tmcs) => {
|
|
5
5
|
const trafficJams = {};
|
|
6
|
+
let prevStatus = "UNKNOWN";
|
|
6
7
|
for (const tmc of tmcs) {
|
|
7
8
|
const { path } = tmc;
|
|
8
9
|
if (!path)
|
|
9
10
|
continue;
|
|
10
11
|
for (const { lng, lat } of path) {
|
|
11
|
-
|
|
12
|
+
const status = amapTraffic2trafficStatus(tmc.status);
|
|
13
|
+
trafficJams[stringifyPoint([lng, lat])] = {
|
|
14
|
+
before: prevStatus,
|
|
15
|
+
after: status
|
|
16
|
+
};
|
|
17
|
+
prevStatus = status;
|
|
12
18
|
}
|
|
13
19
|
}
|
|
14
20
|
return trafficJams;
|
|
@@ -24,6 +30,7 @@ function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
|
24
30
|
switch (status) {
|
|
25
31
|
case "complete": {
|
|
26
32
|
let path = [];
|
|
33
|
+
let tmcs = [];
|
|
27
34
|
const drivingResult = result;
|
|
28
35
|
const routeSteps = [];
|
|
29
36
|
const firstRoute = drivingResult.routes[0];
|
|
@@ -33,13 +40,14 @@ function amapJsApiDrivingRoute(from, to, amapDriving) {
|
|
|
33
40
|
const basicStep = step;
|
|
34
41
|
const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
|
|
35
42
|
path = path.concat(stepPath);
|
|
36
|
-
|
|
43
|
+
tmcs = tmcs.concat(basicStep.tmcs);
|
|
37
44
|
routeSteps.push({
|
|
38
45
|
path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
|
|
39
46
|
duration: basicStep.time,
|
|
40
47
|
distance: basicStep.distance
|
|
41
48
|
});
|
|
42
49
|
}
|
|
50
|
+
Object.assign(trafficJams, amapTmcs2trafficJams(tmcs));
|
|
43
51
|
return resolve({
|
|
44
52
|
path,
|
|
45
53
|
distance: firstRoute.distance,
|
package/dist/v3/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.8.
|
|
3
|
+
const pkgVersion = "2.8.1";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
|
@@ -25,6 +25,7 @@ export declare const pipeAsync: <P extends any[]>(fn?: ((...args: P) => any) | u
|
|
|
25
25
|
export declare const pipeDefer: <P extends any[], R>(fn: (...args: P) => R) => (...args: P) => Promise<R>;
|
|
26
26
|
export declare const pipeOnlyLastEffect: <P extends any[], R>(fn: (...arg: P) => Promise<R>) => (...args: P) => Promise<R>;
|
|
27
27
|
export declare const isPlaceEqual: (p1: Place, p2?: Place) => boolean;
|
|
28
|
+
export declare const isPointExactEqual: (p1: Point, p2?: Point) => boolean;
|
|
28
29
|
export declare const isPointEqual: (p1: Point, p2?: Point) => boolean;
|
|
29
30
|
export declare const isGeoPositionEqual: (p1: GeolocationPosition, p2?: GeolocationPosition) => boolean;
|
|
30
31
|
export declare const isZoneEqual: (z1: Zone, z2?: Zone) => boolean;
|
|
@@ -96,6 +96,9 @@ const pipeOnlyLastEffect = (fn) => {
|
|
|
96
96
|
const isPlaceEqual = (p1, p2) => {
|
|
97
97
|
return isAccuryEqual(p1.lng, p2 == null ? void 0 : p2.lng) && isAccuryEqual(p1.lat, p2 == null ? void 0 : p2.lat);
|
|
98
98
|
};
|
|
99
|
+
const isPointExactEqual = (p1, p2) => {
|
|
100
|
+
return p1[0] === (p2 == null ? void 0 : p2[0]) && p1[1] === (p2 == null ? void 0 : p2[1]);
|
|
101
|
+
};
|
|
99
102
|
const isPointEqual = (p1, p2) => {
|
|
100
103
|
return isAccuryEqual(p1[0], p2 == null ? void 0 : p2[0]) && isAccuryEqual(p1[1], p2 == null ? void 0 : p2[1]);
|
|
101
104
|
};
|
|
@@ -323,6 +326,7 @@ export {
|
|
|
323
326
|
isGeoPositionEqual,
|
|
324
327
|
isPlaceEqual,
|
|
325
328
|
isPointEqual,
|
|
329
|
+
isPointExactEqual,
|
|
326
330
|
isZoneEqual,
|
|
327
331
|
lnglat2point,
|
|
328
332
|
maybeFunctionToFunction,
|