@heycar/heycars-map 2.7.2 → 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/api/gaodeDirectionDriving.js +21 -6
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +6 -4
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +23 -14
- package/dist/v2/business-components/DrivingLine/DrivingLine.d.ts +5 -1
- package/dist/v2/business-components/DrivingLine/DrivingLine.js +44 -10
- package/dist/v2/business-components/DrivingRoute/DrivingRoute.d.ts +2 -1
- package/dist/v2/business-components/DrivingRoute/DrivingRoute.js +4 -2
- package/dist/v2/business-components/TrafficDrivingLine/TrafficDrivingLine.d.ts +6 -0
- package/dist/v2/business-components/TrafficDrivingLine/TrafficDrivingLine.js +117 -0
- package/dist/v2/business-components/TrafficDrivingLine/index.d.ts +1 -0
- package/dist/v2/business-components/TrafficDrivingLine/index.js +4 -0
- package/dist/v2/components/AmapMarker/AmapMarker.js +0 -2
- package/dist/v2/hooks/useDeviationCorrectionDrivingRoute.d.ts +2 -0
- package/dist/v2/hooks/useDeviationCorrectionDrivingRoute.js +6 -2
- package/dist/v2/hooks/useDrivingRoute.d.ts +3 -0
- package/dist/v2/hooks/useDrivingRoute.js +2 -1
- package/dist/v2/hooks/useDrivingTrackCorrection.d.ts +1 -0
- package/dist/v2/types/amap/driving.d.ts +2 -1
- package/dist/v2/types/interface.d.ts +6 -0
- package/dist/v2/utils/compatibleDrivingRoute.js +29 -2
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/transform.d.ts +4 -1
- package/dist/v2/utils/transform.js +23 -1
- package/dist/v3/api/gaodeDirectionDriving.js +21 -6
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +6 -4
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceSection.js +23 -14
- package/dist/v3/business-components/DrivingLine/DrivingLine.d.ts +5 -1
- package/dist/v3/business-components/DrivingLine/DrivingLine.js +44 -10
- package/dist/v3/business-components/DrivingRoute/DrivingRoute.d.ts +2 -1
- package/dist/v3/business-components/DrivingRoute/DrivingRoute.js +4 -2
- package/dist/v3/business-components/TrafficDrivingLine/TrafficDrivingLine.d.ts +8 -0
- package/dist/v3/business-components/TrafficDrivingLine/TrafficDrivingLine.js +115 -0
- package/dist/v3/business-components/TrafficDrivingLine/index.d.ts +1 -0
- package/dist/v3/business-components/TrafficDrivingLine/index.js +4 -0
- package/dist/v3/components/AmapMarker/AmapMarker.js +0 -2
- package/dist/v3/hooks/useDeviationCorrectionDrivingRoute.d.ts +2 -0
- package/dist/v3/hooks/useDeviationCorrectionDrivingRoute.js +6 -2
- package/dist/v3/hooks/useDrivingRoute.d.ts +3 -0
- package/dist/v3/hooks/useDrivingRoute.js +2 -1
- package/dist/v3/hooks/useDrivingTrackCorrection.d.ts +1 -0
- package/dist/v3/types/amap/driving.d.ts +2 -1
- package/dist/v3/types/interface.d.ts +6 -0
- package/dist/v3/utils/compatibleDrivingRoute.js +29 -2
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/transform.d.ts +4 -1
- package/dist/v3/utils/transform.js +23 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gaodePointsStringify, gaodePolyline2amapLngLat } from "../utils/transform.js";
|
|
2
2
|
import { createTypeError, isProxyServiceError } from "../utils/typeChecking.js";
|
|
3
|
-
const GAODE_POLYLINE_REGEX = /^(
|
|
3
|
+
const GAODE_POLYLINE_REGEX = /^(?:-?\d*\.\d+,-?\d*\.\d+)?(?:;-?\d*\.\d+,-?\d*\.\d+)*$/;
|
|
4
4
|
var GaodeDirectionStatus = /* @__PURE__ */ ((GaodeDirectionStatus2) => {
|
|
5
5
|
GaodeDirectionStatus2["SUCCESS"] = "1";
|
|
6
6
|
GaodeDirectionStatus2["FAIL"] = "0";
|
|
@@ -35,10 +35,19 @@ function isGaodeDirectionBasicStep(value) {
|
|
|
35
35
|
function isGaodeEmptyValue(value) {
|
|
36
36
|
return Array.isArray(value) && value.length === 0;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
38
|
+
function isAmapTmcStatus(value) {
|
|
39
|
+
return value === "未知" || value === "畅通" || value === "缓行" || value === "拥堵" || value === "严重拥堵";
|
|
40
|
+
}
|
|
41
|
+
function assertGaodeDirectionDrivingTmc(value) {
|
|
42
|
+
if (typeof value === "object" && value !== null && "status" in value && isAmapTmcStatus(value.status) && "polyline" in value && isGaodeDirectionPolyline(value.polyline))
|
|
40
43
|
return;
|
|
41
|
-
throw createTypeError("
|
|
44
|
+
throw createTypeError("GaodeDirectionDrivingTmc", value);
|
|
45
|
+
}
|
|
46
|
+
function assertGaodoDirectionDrivingStep(value) {
|
|
47
|
+
if (!isGaodeDirectionBasicStep(value) || !("tmcs" in value) || !Array.isArray(value.tmcs)) {
|
|
48
|
+
throw createTypeError("GaodeDirectionDrivingStep", value);
|
|
49
|
+
}
|
|
50
|
+
value.tmcs.forEach(assertGaodeDirectionDrivingTmc);
|
|
42
51
|
}
|
|
43
52
|
function assertGaodeDirectionDrivingRoutePath(value) {
|
|
44
53
|
if (!isGaodeMeasurableObject(value) || !("tolls" in value) || !isGaodeNumberableString(value.tolls) || !("steps" in value) || !Array.isArray(value.steps)) {
|
|
@@ -63,15 +72,21 @@ function assertGaodeDirectionDrivingResponse(value) {
|
|
|
63
72
|
throw createTypeError("GaodeDirectionDrivingResponse", value, detail);
|
|
64
73
|
}
|
|
65
74
|
}
|
|
75
|
+
function gaodeDirectionDrivingTmc2amapTmc(gaodeTmc) {
|
|
76
|
+
const { status, polyline } = gaodeTmc;
|
|
77
|
+
const path = gaodePolyline2amapLngLat(String(polyline));
|
|
78
|
+
return { status, path };
|
|
79
|
+
}
|
|
66
80
|
function gaodeDirectionDrivingRoute2amapDrivingRoute(gaodeRoute) {
|
|
67
81
|
return gaodeRoute.paths.map((routePath) => {
|
|
68
82
|
const { distance, duration, tolls, steps: godeDirectionSteps } = routePath;
|
|
69
83
|
const steps = godeDirectionSteps.map((directionStep) => {
|
|
70
|
-
const { distance: distance2, duration: duration2, polyline } = directionStep;
|
|
84
|
+
const { distance: distance2, duration: duration2, polyline, tmcs } = directionStep;
|
|
71
85
|
return {
|
|
72
86
|
distance: Number(distance2),
|
|
73
87
|
time: Number(duration2),
|
|
74
|
-
path: gaodePolyline2amapLngLat(String(polyline))
|
|
88
|
+
path: gaodePolyline2amapLngLat(String(polyline)),
|
|
89
|
+
tmcs: tmcs.map(gaodeDirectionDrivingTmc2amapTmc)
|
|
75
90
|
};
|
|
76
91
|
});
|
|
77
92
|
return {
|
|
@@ -9,10 +9,10 @@ import { defineSetup, defineLagecySetup } from "../../types/helper.js";
|
|
|
9
9
|
import { generateCreateElementV2PropsOn } from "../../utils/compare.js";
|
|
10
10
|
import { place2point, pipeDefer } from "../../utils/transform.js";
|
|
11
11
|
import { toCoordinatePlaceType } from "../../utils/typeChecking.js";
|
|
12
|
-
import { DrivingLine } from "../DrivingLine/DrivingLine.js";
|
|
13
12
|
import { DrivingRoute } from "../DrivingRoute/DrivingRoute.js";
|
|
14
13
|
import { FitViewOnce, createFittableRegisterOverlay } from "../FitView/FitView.js";
|
|
15
14
|
import { StartEndPoint } from "../StartEndPoint/StartEndPoint.js";
|
|
15
|
+
import { TrafficDrivingLine } from "../TrafficDrivingLine/TrafficDrivingLine.js";
|
|
16
16
|
const BUSINESS_QUOTING_FITVIEW_PANDING = [26, 26, 19, 26];
|
|
17
17
|
const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(props, {
|
|
18
18
|
emit,
|
|
@@ -91,10 +91,12 @@ const BusinessQuotingMapInner = defineSetup("BusinessQuotingMapInner", function(
|
|
|
91
91
|
path,
|
|
92
92
|
distance,
|
|
93
93
|
duration,
|
|
94
|
-
tolls
|
|
95
|
-
|
|
94
|
+
tolls,
|
|
95
|
+
trafficJams
|
|
96
|
+
}) => [h(TrafficDrivingLine, {
|
|
96
97
|
"attrs": {
|
|
97
|
-
"path": path
|
|
98
|
+
"path": path,
|
|
99
|
+
"trafficJams": trafficJams
|
|
98
100
|
}
|
|
99
101
|
}), h(StartEndPoint, {
|
|
100
102
|
"attrs": {
|
|
@@ -14,12 +14,13 @@ import { ConditionalFittablePassengerCircle } from "../PassengerCircle/Passenger
|
|
|
14
14
|
import { PlaceCircle } from "../PlaceCircle/PlaceCircle.js";
|
|
15
15
|
import { StartEndPoint } from "../StartEndPoint/StartEndPoint.js";
|
|
16
16
|
import { TaxiCar } from "../TaxiCar/TaxiCar.js";
|
|
17
|
+
import { TrafficDrivingLine } from "../TrafficDrivingLine/TrafficDrivingLine.js";
|
|
17
18
|
import { WalkingLine } from "../WalkingLine/WalkingLine.js";
|
|
18
19
|
import { WalkingRoute } from "../WalkingRoute/WalkingRoute.js";
|
|
19
20
|
import { WaveCircle } from "../WaveCircle/WaveCircle.js";
|
|
20
21
|
const IS_ENABLE_AUXILIARY_GRASP_ROAD = apiGetAuxiliaryGrapStatus();
|
|
21
22
|
const PASSENGER_DISTANCE_MAX = 2e3;
|
|
22
|
-
const PASSENGER_DISTANCE_MIN =
|
|
23
|
+
const PASSENGER_DISTANCE_MIN = 20;
|
|
23
24
|
const AUTO_FIT_VIEW_INTERVAL = IS_ENABLE_AUXILIARY_GRASP_ROAD ? 24 * 3600 * 1e3 : 15e3;
|
|
24
25
|
const carDurationWithinMinDistance = (distance) => Math.floor(distance / 5);
|
|
25
26
|
const SectionDispatching = defineSetup("SectionDispatching", function(props) {
|
|
@@ -88,10 +89,12 @@ const SectionConfirmed = defineSetup("SectionConfirmed", function(props) {
|
|
|
88
89
|
"to": to,
|
|
89
90
|
"from": from,
|
|
90
91
|
"render": ({
|
|
91
|
-
path
|
|
92
|
-
|
|
92
|
+
path,
|
|
93
|
+
trafficJams
|
|
94
|
+
}) => h(TrafficDrivingLine, {
|
|
93
95
|
"attrs": {
|
|
94
|
-
"path": path
|
|
96
|
+
"path": path,
|
|
97
|
+
"trafficJams": trafficJams
|
|
95
98
|
}
|
|
96
99
|
})
|
|
97
100
|
}
|
|
@@ -197,12 +200,14 @@ const SectionDriverStartService = defineSetup("SectionDriverStartService", funct
|
|
|
197
200
|
path,
|
|
198
201
|
angle,
|
|
199
202
|
distance,
|
|
200
|
-
duration
|
|
203
|
+
duration,
|
|
204
|
+
trafficJams
|
|
201
205
|
}) => {
|
|
202
206
|
var _a;
|
|
203
|
-
return [h(
|
|
207
|
+
return [h(TrafficDrivingLine, {
|
|
204
208
|
"attrs": {
|
|
205
|
-
"path": path
|
|
209
|
+
"path": path,
|
|
210
|
+
"trafficJams": trafficJams
|
|
206
211
|
}
|
|
207
212
|
}), h(TaxiCar, {
|
|
208
213
|
"attrs": {
|
|
@@ -286,10 +291,12 @@ const SectionBookDispatched = defineSetup("SectionBookDispatched", function(prop
|
|
|
286
291
|
"to": to,
|
|
287
292
|
"from": from,
|
|
288
293
|
"render": ({
|
|
289
|
-
path
|
|
290
|
-
|
|
294
|
+
path,
|
|
295
|
+
trafficJams
|
|
296
|
+
}) => h(TrafficDrivingLine, {
|
|
291
297
|
"attrs": {
|
|
292
|
-
"path": path
|
|
298
|
+
"path": path,
|
|
299
|
+
"trafficJams": trafficJams
|
|
293
300
|
}
|
|
294
301
|
})
|
|
295
302
|
}
|
|
@@ -461,12 +468,14 @@ const SectionInService = defineSetup("SectionInService", function(props) {
|
|
|
461
468
|
path,
|
|
462
469
|
angle,
|
|
463
470
|
distance,
|
|
464
|
-
duration
|
|
471
|
+
duration,
|
|
472
|
+
trafficJams
|
|
465
473
|
}) => {
|
|
466
474
|
var _a;
|
|
467
|
-
return [h(
|
|
475
|
+
return [h(TrafficDrivingLine, {
|
|
468
476
|
"attrs": {
|
|
469
|
-
"path": path
|
|
477
|
+
"path": path,
|
|
478
|
+
"trafficJams": trafficJams
|
|
470
479
|
}
|
|
471
480
|
}), h(TaxiCar, {
|
|
472
481
|
"attrs": {
|
|
@@ -601,7 +610,7 @@ const SectionEndService = defineSetup("SectionEndService", function(props) {
|
|
|
601
610
|
}) => h(DrivingLine, {
|
|
602
611
|
"attrs": {
|
|
603
612
|
"path": path,
|
|
604
|
-
"
|
|
613
|
+
"status": "DONE"
|
|
605
614
|
}
|
|
606
615
|
})
|
|
607
616
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { TrafficStatus } from "../../types/interface";
|
|
2
|
+
type DrivingLineStatus = TrafficStatus | "DONE";
|
|
1
3
|
export interface DrivingLineProps {
|
|
2
|
-
|
|
4
|
+
status?: DrivingLineStatus;
|
|
3
5
|
path: [number, number][];
|
|
6
|
+
lineCap?: AMap.LineSharedOptions["lineCap"];
|
|
4
7
|
}
|
|
5
8
|
export declare const ADrivingLine: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<DrivingLineProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<DrivingLineProps, Required<DrivingLineProps>>, never, DrivingLineProps>;
|
|
6
9
|
export declare const GDrivingLine: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<DrivingLineProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<DrivingLineProps, Required<DrivingLineProps>>, never, DrivingLineProps>;
|
|
7
10
|
export declare const DrivingLine: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<DrivingLineProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<DrivingLineProps, Required<DrivingLineProps>>, never, DrivingLineProps>;
|
|
11
|
+
export {};
|
|
@@ -7,17 +7,48 @@ import { createElement } from "../../demi-polyfill/demi-polyfill.js";
|
|
|
7
7
|
import { useMapSupplier } from "../../hooks/useMapSupplier.js";
|
|
8
8
|
import { defineSetup } from "../../types/helper.js";
|
|
9
9
|
import { vec2lnglat } from "../../utils/transform.js";
|
|
10
|
+
const trafficInnerColors = {
|
|
11
|
+
// UNKNOWN: "#487BF4",
|
|
12
|
+
UNKNOWN: "#00C875",
|
|
13
|
+
NORMAL: "#00C875",
|
|
14
|
+
SLOW: "#F9D100",
|
|
15
|
+
TRAFFIC_JAM: "#EB0E33",
|
|
16
|
+
HEAVY_TRAFFIC_JAM: "#99001A",
|
|
17
|
+
DONE: "#96B2CA"
|
|
18
|
+
};
|
|
19
|
+
const trafficOuterColors = {
|
|
20
|
+
// UNKNOWN: "#4175F1",
|
|
21
|
+
UNKNOWN: "#008559",
|
|
22
|
+
NORMAL: "#008559",
|
|
23
|
+
SLOW: "#B29400",
|
|
24
|
+
TRAFFIC_JAM: "#990D24",
|
|
25
|
+
HEAVY_TRAFFIC_JAM: "#4D000D",
|
|
26
|
+
DONE: "#7693AF"
|
|
27
|
+
};
|
|
28
|
+
const trafficBorderColors = {
|
|
29
|
+
// UNKNOWN: "#6C95F5",
|
|
30
|
+
UNKNOWN: "#00C875",
|
|
31
|
+
NORMAL: "#00C875",
|
|
32
|
+
SLOW: "#F9D100",
|
|
33
|
+
TRAFFIC_JAM: "#EB0E33",
|
|
34
|
+
HEAVY_TRAFFIC_JAM: "#99001A",
|
|
35
|
+
DONE: "#7693AF"
|
|
36
|
+
};
|
|
10
37
|
const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
11
38
|
return () => {
|
|
39
|
+
const {
|
|
40
|
+
status = "UNKNOWN",
|
|
41
|
+
lineCap = "round"
|
|
42
|
+
} = props;
|
|
12
43
|
const vw = window.innerWidth * 0.01;
|
|
13
44
|
const strokeWidth = 1 * vw;
|
|
14
45
|
const borderWidth = 0.13 * vw;
|
|
15
46
|
const dirWidth = 0.24 * vw;
|
|
16
47
|
const outlineWidth = 0.4 * vw;
|
|
17
48
|
const dashLength = 0.3 * vw;
|
|
18
|
-
const strokeColorInner =
|
|
19
|
-
const strokeColorOuter =
|
|
20
|
-
const strokeColorBorder =
|
|
49
|
+
const strokeColorInner = trafficInnerColors[status];
|
|
50
|
+
const strokeColorOuter = trafficOuterColors[status];
|
|
51
|
+
const strokeColorBorder = trafficBorderColors[status];
|
|
21
52
|
return h("div", [h(AmapPolyline, {
|
|
22
53
|
"attrs": {
|
|
23
54
|
"path": props.path,
|
|
@@ -25,7 +56,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
25
56
|
"strokeOpacity": 1,
|
|
26
57
|
"strokeColor": strokeColorOuter,
|
|
27
58
|
"lineJoin": "round",
|
|
28
|
-
"lineCap":
|
|
59
|
+
"lineCap": lineCap,
|
|
29
60
|
"zIndex": ZINDEX_LINE_LAYER
|
|
30
61
|
}
|
|
31
62
|
}), h(AmapPolyline, {
|
|
@@ -35,7 +66,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
35
66
|
"strokeOpacity": 1,
|
|
36
67
|
"strokeColor": strokeColorBorder,
|
|
37
68
|
"lineJoin": "round",
|
|
38
|
-
"lineCap":
|
|
69
|
+
"lineCap": lineCap,
|
|
39
70
|
"strokeStyle": "dashed",
|
|
40
71
|
"strokeDasharray": [dashLength, dashLength * 0.5],
|
|
41
72
|
"zIndex": ZINDEX_LINE_LAYER
|
|
@@ -47,7 +78,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
47
78
|
"strokeOpacity": 1,
|
|
48
79
|
"strokeColor": strokeColorInner,
|
|
49
80
|
"lineJoin": "round",
|
|
50
|
-
"lineCap":
|
|
81
|
+
"lineCap": lineCap,
|
|
51
82
|
"zIndex": ZINDEX_LINE_LAYER
|
|
52
83
|
}
|
|
53
84
|
}), h(AmapPolyline, {
|
|
@@ -58,7 +89,7 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
58
89
|
"strokeOpacity": 1,
|
|
59
90
|
"strokeColor": "transparent",
|
|
60
91
|
"lineJoin": "round",
|
|
61
|
-
"lineCap":
|
|
92
|
+
"lineCap": lineCap,
|
|
62
93
|
"zIndex": ZINDEX_LINE_LAYER
|
|
63
94
|
}
|
|
64
95
|
})]);
|
|
@@ -67,15 +98,18 @@ const ADrivingLine = defineSetup("ADrivingLine", function(props) {
|
|
|
67
98
|
const GDrivingLine = defineSetup("GDrivingLine", function(props) {
|
|
68
99
|
const pathRef = computed(() => props.path.map(vec2lnglat));
|
|
69
100
|
return () => {
|
|
101
|
+
const {
|
|
102
|
+
status = "UNKNOWN"
|
|
103
|
+
} = props;
|
|
70
104
|
const vw = window.innerWidth * 0.01;
|
|
71
105
|
const repeat = 10 * vw;
|
|
72
106
|
const strokeWidth = 1.25 * vw * 0.65;
|
|
73
107
|
const borderWidth = 0.175 * vw * 0.65;
|
|
74
108
|
const dirStrokeWeight = 0.375 * vw * 0.65;
|
|
75
109
|
const outlineWidth = 0.45 * vw * 0.65;
|
|
76
|
-
const strokeColorInner =
|
|
77
|
-
const strokeColorOuter =
|
|
78
|
-
const strokeColorBorder =
|
|
110
|
+
const strokeColorInner = trafficInnerColors[status];
|
|
111
|
+
const strokeColorOuter = trafficOuterColors[status];
|
|
112
|
+
const strokeColorBorder = trafficBorderColors[status];
|
|
79
113
|
return h("div", [h(GmapPolyline, {
|
|
80
114
|
"attrs": {
|
|
81
115
|
"path": pathRef.value,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type VNodeChild } from "../../demi-polyfill";
|
|
2
2
|
import { type UseDrivingRouteProps } from "../../hooks/useDrivingRoute";
|
|
3
|
-
import type { Point } from "../../types/interface";
|
|
3
|
+
import type { Point, TrafficJams } from "../../types/interface";
|
|
4
4
|
export type DrivingRouteRenderProps = {
|
|
5
5
|
path: Point[];
|
|
6
6
|
angle?: number;
|
|
7
7
|
distance: number;
|
|
8
8
|
duration: number;
|
|
9
9
|
tolls?: number;
|
|
10
|
+
trafficJams?: TrafficJams;
|
|
10
11
|
};
|
|
11
12
|
export interface DrivingRouteProps extends UseDrivingRouteProps {
|
|
12
13
|
render?: (props: DrivingRouteRenderProps) => VNodeChild;
|
|
@@ -14,7 +14,8 @@ const ADrivingRoute = defineSetup("ADrivingRoute", function(props, {
|
|
|
14
14
|
path,
|
|
15
15
|
distance,
|
|
16
16
|
duration,
|
|
17
|
-
tolls
|
|
17
|
+
tolls,
|
|
18
|
+
trafficJams
|
|
18
19
|
} = toRefs(useADrivingRoute(props).route);
|
|
19
20
|
const {
|
|
20
21
|
angleRef
|
|
@@ -29,7 +30,8 @@ const ADrivingRoute = defineSetup("ADrivingRoute", function(props, {
|
|
|
29
30
|
angle: angleRef,
|
|
30
31
|
distance,
|
|
31
32
|
duration,
|
|
32
|
-
tolls
|
|
33
|
+
tolls,
|
|
34
|
+
trafficJams
|
|
33
35
|
}))]);
|
|
34
36
|
};
|
|
35
37
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Point, TrafficJams } from "../../types/interface";
|
|
2
|
+
export interface TrafficDrivingLineProps {
|
|
3
|
+
path: Point[];
|
|
4
|
+
trafficJams?: TrafficJams;
|
|
5
|
+
}
|
|
6
|
+
export declare const TrafficDrivingLine: import("vue").DefineComponent<import("vue3").ComponentObjectPropsOptions<TrafficDrivingLineProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<TrafficDrivingLineProps, Required<TrafficDrivingLineProps>>, never, TrafficDrivingLineProps>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
import { defineSetup } from "../../types/helper.js";
|
|
3
|
+
import { stringifyPoint, isPointExactEqual } from "../../utils/transform.js";
|
|
4
|
+
import { DrivingLine } from "../DrivingLine/DrivingLine.js";
|
|
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";
|
|
17
|
+
};
|
|
18
|
+
const createMulitpleLineByTrafficJams = (path, trafficJams) => {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
if (!trafficJams)
|
|
21
|
+
return [{
|
|
22
|
+
path,
|
|
23
|
+
status: "UNKNOWN"
|
|
24
|
+
}];
|
|
25
|
+
const firstPoint = path[0];
|
|
26
|
+
if (!firstPoint)
|
|
27
|
+
return [];
|
|
28
|
+
const multipleLines = [];
|
|
29
|
+
let line = {
|
|
30
|
+
path: [firstPoint],
|
|
31
|
+
status: justifyFirstPointStatus((_a = trafficJams[stringifyPoint(firstPoint)]) == null ? void 0 : _a.after, (_b = trafficJams[stringifyPoint(path[1])]) == null ? void 0 : _b.before)
|
|
32
|
+
};
|
|
33
|
+
for (let idx = 1; idx < path.length; idx++) {
|
|
34
|
+
const point = path[idx];
|
|
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);
|
|
38
|
+
if (traffic === line.status)
|
|
39
|
+
continue;
|
|
40
|
+
multipleLines.push(line);
|
|
41
|
+
line = {
|
|
42
|
+
path: [point],
|
|
43
|
+
status: traffic
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
multipleLines.push(line);
|
|
47
|
+
return multipleLines;
|
|
48
|
+
};
|
|
49
|
+
const beautifyMultipleLines = (lines) => {
|
|
50
|
+
const max = lines.length - 1;
|
|
51
|
+
if (max === 0)
|
|
52
|
+
return [{
|
|
53
|
+
...lines[0],
|
|
54
|
+
lineCap: "round"
|
|
55
|
+
}];
|
|
56
|
+
const totalPath = lines.flatMap((line) => line.path);
|
|
57
|
+
const totalLine = {
|
|
58
|
+
path: totalPath,
|
|
59
|
+
status: "NORMAL",
|
|
60
|
+
lineCap: "round"
|
|
61
|
+
};
|
|
62
|
+
const roundCoveredLines = [];
|
|
63
|
+
const buttCoveredLines = [];
|
|
64
|
+
for (const line of lines) {
|
|
65
|
+
const {
|
|
66
|
+
path,
|
|
67
|
+
status
|
|
68
|
+
} = line;
|
|
69
|
+
if (!isSlowOrJam(status))
|
|
70
|
+
continue;
|
|
71
|
+
buttCoveredLines.push({
|
|
72
|
+
status,
|
|
73
|
+
path,
|
|
74
|
+
lineCap: "butt"
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const first = lines[0];
|
|
78
|
+
const last = lines[lines.length - 1];
|
|
79
|
+
const ignoredLine = {
|
|
80
|
+
status: first.status,
|
|
81
|
+
path: first.path.slice(0, 2),
|
|
82
|
+
lineCap: "butt"
|
|
83
|
+
};
|
|
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];
|
|
97
|
+
};
|
|
98
|
+
const TrafficDrivingLine = defineSetup("TrafficDrivingLine", function(props) {
|
|
99
|
+
return () => {
|
|
100
|
+
const {
|
|
101
|
+
path,
|
|
102
|
+
trafficJams
|
|
103
|
+
} = props;
|
|
104
|
+
const multipleLines = createMulitpleLineByTrafficJams(path, trafficJams);
|
|
105
|
+
const beautifiedLines = beautifyMultipleLines(multipleLines);
|
|
106
|
+
return h("div", [beautifiedLines.map((line) => h(DrivingLine, {
|
|
107
|
+
"attrs": {
|
|
108
|
+
"path": line.path,
|
|
109
|
+
"status": line.status,
|
|
110
|
+
"lineCap": line.lineCap
|
|
111
|
+
}
|
|
112
|
+
}))]);
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
export {
|
|
116
|
+
TrafficDrivingLine
|
|
117
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TrafficDrivingLine";
|
|
@@ -5,7 +5,6 @@ import { defineSetup } from "../../types/helper.js";
|
|
|
5
5
|
import { watchNoneImmediatePostEffectForMapProperty, watchPostEffectForAMapEvent } from "../../utils/compare.js";
|
|
6
6
|
import { detectTouchDevice } from "../../utils/platform.js";
|
|
7
7
|
import { referenceCount } from "../../utils/referenceCount.js";
|
|
8
|
-
import { useAmapFixBugOverlayDrag } from "../AmapPolygon/AmapPolygon.js";
|
|
9
8
|
const isTouchDevice = detectTouchDevice();
|
|
10
9
|
const shouldSkipByAmapClickDoubleTriggerBug = (e) => {
|
|
11
10
|
return isTouchDevice && e.originEvent.type === "mouseup";
|
|
@@ -33,7 +32,6 @@ const AmapMarker = defineSetup("AmapMarker", function(props, { emit }) {
|
|
|
33
32
|
(_b = markerRef.value) == null ? void 0 : _b.destroy();
|
|
34
33
|
markerRef.value = void 0;
|
|
35
34
|
});
|
|
36
|
-
useAmapFixBugOverlayDrag(markerRef);
|
|
37
35
|
watchPostEffect((onCleanup) => {
|
|
38
36
|
var _a;
|
|
39
37
|
const map = mapRef == null ? void 0 : mapRef.value;
|
|
@@ -27,6 +27,7 @@ export declare const useDeviationCorrectionDrivingRoute: (props?: UseDeviationCo
|
|
|
27
27
|
duration: number;
|
|
28
28
|
distance: number;
|
|
29
29
|
}[];
|
|
30
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
30
31
|
};
|
|
31
32
|
index: number;
|
|
32
33
|
path: [number, number][];
|
|
@@ -38,6 +39,7 @@ export declare const useDeviationCorrectionDrivingRoute: (props?: UseDeviationCo
|
|
|
38
39
|
duration: number;
|
|
39
40
|
distance: number;
|
|
40
41
|
}[];
|
|
42
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
41
43
|
};
|
|
42
44
|
angleRef: import("vue-demi").Ref<number>;
|
|
43
45
|
graspRoadPathRef: import("vue-demi").Ref<Point[] | undefined>;
|
|
@@ -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 = () => {
|
|
@@ -14,6 +14,7 @@ export declare const useADrivingRoute: (props?: UseDrivingRouteProps) => {
|
|
|
14
14
|
duration: number;
|
|
15
15
|
distance: number;
|
|
16
16
|
}[];
|
|
17
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
17
18
|
};
|
|
18
19
|
apiMapDrivingRoute: (from: Point, to: Point) => Promise<Route>;
|
|
19
20
|
};
|
|
@@ -28,6 +29,7 @@ export declare const useGDrivingRoute: (props?: UseDrivingRouteProps) => {
|
|
|
28
29
|
duration: number;
|
|
29
30
|
distance: number;
|
|
30
31
|
}[];
|
|
32
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
31
33
|
};
|
|
32
34
|
apiMapDrivingRoute: (from: Point, to: Point) => Promise<Route>;
|
|
33
35
|
};
|
|
@@ -42,6 +44,7 @@ export declare const useDrivingRoute: (props?: UseDrivingRouteProps) => {
|
|
|
42
44
|
duration: number;
|
|
43
45
|
distance: number;
|
|
44
46
|
}[];
|
|
47
|
+
trafficJams?: import("../types/interface").TrafficJams | undefined;
|
|
45
48
|
};
|
|
46
49
|
apiMapDrivingRoute: (from: Point, to: Point) => Promise<Route>;
|
|
47
50
|
};
|
|
@@ -78,6 +78,7 @@ export interface Route {
|
|
|
78
78
|
duration: number;
|
|
79
79
|
tolls?: number;
|
|
80
80
|
steps: RouteStep[];
|
|
81
|
+
trafficJams?: TrafficJams;
|
|
81
82
|
}
|
|
82
83
|
export interface TrackPoint {
|
|
83
84
|
lng: number;
|
|
@@ -105,3 +106,8 @@ export type ProxyServiceError = {
|
|
|
105
106
|
code: number;
|
|
106
107
|
msg: string;
|
|
107
108
|
};
|
|
109
|
+
export type TrafficStatus = "UNKNOWN" | "NORMAL" | "SLOW" | "TRAFFIC_JAM" | "HEAVY_TRAFFIC_JAM";
|
|
110
|
+
export type TrafficJams = Record<`${number},${number}`, {
|
|
111
|
+
before: TrafficStatus;
|
|
112
|
+
after: TrafficStatus;
|
|
113
|
+
}>;
|