gisviewer-vue3-arcgis 1.0.171 → 1.0.172
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/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +1 -1
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.mjs +82 -66
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +1 -0
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +132 -125
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +19 -19
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +1 -1
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +1 -0
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/package.json +1 -1
- package/es/src/gis-map/utils/GreenWaveline.d.ts +0 -68
- package/lib/src/gis-map/utils/GreenWaveline.d.ts +0 -68
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import SignalHoloFlow from './signal-holo-flow';
|
|
2
1
|
import { ISignalCountdownProps } from '../../../types';
|
|
2
|
+
import SignalHoloFlow from './signal-holo-flow';
|
|
3
3
|
export default class LSRSignalHoloFlow extends SignalHoloFlow {
|
|
4
4
|
private stopLineLayer;
|
|
5
5
|
private watchHandle;
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Point as
|
|
3
|
-
import
|
|
4
|
-
import P from "
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import * as w from "@arcgis/core/core/reactiveUtils";
|
|
2
|
+
import { Point as f } from "@arcgis/core/geometry";
|
|
3
|
+
import * as d from "@arcgis/core/geometry/support/webMercatorUtils.js";
|
|
4
|
+
import P from "@arcgis/core/layers/GraphicsLayer";
|
|
5
|
+
import g from "./signal-holo-flow.mjs";
|
|
6
|
+
class S extends g {
|
|
7
|
+
constructor(n, a) {
|
|
8
|
+
super(n), this.stopLineLayer = new P(), this.watchHandle = null, this.stopLineMap = /* @__PURE__ */ new Map(), this.countdownPanelProps = a, this.view.map.add(this.stopLineLayer);
|
|
8
9
|
}
|
|
9
10
|
async initializeLayer() {
|
|
10
|
-
var
|
|
11
|
+
var p, l;
|
|
11
12
|
console.time("初始化停止线图层");
|
|
12
|
-
let n = (
|
|
13
|
+
let n = (l = (p = this.mapConfig.holoFlow) == null ? void 0 : p.signal) == null ? void 0 : l.stopLineLayer;
|
|
13
14
|
if (!n)
|
|
14
15
|
return;
|
|
15
16
|
n = this.mapConfig.assetsRoot + "/" + n, (await (await fetch(n)).json()).features.forEach((t) => {
|
|
16
|
-
const { roadId: o, nodeId: e, angle:
|
|
17
|
-
|
|
18
|
-
coord:
|
|
19
|
-
panelPoint:
|
|
20
|
-
angle:
|
|
17
|
+
const { roadId: o, nodeId: e, angle: s, destinationPoint: i } = t.properties, { coordinates: r } = t.geometry, h = this.stopLineMap.get(e);
|
|
18
|
+
h ? h.set(o, {
|
|
19
|
+
coord: r,
|
|
20
|
+
panelPoint: i,
|
|
21
|
+
angle: s
|
|
21
22
|
}) : this.stopLineMap.set(
|
|
22
23
|
e,
|
|
23
24
|
/* @__PURE__ */ new Map([
|
|
24
25
|
[
|
|
25
26
|
o,
|
|
26
|
-
{ coord:
|
|
27
|
+
{ coord: r, panelPoint: i, angle: s }
|
|
27
28
|
]
|
|
28
29
|
])
|
|
29
30
|
);
|
|
@@ -31,77 +32,84 @@ class L extends P {
|
|
|
31
32
|
}
|
|
32
33
|
getPanelScale() {
|
|
33
34
|
const n = this.view.scale;
|
|
34
|
-
let
|
|
35
|
-
return n < 1e3 ?
|
|
35
|
+
let a = 1;
|
|
36
|
+
return n < 1e3 ? a = 1 : n < 2e3 ? a = 0.8 : a = 0.4, a;
|
|
36
37
|
}
|
|
37
38
|
async handleSignalData(n) {
|
|
38
|
-
this.watchHandle || (this.watchHandle =
|
|
39
|
+
this.watchHandle || (this.watchHandle = w.watch(
|
|
39
40
|
() => this.view.extent,
|
|
40
41
|
() => {
|
|
42
|
+
console.log("extent changed");
|
|
41
43
|
const t = this.getPanelScale();
|
|
42
44
|
for (const o of this.countdownPanelProps) {
|
|
43
45
|
t !== this.currentPanelScale && (o.scale = t);
|
|
44
|
-
const { mapPoint: e } = o
|
|
45
|
-
|
|
46
|
+
const { mapPoint: e } = o;
|
|
47
|
+
let s = new f({
|
|
46
48
|
x: e[0],
|
|
47
49
|
y: e[1]
|
|
48
50
|
});
|
|
49
|
-
|
|
51
|
+
this.view.spatialReference.isWebMercator && (s = d.geographicToWebMercator(
|
|
52
|
+
s
|
|
53
|
+
));
|
|
54
|
+
const i = this.view.toScreen(s);
|
|
55
|
+
if (o.position.left = i.x, o.position.top = i.y, this.view.type === "3d") {
|
|
56
|
+
const r = this.getPanelRotation(o.stopLine);
|
|
57
|
+
o.rotation = r;
|
|
58
|
+
}
|
|
50
59
|
}
|
|
51
60
|
this.currentPanelScale = t;
|
|
52
61
|
}
|
|
53
62
|
));
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
console.log(`没有找到路口${s}`);
|
|
63
|
+
const a = n.crossId, c = this.stopLineMap.get(a);
|
|
64
|
+
if (!c)
|
|
57
65
|
return;
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
for (const t of c) {
|
|
66
|
+
const p = n.phaseCountDownList, l = /* @__PURE__ */ new Map();
|
|
67
|
+
for (const t of p) {
|
|
61
68
|
let o = "";
|
|
62
|
-
for (let
|
|
63
|
-
if (
|
|
64
|
-
o =
|
|
69
|
+
for (let r of t.roadIdList)
|
|
70
|
+
if (r.startsWith("-") && (r = r.slice(1)), c.has(r)) {
|
|
71
|
+
o = r;
|
|
65
72
|
break;
|
|
66
73
|
}
|
|
67
|
-
if (!o)
|
|
68
|
-
console.log(`没有找到对应的进口道${s}--${o}`);
|
|
74
|
+
if (!o)
|
|
69
75
|
continue;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.log(`没有找到对应的方向${s}--${JSON.stringify(t)}`);
|
|
76
|
+
let e = l.get(o);
|
|
77
|
+
if (e || (e = {}, l.set(o, e)), !t.direction) {
|
|
78
|
+
console.log(`没有找到对应的方向${a}--${JSON.stringify(t)}`);
|
|
74
79
|
continue;
|
|
75
80
|
}
|
|
76
|
-
const
|
|
77
|
-
|
|
81
|
+
const s = t.direction.toLowerCase(), i = t.color === 1 ? "red" : t.color === 2 ? "yellow" : "green";
|
|
82
|
+
s === "u" ? (e.uNumber = t.leftTime, e.uColor = i) : s === "l" ? (e.lNumber = t.leftTime, e.lColor = i) : s === "s" ? (e.sNumber = t.leftTime, e.sColor = i) : s === "r" && (e.rNumber = t.leftTime, e.rColor = i);
|
|
78
83
|
}
|
|
79
|
-
|
|
80
|
-
const e =
|
|
84
|
+
l.forEach((t, o) => {
|
|
85
|
+
const e = c.get(o);
|
|
81
86
|
if (!e)
|
|
82
87
|
return;
|
|
83
|
-
const
|
|
84
|
-
(
|
|
88
|
+
const s = this.countdownPanelProps.find(
|
|
89
|
+
(i) => i.crossId === a && i.roadId === o
|
|
85
90
|
);
|
|
86
|
-
if (
|
|
87
|
-
|
|
91
|
+
if (s)
|
|
92
|
+
s.lampStatus = t;
|
|
88
93
|
else {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
let i = new f({
|
|
95
|
+
x: e.panelPoint[0],
|
|
96
|
+
y: e.panelPoint[1]
|
|
97
|
+
});
|
|
98
|
+
this.view.spatialReference.isWebMercator && (i = d.geographicToWebMercator(
|
|
99
|
+
i
|
|
100
|
+
));
|
|
101
|
+
const r = this.view.toScreen(i), h = this.getPanelRotation(e.coord);
|
|
102
|
+
console.log(i.toJSON(), r), this.countdownPanelProps.push({
|
|
95
103
|
displayMode: "complex",
|
|
96
|
-
crossId:
|
|
104
|
+
crossId: a,
|
|
97
105
|
roadId: o,
|
|
98
|
-
mapPoint:
|
|
106
|
+
mapPoint: e.panelPoint,
|
|
99
107
|
// 定位点地理坐标
|
|
100
108
|
stopLine: e.coord,
|
|
101
109
|
// 关联的停止线坐标
|
|
102
|
-
position: { left:
|
|
110
|
+
position: { left: r.x, top: r.y },
|
|
103
111
|
// 定位点屏幕坐标
|
|
104
|
-
rotation:
|
|
112
|
+
rotation: h,
|
|
105
113
|
// 面板旋转角度
|
|
106
114
|
scale: this.getPanelScale(),
|
|
107
115
|
lampStatus: t
|
|
@@ -112,7 +120,7 @@ class L extends P {
|
|
|
112
120
|
}
|
|
113
121
|
clearSignal() {
|
|
114
122
|
var n;
|
|
115
|
-
this.stopLineLayer.removeAll(), this.countdownPanelProps =
|
|
123
|
+
this.stopLineLayer.removeAll(), this.countdownPanelProps.length = 0, (n = this.watchHandle) == null || n.remove(), this.watchHandle = null;
|
|
116
124
|
}
|
|
117
125
|
/**
|
|
118
126
|
* 从停止线坐标计算面板旋转角度
|
|
@@ -120,18 +128,26 @@ class L extends P {
|
|
|
120
128
|
* @returns
|
|
121
129
|
*/
|
|
122
130
|
getPanelRotation(n) {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const a = n[0];
|
|
132
|
+
let c = new f({
|
|
133
|
+
x: a[0],
|
|
134
|
+
y: a[1]
|
|
135
|
+
});
|
|
136
|
+
this.view.spatialReference.isWebMercator && (c = d.geographicToWebMercator(
|
|
137
|
+
c
|
|
138
|
+
));
|
|
139
|
+
const p = this.view.toScreen(c), l = n[n.length - 1];
|
|
140
|
+
let t = new f({
|
|
141
|
+
x: l[0],
|
|
142
|
+
y: l[1]
|
|
143
|
+
});
|
|
144
|
+
this.view.spatialReference.isWebMercator && (t = d.geographicToWebMercator(
|
|
145
|
+
t
|
|
146
|
+
));
|
|
147
|
+
const o = this.view.toScreen(t), e = o.x - p.x, s = o.y - p.y;
|
|
148
|
+
return Math.atan2(s, e) * (180 / Math.PI);
|
|
133
149
|
}
|
|
134
150
|
}
|
|
135
151
|
export {
|
|
136
|
-
|
|
152
|
+
S as default
|
|
137
153
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as b from "@arcgis/core/core/promiseUtils.js";
|
|
2
2
|
import * as P from "@arcgis/core/core/reactiveUtils.js";
|
|
3
3
|
import v from "@arcgis/core/geometry/SpatialReference";
|
|
4
4
|
import * as u from "@arcgis/core/views/3d/externalRenderers";
|
|
@@ -8,7 +8,7 @@ import { toRaw as T } from "vue";
|
|
|
8
8
|
import { EVehiclePlateState as m } from "../../../types/index.mjs";
|
|
9
9
|
import C from "../../stores/index.mjs";
|
|
10
10
|
class V {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(i) {
|
|
12
12
|
this.cameraHeightThreshold = 1e3, this.roughness = 0.2, this.metalness = 0.8, this.defaultMaterial = new a.MeshPhongMaterial({
|
|
13
13
|
color: 16777215
|
|
14
14
|
}), this.materialMap = /* @__PURE__ */ new Map([
|
|
@@ -44,19 +44,19 @@ class V {
|
|
|
44
44
|
"queueLength",
|
|
45
45
|
"status"
|
|
46
46
|
]
|
|
47
|
-
], this.view =
|
|
47
|
+
], this.view = i;
|
|
48
48
|
const e = T(this.appDataStore.mapConfig);
|
|
49
49
|
this.assetsRoot = e.assetsRoot, P.watch(
|
|
50
50
|
() => this.view.camera.position.z,
|
|
51
|
-
(t,
|
|
52
|
-
(
|
|
51
|
+
(t, s) => {
|
|
52
|
+
(s <= this.cameraHeightThreshold && t > this.cameraHeightThreshold || s > this.cameraHeightThreshold && t <= this.cameraHeightThreshold) && (this.updateModel = !0);
|
|
53
53
|
}
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
// private readonly vehiclePool = new VehiclePool();
|
|
57
|
-
createCarMaterial(
|
|
57
|
+
createCarMaterial(i) {
|
|
58
58
|
return new a.MeshPhongMaterial({
|
|
59
|
-
color:
|
|
59
|
+
color: i
|
|
60
60
|
// // emissive: 0xc3c3c3,
|
|
61
61
|
// roughness: this.roughness,
|
|
62
62
|
// metalness: this.metalness
|
|
@@ -66,39 +66,44 @@ class V {
|
|
|
66
66
|
return this.logTable;
|
|
67
67
|
}
|
|
68
68
|
async init() {
|
|
69
|
-
const
|
|
70
|
-
await
|
|
69
|
+
const i = new y();
|
|
70
|
+
await b.eachAlways([
|
|
71
71
|
new Promise((e) => {
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
this.carModel = new a.Object3D(), this.carModel.rotation.x = a.MathUtils.degToRad(90), this.carModel.add(
|
|
72
|
+
i.load(`${this.assetsRoot}/3DModels/car.glb`, (t) => {
|
|
73
|
+
const s = t.scene, n = new a.Box3().setFromObject(s).getSize(new a.Vector3());
|
|
74
|
+
this.carModel = new a.Object3D(), this.carModel.rotation.x = a.MathUtils.degToRad(90), this.carModel.add(s), s.position.set(0, 0, n.z / 2), e();
|
|
75
75
|
});
|
|
76
76
|
}),
|
|
77
77
|
new Promise((e) => {
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
this.vanModel = new a.Object3D(), this.vanModel.rotation.x = a.MathUtils.degToRad(90), this.vanModel.add(
|
|
78
|
+
i.load(`${this.assetsRoot}/3DModels/van.glb`, (t) => {
|
|
79
|
+
const s = t.scene, n = new a.Box3().setFromObject(s).getSize(new a.Vector3());
|
|
80
|
+
this.vanModel = new a.Object3D(), this.vanModel.rotation.x = a.MathUtils.degToRad(90), this.vanModel.add(s), s.position.set(0, 0, n.z / 2), e();
|
|
81
81
|
});
|
|
82
82
|
}),
|
|
83
83
|
new Promise((e) => {
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const n = new a.Box3().setFromObject(
|
|
88
|
-
this.truckModel = new a.Object3D(), this.truckModel.rotation.x = a.MathUtils.degToRad(90), this.truckModel.add(
|
|
84
|
+
i.load(`${this.assetsRoot}/3DModels/truck.glb`, (t) => {
|
|
85
|
+
const s = t.scene;
|
|
86
|
+
s.scale.set(1.2, 1, 1.5);
|
|
87
|
+
const n = new a.Box3().setFromObject(s).getSize(new a.Vector3());
|
|
88
|
+
this.truckModel = new a.Object3D(), this.truckModel.rotation.x = a.MathUtils.degToRad(90), this.truckModel.add(s), s.position.set(0, 0, n.z / 2), e();
|
|
89
89
|
});
|
|
90
90
|
}),
|
|
91
91
|
new Promise((e) => {
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
this.busModel = new a.Object3D(), this.busModel.rotation.x = a.MathUtils.degToRad(90), this.busModel.add(
|
|
92
|
+
i.load(`${this.assetsRoot}/3DModels/bus.glb`, (t) => {
|
|
93
|
+
const s = t.scene, n = new a.Box3().setFromObject(s).getSize(new a.Vector3());
|
|
94
|
+
this.busModel = new a.Object3D(), this.busModel.rotation.x = a.MathUtils.degToRad(90), this.busModel.add(s), s.position.set(0, 0, n.z / 2), e();
|
|
95
95
|
});
|
|
96
96
|
}),
|
|
97
97
|
new Promise((e) => {
|
|
98
|
-
|
|
98
|
+
i.load(`${this.assetsRoot}/3DModels/bicycle.glb`, (t) => {
|
|
99
99
|
this.bicycleModel = t.scene, this.bicycleModel.rotation.x = a.MathUtils.degToRad(90), this.bicycleModel.rotation.y = a.MathUtils.degToRad(180), e();
|
|
100
100
|
});
|
|
101
101
|
}),
|
|
102
|
+
new Promise((e) => {
|
|
103
|
+
i.load(`${this.assetsRoot}/3DModels/bicycle.glb`, (t) => {
|
|
104
|
+
this.passengerModel = t.scene, this.passengerModel.rotation.x = a.MathUtils.degToRad(90), this.passengerModel.rotation.y = a.MathUtils.degToRad(180), e();
|
|
105
|
+
});
|
|
106
|
+
}),
|
|
102
107
|
new Promise((e) => {
|
|
103
108
|
this.bluePlateBG = new Image(), this.bluePlateBG.src = `${this.assetsRoot}/Images/PlateBG/blue.png`, this.bluePlateBG.onload = () => {
|
|
104
109
|
e();
|
|
@@ -136,12 +141,12 @@ class V {
|
|
|
136
141
|
})
|
|
137
142
|
]), this.isInitialized = !0;
|
|
138
143
|
}
|
|
139
|
-
setInterpolate(
|
|
140
|
-
this.clearVehicles(), this.needInterpolate =
|
|
144
|
+
setInterpolate(i) {
|
|
145
|
+
this.clearVehicles(), this.needInterpolate = i;
|
|
141
146
|
}
|
|
142
|
-
async setup(
|
|
143
|
-
this.context =
|
|
144
|
-
context:
|
|
147
|
+
async setup(i) {
|
|
148
|
+
this.context = i, this.renderer = new a.WebGLRenderer({
|
|
149
|
+
context: i.gl,
|
|
145
150
|
premultipliedAlpha: !0,
|
|
146
151
|
logarithmicDepthBuffer: !0,
|
|
147
152
|
antialias: !0,
|
|
@@ -150,25 +155,25 @@ class V {
|
|
|
150
155
|
const e = this.renderer.setRenderTarget.bind(
|
|
151
156
|
this.renderer
|
|
152
157
|
);
|
|
153
|
-
this.renderer.setRenderTarget = (
|
|
154
|
-
e(
|
|
158
|
+
this.renderer.setRenderTarget = (s) => {
|
|
159
|
+
e(s), s == null && i.bindRenderTarget();
|
|
155
160
|
}, this.scene = new a.Scene();
|
|
156
|
-
const { camera: t } =
|
|
161
|
+
const { camera: t } = i;
|
|
157
162
|
this.camera = new a.PerspectiveCamera(
|
|
158
163
|
t.fovY,
|
|
159
164
|
t.aspect,
|
|
160
165
|
0.1,
|
|
161
166
|
1e5
|
|
162
|
-
), this.ambient = new a.AmbientLight(16777215, 2), this.scene.add(this.ambient), this.sun = new a.DirectionalLight(16777215, 2), this.scene.add(this.sun),
|
|
167
|
+
), this.ambient = new a.AmbientLight(16777215, 2), this.scene.add(this.ambient), this.sun = new a.DirectionalLight(16777215, 2), this.scene.add(this.sun), i.resetWebGLState();
|
|
163
168
|
}
|
|
164
|
-
async render(
|
|
165
|
-
var
|
|
166
|
-
const e =
|
|
169
|
+
async render(i) {
|
|
170
|
+
var s;
|
|
171
|
+
const e = i.camera;
|
|
167
172
|
if (this.camera.position.set(e.eye[0], e.eye[1], e.eye[2]), this.camera.up.set(e.up[0], e.up[1], e.up[2]), this.camera.lookAt(
|
|
168
173
|
new a.Vector3(e.center[0], e.center[1], e.center[2])
|
|
169
174
|
), this.camera.projectionMatrix.fromArray(e.projectionMatrix), !this.isPaused && this.needInterpolate)
|
|
170
175
|
for (const o of this.vehicleObjectMap.keys()) {
|
|
171
|
-
const n = (
|
|
176
|
+
const n = (s = this.vehicleObjectMap.get(o)) == null ? void 0 : s.model;
|
|
172
177
|
if (!n)
|
|
173
178
|
continue;
|
|
174
179
|
const r = this.computeVehiclePosition(o);
|
|
@@ -177,7 +182,7 @@ class V {
|
|
|
177
182
|
n.position.set(d[0], d[1], d[2]), n.rotation.y = a.MathUtils.degToRad(-r[3]);
|
|
178
183
|
}
|
|
179
184
|
}
|
|
180
|
-
const t =
|
|
185
|
+
const t = i.sunLight;
|
|
181
186
|
this.sun.position.set(t.direction[0], t.direction[1], t.direction[2]), this.sun.intensity = t.diffuse.intensity, this.sun.color = new a.Color(
|
|
182
187
|
t.diffuse.color[0],
|
|
183
188
|
t.diffuse.color[1],
|
|
@@ -186,16 +191,16 @@ class V {
|
|
|
186
191
|
t.ambient.color[0],
|
|
187
192
|
t.ambient.color[1],
|
|
188
193
|
t.ambient.color[2]
|
|
189
|
-
), this.renderer.resetState(),
|
|
194
|
+
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera), u.requestRender(this.view), i.resetWebGLState();
|
|
190
195
|
}
|
|
191
196
|
/**
|
|
192
197
|
* 新增车辆
|
|
193
198
|
* */
|
|
194
|
-
async addVehicles(
|
|
199
|
+
async addVehicles(i) {
|
|
195
200
|
if (this.isPaused || !this.isInitialized)
|
|
196
201
|
return;
|
|
197
202
|
const e = Date.now();
|
|
198
|
-
for (const t of
|
|
203
|
+
for (const t of i) {
|
|
199
204
|
this.appDataStore.saveTrackLog && this.logTable.push([
|
|
200
205
|
t.ptcId,
|
|
201
206
|
t.plateNo,
|
|
@@ -216,19 +221,19 @@ class V {
|
|
|
216
221
|
0,
|
|
217
222
|
0
|
|
218
223
|
]);
|
|
219
|
-
const { vehicleId:
|
|
220
|
-
this.historyPositionMap.set(
|
|
224
|
+
const { vehicleId: s, localTimestamp: o } = t, n = Number(t.x), r = Number(t.y), d = Number(t.heading);
|
|
225
|
+
this.historyPositionMap.set(s, [
|
|
221
226
|
{ pos: [n, r, 0], heading: d, time: o }
|
|
222
227
|
]);
|
|
223
228
|
const h = this.getVehicleModel(t);
|
|
224
|
-
h.name =
|
|
229
|
+
h.name = s, h.visible = !1;
|
|
225
230
|
try {
|
|
226
231
|
const l = await this.createPlateSprite(t);
|
|
227
232
|
l && (h.add(l), l.position.set(0, 5, -4));
|
|
228
233
|
} catch (l) {
|
|
229
234
|
console.log("createPlateSprite error:", l);
|
|
230
235
|
}
|
|
231
|
-
this.scene.add(h), this.vehicleObjectMap.set(
|
|
236
|
+
this.scene.add(h), this.vehicleObjectMap.set(s, {
|
|
232
237
|
model: h,
|
|
233
238
|
data: t,
|
|
234
239
|
waitForDelete: !1,
|
|
@@ -239,50 +244,50 @@ class V {
|
|
|
239
244
|
/**
|
|
240
245
|
* 更新车辆
|
|
241
246
|
* */
|
|
242
|
-
async updateVehicles(
|
|
247
|
+
async updateVehicles(i) {
|
|
243
248
|
if (this.isPaused || !this.isInitialized)
|
|
244
249
|
return;
|
|
245
250
|
const e = [], t = Date.now();
|
|
246
|
-
for (const
|
|
247
|
-
const { vehicleId: o, localTimestamp: n } =
|
|
248
|
-
let h = Number(
|
|
251
|
+
for (const s of i) {
|
|
252
|
+
const { vehicleId: o, localTimestamp: n } = s, r = Number(s.x), d = Number(s.y);
|
|
253
|
+
let h = Number(s.heading);
|
|
249
254
|
const l = this.vehicleObjectMap.get(o), p = this.historyPositionMap.get(
|
|
250
255
|
o
|
|
251
256
|
);
|
|
252
257
|
if (!l || !p)
|
|
253
|
-
e.push(
|
|
258
|
+
e.push(s);
|
|
254
259
|
else {
|
|
255
260
|
if (this.appDataStore.saveTrackLog && this.logTable.push([
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
261
|
+
s.ptcId,
|
|
262
|
+
s.plateNo,
|
|
263
|
+
s.timestamp,
|
|
264
|
+
s.localTimestamp,
|
|
265
|
+
s.speed,
|
|
266
|
+
s.x,
|
|
267
|
+
s.y,
|
|
268
|
+
s.ptcType,
|
|
269
|
+
s.vehicleType,
|
|
270
|
+
s.vehicleColor,
|
|
271
|
+
s.plateColor,
|
|
272
|
+
s.heading,
|
|
273
|
+
s.fixAngle,
|
|
274
|
+
s.roadLayer,
|
|
275
|
+
s.step,
|
|
271
276
|
t,
|
|
272
277
|
p.length,
|
|
273
278
|
1
|
|
274
|
-
]), this.updateModel || l.data.vehicleColor !==
|
|
275
|
-
this.scene.remove(l.model), this.disposeModel(l.model), l.model = this.getVehicleModel(
|
|
276
|
-
const c = await this.createPlateSprite(
|
|
279
|
+
]), this.updateModel || l.data.vehicleColor !== s.vehicleColor || l.data.vehicleType !== s.vehicleType) {
|
|
280
|
+
this.scene.remove(l.model), this.disposeModel(l.model), l.model = this.getVehicleModel(s), l.model.visible = !0;
|
|
281
|
+
const c = await this.createPlateSprite(s);
|
|
277
282
|
c && (l.model.add(c), c.position.set(0, 5, -4)), this.scene.add(l.model);
|
|
278
283
|
}
|
|
279
|
-
if (l.data.showName !==
|
|
284
|
+
if (l.data.showName !== s.showName || l.data.plateColor !== s.plateColor) {
|
|
280
285
|
const c = l.model.getObjectByName("VehiclePlate");
|
|
281
286
|
c && (l.model.remove(c), this.disposeModel(c));
|
|
282
|
-
const g = await this.createPlateSprite(
|
|
287
|
+
const g = await this.createPlateSprite(s);
|
|
283
288
|
g && (l.model.add(g), g.position.set(0, 5, -4));
|
|
284
289
|
}
|
|
285
|
-
if (l.data =
|
|
290
|
+
if (l.data = s, this.needInterpolate) {
|
|
286
291
|
const c = p[p.length - 1];
|
|
287
292
|
Math.abs(h - c.heading) >= 180 && (h > c.heading ? c.heading += 360 : h += 360), p.push({
|
|
288
293
|
pos: [r, d, 0],
|
|
@@ -300,12 +305,12 @@ class V {
|
|
|
300
305
|
}
|
|
301
306
|
await this.addVehicles(e), this.updateModel = !1, this.needInterpolate || this.render(this.context);
|
|
302
307
|
}
|
|
303
|
-
toRenderCoordinates(
|
|
308
|
+
toRenderCoordinates(i) {
|
|
304
309
|
const e = [0, 0, 0];
|
|
305
310
|
return u.toRenderCoordinates(
|
|
306
311
|
// @ts-ignore
|
|
307
312
|
this.view,
|
|
308
|
-
|
|
313
|
+
i,
|
|
309
314
|
0,
|
|
310
315
|
v.WGS84,
|
|
311
316
|
e,
|
|
@@ -316,11 +321,11 @@ class V {
|
|
|
316
321
|
/**
|
|
317
322
|
* 删除车辆
|
|
318
323
|
* */
|
|
319
|
-
deleteVehicles(
|
|
324
|
+
deleteVehicles(i) {
|
|
320
325
|
if (this.isPaused)
|
|
321
326
|
return;
|
|
322
327
|
const e = Date.now();
|
|
323
|
-
|
|
328
|
+
i.forEach((t) => {
|
|
324
329
|
if (this.appDataStore.saveTrackLog) {
|
|
325
330
|
const o = this.historyPositionMap.get(t);
|
|
326
331
|
this.logTable.push([
|
|
@@ -344,29 +349,29 @@ class V {
|
|
|
344
349
|
2
|
|
345
350
|
]);
|
|
346
351
|
}
|
|
347
|
-
const
|
|
348
|
-
|
|
352
|
+
const s = this.vehicleObjectMap.get(t);
|
|
353
|
+
s && (this.needInterpolate ? s.isMoving ? s.waitForDelete = !0 : this.deleteVehicle(s) : this.deleteVehicle(s));
|
|
349
354
|
});
|
|
350
355
|
}
|
|
351
|
-
deleteVehicle(
|
|
352
|
-
this.scene.remove(
|
|
353
|
-
const e =
|
|
356
|
+
deleteVehicle(i) {
|
|
357
|
+
this.scene.remove(i.model), this.disposeModel(i.model);
|
|
358
|
+
const e = i.data.vehicleId;
|
|
354
359
|
this.vehicleObjectMap.delete(e), this.historyPositionMap.delete(e);
|
|
355
360
|
}
|
|
356
|
-
async toggleTrafficInfo(
|
|
357
|
-
|
|
358
|
-
|
|
361
|
+
async toggleTrafficInfo(i) {
|
|
362
|
+
i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent === m.None ? await this.updatePanelContent(m.PlateNumber) : await this.updatePanelContent(
|
|
363
|
+
i.visible ? this.currentSpriteContent : m.None
|
|
359
364
|
));
|
|
360
365
|
}
|
|
361
|
-
togglePause(
|
|
362
|
-
this.isPaused =
|
|
366
|
+
togglePause(i) {
|
|
367
|
+
this.isPaused = i;
|
|
363
368
|
}
|
|
364
369
|
/**
|
|
365
370
|
* 清除全部车辆
|
|
366
371
|
* */
|
|
367
372
|
clearVehicles() {
|
|
368
|
-
for (const
|
|
369
|
-
const e = this.vehicleObjectMap.get(
|
|
373
|
+
for (const i of this.vehicleObjectMap.keys()) {
|
|
374
|
+
const e = this.vehicleObjectMap.get(i);
|
|
370
375
|
e && (this.scene.remove(e.model), this.disposeModel(e.model));
|
|
371
376
|
}
|
|
372
377
|
this.vehicleObjectMap.clear(), this.historyPositionMap.clear();
|
|
@@ -376,14 +381,14 @@ class V {
|
|
|
376
381
|
* @param contentType
|
|
377
382
|
* @returns
|
|
378
383
|
*/
|
|
379
|
-
async updatePanelContent(
|
|
380
|
-
if (
|
|
381
|
-
this.currentSpriteContent =
|
|
384
|
+
async updatePanelContent(i) {
|
|
385
|
+
if (i !== this.currentSpriteContent) {
|
|
386
|
+
this.currentSpriteContent = i;
|
|
382
387
|
for (const e of this.vehicleObjectMap.keys()) {
|
|
383
388
|
const t = this.vehicleObjectMap.get(e);
|
|
384
389
|
if (t) {
|
|
385
|
-
const
|
|
386
|
-
if (
|
|
390
|
+
const s = t.model.getObjectByName("VehiclePlate");
|
|
391
|
+
if (s && (t.model.remove(s), this.disposeModel(s)), i !== m.None) {
|
|
387
392
|
const o = await this.createPlateSprite(t.data);
|
|
388
393
|
o && (t.model.add(o), o.position.set(0, 5, -4));
|
|
389
394
|
}
|
|
@@ -391,36 +396,36 @@ class V {
|
|
|
391
396
|
}
|
|
392
397
|
}
|
|
393
398
|
}
|
|
394
|
-
toggleGroundVehicle(
|
|
395
|
-
console.log("toggleGroundVehicle",
|
|
399
|
+
toggleGroundVehicle(i) {
|
|
400
|
+
console.log("toggleGroundVehicle", i), this.showGroundVehicle = i;
|
|
396
401
|
}
|
|
397
|
-
toggleElevatedVehicle(
|
|
398
|
-
this.showElevatedVehicle =
|
|
402
|
+
toggleElevatedVehicle(i) {
|
|
403
|
+
this.showElevatedVehicle = i;
|
|
399
404
|
}
|
|
400
405
|
/**
|
|
401
406
|
* 释放模型资源
|
|
402
407
|
* */
|
|
403
|
-
disposeModel(
|
|
404
|
-
|
|
408
|
+
disposeModel(i) {
|
|
409
|
+
i.traverse((e) => {
|
|
405
410
|
e instanceof a.Mesh && (e.geometry.dispose(), e.material.dispose());
|
|
406
411
|
});
|
|
407
412
|
}
|
|
408
413
|
/**
|
|
409
414
|
* 计算车辆位置
|
|
410
415
|
* */
|
|
411
|
-
computeVehiclePosition(
|
|
412
|
-
const e = this.historyPositionMap.get(
|
|
416
|
+
computeVehiclePosition(i) {
|
|
417
|
+
const e = this.historyPositionMap.get(i), t = this.vehicleObjectMap.get(i);
|
|
413
418
|
if (!t || !e || !t.isMoving && e.length <= 2)
|
|
414
419
|
return;
|
|
415
|
-
const
|
|
416
|
-
t.isMoving = !0, t.data.roadLayer === "1" ? t.model.visible = this.showGroundVehicle : t.model.visible = this.showElevatedVehicle, t.segmentStartTime || (t.segmentStartTime =
|
|
417
|
-
const o =
|
|
420
|
+
const s = Date.now();
|
|
421
|
+
t.isMoving = !0, t.data.roadLayer === "1" ? t.model.visible = this.showGroundVehicle : t.model.visible = this.showElevatedVehicle, t.segmentStartTime || (t.segmentStartTime = s, t.segmentTotalTime = e[1].time - e[0].time);
|
|
422
|
+
const o = s - t.segmentStartTime, n = Math.min(
|
|
418
423
|
o / t.segmentTotalTime,
|
|
419
424
|
1
|
|
420
425
|
);
|
|
421
426
|
if (n === 1)
|
|
422
427
|
if (e.shift(), e.length === 1) {
|
|
423
|
-
t.waitForDelete === !0 ? this.deleteVehicle(t) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0, t.model.visible = !1, t.isMoving = !1, console.log("hide vehicle",
|
|
428
|
+
t.waitForDelete === !0 ? this.deleteVehicle(t) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0, t.model.visible = !1, t.isMoving = !1, console.log("hide vehicle", i));
|
|
424
429
|
return;
|
|
425
430
|
} else {
|
|
426
431
|
t.segmentStartTime = Date.now();
|
|
@@ -436,7 +441,7 @@ class V {
|
|
|
436
441
|
/**
|
|
437
442
|
* 根据车辆类型、车身颜色获取模型
|
|
438
443
|
* */
|
|
439
|
-
getVehicleModel(
|
|
444
|
+
getVehicleModel(i) {
|
|
440
445
|
if (this.view.camera.position.z >= this.cameraHeightThreshold) {
|
|
441
446
|
const e = new a.SphereGeometry(5, 32, 32), t = new a.MeshPhysicalMaterial({
|
|
442
447
|
color: 325253,
|
|
@@ -447,10 +452,12 @@ class V {
|
|
|
447
452
|
return new a.Mesh(e, t);
|
|
448
453
|
} else {
|
|
449
454
|
let e;
|
|
450
|
-
if (
|
|
455
|
+
if (i.ptcType === 2)
|
|
451
456
|
e = this.bicycleModel.clone();
|
|
457
|
+
else if (i.ptcType === 3)
|
|
458
|
+
e = this.passengerModel.clone();
|
|
452
459
|
else {
|
|
453
|
-
switch (
|
|
460
|
+
switch (i.vehicleType) {
|
|
454
461
|
case 10:
|
|
455
462
|
e = this.carModel.clone();
|
|
456
463
|
break;
|
|
@@ -467,10 +474,10 @@ class V {
|
|
|
467
474
|
e = this.carModel.clone();
|
|
468
475
|
break;
|
|
469
476
|
}
|
|
470
|
-
const t = this.materialMap.get(
|
|
471
|
-
let
|
|
477
|
+
const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
|
|
478
|
+
let s = !1;
|
|
472
479
|
e.traverse((o) => {
|
|
473
|
-
!
|
|
480
|
+
!s && o instanceof a.Mesh && (o.material = t, s = !0);
|
|
474
481
|
});
|
|
475
482
|
}
|
|
476
483
|
return e;
|
|
@@ -479,30 +486,30 @@ class V {
|
|
|
479
486
|
/**
|
|
480
487
|
* 创建号牌canvas
|
|
481
488
|
* */
|
|
482
|
-
createCanvas(
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
const r =
|
|
489
|
+
createCanvas(i, e, t) {
|
|
490
|
+
const s = document.createElement("canvas"), o = i.width, n = i.height;
|
|
491
|
+
s.width = o, s.height = n;
|
|
492
|
+
const r = s.getContext("2d");
|
|
486
493
|
if (!r) {
|
|
487
494
|
console.log("canvas创建失败");
|
|
488
495
|
return;
|
|
489
496
|
}
|
|
490
|
-
return r.fillStyle = "rgba(0,0,0,0.0)", r.fillRect(0, 0, o, n), r.drawImage(
|
|
497
|
+
return r.fillStyle = "rgba(0,0,0,0.0)", r.fillRect(0, 0, o, n), r.drawImage(i, 0, 0, o, n), r.beginPath(), r.translate(o / 2, n / 2), r.fillStyle = t, r.font = "bold 32px 宋体", r.textBaseline = "middle", r.textAlign = "center", r.fillText(e, 0, 0), s;
|
|
491
498
|
}
|
|
492
|
-
createPlateSprite(
|
|
499
|
+
createPlateSprite(i) {
|
|
493
500
|
return new Promise((e, t) => {
|
|
494
501
|
var h, l;
|
|
495
|
-
const
|
|
496
|
-
if (this.currentSpriteContent === m.None || this.currentSpriteContent === m.PlateNumber &&
|
|
502
|
+
const s = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
|
|
503
|
+
if (this.currentSpriteContent === m.None || this.currentSpriteContent === m.PlateNumber && s) {
|
|
497
504
|
e(void 0);
|
|
498
505
|
return;
|
|
499
506
|
}
|
|
500
507
|
let o = new Image(), n = "", r = "";
|
|
501
508
|
if (this.currentSpriteContent === m.PlateNumber || this.currentSpriteContent === m.Mix)
|
|
502
|
-
if (
|
|
503
|
-
o = this.greyPlateBG, n =
|
|
509
|
+
if (s)
|
|
510
|
+
o = this.greyPlateBG, n = i.ptcId, r = "#ffffff";
|
|
504
511
|
else
|
|
505
|
-
switch (n = ((h =
|
|
512
|
+
switch (n = ((h = i.showName) == null ? void 0 : h.substring(0, 2)) + "•" + ((l = i.showName) == null ? void 0 : l.substring(2)), i.plateColor) {
|
|
506
513
|
case 1:
|
|
507
514
|
o = this.bluePlateBG, r = "#ffffff";
|
|
508
515
|
break;
|
|
@@ -522,18 +529,18 @@ class V {
|
|
|
522
529
|
o = this.neoGreenPlateBG, r = "#000000";
|
|
523
530
|
break;
|
|
524
531
|
default:
|
|
525
|
-
o = this.greyPlateBG, n =
|
|
532
|
+
o = this.greyPlateBG, n = i.plateNo, r = "#ffffff";
|
|
526
533
|
break;
|
|
527
534
|
}
|
|
528
535
|
else
|
|
529
|
-
this.currentSpriteContent === m.Id && (o = this.greyPlateBG, n =
|
|
536
|
+
this.currentSpriteContent === m.Id && (o = this.greyPlateBG, n = i.ptcId, r = "#ffffff");
|
|
530
537
|
const d = this.createCanvas(o, n, r);
|
|
531
538
|
if (d) {
|
|
532
539
|
const p = new a.CanvasTexture(d), c = new a.SpriteMaterial({
|
|
533
540
|
map: p,
|
|
534
541
|
transparent: !1
|
|
535
|
-
}), g = new a.Sprite(c), f = 0.05, w = d.width * f,
|
|
536
|
-
g.scale.set(w,
|
|
542
|
+
}), g = new a.Sprite(c), f = 0.05, w = d.width * f, M = d.height * f;
|
|
543
|
+
g.scale.set(w, M, 1), g.name = "VehiclePlate", e(g);
|
|
537
544
|
} else {
|
|
538
545
|
t("canvas创建失败");
|
|
539
546
|
return;
|
|
@@ -323,7 +323,7 @@ class O {
|
|
|
323
323
|
* @returns
|
|
324
324
|
*/
|
|
325
325
|
async showOpenDriveFromFile(e) {
|
|
326
|
-
var
|
|
326
|
+
var f, m;
|
|
327
327
|
this.openDriveClickCallback = e.selectedCallback, this.scaleWatch = $.watch(
|
|
328
328
|
() => this.view.scale,
|
|
329
329
|
(h, p) => {
|
|
@@ -381,7 +381,7 @@ class O {
|
|
|
381
381
|
const a = await (await fetch(c)).arrayBuffer(), n = G.inflate(a, { to: "string" }), l = JSON.parse(n);
|
|
382
382
|
await this.showAllLanes(
|
|
383
383
|
l,
|
|
384
|
-
((
|
|
384
|
+
((f = e.options) == null ? void 0 : f.showJunctionLane) || !1,
|
|
385
385
|
((m = e.options) == null ? void 0 : m.showRoadName) || !0
|
|
386
386
|
);
|
|
387
387
|
const d = o.data.result.junctions;
|
|
@@ -438,7 +438,7 @@ class O {
|
|
|
438
438
|
const { id: l, refLine: d } = n;
|
|
439
439
|
let u = n.name;
|
|
440
440
|
u.includes("(") && (u = u.slice(0, u.indexOf("("))), u = u.replace(/(.)/g, "$1 ");
|
|
441
|
-
const
|
|
441
|
+
const f = new g({
|
|
442
442
|
geometry: {
|
|
443
443
|
type: "polyline",
|
|
444
444
|
paths: [d]
|
|
@@ -449,21 +449,21 @@ class O {
|
|
|
449
449
|
roadName: u
|
|
450
450
|
}
|
|
451
451
|
});
|
|
452
|
-
this.allRefLineGraphics.push(
|
|
452
|
+
this.allRefLineGraphics.push(f), n.laneSections.sort((m, h) => Number(m.id) - Number(h.id));
|
|
453
453
|
for (let m = 0; m < n.laneSections.length; m++) {
|
|
454
454
|
const h = n.laneSections[m], p = Number(h.id);
|
|
455
|
-
for (const
|
|
456
|
-
const v = Number(
|
|
455
|
+
for (const y of h.lanePaths) {
|
|
456
|
+
const v = Number(y.id);
|
|
457
457
|
if (v === 0)
|
|
458
458
|
continue;
|
|
459
|
-
const I =
|
|
459
|
+
const I = y.type, M = [...y.outerPath], A = y.innerPath.concat(
|
|
460
460
|
M.reverse()
|
|
461
461
|
);
|
|
462
462
|
if (A.length <= 3) {
|
|
463
463
|
console.warn(`lane ${v} has less than 3 points`);
|
|
464
464
|
continue;
|
|
465
465
|
}
|
|
466
|
-
A.push(
|
|
466
|
+
A.push(y.innerPath[0]);
|
|
467
467
|
const N = new L({
|
|
468
468
|
rings: [A]
|
|
469
469
|
});
|
|
@@ -483,8 +483,8 @@ class O {
|
|
|
483
483
|
type: I,
|
|
484
484
|
sumoId: "",
|
|
485
485
|
// 记录左右边线的起始点,用于按长度高亮车道的一部分
|
|
486
|
-
leftLine:
|
|
487
|
-
rightLine:
|
|
486
|
+
leftLine: y.innerPath,
|
|
487
|
+
rightLine: y.outerPath
|
|
488
488
|
}
|
|
489
489
|
});
|
|
490
490
|
this.allLaneGraphics.push(j), r.push(j);
|
|
@@ -573,7 +573,7 @@ class O {
|
|
|
573
573
|
(p) => `${p.attributes.roadId}+${p.attributes.sectionId}` === r
|
|
574
574
|
), l = S.union(
|
|
575
575
|
n.map((p) => p.geometry)
|
|
576
|
-
), d = this.hitGraphic.getAttribute("fromNode"), u = this.hitGraphic.getAttribute("toNode"),
|
|
576
|
+
), d = this.hitGraphic.getAttribute("fromNode"), u = this.hitGraphic.getAttribute("toNode"), f = this.junctionNames.get(d) || d, m = this.junctionNames.get(u) || u, h = new g({
|
|
577
577
|
geometry: l,
|
|
578
578
|
symbol: {
|
|
579
579
|
type: "simple-fill",
|
|
@@ -588,7 +588,7 @@ class O {
|
|
|
588
588
|
type: "OpenDriveSection",
|
|
589
589
|
id: r,
|
|
590
590
|
selected: !1,
|
|
591
|
-
fromNodeName:
|
|
591
|
+
fromNodeName: f,
|
|
592
592
|
toNodeName: m,
|
|
593
593
|
laneCount: n.length
|
|
594
594
|
},
|
|
@@ -985,13 +985,13 @@ class O {
|
|
|
985
985
|
type: "edge",
|
|
986
986
|
id: d
|
|
987
987
|
});
|
|
988
|
-
const u = `http://${this.openDriveServer}/api/sumo/getSumoEdge`,
|
|
988
|
+
const u = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, f = await b.get(u, {
|
|
989
989
|
params: {
|
|
990
990
|
id: `${n}+${a.getAttribute("sectionId")}`,
|
|
991
991
|
projectName: this.projectName
|
|
992
992
|
}
|
|
993
993
|
});
|
|
994
|
-
|
|
994
|
+
f.status === 200 && f.data.status === 0 && i.push(f.data.result);
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
const c = this.junctionLayer.graphics.filter((a) => {
|
|
@@ -1036,17 +1036,17 @@ class O {
|
|
|
1036
1036
|
);
|
|
1037
1037
|
if (!l)
|
|
1038
1038
|
return { status: -1, message: "未找到车道" };
|
|
1039
|
-
const d = e.start || 0, u = e.end || 100,
|
|
1039
|
+
const d = e.start || 0, u = e.end || 100, f = D.lineString(l.getAttribute("leftLine")), m = x(f, d, u, {
|
|
1040
1040
|
units: "meters"
|
|
1041
1041
|
}), h = D.lineString(l.getAttribute("rightLine")), p = x(h, d, u, {
|
|
1042
1042
|
units: "meters"
|
|
1043
|
-
}),
|
|
1043
|
+
}), y = m.geometry.coordinates.concat(
|
|
1044
1044
|
p.geometry.coordinates.reverse()
|
|
1045
1045
|
);
|
|
1046
|
-
|
|
1046
|
+
y.push(y[y.length - 1]);
|
|
1047
1047
|
const v = new g({
|
|
1048
1048
|
geometry: new L({
|
|
1049
|
-
rings: [
|
|
1049
|
+
rings: [y]
|
|
1050
1050
|
}),
|
|
1051
1051
|
attributes: {
|
|
1052
1052
|
ObjectID: l.getAttribute("ObjectID"),
|
|
@@ -1071,7 +1071,7 @@ class O {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
1073
|
});
|
|
1074
|
-
return this.splitLaneLayer.add(v), this.view.goTo(v), { status: 0, message: "ok", result:
|
|
1074
|
+
return this.splitLaneLayer.add(v), this.view.goTo(v), { status: 0, message: "ok", result: { coordinates: y } };
|
|
1075
1075
|
}
|
|
1076
1076
|
clearSplitLane() {
|
|
1077
1077
|
this.splitLaneLayer.removeAll();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import SignalHoloFlow from './signal-holo-flow';
|
|
2
1
|
import { ISignalCountdownProps } from '../../../types';
|
|
2
|
+
import SignalHoloFlow from './signal-holo-flow';
|
|
3
3
|
export default class LSRSignalHoloFlow extends SignalHoloFlow {
|
|
4
4
|
private stopLineLayer;
|
|
5
5
|
private watchHandle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/core/reactiveUtils"),d=require("@arcgis/core/geometry"),g=require("@arcgis/core/geometry/support/webMercatorUtils.js"),m=require("@arcgis/core/layers/GraphicsLayer"),y=require("./signal-holo-flow.js");function w(f){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const i in f)if(i!=="default"){const l=Object.getOwnPropertyDescriptor(f,i);Object.defineProperty(o,i,l.get?l:{enumerable:!0,get:()=>f[i]})}}return o.default=f,Object.freeze(o)}const L=w(P),u=w(g);class M extends y.default{constructor(o,i){super(o),this.stopLineLayer=new m,this.watchHandle=null,this.stopLineMap=new Map,this.countdownPanelProps=i,this.view.map.add(this.stopLineLayer)}async initializeLayer(){var p,c;console.time("初始化停止线图层");let o=(c=(p=this.mapConfig.holoFlow)==null?void 0:p.signal)==null?void 0:c.stopLineLayer;if(!o)return;o=this.mapConfig.assetsRoot+"/"+o,(await(await fetch(o)).json()).features.forEach(t=>{const{roadId:n,nodeId:e,angle:a,destinationPoint:s}=t.properties,{coordinates:r}=t.geometry,h=this.stopLineMap.get(e);h?h.set(n,{coord:r,panelPoint:s,angle:a}):this.stopLineMap.set(e,new Map([[n,{coord:r,panelPoint:s,angle:a}]]))}),console.timeEnd("初始化停止线图层")}getPanelScale(){const o=this.view.scale;let i=1;return o<1e3?i=1:o<2e3?i=.8:i=.4,i}async handleSignalData(o){this.watchHandle||(this.watchHandle=L.watch(()=>this.view.extent,()=>{console.log("extent changed");const t=this.getPanelScale();for(const n of this.countdownPanelProps){t!==this.currentPanelScale&&(n.scale=t);const{mapPoint:e}=n;let a=new d.Point({x:e[0],y:e[1]});this.view.spatialReference.isWebMercator&&(a=u.geographicToWebMercator(a));const s=this.view.toScreen(a);if(n.position.left=s.x,n.position.top=s.y,this.view.type==="3d"){const r=this.getPanelRotation(n.stopLine);n.rotation=r}}this.currentPanelScale=t}));const i=o.crossId,l=this.stopLineMap.get(i);if(!l)return;const p=o.phaseCountDownList,c=new Map;for(const t of p){let n="";for(let r of t.roadIdList)if(r.startsWith("-")&&(r=r.slice(1)),l.has(r)){n=r;break}if(!n)continue;let e=c.get(n);if(e||(e={},c.set(n,e)),!t.direction){console.log(`没有找到对应的方向${i}--${JSON.stringify(t)}`);continue}const a=t.direction.toLowerCase(),s=t.color===1?"red":t.color===2?"yellow":"green";a==="u"?(e.uNumber=t.leftTime,e.uColor=s):a==="l"?(e.lNumber=t.leftTime,e.lColor=s):a==="s"?(e.sNumber=t.leftTime,e.sColor=s):a==="r"&&(e.rNumber=t.leftTime,e.rColor=s)}c.forEach((t,n)=>{const e=l.get(n);if(!e)return;const a=this.countdownPanelProps.find(s=>s.crossId===i&&s.roadId===n);if(a)a.lampStatus=t;else{let s=new d.Point({x:e.panelPoint[0],y:e.panelPoint[1]});this.view.spatialReference.isWebMercator&&(s=u.geographicToWebMercator(s));const r=this.view.toScreen(s),h=this.getPanelRotation(e.coord);console.log(s.toJSON(),r),this.countdownPanelProps.push({displayMode:"complex",crossId:i,roadId:n,mapPoint:e.panelPoint,stopLine:e.coord,position:{left:r.x,top:r.y},rotation:h,scale:this.getPanelScale(),lampStatus:t})}})}clearSignal(){var o;this.stopLineLayer.removeAll(),this.countdownPanelProps.length=0,(o=this.watchHandle)==null||o.remove(),this.watchHandle=null}getPanelRotation(o){const i=o[0];let l=new d.Point({x:i[0],y:i[1]});this.view.spatialReference.isWebMercator&&(l=u.geographicToWebMercator(l));const p=this.view.toScreen(l),c=o[o.length-1];let t=new d.Point({x:c[0],y:c[1]});this.view.spatialReference.isWebMercator&&(t=u.geographicToWebMercator(t));const n=this.view.toScreen(t),e=n.x-p.x,a=n.y-p.y;return Math.atan2(a,e)*(180/Math.PI)}}exports.default=M;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("@arcgis/core/core/promiseUtils.js"),y=require("@arcgis/core/core/reactiveUtils.js"),T=require("@arcgis/core/geometry/SpatialReference"),S=require("@arcgis/core/views/3d/externalRenderers"),C=require("three"),G=require("three/examples/jsm/loaders/GLTFLoader"),B=require("vue"),m=require("../../../types/index.js"),x=require("../../stores/index.js");function f(u){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>u[e]})}}return s.default=u,Object.freeze(s)}const R=f(v),V=f(y),b=f(S),o=f(C);class I{constructor(s){this.cameraHeightThreshold=1e3,this.roughness=.2,this.metalness=.8,this.defaultMaterial=new o.MeshPhongMaterial({color:16777215}),this.materialMap=new Map([[1,this.createCarMaterial(16777215)],[2,this.createCarMaterial(7833753)],[3,this.createCarMaterial(16766720)],[4,this.createCarMaterial(16758465)],[5,this.createCarMaterial(14423100)],[6,this.createCarMaterial(3329330)],[7,this.createCarMaterial(2003183)],[8,this.createCarMaterial(16032864)],[9,this.createCarMaterial(2105376)],[10,this.createCarMaterial(9662683)],[99,this.createCarMaterial(6908265)]]),this.isInitialized=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.isPaused=!1,this.currentSpriteContent=m.EVehiclePlateState.None,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.needInterpolate=!0,this.updateModel=!1,this.appDataStore=x.default.useAppDataStore,this.logTable=[["ptcId","plateno","timestamp","localTimestamp","speed","longitude","latitude","ptcType","vehicleType","vehicleColor","plateColor","heading","fixAngle","roadLayer","step","receiveTimestamp","queueLength","status"]],this.view=s;const e=B.toRaw(this.appDataStore.mapConfig);this.assetsRoot=e.assetsRoot,V.watch(()=>this.view.camera.position.z,(t,i)=>{(i<=this.cameraHeightThreshold&&t>this.cameraHeightThreshold||i>this.cameraHeightThreshold&&t<=this.cameraHeightThreshold)&&(this.updateModel=!0)})}createCarMaterial(s){return new o.MeshPhongMaterial({color:s})}getLog(){return this.logTable}async init(){const s=new G.GLTFLoader;await R.eachAlways([new Promise(e=>{s.load(`${this.assetsRoot}/3DModels/car.glb`,t=>{const i=t.scene,n=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.carModel=new o.Object3D,this.carModel.rotation.x=o.MathUtils.degToRad(90),this.carModel.add(i),i.position.set(0,0,n.z/2),e()})}),new Promise(e=>{s.load(`${this.assetsRoot}/3DModels/van.glb`,t=>{const i=t.scene,n=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.vanModel=new o.Object3D,this.vanModel.rotation.x=o.MathUtils.degToRad(90),this.vanModel.add(i),i.position.set(0,0,n.z/2),e()})}),new Promise(e=>{s.load(`${this.assetsRoot}/3DModels/truck.glb`,t=>{const i=t.scene;i.scale.set(1.2,1,1.5);const n=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.truckModel=new o.Object3D,this.truckModel.rotation.x=o.MathUtils.degToRad(90),this.truckModel.add(i),i.position.set(0,0,n.z/2),e()})}),new Promise(e=>{s.load(`${this.assetsRoot}/3DModels/bus.glb`,t=>{const i=t.scene,n=new o.Box3().setFromObject(i).getSize(new o.Vector3);this.busModel=new o.Object3D,this.busModel.rotation.x=o.MathUtils.degToRad(90),this.busModel.add(i),i.position.set(0,0,n.z/2),e()})}),new Promise(e=>{s.load(`${this.assetsRoot}/3DModels/bicycle.glb`,t=>{this.bicycleModel=t.scene,this.bicycleModel.rotation.x=o.MathUtils.degToRad(90),this.bicycleModel.rotation.y=o.MathUtils.degToRad(180),e()})}),new Promise(e=>{this.bluePlateBG=new Image,this.bluePlateBG.src=`${this.assetsRoot}/Images/PlateBG/blue.png`,this.bluePlateBG.onload=()=>{e()}}),new Promise(e=>{this.yellowPlateBG=new Image,this.yellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/yellow.png`,this.yellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.whitePlateBG=new Image,this.whitePlateBG.src=`${this.assetsRoot}/Images/PlateBG/white.png`,this.whitePlateBG.onload=()=>{e()}}),new Promise(e=>{this.blackPlateBG=new Image,this.blackPlateBG.src=`${this.assetsRoot}/Images/PlateBG/black.png`,this.blackPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoYellowPlateBG=new Image,this.neoYellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_yellow.png`,this.neoYellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoGreenPlateBG=new Image,this.neoGreenPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_green.png`,this.neoGreenPlateBG.onload=()=>{e()}}),new Promise(e=>{this.greyPlateBG=new Image,this.greyPlateBG.src=`${this.assetsRoot}/Images/PlateBG/grey.png`,this.greyPlateBG.onload=()=>{e()}})]),this.isInitialized=!0}setInterpolate(s){this.clearVehicles(),this.needInterpolate=s}async setup(s){this.context=s,this.renderer=new o.WebGLRenderer({context:s.gl,premultipliedAlpha:!0,logarithmicDepthBuffer:!0,antialias:!0,powerPreference:"high-performance"}),this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setViewport(0,0,this.view.width,this.view.height),this.renderer.autoClearDepth=!1,this.renderer.autoClearStencil=!1,this.renderer.autoClearColor=!1;const e=this.renderer.setRenderTarget.bind(this.renderer);this.renderer.setRenderTarget=i=>{e(i),i==null&&s.bindRenderTarget()},this.scene=new o.Scene;const{camera:t}=s;this.camera=new o.PerspectiveCamera(t.fovY,t.aspect,.1,1e5),this.ambient=new o.AmbientLight(16777215,2),this.scene.add(this.ambient),this.sun=new o.DirectionalLight(16777215,2),this.scene.add(this.sun),s.resetWebGLState()}async render(s){var i;const e=s.camera;if(this.camera.position.set(e.eye[0],e.eye[1],e.eye[2]),this.camera.up.set(e.up[0],e.up[1],e.up[2]),this.camera.lookAt(new o.Vector3(e.center[0],e.center[1],e.center[2])),this.camera.projectionMatrix.fromArray(e.projectionMatrix),!this.isPaused&&this.needInterpolate)for(const a of this.vehicleObjectMap.keys()){const n=(i=this.vehicleObjectMap.get(a))==null?void 0:i.model;if(!n)continue;const r=this.computeVehiclePosition(a);if(r){const d=this.toRenderCoordinates(r);n.position.set(d[0],d[1],d[2]),n.rotation.y=o.MathUtils.degToRad(-r[3])}}const t=s.sunLight;this.sun.position.set(t.direction[0],t.direction[1],t.direction[2]),this.sun.intensity=t.diffuse.intensity,this.sun.color=new o.Color(t.diffuse.color[0],t.diffuse.color[1],t.diffuse.color[2]),this.ambient.intensity=t.ambient.intensity,this.ambient.color=new o.Color(t.ambient.color[0],t.ambient.color[1],t.ambient.color[2]),this.renderer.resetState(),s.bindRenderTarget(),this.renderer.render(this.scene,this.camera),b.requestRender(this.view),s.resetWebGLState()}async addVehicles(s){if(this.isPaused||!this.isInitialized)return;const e=Date.now();for(const t of s){this.appDataStore.saveTrackLog&&this.logTable.push([t.ptcId,t.plateNo,t.timestamp,t.localTimestamp,t.speed,t.x,t.y,t.ptcType,t.vehicleType,t.vehicleColor,t.plateColor,t.heading,t.fixAngle,t.roadLayer,t.step,e,0,0]);const{vehicleId:i,localTimestamp:a}=t,n=Number(t.x),r=Number(t.y),d=Number(t.heading);this.historyPositionMap.set(i,[{pos:[n,r,0],heading:d,time:a}]);const h=this.getVehicleModel(t);h.name=i,h.visible=!1;try{const l=await this.createPlateSprite(t);l&&(h.add(l),l.position.set(0,5,-4))}catch(l){console.log("createPlateSprite error:",l)}this.scene.add(h),this.vehicleObjectMap.set(i,{model:h,data:t,waitForDelete:!1,isMoving:!1})}}async updateVehicles(s){if(this.isPaused||!this.isInitialized)return;const e=[],t=Date.now();for(const i of s){const{vehicleId:a,localTimestamp:n}=i,r=Number(i.x),d=Number(i.y);let h=Number(i.heading);const l=this.vehicleObjectMap.get(a),p=this.historyPositionMap.get(a);if(!l||!p)e.push(i);else{if(this.appDataStore.saveTrackLog&&this.logTable.push([i.ptcId,i.plateNo,i.timestamp,i.localTimestamp,i.speed,i.x,i.y,i.ptcType,i.vehicleType,i.vehicleColor,i.plateColor,i.heading,i.fixAngle,i.roadLayer,i.step,t,p.length,1]),this.updateModel||l.data.vehicleColor!==i.vehicleColor||l.data.vehicleType!==i.vehicleType){this.scene.remove(l.model),this.disposeModel(l.model),l.model=this.getVehicleModel(i),l.model.visible=!0;const c=await this.createPlateSprite(i);c&&(l.model.add(c),c.position.set(0,5,-4)),this.scene.add(l.model)}if(l.data.showName!==i.showName||l.data.plateColor!==i.plateColor){const c=l.model.getObjectByName("VehiclePlate");c&&(l.model.remove(c),this.disposeModel(c));const g=await this.createPlateSprite(i);g&&(l.model.add(g),g.position.set(0,5,-4))}if(l.data=i,this.needInterpolate){const c=p[p.length-1];Math.abs(h-c.heading)>=180&&(h>c.heading?c.heading+=360:h+=360),p.push({pos:[r,d,0],heading:h,time:n})}else{this.historyPositionMap.set(a,[{pos:[r,d,0],heading:h,time:n}]);const c=this.toRenderCoordinates([r,d,0]);l.model.position.set(c[0],c[1],c[2]),l.model.rotation.y=o.MathUtils.degToRad(-h)}}}await this.addVehicles(e),this.updateModel=!1,this.needInterpolate||this.render(this.context)}toRenderCoordinates(s){const e=[0,0,0];return b.toRenderCoordinates(this.view,s,0,T.WGS84,e,0,1),e}deleteVehicles(s){if(this.isPaused)return;const e=Date.now();s.forEach(t=>{if(this.appDataStore.saveTrackLog){const a=this.historyPositionMap.get(t);this.logTable.push([t,"","","","","","","","","","","","","","",e,a?a.length:0,2])}const i=this.vehicleObjectMap.get(t);i&&(this.needInterpolate?i.isMoving?i.waitForDelete=!0:this.deleteVehicle(i):this.deleteVehicle(i))})}deleteVehicle(s){this.scene.remove(s.model),this.disposeModel(s.model);const e=s.data.vehicleId;this.vehicleObjectMap.delete(e),this.historyPositionMap.delete(e)}async toggleTrafficInfo(s){s.name==="vehiclePlate"&&(s.visible===!0&&this.currentSpriteContent===m.EVehiclePlateState.None?await this.updatePanelContent(m.EVehiclePlateState.PlateNumber):await this.updatePanelContent(s.visible?this.currentSpriteContent:m.EVehiclePlateState.None))}togglePause(s){this.isPaused=s}clearVehicles(){for(const s of this.vehicleObjectMap.keys()){const e=this.vehicleObjectMap.get(s);e&&(this.scene.remove(e.model),this.disposeModel(e.model))}this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}async updatePanelContent(s){if(s!==this.currentSpriteContent){this.currentSpriteContent=s;for(const e of this.vehicleObjectMap.keys()){const t=this.vehicleObjectMap.get(e);if(t){const i=t.model.getObjectByName("VehiclePlate");if(i&&(t.model.remove(i),this.disposeModel(i)),s!==m.EVehiclePlateState.None){const a=await this.createPlateSprite(t.data);a&&(t.model.add(a),a.position.set(0,5,-4))}}}}}toggleGroundVehicle(s){console.log("toggleGroundVehicle",s),this.showGroundVehicle=s}toggleElevatedVehicle(s){this.showElevatedVehicle=s}disposeModel(s){s.traverse(e=>{e instanceof o.Mesh&&(e.geometry.dispose(),e.material.dispose())})}computeVehiclePosition(s){const e=this.historyPositionMap.get(s),t=this.vehicleObjectMap.get(s);if(!t||!e||!t.isMoving&&e.length<=2)return;const i=Date.now();t.isMoving=!0,t.data.roadLayer==="1"?t.model.visible=this.showGroundVehicle:t.model.visible=this.showElevatedVehicle,t.segmentStartTime||(t.segmentStartTime=i,t.segmentTotalTime=e[1].time-e[0].time);const a=i-t.segmentStartTime,n=Math.min(a/t.segmentTotalTime,1);if(n===1)if(e.shift(),e.length===1){t.waitForDelete===!0?this.deleteVehicle(t):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0,t.model.visible=!1,t.isMoving=!1,console.log("hide vehicle",s));return}else{t.segmentStartTime=Date.now();const r=a-t.segmentTotalTime;return t.segmentTotalTime=e[1].time-e[0].time-r,(e[1].heading>=270&&e[0].heading<=90||e[1].heading<=90&&e[0].heading>=270)&&(e[1].heading>e[0].heading?e[0].heading+=360:e[1].heading+=360),e[0].pos.concat(e[0].heading)}else if(e.length>=2){const r=e[0].pos[0]+(e[1].pos[0]-e[0].pos[0])*n,d=e[0].pos[1]+(e[1].pos[1]-e[0].pos[1])*n,h=e[0].heading+(e[1].heading-e[0].heading)*n;return[r,d,0,h]}else return}getVehicleModel(s){if(this.view.camera.position.z>=this.cameraHeightThreshold){const e=new o.SphereGeometry(5,32,32),t=new o.MeshPhysicalMaterial({color:325253,emissive:0,roughness:this.roughness,metalness:this.metalness});return new o.Mesh(e,t)}else{let e;if(s.ptcType===2)e=this.bicycleModel.clone();else{switch(s.vehicleType){case 10:e=this.carModel.clone();break;case 20:e=this.vanModel.clone();break;case 25:e=this.truckModel.clone();break;case 50:e=this.busModel.clone();break;default:e=this.carModel.clone();break}const t=this.materialMap.get(s.vehicleColor)||this.defaultMaterial;let i=!1;e.traverse(a=>{!i&&a instanceof o.Mesh&&(a.material=t,i=!0)})}return e}}createCanvas(s,e,t){const i=document.createElement("canvas"),a=s.width,n=s.height;i.width=a,i.height=n;const r=i.getContext("2d");if(!r){console.log("canvas创建失败");return}return r.fillStyle="rgba(0,0,0,0.0)",r.fillRect(0,0,a,n),r.drawImage(s,0,0,a,n),r.beginPath(),r.translate(a/2,n/2),r.fillStyle=t,r.font="bold 32px 宋体",r.textBaseline="middle",r.textAlign="center",r.fillText(e,0,0),i}createPlateSprite(s){return new Promise((e,t)=>{var h,l;const i=!s.plateNo||s.plateNo==="0"||s.plateNo==="000000";if(this.currentSpriteContent===m.EVehiclePlateState.None||this.currentSpriteContent===m.EVehiclePlateState.PlateNumber&&i){e(void 0);return}let a=new Image,n="",r="";if(this.currentSpriteContent===m.EVehiclePlateState.PlateNumber||this.currentSpriteContent===m.EVehiclePlateState.Mix)if(i)a=this.greyPlateBG,n=s.ptcId,r="#ffffff";else switch(n=((h=s.showName)==null?void 0:h.substring(0,2))+"•"+((l=s.showName)==null?void 0:l.substring(2)),s.plateColor){case 1:a=this.bluePlateBG,r="#ffffff";break;case 2:a=this.yellowPlateBG,r="#000000";break;case 3:a=this.whitePlateBG,r="#000000";break;case 4:a=this.blackPlateBG,r="#ffffff";break;case 5:a=this.neoYellowPlateBG,r="#000000";break;case 6:a=this.neoGreenPlateBG,r="#000000";break;default:a=this.greyPlateBG,n=s.plateNo,r="#ffffff";break}else this.currentSpriteContent===m.EVehiclePlateState.Id&&(a=this.greyPlateBG,n=s.ptcId,r="#ffffff");const d=this.createCanvas(a,n,r);if(d){const p=new o.CanvasTexture(d),c=new o.SpriteMaterial({map:p,transparent:!1}),g=new o.Sprite(c),w=.05,M=d.width*w,P=d.height*w;g.scale.set(M,P,1),g.name="VehiclePlate",e(g)}else{t("canvas创建失败");return}a.onerror=p=>{console.log(`号牌背景加载失败: ${a.src}`,p),t(p)}})}}exports.default=I;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("@arcgis/core/core/promiseUtils.js"),y=require("@arcgis/core/core/reactiveUtils.js"),T=require("@arcgis/core/geometry/SpatialReference"),S=require("@arcgis/core/views/3d/externalRenderers"),C=require("three"),G=require("three/examples/jsm/loaders/GLTFLoader"),x=require("vue"),g=require("../../../types/index.js"),B=require("../../stores/index.js");function f(u){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(i,e,t.get?t:{enumerable:!0,get:()=>u[e]})}}return i.default=u,Object.freeze(i)}const R=f(v),V=f(y),w=f(S),o=f(C);class I{constructor(i){this.cameraHeightThreshold=1e3,this.roughness=.2,this.metalness=.8,this.defaultMaterial=new o.MeshPhongMaterial({color:16777215}),this.materialMap=new Map([[1,this.createCarMaterial(16777215)],[2,this.createCarMaterial(7833753)],[3,this.createCarMaterial(16766720)],[4,this.createCarMaterial(16758465)],[5,this.createCarMaterial(14423100)],[6,this.createCarMaterial(3329330)],[7,this.createCarMaterial(2003183)],[8,this.createCarMaterial(16032864)],[9,this.createCarMaterial(2105376)],[10,this.createCarMaterial(9662683)],[99,this.createCarMaterial(6908265)]]),this.isInitialized=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.isPaused=!1,this.currentSpriteContent=g.EVehiclePlateState.None,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.needInterpolate=!0,this.updateModel=!1,this.appDataStore=B.default.useAppDataStore,this.logTable=[["ptcId","plateno","timestamp","localTimestamp","speed","longitude","latitude","ptcType","vehicleType","vehicleColor","plateColor","heading","fixAngle","roadLayer","step","receiveTimestamp","queueLength","status"]],this.view=i;const e=x.toRaw(this.appDataStore.mapConfig);this.assetsRoot=e.assetsRoot,V.watch(()=>this.view.camera.position.z,(t,s)=>{(s<=this.cameraHeightThreshold&&t>this.cameraHeightThreshold||s>this.cameraHeightThreshold&&t<=this.cameraHeightThreshold)&&(this.updateModel=!0)})}createCarMaterial(i){return new o.MeshPhongMaterial({color:i})}getLog(){return this.logTable}async init(){const i=new G.GLTFLoader;await R.eachAlways([new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/car.glb`,t=>{const s=t.scene,n=new o.Box3().setFromObject(s).getSize(new o.Vector3);this.carModel=new o.Object3D,this.carModel.rotation.x=o.MathUtils.degToRad(90),this.carModel.add(s),s.position.set(0,0,n.z/2),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/van.glb`,t=>{const s=t.scene,n=new o.Box3().setFromObject(s).getSize(new o.Vector3);this.vanModel=new o.Object3D,this.vanModel.rotation.x=o.MathUtils.degToRad(90),this.vanModel.add(s),s.position.set(0,0,n.z/2),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/truck.glb`,t=>{const s=t.scene;s.scale.set(1.2,1,1.5);const n=new o.Box3().setFromObject(s).getSize(new o.Vector3);this.truckModel=new o.Object3D,this.truckModel.rotation.x=o.MathUtils.degToRad(90),this.truckModel.add(s),s.position.set(0,0,n.z/2),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/bus.glb`,t=>{const s=t.scene,n=new o.Box3().setFromObject(s).getSize(new o.Vector3);this.busModel=new o.Object3D,this.busModel.rotation.x=o.MathUtils.degToRad(90),this.busModel.add(s),s.position.set(0,0,n.z/2),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/bicycle.glb`,t=>{this.bicycleModel=t.scene,this.bicycleModel.rotation.x=o.MathUtils.degToRad(90),this.bicycleModel.rotation.y=o.MathUtils.degToRad(180),e()})}),new Promise(e=>{i.load(`${this.assetsRoot}/3DModels/bicycle.glb`,t=>{this.passengerModel=t.scene,this.passengerModel.rotation.x=o.MathUtils.degToRad(90),this.passengerModel.rotation.y=o.MathUtils.degToRad(180),e()})}),new Promise(e=>{this.bluePlateBG=new Image,this.bluePlateBG.src=`${this.assetsRoot}/Images/PlateBG/blue.png`,this.bluePlateBG.onload=()=>{e()}}),new Promise(e=>{this.yellowPlateBG=new Image,this.yellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/yellow.png`,this.yellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.whitePlateBG=new Image,this.whitePlateBG.src=`${this.assetsRoot}/Images/PlateBG/white.png`,this.whitePlateBG.onload=()=>{e()}}),new Promise(e=>{this.blackPlateBG=new Image,this.blackPlateBG.src=`${this.assetsRoot}/Images/PlateBG/black.png`,this.blackPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoYellowPlateBG=new Image,this.neoYellowPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_yellow.png`,this.neoYellowPlateBG.onload=()=>{e()}}),new Promise(e=>{this.neoGreenPlateBG=new Image,this.neoGreenPlateBG.src=`${this.assetsRoot}/Images/PlateBG/neo_green.png`,this.neoGreenPlateBG.onload=()=>{e()}}),new Promise(e=>{this.greyPlateBG=new Image,this.greyPlateBG.src=`${this.assetsRoot}/Images/PlateBG/grey.png`,this.greyPlateBG.onload=()=>{e()}})]),this.isInitialized=!0}setInterpolate(i){this.clearVehicles(),this.needInterpolate=i}async setup(i){this.context=i,this.renderer=new o.WebGLRenderer({context:i.gl,premultipliedAlpha:!0,logarithmicDepthBuffer:!0,antialias:!0,powerPreference:"high-performance"}),this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setViewport(0,0,this.view.width,this.view.height),this.renderer.autoClearDepth=!1,this.renderer.autoClearStencil=!1,this.renderer.autoClearColor=!1;const e=this.renderer.setRenderTarget.bind(this.renderer);this.renderer.setRenderTarget=s=>{e(s),s==null&&i.bindRenderTarget()},this.scene=new o.Scene;const{camera:t}=i;this.camera=new o.PerspectiveCamera(t.fovY,t.aspect,.1,1e5),this.ambient=new o.AmbientLight(16777215,2),this.scene.add(this.ambient),this.sun=new o.DirectionalLight(16777215,2),this.scene.add(this.sun),i.resetWebGLState()}async render(i){var s;const e=i.camera;if(this.camera.position.set(e.eye[0],e.eye[1],e.eye[2]),this.camera.up.set(e.up[0],e.up[1],e.up[2]),this.camera.lookAt(new o.Vector3(e.center[0],e.center[1],e.center[2])),this.camera.projectionMatrix.fromArray(e.projectionMatrix),!this.isPaused&&this.needInterpolate)for(const a of this.vehicleObjectMap.keys()){const n=(s=this.vehicleObjectMap.get(a))==null?void 0:s.model;if(!n)continue;const r=this.computeVehiclePosition(a);if(r){const d=this.toRenderCoordinates(r);n.position.set(d[0],d[1],d[2]),n.rotation.y=o.MathUtils.degToRad(-r[3])}}const t=i.sunLight;this.sun.position.set(t.direction[0],t.direction[1],t.direction[2]),this.sun.intensity=t.diffuse.intensity,this.sun.color=new o.Color(t.diffuse.color[0],t.diffuse.color[1],t.diffuse.color[2]),this.ambient.intensity=t.ambient.intensity,this.ambient.color=new o.Color(t.ambient.color[0],t.ambient.color[1],t.ambient.color[2]),this.renderer.resetState(),i.bindRenderTarget(),this.renderer.render(this.scene,this.camera),w.requestRender(this.view),i.resetWebGLState()}async addVehicles(i){if(this.isPaused||!this.isInitialized)return;const e=Date.now();for(const t of i){this.appDataStore.saveTrackLog&&this.logTable.push([t.ptcId,t.plateNo,t.timestamp,t.localTimestamp,t.speed,t.x,t.y,t.ptcType,t.vehicleType,t.vehicleColor,t.plateColor,t.heading,t.fixAngle,t.roadLayer,t.step,e,0,0]);const{vehicleId:s,localTimestamp:a}=t,n=Number(t.x),r=Number(t.y),d=Number(t.heading);this.historyPositionMap.set(s,[{pos:[n,r,0],heading:d,time:a}]);const h=this.getVehicleModel(t);h.name=s,h.visible=!1;try{const l=await this.createPlateSprite(t);l&&(h.add(l),l.position.set(0,5,-4))}catch(l){console.log("createPlateSprite error:",l)}this.scene.add(h),this.vehicleObjectMap.set(s,{model:h,data:t,waitForDelete:!1,isMoving:!1})}}async updateVehicles(i){if(this.isPaused||!this.isInitialized)return;const e=[],t=Date.now();for(const s of i){const{vehicleId:a,localTimestamp:n}=s,r=Number(s.x),d=Number(s.y);let h=Number(s.heading);const l=this.vehicleObjectMap.get(a),p=this.historyPositionMap.get(a);if(!l||!p)e.push(s);else{if(this.appDataStore.saveTrackLog&&this.logTable.push([s.ptcId,s.plateNo,s.timestamp,s.localTimestamp,s.speed,s.x,s.y,s.ptcType,s.vehicleType,s.vehicleColor,s.plateColor,s.heading,s.fixAngle,s.roadLayer,s.step,t,p.length,1]),this.updateModel||l.data.vehicleColor!==s.vehicleColor||l.data.vehicleType!==s.vehicleType){this.scene.remove(l.model),this.disposeModel(l.model),l.model=this.getVehicleModel(s),l.model.visible=!0;const c=await this.createPlateSprite(s);c&&(l.model.add(c),c.position.set(0,5,-4)),this.scene.add(l.model)}if(l.data.showName!==s.showName||l.data.plateColor!==s.plateColor){const c=l.model.getObjectByName("VehiclePlate");c&&(l.model.remove(c),this.disposeModel(c));const m=await this.createPlateSprite(s);m&&(l.model.add(m),m.position.set(0,5,-4))}if(l.data=s,this.needInterpolate){const c=p[p.length-1];Math.abs(h-c.heading)>=180&&(h>c.heading?c.heading+=360:h+=360),p.push({pos:[r,d,0],heading:h,time:n})}else{this.historyPositionMap.set(a,[{pos:[r,d,0],heading:h,time:n}]);const c=this.toRenderCoordinates([r,d,0]);l.model.position.set(c[0],c[1],c[2]),l.model.rotation.y=o.MathUtils.degToRad(-h)}}}await this.addVehicles(e),this.updateModel=!1,this.needInterpolate||this.render(this.context)}toRenderCoordinates(i){const e=[0,0,0];return w.toRenderCoordinates(this.view,i,0,T.WGS84,e,0,1),e}deleteVehicles(i){if(this.isPaused)return;const e=Date.now();i.forEach(t=>{if(this.appDataStore.saveTrackLog){const a=this.historyPositionMap.get(t);this.logTable.push([t,"","","","","","","","","","","","","","",e,a?a.length:0,2])}const s=this.vehicleObjectMap.get(t);s&&(this.needInterpolate?s.isMoving?s.waitForDelete=!0:this.deleteVehicle(s):this.deleteVehicle(s))})}deleteVehicle(i){this.scene.remove(i.model),this.disposeModel(i.model);const e=i.data.vehicleId;this.vehicleObjectMap.delete(e),this.historyPositionMap.delete(e)}async toggleTrafficInfo(i){i.name==="vehiclePlate"&&(i.visible===!0&&this.currentSpriteContent===g.EVehiclePlateState.None?await this.updatePanelContent(g.EVehiclePlateState.PlateNumber):await this.updatePanelContent(i.visible?this.currentSpriteContent:g.EVehiclePlateState.None))}togglePause(i){this.isPaused=i}clearVehicles(){for(const i of this.vehicleObjectMap.keys()){const e=this.vehicleObjectMap.get(i);e&&(this.scene.remove(e.model),this.disposeModel(e.model))}this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}async updatePanelContent(i){if(i!==this.currentSpriteContent){this.currentSpriteContent=i;for(const e of this.vehicleObjectMap.keys()){const t=this.vehicleObjectMap.get(e);if(t){const s=t.model.getObjectByName("VehiclePlate");if(s&&(t.model.remove(s),this.disposeModel(s)),i!==g.EVehiclePlateState.None){const a=await this.createPlateSprite(t.data);a&&(t.model.add(a),a.position.set(0,5,-4))}}}}}toggleGroundVehicle(i){console.log("toggleGroundVehicle",i),this.showGroundVehicle=i}toggleElevatedVehicle(i){this.showElevatedVehicle=i}disposeModel(i){i.traverse(e=>{e instanceof o.Mesh&&(e.geometry.dispose(),e.material.dispose())})}computeVehiclePosition(i){const e=this.historyPositionMap.get(i),t=this.vehicleObjectMap.get(i);if(!t||!e||!t.isMoving&&e.length<=2)return;const s=Date.now();t.isMoving=!0,t.data.roadLayer==="1"?t.model.visible=this.showGroundVehicle:t.model.visible=this.showElevatedVehicle,t.segmentStartTime||(t.segmentStartTime=s,t.segmentTotalTime=e[1].time-e[0].time);const a=s-t.segmentStartTime,n=Math.min(a/t.segmentTotalTime,1);if(n===1)if(e.shift(),e.length===1){t.waitForDelete===!0?this.deleteVehicle(t):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0,t.model.visible=!1,t.isMoving=!1,console.log("hide vehicle",i));return}else{t.segmentStartTime=Date.now();const r=a-t.segmentTotalTime;return t.segmentTotalTime=e[1].time-e[0].time-r,(e[1].heading>=270&&e[0].heading<=90||e[1].heading<=90&&e[0].heading>=270)&&(e[1].heading>e[0].heading?e[0].heading+=360:e[1].heading+=360),e[0].pos.concat(e[0].heading)}else if(e.length>=2){const r=e[0].pos[0]+(e[1].pos[0]-e[0].pos[0])*n,d=e[0].pos[1]+(e[1].pos[1]-e[0].pos[1])*n,h=e[0].heading+(e[1].heading-e[0].heading)*n;return[r,d,0,h]}else return}getVehicleModel(i){if(this.view.camera.position.z>=this.cameraHeightThreshold){const e=new o.SphereGeometry(5,32,32),t=new o.MeshPhysicalMaterial({color:325253,emissive:0,roughness:this.roughness,metalness:this.metalness});return new o.Mesh(e,t)}else{let e;if(i.ptcType===2)e=this.bicycleModel.clone();else if(i.ptcType===3)e=this.passengerModel.clone();else{switch(i.vehicleType){case 10:e=this.carModel.clone();break;case 20:e=this.vanModel.clone();break;case 25:e=this.truckModel.clone();break;case 50:e=this.busModel.clone();break;default:e=this.carModel.clone();break}const t=this.materialMap.get(i.vehicleColor)||this.defaultMaterial;let s=!1;e.traverse(a=>{!s&&a instanceof o.Mesh&&(a.material=t,s=!0)})}return e}}createCanvas(i,e,t){const s=document.createElement("canvas"),a=i.width,n=i.height;s.width=a,s.height=n;const r=s.getContext("2d");if(!r){console.log("canvas创建失败");return}return r.fillStyle="rgba(0,0,0,0.0)",r.fillRect(0,0,a,n),r.drawImage(i,0,0,a,n),r.beginPath(),r.translate(a/2,n/2),r.fillStyle=t,r.font="bold 32px 宋体",r.textBaseline="middle",r.textAlign="center",r.fillText(e,0,0),s}createPlateSprite(i){return new Promise((e,t)=>{var h,l;const s=!i.plateNo||i.plateNo==="0"||i.plateNo==="000000";if(this.currentSpriteContent===g.EVehiclePlateState.None||this.currentSpriteContent===g.EVehiclePlateState.PlateNumber&&s){e(void 0);return}let a=new Image,n="",r="";if(this.currentSpriteContent===g.EVehiclePlateState.PlateNumber||this.currentSpriteContent===g.EVehiclePlateState.Mix)if(s)a=this.greyPlateBG,n=i.ptcId,r="#ffffff";else switch(n=((h=i.showName)==null?void 0:h.substring(0,2))+"•"+((l=i.showName)==null?void 0:l.substring(2)),i.plateColor){case 1:a=this.bluePlateBG,r="#ffffff";break;case 2:a=this.yellowPlateBG,r="#000000";break;case 3:a=this.whitePlateBG,r="#000000";break;case 4:a=this.blackPlateBG,r="#ffffff";break;case 5:a=this.neoYellowPlateBG,r="#000000";break;case 6:a=this.neoGreenPlateBG,r="#000000";break;default:a=this.greyPlateBG,n=i.plateNo,r="#ffffff";break}else this.currentSpriteContent===g.EVehiclePlateState.Id&&(a=this.greyPlateBG,n=i.ptcId,r="#ffffff");const d=this.createCanvas(a,n,r);if(d){const p=new o.CanvasTexture(d),c=new o.SpriteMaterial({map:p,transparent:!1}),m=new o.Sprite(c),b=.05,M=d.width*b,P=d.height*b;m.scale.set(M,P,1),m.name="VehiclePlate",e(m)}else{t("canvas创建失败");return}a.onerror=p=>{console.log(`号牌背景加载失败: ${a.src}`,p),t(p)}})}}exports.default=I;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),J=require("@arcgis/core/core/reactiveUtils.js"),L=require("@arcgis/core/geometry"),E=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),T=require("md5"),O=require("pako"),H=require("vue"),_=require("../../stores/index.js"),z=require("../common-utils.js");function N(S){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(S){for(const t in S)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(S,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>S[t]})}}return e.default=S,Object.freeze(e)}const M=N(F),U=N(J),A=N(E),P=N(q);class k{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new x({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new w({id:"OpenDriveJunction"}),this.sectionLayer=new w({id:"OpenDriveSection"}),this.highlightLayer=new w({id:"OpenDriveHighlight"}),this.flashLayer=new w({id:"OpenDriveFlash"}),this.drawLayer=new w({id:"Draw"}),this.splitLaneLayer=new w({id:"SplitLane"}),this.borderLayer=new w({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new k(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let r=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:T(o),border:r}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var y,m;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(u,p)=>{u>this.junctionScale&&p<=this.junctionScale?this.updateAllJunctionSymbol("marker"):u<=this.junctionScale&&p>this.junctionScale&&this.updateAllJunctionSymbol("picture")}),console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;if(this.projectName=t.result.md5,console.timeEnd("md5用时"),this.xodrBorder=t.result.border,this.xodrBorder.length>0){const u=new f({geometry:new L.Polygon({rings:[this.xodrBorder]}),symbol:{type:"simple-fill",style:"none",outline:{style:"dash",color:"black",width:2}}});console.log(u.toJSON()),this.borderLayer.add(u)}this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(u){return{status:-1,message:u.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;z.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),n=O.inflate(a,{to:"string"}),l=JSON.parse(n);await this.showAllLanes(l,((y=e.options)==null?void 0:y.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0);const d=o.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const h=_.default.useAppDataStore;return H.watch(()=>h.isSketching,()=>{var u,p;h.isSketching?((u=this.mouseMoveHandler)==null||u.remove(),this.mouseMoveHandler=void 0,(p=this.mouseClickHandler)==null||p.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const r=await(await fetch(s)).arrayBuffer(),a=O.inflate(r,{to:"string"}),n=JSON.parse(a);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:l,refLine:d}=n;let h=n.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const y=new f({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(y),n.laneSections.sort((m,u)=>Number(m.id)-Number(u.id));for(let m=0;m<n.laneSections.length;m++){const u=n.laneSections[m],p=Number(u.id);for(const g of u.lanePaths){const v=Number(g.id);if(v===0)continue;const I=g.type,$=[...g.outerPath],j=g.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(g.innerPath[0]);const C=new L.Polygon({rings:[j]});if(C){const D=new f({geometry:C,attributes:{ObjectID:c++,id:`${l}+${p}+${v}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(l),roadName:n.name,sectionId:String(p),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:g.innerPath,rightLine:g.outerPath}});this.allLaneGraphics.push(D),r.push(D)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];let i;this.xodrBorder.length>0&&(i=new L.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const s=new L.Point({x:o.coordinates[0],y:o.coordinates[1]});let c=!0;if(i&&(c=A.contains(i,s)),c){const r=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===r||this.selectedSectionIds.includes(r)||this.sectionLayer.graphics.findIndex(p=>p.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(p=>`${p.attributes.roadId}+${p.attributes.sectionId}`===r),l=A.union(n.map(p=>p.geometry)),d=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),y=this.junctionNames.get(d)||d,m=this.junctionNames.get(h)||h,u=new f({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:r,selected:!1,fromNodeName:y,toNodeName:m,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(u)}else if(s.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),r=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:l.data.result}),s.setAttribute("selected",!0),s.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(r);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const d=l.data.result.obj_id;s.setAttribute("edgeId",d),this.openDriveClickCallback({type:"OpenDriveSection",id:d,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(n=>n!==r),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(r,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i,o;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),this.borderLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,r=s[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],n=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(a=>a.geometry),r=A.union(c);if(e.flash){const a=new f({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!e||e.type==="edge"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const o=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==o)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o)),s.length>0){const c=new Map;return s.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let n=c.get(a);n?n.push(r.geometry):(n=[r.geometry],c.set(a,n))}),c.forEach((r,a)=>{const n=A.union(r),l=new f({geometry:n,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new L.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${n}#${l}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,y=await b.get(h,{params:{id:`${n}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});y.status===200&&y.data.status===0&&s.push(y.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return A.contains(t,n)}),r=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let r=s[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===r&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===n);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,h=e.end||100,y=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(y,d,h,{units:"meters"}),u=P.lineString(l.getAttribute("rightLine")),p=G.lineSliceAlong(u,d,h,{units:"meters"}),g=m.geometry.coordinates.concat(p.geometry.coordinates.reverse());g.push(g[g.length-1]);const v=new f({geometry:new L.Polygon({rings:[g]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:m.geometry.coordinates,rightLine:p.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(i=>{i.getAttribute("selected")||(i.symbol=this.getCrossGraphicSymbol(i.attributes,e))}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i?1:2}.png`,width:"18px",height:"28px",yOffset:"12px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?50:40,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:45,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/xhj_1.png",offsetY:i?22:15}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/xhj_2.png",width:"27px",height:"42px",yOffset:"22px"}}}exports.default=k;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),J=require("@arcgis/core/core/reactiveUtils.js"),L=require("@arcgis/core/geometry"),E=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),T=require("md5"),O=require("pako"),H=require("vue"),_=require("../../stores/index.js"),z=require("../common-utils.js");function N(S){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(S){for(const t in S)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(S,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>S[t]})}}return e.default=S,Object.freeze(e)}const M=N(F),U=N(J),A=N(E),P=N(q);class k{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"sectionIndex",alias:"路段序号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new x({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new w({id:"OpenDriveJunction"}),this.sectionLayer=new w({id:"OpenDriveSection"}),this.highlightLayer=new w({id:"OpenDriveHighlight"}),this.flashLayer=new w({id:"OpenDriveFlash"}),this.drawLayer=new w({id:"Draw"}),this.splitLaneLayer=new w({id:"SplitLane"}),this.borderLayer=new w({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new k(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let r=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:T(o),border:r}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var g,m;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(u,p)=>{u>this.junctionScale&&p<=this.junctionScale?this.updateAllJunctionSymbol("marker"):u<=this.junctionScale&&p>this.junctionScale&&this.updateAllJunctionSymbol("picture")}),console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;if(this.projectName=t.result.md5,console.timeEnd("md5用时"),this.xodrBorder=t.result.border,this.xodrBorder.length>0){const u=new f({geometry:new L.Polygon({rings:[this.xodrBorder]}),symbol:{type:"simple-fill",style:"none",outline:{style:"dash",color:"black",width:2}}});console.log(u.toJSON()),this.borderLayer.add(u)}this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(u){return{status:-1,message:u.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;z.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),n=O.inflate(a,{to:"string"}),l=JSON.parse(n);await this.showAllLanes(l,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0);const d=o.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const h=_.default.useAppDataStore;return H.watch(()=>h.isSketching,()=>{var u,p;h.isSketching?((u=this.mouseMoveHandler)==null||u.remove(),this.mouseMoveHandler=void 0,(p=this.mouseClickHandler)==null||p.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const r=await(await fetch(s)).arrayBuffer(),a=O.inflate(r,{to:"string"}),n=JSON.parse(a);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:l,refLine:d}=n;let h=n.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const g=new f({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(g),n.laneSections.sort((m,u)=>Number(m.id)-Number(u.id));for(let m=0;m<n.laneSections.length;m++){const u=n.laneSections[m],p=Number(u.id);for(const y of u.lanePaths){const v=Number(y.id);if(v===0)continue;const I=y.type,$=[...y.outerPath],j=y.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(y.innerPath[0]);const C=new L.Polygon({rings:[j]});if(C){const D=new f({geometry:C,attributes:{ObjectID:c++,id:`${l}+${p}+${v}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(l),roadName:n.name,sectionId:String(p),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:y.innerPath,rightLine:y.outerPath}});this.allLaneGraphics.push(D),r.push(D)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];let i;this.xodrBorder.length>0&&(i=new L.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const s=new L.Point({x:o.coordinates[0],y:o.coordinates[1]});let c=!0;if(i&&(c=A.contains(i,s)),c){const r=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===r||this.selectedSectionIds.includes(r)||this.sectionLayer.graphics.findIndex(p=>p.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(p=>`${p.attributes.roadId}+${p.attributes.sectionId}`===r),l=A.union(n.map(p=>p.geometry)),d=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(d)||d,m=this.junctionNames.get(h)||h,u=new f({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:r,selected:!1,fromNodeName:g,toNodeName:m,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(u)}else if(s.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),r=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:l.data.result}),s.setAttribute("selected",!0),s.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(r);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const d=l.data.result.obj_id;s.setAttribute("edgeId",d),this.openDriveClickCallback({type:"OpenDriveSection",id:d,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(n=>n!==r),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(r,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i,o;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),this.borderLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,r=s[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],n=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(a=>a.geometry),r=A.union(c);if(e.flash){const a=new f({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!e||e.type==="edge"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const o=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==o)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o)),s.length>0){const c=new Map;return s.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let n=c.get(a);n?n.push(r.geometry):(n=[r.geometry],c.set(a,n))}),c.forEach((r,a)=>{const n=A.union(r),l=new f({geometry:n,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new L.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${n}#${l}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(h,{params:{id:`${n}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return A.contains(t,n)}),r=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let r=s[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===r&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===n);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,h=e.end||100,g=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(g,d,h,{units:"meters"}),u=P.lineString(l.getAttribute("rightLine")),p=G.lineSliceAlong(u,d,h,{units:"meters"}),y=m.geometry.coordinates.concat(p.geometry.coordinates.reverse());y.push(y[y.length-1]);const v=new f({geometry:new L.Polygon({rings:[y]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:m.geometry.coordinates,rightLine:p.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:{coordinates:y}}}clearSplitLane(){this.splitLaneLayer.removeAll()}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(i=>{i.getAttribute("selected")||(i.symbol=this.getCrossGraphicSymbol(i.attributes,e))}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i?1:2}.png`,width:"18px",height:"28px",yOffset:"12px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?50:40,haloSize:2,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:45,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/xhj_1.png",offsetY:i?22:15}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/xhj_2.png",width:"27px",height:"42px",yOffset:"22px"}}}exports.default=k;
|
package/package.json
CHANGED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import Graphic from '@arcgis/core/Graphic';
|
|
2
|
-
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
|
|
3
|
-
import MapView from '@arcgis/core/views/MapView';
|
|
4
|
-
import SceneView from '@arcgis/core/views/SceneView';
|
|
5
|
-
interface GreenWaveLineOptions {
|
|
6
|
-
viewer: MapView | SceneView;
|
|
7
|
-
graphicsLayerOptions: {
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
interface roadPath {
|
|
12
|
-
paths: [number, number][];
|
|
13
|
-
symbol: any;
|
|
14
|
-
attributes: any;
|
|
15
|
-
visible?: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface animationOptions {
|
|
18
|
-
isAnimation: boolean;
|
|
19
|
-
positive?: boolean;
|
|
20
|
-
positiveColor?: number[];
|
|
21
|
-
negative?: boolean;
|
|
22
|
-
negativeColor?: number[];
|
|
23
|
-
}
|
|
24
|
-
export default class GreenWaveLine {
|
|
25
|
-
private viewer;
|
|
26
|
-
overlayLayer: GraphicsLayer;
|
|
27
|
-
customGreenWaveLineView: any;
|
|
28
|
-
material: THREE.ShaderMaterial;
|
|
29
|
-
renderer: THREE.WebGLRenderer;
|
|
30
|
-
threeScene: THREE.Scene;
|
|
31
|
-
camera: THREE.PerspectiveCamera;
|
|
32
|
-
private defaultAnimationOptions;
|
|
33
|
-
constructor(options: GreenWaveLineOptions);
|
|
34
|
-
addGreenWaveLine(paths: roadPath[], options?: animationOptions): void;
|
|
35
|
-
getAnimationPath(paths: [number, number][], options?: animationOptions): any;
|
|
36
|
-
createLine(paths: any, symbol: any, attributes: any, visible: boolean): Graphic;
|
|
37
|
-
addPointText(points: any[]): void;
|
|
38
|
-
createPointText(point: any, symbol: any, attributes: any, visible: boolean): Graphic;
|
|
39
|
-
/**
|
|
40
|
-
* 隐藏覆盖物
|
|
41
|
-
*
|
|
42
|
-
* @param {string[]} [ids]
|
|
43
|
-
* @memberof GreenWaveLine
|
|
44
|
-
*/
|
|
45
|
-
hideWaveLine(ids?: string[]): void;
|
|
46
|
-
/**
|
|
47
|
-
* 显示覆盖物
|
|
48
|
-
*
|
|
49
|
-
* @param {string[]} [ids]
|
|
50
|
-
* @memberof GreenWaveLine
|
|
51
|
-
*/
|
|
52
|
-
showWaveLine(ids?: string[]): void;
|
|
53
|
-
/**
|
|
54
|
-
* 隐藏图层
|
|
55
|
-
*
|
|
56
|
-
* @memberof GreenWaveLine
|
|
57
|
-
*/
|
|
58
|
-
hideLayer(): void;
|
|
59
|
-
/**
|
|
60
|
-
* 显示图层
|
|
61
|
-
*
|
|
62
|
-
* @memberof Overlay
|
|
63
|
-
*/
|
|
64
|
-
showLayer(): void;
|
|
65
|
-
clearGreenWaveLine(): void;
|
|
66
|
-
destroy(): void;
|
|
67
|
-
}
|
|
68
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import Graphic from '@arcgis/core/Graphic';
|
|
2
|
-
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
|
|
3
|
-
import MapView from '@arcgis/core/views/MapView';
|
|
4
|
-
import SceneView from '@arcgis/core/views/SceneView';
|
|
5
|
-
interface GreenWaveLineOptions {
|
|
6
|
-
viewer: MapView | SceneView;
|
|
7
|
-
graphicsLayerOptions: {
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
interface roadPath {
|
|
12
|
-
paths: [number, number][];
|
|
13
|
-
symbol: any;
|
|
14
|
-
attributes: any;
|
|
15
|
-
visible?: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface animationOptions {
|
|
18
|
-
isAnimation: boolean;
|
|
19
|
-
positive?: boolean;
|
|
20
|
-
positiveColor?: number[];
|
|
21
|
-
negative?: boolean;
|
|
22
|
-
negativeColor?: number[];
|
|
23
|
-
}
|
|
24
|
-
export default class GreenWaveLine {
|
|
25
|
-
private viewer;
|
|
26
|
-
overlayLayer: GraphicsLayer;
|
|
27
|
-
customGreenWaveLineView: any;
|
|
28
|
-
material: THREE.ShaderMaterial;
|
|
29
|
-
renderer: THREE.WebGLRenderer;
|
|
30
|
-
threeScene: THREE.Scene;
|
|
31
|
-
camera: THREE.PerspectiveCamera;
|
|
32
|
-
private defaultAnimationOptions;
|
|
33
|
-
constructor(options: GreenWaveLineOptions);
|
|
34
|
-
addGreenWaveLine(paths: roadPath[], options?: animationOptions): void;
|
|
35
|
-
getAnimationPath(paths: [number, number][], options?: animationOptions): any;
|
|
36
|
-
createLine(paths: any, symbol: any, attributes: any, visible: boolean): Graphic;
|
|
37
|
-
addPointText(points: any[]): void;
|
|
38
|
-
createPointText(point: any, symbol: any, attributes: any, visible: boolean): Graphic;
|
|
39
|
-
/**
|
|
40
|
-
* 隐藏覆盖物
|
|
41
|
-
*
|
|
42
|
-
* @param {string[]} [ids]
|
|
43
|
-
* @memberof GreenWaveLine
|
|
44
|
-
*/
|
|
45
|
-
hideWaveLine(ids?: string[]): void;
|
|
46
|
-
/**
|
|
47
|
-
* 显示覆盖物
|
|
48
|
-
*
|
|
49
|
-
* @param {string[]} [ids]
|
|
50
|
-
* @memberof GreenWaveLine
|
|
51
|
-
*/
|
|
52
|
-
showWaveLine(ids?: string[]): void;
|
|
53
|
-
/**
|
|
54
|
-
* 隐藏图层
|
|
55
|
-
*
|
|
56
|
-
* @memberof GreenWaveLine
|
|
57
|
-
*/
|
|
58
|
-
hideLayer(): void;
|
|
59
|
-
/**
|
|
60
|
-
* 显示图层
|
|
61
|
-
*
|
|
62
|
-
* @memberof Overlay
|
|
63
|
-
*/
|
|
64
|
-
showLayer(): void;
|
|
65
|
-
clearGreenWaveLine(): void;
|
|
66
|
-
destroy(): void;
|
|
67
|
-
}
|
|
68
|
-
export {};
|