gisviewer-vue3-arcgis 1.0.250 → 1.0.251
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/green-wave-band-controller/index.mjs +146 -134
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +87 -86
- package/es/src/types/index.d.ts +4 -1
- package/lib/src/gis-map/utils/green-wave-band-controller/index.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/lib/src/types/index.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as y from "@arcgis/core/core/reactiveUtils.js";
|
|
2
|
-
import { Polyline as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import { Polyline as b } from "@arcgis/core/geometry";
|
|
3
|
+
import n from "@arcgis/core/Graphic";
|
|
4
|
+
import h from "@arcgis/core/layers/GraphicsLayer";
|
|
5
|
+
import m from "axios";
|
|
6
6
|
class w {
|
|
7
7
|
constructor(e) {
|
|
8
|
-
this.selectedNodeIds = [], this.nodeScale = 5e3, this.hasGpu = !1, this.hasGpu = localStorage.getItem("gpu") !== "Unknown", this.view = e, this.roadsectLayer = new
|
|
8
|
+
this.selectedNodeIds = [], this.nodeScale = 5e3, this.hasGpu = !1, this.hasGpu = localStorage.getItem("gpu") !== "Unknown", this.view = e, this.roadsectLayer = new h({
|
|
9
9
|
id: "roadsectLayer"
|
|
10
|
-
}), this.view.map.add(this.roadsectLayer), this.allNodesLayer = new
|
|
10
|
+
}), this.view.map.add(this.roadsectLayer), this.allNodesLayer = new h({
|
|
11
11
|
id: "allNodesLayer"
|
|
12
|
-
}), this.view.map.add(this.allNodesLayer), this.bandLayer = new
|
|
12
|
+
}), this.view.map.add(this.allNodesLayer), this.bandLayer = new h({
|
|
13
13
|
id: "bandLayer"
|
|
14
14
|
}), this.view.map.add(this.bandLayer);
|
|
15
15
|
}
|
|
@@ -18,8 +18,8 @@ class w {
|
|
|
18
18
|
* @param params
|
|
19
19
|
*/
|
|
20
20
|
addGreenWaveBand(e) {
|
|
21
|
-
this.addNodeCallback = e.addCrossCallback, this.removeNodeCallback = e.removeCrossCallback, e.removeAllCrossCallback && (this.removeAllNodeCallback = e.removeAllCrossCallback), this.selectedNodeIds = [], this.openDriveServer = e.odrServer, this.showAllNodes(e.crossesInArea), this.viewClickWatcher || (this.viewClickWatcher = this.view.on("click", (
|
|
22
|
-
this.handleViewClick(
|
|
21
|
+
this.addNodeCallback = e.addCrossCallback, this.removeNodeCallback = e.removeCrossCallback, e.removeAllCrossCallback && (this.removeAllNodeCallback = e.removeAllCrossCallback), this.selectedNodeIds = [], this.openDriveServer = e.odrServer, this.showAllNodes(e.crossesInArea), this.viewClickWatcher || (this.viewClickWatcher = this.view.on("click", (i) => {
|
|
22
|
+
this.handleViewClick(i);
|
|
23
23
|
}));
|
|
24
24
|
}
|
|
25
25
|
stopAddGreenWaveBand() {
|
|
@@ -27,38 +27,46 @@ class w {
|
|
|
27
27
|
(e = this.viewClickWatcher) == null || e.remove(), this.viewClickWatcher = void 0, this.allNodesLayer.removeAll(), this.selectedNodeIds = [], this.roadsectLayer.removeAll(), this.bandLayer.removeAll();
|
|
28
28
|
}
|
|
29
29
|
async showGreenWaveBand(e) {
|
|
30
|
-
this.
|
|
30
|
+
this.bandLayer.graphics.forEach((t) => {
|
|
31
|
+
t.getAttribute("bandId") === e.bandId && this.bandLayer.remove(t);
|
|
32
|
+
}), this.roadsectLayer.graphics.forEach((t) => {
|
|
33
|
+
t.getAttribute("bandId") === e.bandId && this.roadsectLayer.remove(t);
|
|
34
|
+
}), this.scaleWatcher || (this.scaleWatcher = y.watch(
|
|
31
35
|
() => this.view.scale,
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}) :
|
|
36
|
-
|
|
36
|
+
(t, r) => {
|
|
37
|
+
t > this.nodeScale && r <= this.nodeScale ? this.bandLayer.graphics.forEach((a) => {
|
|
38
|
+
a.geometry.type === "point" && (a.symbol = this.getShowNodeSymbol("marker"));
|
|
39
|
+
}) : t <= this.nodeScale && r > this.nodeScale && this.bandLayer.graphics.forEach((a) => {
|
|
40
|
+
a.geometry.type === "point" && (a.symbol = this.getShowNodeSymbol("picture"));
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
43
|
));
|
|
40
|
-
const
|
|
44
|
+
const i = new b({
|
|
41
45
|
paths: [e.coordinates]
|
|
42
|
-
}),
|
|
43
|
-
geometry:
|
|
44
|
-
symbol: this.getLineSymbol(!0),
|
|
46
|
+
}), s = new n({
|
|
47
|
+
geometry: i,
|
|
48
|
+
symbol: this.getLineSymbol(!0, e),
|
|
45
49
|
attributes: {
|
|
46
50
|
bandId: e.bandId,
|
|
47
51
|
type: "greenWaveBand",
|
|
48
52
|
id: e.bandId
|
|
49
53
|
}
|
|
50
54
|
});
|
|
51
|
-
this.roadsectLayer.add(
|
|
52
|
-
const
|
|
55
|
+
this.roadsectLayer.add(s), await this.view.goTo(s), e.nodeList && e.nodeList.forEach((t) => {
|
|
56
|
+
const r = new n({
|
|
53
57
|
geometry: {
|
|
54
58
|
type: "point",
|
|
55
|
-
x:
|
|
56
|
-
y:
|
|
59
|
+
x: t.longitude,
|
|
60
|
+
y: t.latitude
|
|
57
61
|
},
|
|
58
62
|
symbol: this.getShowNodeSymbol("picture"),
|
|
59
|
-
attributes:
|
|
63
|
+
attributes: {
|
|
64
|
+
...t,
|
|
65
|
+
bandId: e.bandId,
|
|
66
|
+
type: "greenWaveBandNode"
|
|
67
|
+
}
|
|
60
68
|
});
|
|
61
|
-
this.bandLayer.add(
|
|
69
|
+
this.bandLayer.add(r);
|
|
62
70
|
});
|
|
63
71
|
}
|
|
64
72
|
/**
|
|
@@ -66,20 +74,20 @@ class w {
|
|
|
66
74
|
* @param nodeAttributes
|
|
67
75
|
*/
|
|
68
76
|
showAllNodes(e) {
|
|
69
|
-
const
|
|
70
|
-
e.forEach((
|
|
71
|
-
|
|
72
|
-
new
|
|
77
|
+
const i = [];
|
|
78
|
+
e.forEach((s) => {
|
|
79
|
+
i.push(
|
|
80
|
+
new n({
|
|
73
81
|
geometry: {
|
|
74
82
|
type: "point",
|
|
75
|
-
x:
|
|
76
|
-
y:
|
|
83
|
+
x: s.longitude,
|
|
84
|
+
y: s.latitude
|
|
77
85
|
},
|
|
78
86
|
symbol: this.getEditableNodeSymbol(!1),
|
|
79
|
-
attributes: { ...
|
|
87
|
+
attributes: { ...s, selected: !1 }
|
|
80
88
|
})
|
|
81
89
|
);
|
|
82
|
-
}), this.allNodesLayer.addMany(
|
|
90
|
+
}), this.allNodesLayer.addMany(i);
|
|
83
91
|
}
|
|
84
92
|
/**
|
|
85
93
|
* 点击待选/已选路口
|
|
@@ -87,51 +95,51 @@ class w {
|
|
|
87
95
|
* @returns
|
|
88
96
|
*/
|
|
89
97
|
async handleViewClick(e) {
|
|
90
|
-
var
|
|
91
|
-
const
|
|
98
|
+
var a;
|
|
99
|
+
const s = (a = (await this.view.hitTest(e, {
|
|
92
100
|
include: [this.allNodesLayer]
|
|
93
|
-
})).results) == null ? void 0 :
|
|
101
|
+
})).results) == null ? void 0 : a.filter(
|
|
94
102
|
(d) => d.type === "graphic"
|
|
95
103
|
);
|
|
96
|
-
if (
|
|
104
|
+
if (s.length === 0)
|
|
97
105
|
return;
|
|
98
|
-
const
|
|
99
|
-
if (this.selectedNodeIds.includes(
|
|
100
|
-
const d = this.selectedNodeIds.indexOf(
|
|
106
|
+
const t = s[0].graphic, r = t.getAttribute("id");
|
|
107
|
+
if (this.selectedNodeIds.includes(r)) {
|
|
108
|
+
const d = this.selectedNodeIds.indexOf(r) + 1;
|
|
101
109
|
if (d === 1)
|
|
102
|
-
this.removeAllNodeCallback && this.removeAllNodeCallback(), this.selectedNodeIds = [], this.allNodesLayer.graphics.forEach((
|
|
103
|
-
|
|
110
|
+
this.removeAllNodeCallback && this.removeAllNodeCallback(), this.selectedNodeIds = [], this.allNodesLayer.graphics.forEach((o) => {
|
|
111
|
+
o.setAttribute("selected", !1), o.symbol = this.getEditableNodeSymbol(!1), o.visible = !0;
|
|
104
112
|
}), this.roadsectLayer.removeAll();
|
|
105
113
|
else {
|
|
106
|
-
for (let
|
|
114
|
+
for (let o = d; o < this.selectedNodeIds.length; o++) {
|
|
107
115
|
this.removeNodeCallback && this.removeNodeCallback({
|
|
108
|
-
id: this.selectedNodeIds[
|
|
116
|
+
id: this.selectedNodeIds[o]
|
|
109
117
|
});
|
|
110
|
-
for (let
|
|
111
|
-
const
|
|
112
|
-
(
|
|
118
|
+
for (let l = 0; l < this.roadsectLayer.graphics.length; l++) {
|
|
119
|
+
const c = this.roadsectLayer.graphics.getItemAt(l);
|
|
120
|
+
(c.getAttribute("id") === this.selectedNodeIds[o] || !c.getAttribute("selected")) && (this.roadsectLayer.remove(c), l--);
|
|
113
121
|
}
|
|
114
122
|
}
|
|
115
|
-
this.selectedNodeIds = this.selectedNodeIds.slice(0, d), this.allNodesLayer.graphics.forEach((
|
|
116
|
-
const
|
|
117
|
-
|
|
123
|
+
this.selectedNodeIds = this.selectedNodeIds.slice(0, d), this.allNodesLayer.graphics.forEach((o) => {
|
|
124
|
+
const l = this.selectedNodeIds.includes(
|
|
125
|
+
o.getAttribute("id")
|
|
118
126
|
);
|
|
119
|
-
|
|
120
|
-
}), await this.showDownstreamNodes(
|
|
127
|
+
o.setAttribute("selected", l), o.symbol = this.getEditableNodeSymbol(l), o.visible = l;
|
|
128
|
+
}), await this.showDownstreamNodes(r);
|
|
121
129
|
}
|
|
122
130
|
} else {
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
t.setAttribute("selected", !0), t.symbol = this.getEditableNodeSymbol(!0), this.selectedNodeIds.push(r), this.allNodesLayer.graphics.forEach((o) => {
|
|
132
|
+
o.visible = o.getAttribute("selected");
|
|
125
133
|
});
|
|
126
134
|
let d = [];
|
|
127
|
-
for (let
|
|
128
|
-
const
|
|
129
|
-
|
|
135
|
+
for (let o = 0; o < this.roadsectLayer.graphics.length; o++) {
|
|
136
|
+
const l = this.roadsectLayer.graphics.getItemAt(o);
|
|
137
|
+
l.getAttribute("id") === r ? (l.symbol = this.getLineSymbol(!0), l.setAttribute("selected", !0), d = l.geometry.paths[0]) : l.getAttribute("selected") || (this.roadsectLayer.remove(l), o--);
|
|
130
138
|
}
|
|
131
139
|
this.addNodeCallback && this.addNodeCallback({
|
|
132
|
-
...
|
|
140
|
+
...t.attributes,
|
|
133
141
|
roadsect: d
|
|
134
|
-
}), await this.showDownstreamNodes(
|
|
142
|
+
}), await this.showDownstreamNodes(r);
|
|
135
143
|
}
|
|
136
144
|
}
|
|
137
145
|
/**
|
|
@@ -140,99 +148,103 @@ class w {
|
|
|
140
148
|
*/
|
|
141
149
|
async showDownstreamNodes(e) {
|
|
142
150
|
this.view.container.style.cursor = "progress";
|
|
143
|
-
const
|
|
151
|
+
const i = await m.get(
|
|
144
152
|
`http://${this.openDriveServer}/api/computable/getDownstreamNodes`,
|
|
145
153
|
{ params: { nodeId: e } }
|
|
146
154
|
);
|
|
147
|
-
if (
|
|
155
|
+
if (i.status !== 200 || i.data.status !== 0) {
|
|
148
156
|
this.view.container.style.cursor = "default";
|
|
149
157
|
return;
|
|
150
158
|
}
|
|
151
|
-
|
|
152
|
-
this.allNodesLayer.graphics.forEach((
|
|
153
|
-
if (
|
|
154
|
-
const
|
|
159
|
+
i.data.result.forEach((t) => {
|
|
160
|
+
this.allNodesLayer.graphics.forEach((r) => {
|
|
161
|
+
if (r.getAttribute("nodeId") === t.id && r.getAttribute("selected") === !1 && (r.visible = !0, t.coordinates)) {
|
|
162
|
+
const a = new n({
|
|
155
163
|
geometry: {
|
|
156
164
|
type: "polyline",
|
|
157
|
-
paths: [
|
|
165
|
+
paths: [t.coordinates]
|
|
158
166
|
},
|
|
159
167
|
symbol: this.getLineSymbol(!1),
|
|
160
|
-
attributes: { ...
|
|
168
|
+
attributes: { ...t, selected: !1 }
|
|
161
169
|
});
|
|
162
|
-
this.roadsectLayer.add(
|
|
170
|
+
this.roadsectLayer.add(a);
|
|
163
171
|
}
|
|
164
172
|
});
|
|
165
173
|
}), this.view.container.style.cursor = "default";
|
|
166
174
|
}
|
|
167
|
-
getLineSymbol(e) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
type: "
|
|
172
|
-
|
|
173
|
-
type: "
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
[
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
[
|
|
204
|
-
|
|
175
|
+
getLineSymbol(e, i) {
|
|
176
|
+
if (e) {
|
|
177
|
+
const s = (i == null ? void 0 : i.lineWidth) || 4, t = (i == null ? void 0 : i.lineColor) || [55, 125, 34, 255], r = (i == null ? void 0 : i.arrowColor) || [255, 255, 255, 255];
|
|
178
|
+
return Array.isArray(t) && t.length === 3 && t.push(255), Array.isArray(r) && r.length === 3 && r.push(255), {
|
|
179
|
+
type: "cim",
|
|
180
|
+
data: {
|
|
181
|
+
type: "CIMSymbolReference",
|
|
182
|
+
symbol: {
|
|
183
|
+
type: "CIMLineSymbol",
|
|
184
|
+
symbolLayers: [
|
|
185
|
+
{
|
|
186
|
+
type: "CIMVectorMarker",
|
|
187
|
+
enable: !0,
|
|
188
|
+
size: 4,
|
|
189
|
+
markerPlacement: {
|
|
190
|
+
type: "CIMMarkerPlacementAlongLineSameSize",
|
|
191
|
+
endings: "WithMarkers",
|
|
192
|
+
placementTemplate: [40],
|
|
193
|
+
angleToLine: !0
|
|
194
|
+
},
|
|
195
|
+
frame: {
|
|
196
|
+
xmin: -5,
|
|
197
|
+
ymin: -5,
|
|
198
|
+
xmax: 5,
|
|
199
|
+
ymax: 5
|
|
200
|
+
},
|
|
201
|
+
markerGraphics: [
|
|
202
|
+
{
|
|
203
|
+
type: "CIMMarkerGraphic",
|
|
204
|
+
geometry: {
|
|
205
|
+
paths: [
|
|
206
|
+
[
|
|
207
|
+
[s, -s],
|
|
208
|
+
[3 * s, 0],
|
|
209
|
+
[s, s]
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
[-s, s],
|
|
213
|
+
[-3 * s, 0],
|
|
214
|
+
[-s, -s]
|
|
215
|
+
]
|
|
205
216
|
]
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
},
|
|
218
|
+
symbol: {
|
|
219
|
+
type: "CIMLineSymbol",
|
|
220
|
+
symbolLayers: [
|
|
221
|
+
{
|
|
222
|
+
type: "CIMSolidStroke",
|
|
223
|
+
enable: !0,
|
|
224
|
+
width: 1.5,
|
|
225
|
+
color: r
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
}
|
|
218
229
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
type: "CIMSolidStroke",
|
|
234
|
+
enable: !0,
|
|
235
|
+
width: s,
|
|
236
|
+
color: t
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}
|
|
229
240
|
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
241
|
+
};
|
|
242
|
+
} else
|
|
243
|
+
return {
|
|
244
|
+
type: "simple-line",
|
|
245
|
+
color: "gray",
|
|
246
|
+
width: 2
|
|
247
|
+
};
|
|
236
248
|
}
|
|
237
249
|
getShowNodeSymbol(e) {
|
|
238
250
|
return e === "marker" ? {
|
|
@@ -308,11 +308,11 @@ class O {
|
|
|
308
308
|
var t;
|
|
309
309
|
try {
|
|
310
310
|
const o = await (await fetch(e)).text();
|
|
311
|
-
let
|
|
311
|
+
let n = (t = new F({
|
|
312
312
|
ignoreAttributes: !1,
|
|
313
313
|
allowBooleanAttributes: !0
|
|
314
314
|
}).parse(o).OpenDRIVE.userData) == null ? void 0 : t.border;
|
|
315
|
-
return
|
|
315
|
+
return n ? n = JSON.parse(n) : n = [], { status: 0, message: "ok", result: { md5: J(o), border: n } };
|
|
316
316
|
} catch (s) {
|
|
317
317
|
return { status: -1, message: s.message };
|
|
318
318
|
}
|
|
@@ -359,7 +359,7 @@ class O {
|
|
|
359
359
|
);
|
|
360
360
|
let c = o.data.result.json;
|
|
361
361
|
c.startsWith(window.location.protocol) || (c = `${window.location.protocol}//${e.server}${c}`);
|
|
362
|
-
const a = await (await fetch(c)).arrayBuffer(),
|
|
362
|
+
const a = await (await fetch(c)).arrayBuffer(), r = G.inflate(a, { to: "string" }), l = JSON.parse(r);
|
|
363
363
|
if (await this.showAllLanes(
|
|
364
364
|
l,
|
|
365
365
|
((y = e.options) == null ? void 0 : y.showJunctionLane) || !1,
|
|
@@ -397,8 +397,8 @@ class O {
|
|
|
397
397
|
throw new Error(`OpenDriveRenderer: ${o.statusText}`);
|
|
398
398
|
let i = o.data.result.json;
|
|
399
399
|
i.startsWith(window.location.protocol) || (i = `${window.location.protocol}//${e}${i}`);
|
|
400
|
-
const
|
|
401
|
-
return await this.showAllLanes(
|
|
400
|
+
const n = await (await fetch(i)).arrayBuffer(), a = G.inflate(n, { to: "string" }), r = JSON.parse(a);
|
|
401
|
+
return console.log(r), await this.showAllLanes(r, !1, !1), { status: 0, message: "ok" };
|
|
402
402
|
}
|
|
403
403
|
/**
|
|
404
404
|
* 显示所有车道
|
|
@@ -408,18 +408,19 @@ class O {
|
|
|
408
408
|
* @returns
|
|
409
409
|
*/
|
|
410
410
|
async showAllLanes(e, t, s) {
|
|
411
|
+
console.log(e);
|
|
411
412
|
const o = await this.laneLayer.queryFeatures();
|
|
412
413
|
return o.features.length > 0 && this.laneLayer.applyEdits({
|
|
413
414
|
deleteFeatures: o.features
|
|
414
415
|
}), this.roadNameLayer.visible = s, new Promise((i) => {
|
|
415
416
|
let c = 0;
|
|
416
417
|
this.allLaneGraphics = [], this.allRefLineGraphics = [];
|
|
417
|
-
const
|
|
418
|
-
for (const
|
|
419
|
-
if (!t &&
|
|
418
|
+
const n = [];
|
|
419
|
+
for (const r of e) {
|
|
420
|
+
if (!t && r.junction !== "-1")
|
|
420
421
|
continue;
|
|
421
|
-
const { id: l, refLine: h } =
|
|
422
|
-
let p =
|
|
422
|
+
const { id: l, refLine: h } = r;
|
|
423
|
+
let p = r.name;
|
|
423
424
|
p.includes("(") && (p = p.slice(0, p.indexOf("("))), p = p.replace(/(.)/g, "$1 ");
|
|
424
425
|
const y = new g({
|
|
425
426
|
geometry: {
|
|
@@ -432,9 +433,9 @@ class O {
|
|
|
432
433
|
roadName: p
|
|
433
434
|
}
|
|
434
435
|
});
|
|
435
|
-
this.allRefLineGraphics.push(y),
|
|
436
|
-
for (let m = 0; m <
|
|
437
|
-
const f =
|
|
436
|
+
this.allRefLineGraphics.push(y), r.laneSections.sort((m, f) => Number(m.id) - Number(f.id));
|
|
437
|
+
for (let m = 0; m < r.laneSections.length; m++) {
|
|
438
|
+
const f = r.laneSections[m], d = Number(f.id);
|
|
438
439
|
for (const u of f.lanePaths) {
|
|
439
440
|
const v = Number(u.id);
|
|
440
441
|
if (v === 0)
|
|
@@ -456,10 +457,10 @@ class O {
|
|
|
456
457
|
attributes: {
|
|
457
458
|
ObjectID: c++,
|
|
458
459
|
id: `${l}+${d}+${v}`,
|
|
459
|
-
fromNode:
|
|
460
|
-
toNode:
|
|
460
|
+
fromNode: r.fromNode,
|
|
461
|
+
toNode: r.toNode,
|
|
461
462
|
roadId: String(l),
|
|
462
|
-
roadName:
|
|
463
|
+
roadName: r.name,
|
|
463
464
|
sectionId: String(d),
|
|
464
465
|
sectionIndex: m,
|
|
465
466
|
laneId: v,
|
|
@@ -470,23 +471,23 @@ class O {
|
|
|
470
471
|
rightLine: u.outerPath
|
|
471
472
|
}
|
|
472
473
|
});
|
|
473
|
-
this.allLaneGraphics.push(j),
|
|
474
|
+
this.allLaneGraphics.push(j), n.push(j);
|
|
474
475
|
}
|
|
475
476
|
}
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
479
|
const a = setInterval(() => {
|
|
479
|
-
if (
|
|
480
|
-
if (
|
|
481
|
-
const
|
|
480
|
+
if (n.length > 0 || this.allRefLineGraphics.length > 0) {
|
|
481
|
+
if (n.length > 0) {
|
|
482
|
+
const r = n.splice(0, 100);
|
|
482
483
|
this.laneLayer.applyEdits({
|
|
483
|
-
addFeatures:
|
|
484
|
+
addFeatures: r
|
|
484
485
|
});
|
|
485
486
|
}
|
|
486
487
|
if (this.allRefLineGraphics.length > 0) {
|
|
487
|
-
const
|
|
488
|
+
const r = this.allRefLineGraphics.splice(0, 10);
|
|
488
489
|
this.roadNameLayer.applyEdits({
|
|
489
|
-
addFeatures:
|
|
490
|
+
addFeatures: r
|
|
490
491
|
});
|
|
491
492
|
}
|
|
492
493
|
} else
|
|
@@ -513,7 +514,7 @@ class O {
|
|
|
513
514
|
});
|
|
514
515
|
let c = !0;
|
|
515
516
|
if (s && (c = L.contains(s, i)), c) {
|
|
516
|
-
const
|
|
517
|
+
const n = new g({
|
|
517
518
|
geometry: i,
|
|
518
519
|
attributes: {
|
|
519
520
|
...o,
|
|
@@ -522,7 +523,7 @@ class O {
|
|
|
522
523
|
},
|
|
523
524
|
symbol: this.getCrossGraphicSymbol(o, "marker")
|
|
524
525
|
});
|
|
525
|
-
t.push(
|
|
526
|
+
t.push(n);
|
|
526
527
|
}
|
|
527
528
|
}
|
|
528
529
|
this.junctionLayer.addMany(t);
|
|
@@ -536,7 +537,7 @@ class O {
|
|
|
536
537
|
const o = (c = (await this.view.hitTest(t, {
|
|
537
538
|
include: [this.laneLayer, this.junctionLayer]
|
|
538
539
|
})).results) == null ? void 0 : c.filter(
|
|
539
|
-
(
|
|
540
|
+
(n) => n.type === "graphic"
|
|
540
541
|
);
|
|
541
542
|
if (o.length === 0) {
|
|
542
543
|
this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = ""), this.view.closePopup();
|
|
@@ -544,18 +545,18 @@ class O {
|
|
|
544
545
|
}
|
|
545
546
|
const i = o[0];
|
|
546
547
|
if (this.hitGraphic = i.graphic, i.layer.id === "OpenDriveLane") {
|
|
547
|
-
const
|
|
548
|
+
const n = `${this.hitGraphic.getAttribute(
|
|
548
549
|
"roadId"
|
|
549
550
|
)}+${this.hitGraphic.getAttribute("sectionId")}`;
|
|
550
|
-
if (this.currentSectionCode ===
|
|
551
|
-
(d) => d.getAttribute("id") ===
|
|
551
|
+
if (this.currentSectionCode === n || this.selectedSectionIds.includes(n) || this.sectionLayer.graphics.findIndex(
|
|
552
|
+
(d) => d.getAttribute("id") === n
|
|
552
553
|
) >= 0)
|
|
553
554
|
return;
|
|
554
|
-
this.currentSectionCode =
|
|
555
|
-
const
|
|
556
|
-
(d) => `${d.attributes.roadId}+${d.attributes.sectionId}` ===
|
|
555
|
+
this.currentSectionCode = n;
|
|
556
|
+
const r = this.allLaneGraphics.filter(
|
|
557
|
+
(d) => `${d.attributes.roadId}+${d.attributes.sectionId}` === n
|
|
557
558
|
), l = L.union(
|
|
558
|
-
|
|
559
|
+
r.map((d) => d.geometry)
|
|
559
560
|
), h = this.hitGraphic.getAttribute("fromNode"), p = this.hitGraphic.getAttribute("toNode"), y = this.junctionNames.get(h) || h, m = this.junctionNames.get(p) || p, f = new g({
|
|
560
561
|
geometry: l,
|
|
561
562
|
symbol: {
|
|
@@ -569,11 +570,11 @@ class O {
|
|
|
569
570
|
},
|
|
570
571
|
attributes: {
|
|
571
572
|
type: "OpenDriveSection",
|
|
572
|
-
id:
|
|
573
|
+
id: n,
|
|
573
574
|
selected: !1,
|
|
574
575
|
fromNodeName: y,
|
|
575
576
|
toNodeName: m,
|
|
576
|
-
laneCount:
|
|
577
|
+
laneCount: r.length
|
|
577
578
|
},
|
|
578
579
|
popupTemplate: {
|
|
579
580
|
title: this.hitGraphic.getAttribute("roadName"),
|
|
@@ -600,10 +601,10 @@ class O {
|
|
|
600
601
|
});
|
|
601
602
|
this.highlightLayer.removeAll(), this.highlightLayer.add(f);
|
|
602
603
|
} else if (i.layer.id === "OpenDriveJunction") {
|
|
603
|
-
const
|
|
604
|
-
if (
|
|
604
|
+
const n = this.hitGraphic.getAttribute("id");
|
|
605
|
+
if (n === this.currentJunctionId)
|
|
605
606
|
return;
|
|
606
|
-
this.currentJunctionId =
|
|
607
|
+
this.currentJunctionId = n;
|
|
607
608
|
}
|
|
608
609
|
});
|
|
609
610
|
this.mouseMoveHandler = this.view.on("pointer-move", async (t) => {
|
|
@@ -620,22 +621,22 @@ class O {
|
|
|
620
621
|
const o = (a = (await this.view.hitTest(t, {
|
|
621
622
|
include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
|
|
622
623
|
})).results) == null ? void 0 : a.filter(
|
|
623
|
-
(
|
|
624
|
+
(r) => r.type === "graphic"
|
|
624
625
|
);
|
|
625
626
|
if (o.length === 0)
|
|
626
627
|
return;
|
|
627
|
-
const i = o[0].graphic, c = i.getAttribute("type"),
|
|
628
|
+
const i = o[0].graphic, c = i.getAttribute("type"), n = i.getAttribute("id");
|
|
628
629
|
if (c === "OpenDriveJunction")
|
|
629
630
|
if (i.getAttribute("selected") === !1) {
|
|
630
|
-
const
|
|
631
|
+
const r = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, l = await b.get(r, {
|
|
631
632
|
params: {
|
|
632
|
-
id:
|
|
633
|
+
id: n,
|
|
633
634
|
projectName: this.projectName
|
|
634
635
|
}
|
|
635
636
|
});
|
|
636
637
|
l.status === 200 && l.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
|
|
637
638
|
type: "OpenDriveJunction",
|
|
638
|
-
id:
|
|
639
|
+
id: n,
|
|
639
640
|
details: l.data.result
|
|
640
641
|
}), i.setAttribute("selected", !0), i.symbol = {
|
|
641
642
|
type: "picture-marker",
|
|
@@ -646,7 +647,7 @@ class O {
|
|
|
646
647
|
} else
|
|
647
648
|
this.openDriveClickCallback && this.openDriveClickCallback({
|
|
648
649
|
type: "OpenDriveJunction",
|
|
649
|
-
id:
|
|
650
|
+
id: n,
|
|
650
651
|
details: void 0
|
|
651
652
|
}), i.setAttribute("selected", !1), i.symbol = this.getCrossGraphicSymbol(
|
|
652
653
|
i.attributes,
|
|
@@ -654,10 +655,10 @@ class O {
|
|
|
654
655
|
);
|
|
655
656
|
else if (c === "OpenDriveSection")
|
|
656
657
|
if (i.layer.id === "OpenDriveHighlight") {
|
|
657
|
-
this.highlightLayer.remove(i), this.sectionLayer.add(i), i.setAttribute("selected", !0), this.selectedSectionIds.push(
|
|
658
|
-
const
|
|
658
|
+
this.highlightLayer.remove(i), this.sectionLayer.add(i), i.setAttribute("selected", !0), this.selectedSectionIds.push(n);
|
|
659
|
+
const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, l = await b.get(r, {
|
|
659
660
|
params: {
|
|
660
|
-
id:
|
|
661
|
+
id: n,
|
|
661
662
|
projectName: this.projectName
|
|
662
663
|
}
|
|
663
664
|
});
|
|
@@ -671,7 +672,7 @@ class O {
|
|
|
671
672
|
}
|
|
672
673
|
} else
|
|
673
674
|
this.sectionLayer.remove(i), this.selectedSectionIds = this.selectedSectionIds.filter(
|
|
674
|
-
(
|
|
675
|
+
(r) => r !== n
|
|
675
676
|
), this.openDriveClickCallback && this.openDriveClickCallback({
|
|
676
677
|
type: "OpenDriveSection",
|
|
677
678
|
id: i.getAttribute("edgeId"),
|
|
@@ -738,7 +739,7 @@ class O {
|
|
|
738
739
|
if (i) {
|
|
739
740
|
const c = `${s}+${i.getAttribute(
|
|
740
741
|
"sectionId"
|
|
741
|
-
)}`,
|
|
742
|
+
)}`, n = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, a = await b.get(n, {
|
|
742
743
|
params: {
|
|
743
744
|
id: c,
|
|
744
745
|
projectName: this.projectName
|
|
@@ -780,11 +781,11 @@ class O {
|
|
|
780
781
|
const i = s.split("_");
|
|
781
782
|
if (i.length > 2)
|
|
782
783
|
return { status: -1, message: "id格式错误" };
|
|
783
|
-
const c = i.length === 2 ? Number(i[1]) : void 0,
|
|
784
|
-
if (
|
|
784
|
+
const c = i.length === 2 ? Number(i[1]) : void 0, n = i[0].split("#");
|
|
785
|
+
if (n.length > 2)
|
|
785
786
|
return { status: -1, message: "id格式错误" };
|
|
786
|
-
const a =
|
|
787
|
-
return await this.findLane({ roadsectId: a, segmentId:
|
|
787
|
+
const a = n[0], r = n.length === 2 ? Number(n[1]) : void 0;
|
|
788
|
+
return await this.findLane({ roadsectId: a, segmentId: r, laneId: c, flash: o });
|
|
788
789
|
} else
|
|
789
790
|
return { status: -1, message: "未知类型" };
|
|
790
791
|
}
|
|
@@ -827,32 +828,32 @@ class O {
|
|
|
827
828
|
return { status: -1, message: "未找到。请检查路段编号" };
|
|
828
829
|
if (s !== void 0) {
|
|
829
830
|
const a = [];
|
|
830
|
-
if (i.forEach((
|
|
831
|
-
const l = Number(
|
|
831
|
+
if (i.forEach((r) => {
|
|
832
|
+
const l = Number(r.attributes.sectionId);
|
|
832
833
|
a.indexOf(l) === -1 && a.push(l);
|
|
833
|
-
}), a.sort((
|
|
834
|
+
}), a.sort((r, l) => r - l), s > a.length - 1)
|
|
834
835
|
return { status: -1, message: "未找到。请检查基本段编号" };
|
|
835
836
|
s = a[s], i = i.filter(
|
|
836
|
-
(
|
|
837
|
+
(r) => Number(r.attributes.sectionId) === s
|
|
837
838
|
);
|
|
838
839
|
}
|
|
839
840
|
if (o !== void 0) {
|
|
840
841
|
const a = [];
|
|
841
|
-
if (i.forEach((
|
|
842
|
-
const l = Number(
|
|
842
|
+
if (i.forEach((r) => {
|
|
843
|
+
const l = Number(r.attributes.laneId);
|
|
843
844
|
a.indexOf(l) === -1 && a.push(l);
|
|
844
|
-
}), a.sort((
|
|
845
|
+
}), a.sort((r, l) => r - l), o > a.length - 1)
|
|
845
846
|
return { status: -1, message: "未找到。请检查车道编号" };
|
|
846
847
|
o = a[o], i = i.filter(
|
|
847
|
-
(
|
|
848
|
+
(r) => Number(r.attributes.laneId) === o
|
|
848
849
|
);
|
|
849
850
|
}
|
|
850
851
|
const c = i.map(
|
|
851
852
|
(a) => a.geometry
|
|
852
|
-
),
|
|
853
|
+
), n = L.union(c);
|
|
853
854
|
if (e.flash) {
|
|
854
855
|
const a = new g({
|
|
855
|
-
geometry:
|
|
856
|
+
geometry: n,
|
|
856
857
|
symbol: {
|
|
857
858
|
type: "simple-fill",
|
|
858
859
|
color: [0, 255, 255, 0.6],
|
|
@@ -864,7 +865,7 @@ class O {
|
|
|
864
865
|
});
|
|
865
866
|
this.flashGraphic(a);
|
|
866
867
|
}
|
|
867
|
-
return await this.view.goTo(
|
|
868
|
+
return await this.view.goTo(n, { duration: 1e3 }), { status: 0, message: "ok" };
|
|
868
869
|
}
|
|
869
870
|
/**
|
|
870
871
|
* graphic渐隐渐显闪烁
|
|
@@ -924,14 +925,14 @@ class O {
|
|
|
924
925
|
(c) => c.getAttribute("roadId") === s && c.getAttribute("sectionIndex") === o
|
|
925
926
|
)), i.length > 0) {
|
|
926
927
|
const c = /* @__PURE__ */ new Map();
|
|
927
|
-
return i.forEach((
|
|
928
|
-
const a =
|
|
928
|
+
return i.forEach((n) => {
|
|
929
|
+
const a = n.getAttribute("roadId") + "+" + n.getAttribute("sectionId");
|
|
929
930
|
this.selectedSectionIds.includes(a) || this.selectedSectionIds.push(a);
|
|
930
|
-
let
|
|
931
|
-
|
|
932
|
-
}), c.forEach(async (
|
|
933
|
-
const
|
|
934
|
-
geometry:
|
|
931
|
+
let r = c.get(a);
|
|
932
|
+
r ? r.push(n.geometry) : (r = [n.geometry], c.set(a, r));
|
|
933
|
+
}), c.forEach(async (n, a) => {
|
|
934
|
+
const r = L.union(n), l = new g({
|
|
935
|
+
geometry: r,
|
|
935
936
|
symbol: {
|
|
936
937
|
type: "simple-fill",
|
|
937
938
|
color: [0, 255, 255, 0.5],
|
|
@@ -965,7 +966,7 @@ class O {
|
|
|
965
966
|
outFields: ["*"]
|
|
966
967
|
}), o = [], i = [];
|
|
967
968
|
for (const a of s.features) {
|
|
968
|
-
const
|
|
969
|
+
const r = a.getAttribute("roadId"), l = a.getAttribute("sectionIndex"), h = `${r}#${l}`;
|
|
969
970
|
if (o.indexOf(h) === -1) {
|
|
970
971
|
o.push(h), this.selectSumo({
|
|
971
972
|
type: "edge",
|
|
@@ -973,7 +974,7 @@ class O {
|
|
|
973
974
|
});
|
|
974
975
|
const p = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, y = await b.get(p, {
|
|
975
976
|
params: {
|
|
976
|
-
id: `${
|
|
977
|
+
id: `${r}+${a.getAttribute("sectionId")}`,
|
|
977
978
|
projectName: this.projectName
|
|
978
979
|
}
|
|
979
980
|
});
|
|
@@ -981,28 +982,28 @@ class O {
|
|
|
981
982
|
}
|
|
982
983
|
}
|
|
983
984
|
const c = this.junctionLayer.graphics.filter((a) => {
|
|
984
|
-
const
|
|
985
|
-
return L.contains(t,
|
|
986
|
-
}),
|
|
985
|
+
const r = a.geometry;
|
|
986
|
+
return L.contains(t, r);
|
|
987
|
+
}), n = [];
|
|
987
988
|
for (const a of c) {
|
|
988
|
-
const
|
|
989
|
+
const r = a.getAttribute("id");
|
|
989
990
|
this.selectSumo({
|
|
990
991
|
type: "junction",
|
|
991
|
-
id:
|
|
992
|
+
id: r
|
|
992
993
|
});
|
|
993
994
|
const l = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, h = await b.get(l, {
|
|
994
995
|
params: {
|
|
995
|
-
id:
|
|
996
|
+
id: r,
|
|
996
997
|
projectName: this.projectName
|
|
997
998
|
}
|
|
998
999
|
});
|
|
999
|
-
h.status === 200 && h.data.status === 0 &&
|
|
1000
|
+
h.status === 200 && h.data.status === 0 && n.push(h.data.result);
|
|
1000
1001
|
}
|
|
1001
1002
|
return {
|
|
1002
1003
|
status: 0,
|
|
1003
1004
|
message: "ok",
|
|
1004
1005
|
result: {
|
|
1005
|
-
junctions:
|
|
1006
|
+
junctions: n,
|
|
1006
1007
|
edges: i
|
|
1007
1008
|
}
|
|
1008
1009
|
};
|
|
@@ -1012,13 +1013,13 @@ class O {
|
|
|
1012
1013
|
if (s.length !== 2)
|
|
1013
1014
|
return { status: -1, message: "车道编号格式错误" };
|
|
1014
1015
|
const o = Number(s[1]), i = s[0].split("#"), c = i.length === 2 ? Number(i[1]) : 0;
|
|
1015
|
-
let
|
|
1016
|
-
|
|
1017
|
-
const a = this.allLaneGraphics.filter((I) => I.getAttribute("roadId") ===
|
|
1016
|
+
let n = i[0];
|
|
1017
|
+
n.startsWith("-") && (n = n.slice(1));
|
|
1018
|
+
const a = this.allLaneGraphics.filter((I) => I.getAttribute("roadId") === n && I.getAttribute("sectionIndex") === c);
|
|
1018
1019
|
if (a.length === 0)
|
|
1019
1020
|
return { status: -1, message: "未找到路段" };
|
|
1020
|
-
const
|
|
1021
|
-
(I) => Math.abs(I.getAttribute("laneId")) ===
|
|
1021
|
+
const r = a.length - o, l = a.find(
|
|
1022
|
+
(I) => Math.abs(I.getAttribute("laneId")) === r
|
|
1022
1023
|
);
|
|
1023
1024
|
if (!l)
|
|
1024
1025
|
return { status: -1, message: "未找到车道" };
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -307,7 +307,10 @@ export interface IEditSignalControlAreaParams {
|
|
|
307
307
|
export interface IShowGreenWaveBandParams {
|
|
308
308
|
bandId: string;
|
|
309
309
|
coordinates: number[][];
|
|
310
|
-
nodeList
|
|
310
|
+
nodeList?: INode[];
|
|
311
|
+
lineColor?: string | number[];
|
|
312
|
+
lineWidth?: number;
|
|
313
|
+
arrowColor?: string | number[];
|
|
311
314
|
}
|
|
312
315
|
export interface IRoadLine {
|
|
313
316
|
id: string;
|
|
@@ -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 b=require("@arcgis/core/core/reactiveUtils.js"),m=require("@arcgis/core/geometry"),c=require("@arcgis/core/Graphic"),y=require("@arcgis/core/layers/GraphicsLayer"),u=require("axios");function g(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>n[s]})}}return e.default=n,Object.freeze(e)}const p=g(b);class f{constructor(e){this.selectedNodeIds=[],this.nodeScale=5e3,this.hasGpu=!1,this.hasGpu=localStorage.getItem("gpu")!=="Unknown",this.view=e,this.roadsectLayer=new y({id:"roadsectLayer"}),this.view.map.add(this.roadsectLayer),this.allNodesLayer=new y({id:"allNodesLayer"}),this.view.map.add(this.allNodesLayer),this.bandLayer=new y({id:"bandLayer"}),this.view.map.add(this.bandLayer)}addGreenWaveBand(e){this.addNodeCallback=e.addCrossCallback,this.removeNodeCallback=e.removeCrossCallback,e.removeAllCrossCallback&&(this.removeAllNodeCallback=e.removeAllCrossCallback),this.selectedNodeIds=[],this.openDriveServer=e.odrServer,this.showAllNodes(e.crossesInArea),this.viewClickWatcher||(this.viewClickWatcher=this.view.on("click",s=>{this.handleViewClick(s)}))}stopAddGreenWaveBand(){var e;(e=this.viewClickWatcher)==null||e.remove(),this.viewClickWatcher=void 0,this.allNodesLayer.removeAll(),this.selectedNodeIds=[],this.roadsectLayer.removeAll(),this.bandLayer.removeAll()}async showGreenWaveBand(e){this.bandLayer.graphics.forEach(t=>{t.getAttribute("bandId")===e.bandId&&this.bandLayer.remove(t)}),this.roadsectLayer.graphics.forEach(t=>{t.getAttribute("bandId")===e.bandId&&this.roadsectLayer.remove(t)}),this.scaleWatcher||(this.scaleWatcher=p.watch(()=>this.view.scale,(t,o)=>{t>this.nodeScale&&o<=this.nodeScale?this.bandLayer.graphics.forEach(a=>{a.geometry.type==="point"&&(a.symbol=this.getShowNodeSymbol("marker"))}):t<=this.nodeScale&&o>this.nodeScale&&this.bandLayer.graphics.forEach(a=>{a.geometry.type==="point"&&(a.symbol=this.getShowNodeSymbol("picture"))})}));const s=new m.Polyline({paths:[e.coordinates]}),i=new c({geometry:s,symbol:this.getLineSymbol(!0,e),attributes:{bandId:e.bandId,type:"greenWaveBand",id:e.bandId}});this.roadsectLayer.add(i),await this.view.goTo(i),e.nodeList&&e.nodeList.forEach(t=>{const o=new c({geometry:{type:"point",x:t.longitude,y:t.latitude},symbol:this.getShowNodeSymbol("picture"),attributes:{...t,bandId:e.bandId,type:"greenWaveBandNode"}});this.bandLayer.add(o)})}showAllNodes(e){const s=[];e.forEach(i=>{s.push(new c({geometry:{type:"point",x:i.longitude,y:i.latitude},symbol:this.getEditableNodeSymbol(!1),attributes:{...i,selected:!1}}))}),this.allNodesLayer.addMany(s)}async handleViewClick(e){var a;const i=(a=(await this.view.hitTest(e,{include:[this.allNodesLayer]})).results)==null?void 0:a.filter(d=>d.type==="graphic");if(i.length===0)return;const t=i[0].graphic,o=t.getAttribute("id");if(this.selectedNodeIds.includes(o)){const d=this.selectedNodeIds.indexOf(o)+1;if(d===1)this.removeAllNodeCallback&&this.removeAllNodeCallback(),this.selectedNodeIds=[],this.allNodesLayer.graphics.forEach(r=>{r.setAttribute("selected",!1),r.symbol=this.getEditableNodeSymbol(!1),r.visible=!0}),this.roadsectLayer.removeAll();else{for(let r=d;r<this.selectedNodeIds.length;r++){this.removeNodeCallback&&this.removeNodeCallback({id:this.selectedNodeIds[r]});for(let l=0;l<this.roadsectLayer.graphics.length;l++){const h=this.roadsectLayer.graphics.getItemAt(l);(h.getAttribute("id")===this.selectedNodeIds[r]||!h.getAttribute("selected"))&&(this.roadsectLayer.remove(h),l--)}}this.selectedNodeIds=this.selectedNodeIds.slice(0,d),this.allNodesLayer.graphics.forEach(r=>{const l=this.selectedNodeIds.includes(r.getAttribute("id"));r.setAttribute("selected",l),r.symbol=this.getEditableNodeSymbol(l),r.visible=l}),await this.showDownstreamNodes(o)}}else{t.setAttribute("selected",!0),t.symbol=this.getEditableNodeSymbol(!0),this.selectedNodeIds.push(o),this.allNodesLayer.graphics.forEach(r=>{r.visible=r.getAttribute("selected")});let d=[];for(let r=0;r<this.roadsectLayer.graphics.length;r++){const l=this.roadsectLayer.graphics.getItemAt(r);l.getAttribute("id")===o?(l.symbol=this.getLineSymbol(!0),l.setAttribute("selected",!0),d=l.geometry.paths[0]):l.getAttribute("selected")||(this.roadsectLayer.remove(l),r--)}this.addNodeCallback&&this.addNodeCallback({...t.attributes,roadsect:d}),await this.showDownstreamNodes(o)}}async showDownstreamNodes(e){this.view.container.style.cursor="progress";const s=await u.get(`http://${this.openDriveServer}/api/computable/getDownstreamNodes`,{params:{nodeId:e}});if(s.status!==200||s.data.status!==0){this.view.container.style.cursor="default";return}s.data.result.forEach(t=>{this.allNodesLayer.graphics.forEach(o=>{if(o.getAttribute("nodeId")===t.id&&o.getAttribute("selected")===!1&&(o.visible=!0,t.coordinates)){const a=new c({geometry:{type:"polyline",paths:[t.coordinates]},symbol:this.getLineSymbol(!1),attributes:{...t,selected:!1}});this.roadsectLayer.add(a)}})}),this.view.container.style.cursor="default"}getLineSymbol(e,s){if(e){const i=(s==null?void 0:s.lineWidth)||4,t=(s==null?void 0:s.lineColor)||[55,125,34,255],o=(s==null?void 0:s.arrowColor)||[255,255,255,255];return Array.isArray(t)&&t.length===3&&t.push(255),Array.isArray(o)&&o.length===3&&o.push(255),{type:"cim",data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,size:4,markerPlacement:{type:"CIMMarkerPlacementAlongLineSameSize",endings:"WithMarkers",placementTemplate:[40],angleToLine:!0},frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[i,-i],[3*i,0],[i,i]],[[-i,i],[-3*i,0],[-i,-i]]]},symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,width:1.5,color:o}]}}]},{type:"CIMSolidStroke",enable:!0,width:i,color:t}]}}}}else return{type:"simple-line",color:"gray",width:2}}getShowNodeSymbol(e){return e==="marker"?{type:"simple-marker",style:"circle",color:[61,139,249],size:8,outline:{color:"white",width:1}}:this.getEditableNodeSymbol(!0)}getEditableNodeSymbol(e){return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:30,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:20,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:25,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/cross/${e?"gis_xhj_blue":"gis_xhj_gray"}.png`}]}}}}}exports.default=f;
|
|
@@ -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"),S=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),E=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),T=require("md5"),O=require("pako"),_=require("vue"),z=require("../../stores/index.js"),H=require("../common-utils.js");function N(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=N(F),U=N(J),A=N(q),P=N(E);class D{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 D(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,g;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(u,h)=>{u>this.junctionScale&&h<=this.junctionScale?this.updateAllJunctionSymbol("marker"):u<=this.junctionScale&&h>this.junctionScale&&this.updateAllJunctionSymbol("picture")});let t=e.file.split("/").pop()||"";t=t.split(".").slice(0,-1).join("."),console.log(`OpenDriveRenderer: 显示OpenDrive文件 ${t}`),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:t}})}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;H.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);if(await this.showAllLanes(l,((y=e.options)==null?void 0:y.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0),((g=e.options)==null?void 0:g.showJunctionPoint)!==!1){const u=o.data.result.junctions;this.showJunction(u)}e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const p=z.default.useAppDataStore;return _.watch(()=>p.isSketching,()=>{var u,h;p.isSketching?((u=this.mouseMoveHandler)==null||u.remove(),this.mouseMoveHandler=void 0,(h=this.mouseClickHandler)==null||h.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 p=n.name;p.includes("(")&&(p=p.slice(0,p.indexOf("("))),p=p.replace(/(.)/g,"$1 ");const y=new f({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:p}});this.allRefLineGraphics.push(y),n.laneSections.sort((m,g)=>Number(m.id)-Number(g.id));for(let m=0;m<n.laneSections.length;m++){const g=n.laneSections[m],u=Number(g.id);for(const h of g.lanePaths){const v=Number(h.id);if(v===0)continue;const I=h.type,$=[...h.outerPath],j=h.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(h.innerPath[0]);const k=new S.Polygon({rings:[j]});if(k){const C=new f({geometry:k,attributes:{ObjectID:c++,id:`${l}+${u}+${v}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(l),roadName:n.name,sectionId:String(u),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:h.innerPath,rightLine:h.outerPath}});this.allLaneGraphics.push(C),r.push(C)}}}}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 S.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 S.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(u=>u.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===r),l=A.union(n.map(u=>u.geometry)),d=this.hitGraphic.getAttribute("fromNode"),p=this.hitGraphic.getAttribute("toNode"),y=this.junctionNames.get(d)||d,m=this.junctionNames.get(p)||p,g=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(g)}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:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}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"}}async 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(async(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),await this.view.goTo(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new S.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 p=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,y=await b.get(p,{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,p=e.end||100,y=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(y,d,p,{units:"meters"}),g=P.lineString(l.getAttribute("rightLine")),u=G.lineSliceAlong(g,d,p,{units:"meters"}),h=m.geometry.coordinates.concat(u.geometry.coordinates.reverse());h.push(h[h.length-1]);const v=new f({geometry:new S.Polygon({rings:[h]}),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:u.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:h}}}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/cross/${i?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};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?25:15,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:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=D;
|
|
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"),S=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),E=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),T=require("md5"),O=require("pako"),_=require("vue"),z=require("../../stores/index.js"),H=require("../common-utils.js");function N(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=N(F),U=N(J),A=N(q),P=N(E);class D{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 D(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let n=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return n?n=JSON.parse(n):n=[],{status:0,message:"ok",result:{md5:T(o),border:n}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var y,m,g;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(u,h)=>{u>this.junctionScale&&h<=this.junctionScale?this.updateAllJunctionSymbol("marker"):u<=this.junctionScale&&h>this.junctionScale&&this.updateAllJunctionSymbol("picture")});let t=e.file.split("/").pop()||"";t=t.split(".").slice(0,-1).join("."),console.log(`OpenDriveRenderer: 显示OpenDrive文件 ${t}`),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:t}})}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;H.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(),r=O.inflate(a,{to:"string"}),l=JSON.parse(r);if(await this.showAllLanes(l,((y=e.options)==null?void 0:y.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0),((g=e.options)==null?void 0:g.showJunctionPoint)!==!1){const u=o.data.result.junctions;this.showJunction(u)}e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const p=z.default.useAppDataStore;return _.watch(()=>p.isSketching,()=>{var u,h;p.isSketching?((u=this.mouseMoveHandler)==null||u.remove(),this.mouseMoveHandler=void 0,(h=this.mouseClickHandler)==null||h.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 n=await(await fetch(s)).arrayBuffer(),a=O.inflate(n,{to:"string"}),r=JSON.parse(a);return console.log(r),await this.showAllLanes(r,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){console.log(e);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 n=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:l,refLine:d}=r;let p=r.name;p.includes("(")&&(p=p.slice(0,p.indexOf("("))),p=p.replace(/(.)/g,"$1 ");const y=new f({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:p}});this.allRefLineGraphics.push(y),r.laneSections.sort((m,g)=>Number(m.id)-Number(g.id));for(let m=0;m<r.laneSections.length;m++){const g=r.laneSections[m],u=Number(g.id);for(const h of g.lanePaths){const v=Number(h.id);if(v===0)continue;const I=h.type,$=[...h.outerPath],j=h.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(h.innerPath[0]);const k=new S.Polygon({rings:[j]});if(k){const C=new f({geometry:k,attributes:{ObjectID:c++,id:`${l}+${u}+${v}`,fromNode:r.fromNode,toNode:r.toNode,roadId:String(l),roadName:r.name,sectionId:String(u),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:h.innerPath,rightLine:h.outerPath}});this.allLaneGraphics.push(C),n.push(C)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const r=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:r})}if(this.allRefLineGraphics.length>0){const r=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:r})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];let i;this.xodrBorder.length>0&&(i=new S.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 S.Point({x:o.coordinates[0],y:o.coordinates[1]});let c=!0;if(i&&(c=A.contains(i,s)),c){const n=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(n)}}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(n=>n.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 n=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===n||this.selectedSectionIds.includes(n)||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const r=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),l=A.union(r.map(u=>u.geometry)),d=this.hitGraphic.getAttribute("fromNode"),p=this.hitGraphic.getAttribute("toNode"),y=this.junctionNames.get(d)||d,m=this.junctionNames.get(p)||p,g=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:n,selected:!1,fromNodeName:y,toNodeName:m,laneCount:r.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(g)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n}});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(r=>r.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),n=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(r,{params:{id:n,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,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:n,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(n);const r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(r,{params:{id:n,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(r=>r!==n),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")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(n,{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:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}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,n=s[0].split("#");if(n.length>2)return{status:-1,message:"id格式错误"};const a=n[0],r=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:r,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(r=>{const l=Number(r.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((r,l)=>r-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(r=>Number(r.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(r=>{const l=Number(r.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((r,l)=>r-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(r=>Number(r.attributes.laneId)===o)}const c=s.map(a=>a.geometry),n=A.union(c);if(e.flash){const a=new f({geometry:n,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(n,{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"}}async 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(n=>{const a=n.getAttribute("roadId")+"+"+n.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let r=c.get(a);r?r.push(n.geometry):(r=[n.geometry],c.set(a,r))}),c.forEach(async(n,a)=>{const r=A.union(n),l=new f({geometry:r,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),await this.view.goTo(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new S.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const r=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${r}#${l}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const p=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,y=await b.get(p,{params:{id:`${r}+${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 r=a.geometry;return A.contains(t,r)}),n=[];for(const a of c){const r=a.getAttribute("id");this.selectSumo({type:"junction",id:r});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:r,projectName:this.projectName}});d.status===200&&d.data.status===0&&n.push(d.data.result)}return{status:0,message:"ok",result:{junctions:n,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 n=s[0];n.startsWith("-")&&(n=n.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===n&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const r=a.length-o,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===r);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,p=e.end||100,y=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(y,d,p,{units:"meters"}),g=P.lineString(l.getAttribute("rightLine")),u=G.lineSliceAlong(g,d,p,{units:"meters"}),h=m.geometry.coordinates.concat(u.geometry.coordinates.reverse());h.push(h[h.length-1]);const v=new f({geometry:new S.Polygon({rings:[h]}),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:u.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:h}}}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/cross/${i?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};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?25:15,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:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=D;
|
package/lib/src/types/index.d.ts
CHANGED
|
@@ -307,7 +307,10 @@ export interface IEditSignalControlAreaParams {
|
|
|
307
307
|
export interface IShowGreenWaveBandParams {
|
|
308
308
|
bandId: string;
|
|
309
309
|
coordinates: number[][];
|
|
310
|
-
nodeList
|
|
310
|
+
nodeList?: INode[];
|
|
311
|
+
lineColor?: string | number[];
|
|
312
|
+
lineWidth?: number;
|
|
313
|
+
arrowColor?: string | number[];
|
|
311
314
|
}
|
|
312
315
|
export interface IRoadLine {
|
|
313
316
|
id: string;
|