gisviewer-vue3-arcgis 1.0.217 → 1.0.218
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/signal-control-area-controller/show-area.d.ts +9 -0
- package/es/src/gis-map/utils/signal-control-area-controller/show-area.mjs +197 -120
- package/lib/src/gis-map/utils/signal-control-area-controller/show-area.d.ts +9 -0
- package/lib/src/gis-map/utils/signal-control-area-controller/show-area.js +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,9 @@ import { IFindSignalControlAreaParams, ILayerVisibleParams, IResult, IShowSignal
|
|
|
2
2
|
export default class SignalControlAreaController1 {
|
|
3
3
|
private view;
|
|
4
4
|
private hasGpu;
|
|
5
|
+
/** 支队图层 */
|
|
6
|
+
private detachmentLayer;
|
|
7
|
+
private detachmentLayerLoaded;
|
|
5
8
|
/** 区控虚线图层 */
|
|
6
9
|
private districtControllerDashLayer;
|
|
7
10
|
/** 区控实线图层,区控符号由半透明实线+不透明虚线组成 */
|
|
@@ -19,6 +22,7 @@ export default class SignalControlAreaController1 {
|
|
|
19
22
|
private subDistrictControllerOid;
|
|
20
23
|
private signalOid;
|
|
21
24
|
private popupEnabled;
|
|
25
|
+
private mapConfig;
|
|
22
26
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
23
27
|
/** 暂存等待绘制的区控graphic */
|
|
24
28
|
private districtGraphics;
|
|
@@ -78,4 +82,9 @@ export default class SignalControlAreaController1 {
|
|
|
78
82
|
* 重置所有graphic的置灰状态
|
|
79
83
|
*/
|
|
80
84
|
private resetSelectedSymbol;
|
|
85
|
+
/**
|
|
86
|
+
* 加载支队图层
|
|
87
|
+
* 现场环境用url创建FeatureLayer有各种问题,改为用url创建Graphic,再将Graphic添加到FeatureLayer
|
|
88
|
+
*/
|
|
89
|
+
private loadDetachmentLayer;
|
|
81
90
|
}
|
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as L from "@arcgis/core/core/reactiveUtils";
|
|
2
|
+
import { Polygon as b } from "@arcgis/core/geometry";
|
|
3
|
+
import { webMercatorToGeographic as w } from "@arcgis/core/geometry/support/webMercatorUtils";
|
|
2
4
|
import y from "@arcgis/core/Graphic";
|
|
3
5
|
import c from "@arcgis/core/layers/FeatureLayer";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
+
import C from "@arcgis/core/layers/GraphicsLayer";
|
|
7
|
+
import E from "@turf/buffer";
|
|
8
|
+
import D from "@turf/convex";
|
|
6
9
|
import * as d from "@turf/helpers";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
10
|
+
import m from "axios";
|
|
11
|
+
import F from "concaveman";
|
|
12
|
+
import k from "../../stores/index.mjs";
|
|
13
|
+
import G from "./district-controller.mjs";
|
|
14
|
+
import { districtDashLineLayerOptions as v, districtSolidLineLayerOptions as S, subDistrictLayerOptions as x, signalMarkerLayerOptions as I, signalPictureLayerOptions as q, signalClusterLayerOptions as M } from "./layer-symbol.mjs";
|
|
15
|
+
class U {
|
|
11
16
|
constructor(t) {
|
|
12
|
-
this.districtControllerOid = 0, this.subDistrictControllerOid = 0, this.signalOid = 0, this.popupEnabled = !0, this.districtGraphics = [], this.subDistrictGraphics = [], this.signalGraphics = [], this.view = t, this.hasGpu = localStorage.getItem("gpu") !== "Unknown"
|
|
13
|
-
|
|
17
|
+
this.detachmentLayerLoaded = !1, this.districtControllerOid = 0, this.subDistrictControllerOid = 0, this.signalOid = 0, this.popupEnabled = !0, this.districtGraphics = [], this.subDistrictGraphics = [], this.signalGraphics = [], this.view = t, this.hasGpu = localStorage.getItem("gpu") !== "Unknown";
|
|
18
|
+
const e = k.useAppDataStore;
|
|
19
|
+
this.mapConfig = JSON.parse(JSON.stringify(e.mapConfig)), this.detachmentLayer = new C(), this.districtControllerDashLayer = new c(
|
|
20
|
+
v
|
|
14
21
|
), this.districtControllerDashLayer.spatialReference = t.spatialReference, this.districtControllerSolidLayer = new c(
|
|
15
|
-
|
|
22
|
+
S
|
|
16
23
|
), this.districtControllerSolidLayer.spatialReference = t.spatialReference, this.districtControllerSolidLayer.popupEnabled = this.popupEnabled, this.subDistrictControllerLayer = new c(
|
|
17
|
-
|
|
24
|
+
x
|
|
18
25
|
), this.subDistrictControllerLayer.spatialReference = t.spatialReference, this.subDistrictControllerLayer.popupEnabled = this.popupEnabled, this.signalMarkerLayer = new c(
|
|
19
|
-
|
|
26
|
+
I
|
|
20
27
|
), this.signalMarkerLayer.spatialReference = t.spatialReference, this.signalMarkerLayer.popupEnabled = this.popupEnabled, this.signalPictureLayer = new c(
|
|
21
|
-
|
|
28
|
+
q
|
|
22
29
|
), this.signalPictureLayer.spatialReference = t.spatialReference, this.signalPictureLayer.popupEnabled = this.popupEnabled, this.signalClusterLayer = new c(
|
|
23
|
-
|
|
30
|
+
M
|
|
24
31
|
), this.signalClusterLayer.spatialReference = t.spatialReference, this.signalClusterLayer.popupEnabled = this.popupEnabled, this.view.map.addMany([
|
|
32
|
+
this.detachmentLayer,
|
|
25
33
|
this.districtControllerSolidLayer,
|
|
26
34
|
this.districtControllerDashLayer,
|
|
27
35
|
this.signalMarkerLayer,
|
|
@@ -36,10 +44,10 @@ class P {
|
|
|
36
44
|
* @returns
|
|
37
45
|
*/
|
|
38
46
|
async showSignalControlArea(t) {
|
|
39
|
-
await this.clearSignalControlArea(), this.districtControllerDashLayer.visible = !1, this.districtControllerSolidLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.signalMarkerLayer.visible = !1, this.signalPictureLayer.visible = !1, this.signalClusterLayer.visible = !0;
|
|
40
|
-
for (const
|
|
41
|
-
const s = new
|
|
42
|
-
|
|
47
|
+
this.detachmentLayerLoaded || await this.loadDetachmentLayer(), await this.clearSignalControlArea(), this.districtControllerDashLayer.visible = !1, this.districtControllerSolidLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.signalMarkerLayer.visible = !1, this.signalPictureLayer.visible = !1, this.signalClusterLayer.visible = !0;
|
|
48
|
+
for (const e of t.areaList) {
|
|
49
|
+
const s = new G(
|
|
50
|
+
e,
|
|
43
51
|
t.style || ""
|
|
44
52
|
);
|
|
45
53
|
this.generateGraphic(s, !0, t.style);
|
|
@@ -98,6 +106,9 @@ class P {
|
|
|
98
106
|
case "signalCluster":
|
|
99
107
|
this.signalClusterLayer.visible = t.visible;
|
|
100
108
|
break;
|
|
109
|
+
case "shanghai_district":
|
|
110
|
+
this.detachmentLayer.visible = t.visible;
|
|
111
|
+
break;
|
|
101
112
|
}
|
|
102
113
|
return { status: 0, message: "ok" };
|
|
103
114
|
}
|
|
@@ -109,28 +120,28 @@ class P {
|
|
|
109
120
|
async locateSignalControlArea(t) {
|
|
110
121
|
switch (t.type) {
|
|
111
122
|
case "district": {
|
|
112
|
-
const
|
|
113
|
-
|
|
123
|
+
const i = this.districtControllerDashLayer.createQuery();
|
|
124
|
+
i.where = `id = '${t.id}'`, i.returnGeometry = !0, i.outFields = ["*"];
|
|
114
125
|
const r = await this.districtControllerDashLayer.queryFeatures(
|
|
115
|
-
|
|
126
|
+
i
|
|
116
127
|
);
|
|
117
128
|
return r.features.length > 0 ? (await this.view.goTo(r.features, {
|
|
118
129
|
duration: this.hasGpu ? 1e3 : 0
|
|
119
130
|
}), { status: 0, message: "ok" }) : { status: 1, message: "未找到区控" };
|
|
120
131
|
}
|
|
121
132
|
case "subDistrict":
|
|
122
|
-
const
|
|
123
|
-
|
|
133
|
+
const e = this.subDistrictControllerLayer.createQuery();
|
|
134
|
+
e.where = `id = '${t.id}'`, e.returnGeometry = !0, e.outFields = ["*"];
|
|
124
135
|
const s = await this.subDistrictControllerLayer.queryFeatures(
|
|
125
|
-
|
|
136
|
+
e
|
|
126
137
|
);
|
|
127
138
|
return s.features.length > 0 ? (await this.view.goTo(s.features, {
|
|
128
139
|
duration: this.hasGpu ? 1e3 : 0
|
|
129
140
|
}), { status: 0, message: "ok" }) : { status: 1, message: "未找到子区" };
|
|
130
141
|
case "signal": {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
const r = await this.signalMarkerLayer.queryFeatures(
|
|
142
|
+
const i = this.signalMarkerLayer.createQuery();
|
|
143
|
+
i.where = `id = '${t.id}'`, i.returnGeometry = !0, i.outFields = ["*"];
|
|
144
|
+
const r = await this.signalMarkerLayer.queryFeatures(i);
|
|
134
145
|
return r.features.length > 0 ? (await this.view.goTo(
|
|
135
146
|
{ target: r.features[0], scale: t.scale || 1e3 },
|
|
136
147
|
{
|
|
@@ -148,24 +159,24 @@ class P {
|
|
|
148
159
|
* @returns
|
|
149
160
|
*/
|
|
150
161
|
async highlightSignalControlArea(t) {
|
|
151
|
-
var
|
|
152
|
-
switch ((
|
|
162
|
+
var e;
|
|
163
|
+
switch ((e = this.view.popup) != null && e.visible && this.view.popup.close(), t.type) {
|
|
153
164
|
case "district": {
|
|
154
165
|
const s = this.districtControllerDashLayer.definitionExpression;
|
|
155
166
|
this.districtControllerDashLayer.definitionExpression = `id = '${t.id}'`;
|
|
156
|
-
const
|
|
157
|
-
return
|
|
167
|
+
const i = await this.districtControllerDashLayer.queryFeatures();
|
|
168
|
+
return i.features.length > 0 ? (this.districtControllerSolidLayer.definitionExpression = `id = '${t.id}'`, this.subDistrictControllerLayer.definitionExpression = `parentId = '${t.id}'`, this.signalMarkerLayer.definitionExpression = `districtId = '${t.id}'`, this.signalPictureLayer.definitionExpression = `districtId = '${t.id}'`, this.signalClusterLayer.definitionExpression = `districtId = '${t.id}'`, await this.view.goTo(i.features, {
|
|
158
169
|
duration: this.hasGpu ? 1e3 : 0
|
|
159
170
|
}), { status: 0, message: "ok" }) : (this.districtControllerDashLayer.definitionExpression = s, { status: 1, message: "未找到区控" });
|
|
160
171
|
}
|
|
161
172
|
case "subDistrict": {
|
|
162
173
|
const s = this.subDistrictControllerLayer.definitionExpression;
|
|
163
174
|
this.subDistrictControllerLayer.definitionExpression = `id = '${t.id}'`;
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
175
|
+
const i = await this.subDistrictControllerLayer.queryFeatures();
|
|
176
|
+
if (i.features.length > 0) {
|
|
166
177
|
this.signalMarkerLayer.definitionExpression = `subDistrictId = '${t.id}'`, this.signalPictureLayer.definitionExpression = `subDistrictId = '${t.id}'`, this.signalClusterLayer.definitionExpression = `subDistrictId = '${t.id}'`;
|
|
167
|
-
const
|
|
168
|
-
return this.districtControllerDashLayer.definitionExpression = `id = '${
|
|
178
|
+
const o = i.features[0].attributes.parentId;
|
|
179
|
+
return this.districtControllerDashLayer.definitionExpression = `id = '${o}'`, this.districtControllerSolidLayer.definitionExpression = `id = '${o}'`, await this.view.goTo(i.features, {
|
|
169
180
|
duration: this.hasGpu ? 1e3 : 0
|
|
170
181
|
}), { status: 0, message: "ok" };
|
|
171
182
|
} else
|
|
@@ -174,12 +185,12 @@ class P {
|
|
|
174
185
|
case "signal": {
|
|
175
186
|
const s = this.signalMarkerLayer.definitionExpression;
|
|
176
187
|
this.signalMarkerLayer.definitionExpression = `id = '${t.id}'`;
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
188
|
+
const i = await this.signalMarkerLayer.queryFeatures();
|
|
189
|
+
if (i.features.length > 0) {
|
|
179
190
|
this.signalPictureLayer.definitionExpression = `id = '${t.id}'`, this.signalClusterLayer.definitionExpression = `id = '${t.id}'`;
|
|
180
|
-
const r =
|
|
181
|
-
return this.districtControllerDashLayer.definitionExpression = `id = '${
|
|
182
|
-
{ target:
|
|
191
|
+
const r = i.features[0], { districtId: o, subDistrictId: h } = r.attributes;
|
|
192
|
+
return this.districtControllerDashLayer.definitionExpression = `id = '${o}'`, this.districtControllerSolidLayer.definitionExpression = `id = '${o}'`, this.subDistrictControllerLayer.definitionExpression = `id = '${h}'`, await this.view.goTo(
|
|
193
|
+
{ target: i.features, scale: t.scale || 1e3 },
|
|
183
194
|
{
|
|
184
195
|
duration: this.hasGpu ? 1e3 : 0
|
|
185
196
|
}
|
|
@@ -208,42 +219,42 @@ class P {
|
|
|
208
219
|
* @param isDistrict 是否是区控
|
|
209
220
|
* @returns
|
|
210
221
|
*/
|
|
211
|
-
generateGraphic(t,
|
|
212
|
-
const
|
|
222
|
+
generateGraphic(t, e, s) {
|
|
223
|
+
const i = t.getAllSignalCoordinates();
|
|
213
224
|
let r = null;
|
|
214
|
-
if (
|
|
215
|
-
if (
|
|
216
|
-
r = d.lineString(
|
|
225
|
+
if (i.length >= 2)
|
|
226
|
+
if (i.length === 2)
|
|
227
|
+
r = d.lineString(i);
|
|
217
228
|
else {
|
|
218
|
-
if (
|
|
219
|
-
const
|
|
220
|
-
|
|
229
|
+
if (e) {
|
|
230
|
+
const a = d.featureCollection(
|
|
231
|
+
i.map((n) => d.point(n))
|
|
221
232
|
);
|
|
222
|
-
r =
|
|
233
|
+
r = D(a);
|
|
223
234
|
} else {
|
|
224
|
-
const
|
|
225
|
-
|
|
235
|
+
const a = F(i, 0.5);
|
|
236
|
+
a.length >= 4 && (r = d.polygon([a]));
|
|
226
237
|
}
|
|
227
|
-
r || (r = d.lineString(
|
|
238
|
+
r || (r = d.lineString(i));
|
|
228
239
|
}
|
|
229
|
-
else if (
|
|
230
|
-
r = d.point(
|
|
240
|
+
else if (i.length === 1)
|
|
241
|
+
r = d.point(i[0]);
|
|
231
242
|
else
|
|
232
243
|
return;
|
|
233
|
-
const
|
|
244
|
+
const o = E(
|
|
234
245
|
r.geometry,
|
|
235
246
|
// 区控面积更大,需要更大的缓冲半径
|
|
236
|
-
|
|
247
|
+
e ? 200 : 30,
|
|
237
248
|
{
|
|
238
249
|
units: "meters"
|
|
239
250
|
}
|
|
240
|
-
),
|
|
251
|
+
), h = new y({
|
|
241
252
|
geometry: {
|
|
242
253
|
type: "polyline",
|
|
243
|
-
paths:
|
|
254
|
+
paths: o.geometry.coordinates
|
|
244
255
|
},
|
|
245
256
|
attributes: {
|
|
246
|
-
ObjectID:
|
|
257
|
+
ObjectID: e ? this.districtControllerOid++ : this.subDistrictControllerOid++,
|
|
247
258
|
id: t.id,
|
|
248
259
|
name: t.name,
|
|
249
260
|
subDistrictCount: t.subDistrictCount,
|
|
@@ -251,40 +262,40 @@ class P {
|
|
|
251
262
|
parentId: t.parentId,
|
|
252
263
|
parentName: t.parentName,
|
|
253
264
|
selected: s,
|
|
254
|
-
type:
|
|
265
|
+
type: e ? "district" : "subDistrict"
|
|
255
266
|
}
|
|
256
267
|
});
|
|
257
|
-
|
|
258
|
-
for (const
|
|
259
|
-
this.generateGraphic(
|
|
260
|
-
t.signals.forEach((
|
|
261
|
-
const
|
|
268
|
+
e ? this.districtGraphics.push(h) : this.subDistrictGraphics.push(h);
|
|
269
|
+
for (const a of t.subDistricts)
|
|
270
|
+
this.generateGraphic(a, !1, s);
|
|
271
|
+
t.signals.forEach((a) => {
|
|
272
|
+
const n = new y({
|
|
262
273
|
geometry: {
|
|
263
274
|
type: "point",
|
|
264
|
-
x:
|
|
265
|
-
y:
|
|
275
|
+
x: a.longitude,
|
|
276
|
+
y: a.latitude
|
|
266
277
|
},
|
|
267
278
|
attributes: {
|
|
268
279
|
ObjectID: this.signalOid++,
|
|
269
|
-
id:
|
|
270
|
-
name:
|
|
271
|
-
signalId:
|
|
272
|
-
nodeId:
|
|
273
|
-
isKey:
|
|
274
|
-
districtId:
|
|
275
|
-
districtName:
|
|
276
|
-
subDistrictId:
|
|
277
|
-
subDistrictName:
|
|
280
|
+
id: a.id,
|
|
281
|
+
name: a.name,
|
|
282
|
+
signalId: a.signalId,
|
|
283
|
+
nodeId: a.nodeId,
|
|
284
|
+
isKey: a.isKey,
|
|
285
|
+
districtId: e ? t.id : t.parentId,
|
|
286
|
+
districtName: e ? t.name : t.parentName,
|
|
287
|
+
subDistrictId: e ? "" : t.id,
|
|
288
|
+
subDistrictName: e ? "" : t.name,
|
|
278
289
|
type: "signal",
|
|
279
290
|
selected: !0
|
|
280
291
|
}
|
|
281
292
|
});
|
|
282
|
-
this.signalGraphics.push(
|
|
293
|
+
this.signalGraphics.push(n);
|
|
283
294
|
});
|
|
284
295
|
}
|
|
285
296
|
async viewHitTest(t) {
|
|
286
|
-
var
|
|
287
|
-
const s = (
|
|
297
|
+
var a;
|
|
298
|
+
const s = (a = (await this.view.hitTest(t, {
|
|
288
299
|
include: [
|
|
289
300
|
this.districtControllerSolidLayer,
|
|
290
301
|
this.subDistrictControllerLayer,
|
|
@@ -292,53 +303,53 @@ class P {
|
|
|
292
303
|
this.signalPictureLayer,
|
|
293
304
|
this.signalClusterLayer
|
|
294
305
|
]
|
|
295
|
-
})).results) == null ? void 0 :
|
|
296
|
-
(
|
|
306
|
+
})).results) == null ? void 0 : a.filter(
|
|
307
|
+
(n) => n.type === "graphic"
|
|
297
308
|
);
|
|
298
309
|
if (s.length === 0)
|
|
299
310
|
return;
|
|
300
|
-
const
|
|
311
|
+
const i = s[0].graphic;
|
|
301
312
|
let r = null;
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
switch (
|
|
313
|
+
i.geometry.type === "point" ? r = i.geometry : i.geometry.type === "polyline" ? r = i.geometry.extent.center : i.geometry.type === "polygon" && (r = i.geometry.centroid), r !== null && await this.view.goTo(r, { duration: 1e3 });
|
|
314
|
+
const o = i.getAttribute("type"), h = i.getAttribute("id");
|
|
315
|
+
switch (o) {
|
|
305
316
|
case "district": {
|
|
306
|
-
let
|
|
307
|
-
|
|
308
|
-
|
|
317
|
+
let n = await this.districtControllerSolidLayer.queryFeatures();
|
|
318
|
+
n.features.forEach((l) => {
|
|
319
|
+
l.attributes.selected = l.attributes.id === h;
|
|
309
320
|
}), await this.districtControllerSolidLayer.applyEdits({
|
|
310
|
-
updateFeatures:
|
|
311
|
-
}),
|
|
312
|
-
|
|
321
|
+
updateFeatures: n.features
|
|
322
|
+
}), n = await this.districtControllerDashLayer.queryFeatures(), n.features.forEach((l) => {
|
|
323
|
+
l.attributes.selected = l.attributes.id === h;
|
|
313
324
|
}), await this.districtControllerDashLayer.applyEdits({
|
|
314
|
-
updateFeatures:
|
|
325
|
+
updateFeatures: n.features
|
|
315
326
|
});
|
|
316
327
|
break;
|
|
317
328
|
}
|
|
318
329
|
case "subDistrict": {
|
|
319
|
-
let
|
|
320
|
-
|
|
321
|
-
|
|
330
|
+
let n = await this.subDistrictControllerLayer.queryFeatures();
|
|
331
|
+
n.features.forEach((u) => {
|
|
332
|
+
u.attributes.selected = u.attributes.id === h;
|
|
322
333
|
}), await this.subDistrictControllerLayer.applyEdits({
|
|
323
|
-
updateFeatures:
|
|
324
|
-
}),
|
|
325
|
-
|
|
334
|
+
updateFeatures: n.features
|
|
335
|
+
}), n = await this.signalMarkerLayer.queryFeatures(), n.features.forEach((u) => {
|
|
336
|
+
u.attributes.selected = u.attributes.subDistrictId === h;
|
|
326
337
|
});
|
|
327
|
-
let
|
|
328
|
-
updateFeatures:
|
|
338
|
+
let l = await this.signalMarkerLayer.applyEdits({
|
|
339
|
+
updateFeatures: n.features
|
|
329
340
|
});
|
|
330
|
-
console.log(
|
|
331
|
-
|
|
332
|
-
}),
|
|
333
|
-
updateFeatures:
|
|
334
|
-
}), console.log(
|
|
341
|
+
console.log(l), n = await this.signalPictureLayer.queryFeatures(), n.features.forEach((u) => {
|
|
342
|
+
u.attributes.selected = u.attributes.subDistrictId === h;
|
|
343
|
+
}), l = await this.signalPictureLayer.applyEdits({
|
|
344
|
+
updateFeatures: n.features
|
|
345
|
+
}), console.log(l);
|
|
335
346
|
break;
|
|
336
347
|
}
|
|
337
348
|
}
|
|
338
|
-
|
|
349
|
+
L.when(
|
|
339
350
|
() => this.view.popup.visible === !1,
|
|
340
351
|
async () => {
|
|
341
|
-
await this.resetSelectedSymbol(
|
|
352
|
+
await this.resetSelectedSymbol(o);
|
|
342
353
|
},
|
|
343
354
|
{
|
|
344
355
|
once: !0
|
|
@@ -351,38 +362,104 @@ class P {
|
|
|
351
362
|
async resetSelectedSymbol(t) {
|
|
352
363
|
switch (t) {
|
|
353
364
|
case "district": {
|
|
354
|
-
let
|
|
355
|
-
|
|
365
|
+
let e = await this.districtControllerSolidLayer.queryFeatures();
|
|
366
|
+
e.features.forEach((s) => {
|
|
356
367
|
s.attributes.selected = !0;
|
|
357
368
|
}), await this.districtControllerSolidLayer.applyEdits({
|
|
358
|
-
updateFeatures:
|
|
359
|
-
}),
|
|
369
|
+
updateFeatures: e.features
|
|
370
|
+
}), e = await this.districtControllerDashLayer.queryFeatures(), e.features.forEach((s) => {
|
|
360
371
|
s.attributes.selected = !0;
|
|
361
372
|
}), await this.districtControllerDashLayer.applyEdits({
|
|
362
|
-
updateFeatures:
|
|
373
|
+
updateFeatures: e.features
|
|
363
374
|
});
|
|
364
375
|
break;
|
|
365
376
|
}
|
|
366
377
|
case "subDistrict": {
|
|
367
|
-
let
|
|
368
|
-
|
|
378
|
+
let e = await this.subDistrictControllerLayer.queryFeatures();
|
|
379
|
+
e.features.forEach((s) => {
|
|
369
380
|
s.attributes.selected = !0;
|
|
370
381
|
}), await this.subDistrictControllerLayer.applyEdits({
|
|
371
|
-
updateFeatures:
|
|
372
|
-
}),
|
|
382
|
+
updateFeatures: e.features
|
|
383
|
+
}), e = await this.signalMarkerLayer.queryFeatures(), console.log("marker count", e.features.length), e.features.forEach((s) => {
|
|
373
384
|
s.attributes.selected = !0;
|
|
374
385
|
}), await this.signalMarkerLayer.applyEdits({
|
|
375
|
-
updateFeatures:
|
|
376
|
-
}),
|
|
386
|
+
updateFeatures: e.features
|
|
387
|
+
}), e = await this.signalPictureLayer.queryFeatures(), console.log("picture count", e.features.length), e.features.forEach((s) => {
|
|
377
388
|
s.attributes.selected = !0;
|
|
378
389
|
}), await this.signalPictureLayer.applyEdits({
|
|
379
|
-
updateFeatures:
|
|
390
|
+
updateFeatures: e.features
|
|
380
391
|
});
|
|
381
392
|
break;
|
|
382
393
|
}
|
|
383
394
|
}
|
|
384
395
|
}
|
|
396
|
+
/**
|
|
397
|
+
* 加载支队图层
|
|
398
|
+
* 现场环境用url创建FeatureLayer有各种问题,改为用url创建Graphic,再将Graphic添加到FeatureLayer
|
|
399
|
+
*/
|
|
400
|
+
async loadDetachmentLayer() {
|
|
401
|
+
const t = this.mapConfig.baseLayers;
|
|
402
|
+
if (!t)
|
|
403
|
+
return;
|
|
404
|
+
const e = t.find(
|
|
405
|
+
(a) => a.options.id === "shanghai_district"
|
|
406
|
+
);
|
|
407
|
+
if (!e)
|
|
408
|
+
return;
|
|
409
|
+
const s = await m.get(`${e.url}/query`, {
|
|
410
|
+
params: {
|
|
411
|
+
where: "1=1",
|
|
412
|
+
outFields: "*",
|
|
413
|
+
f: "json",
|
|
414
|
+
returnGeometry: !0
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
if (s.status !== 200)
|
|
418
|
+
return;
|
|
419
|
+
const i = s.data, r = [], { renderer: o, labelingInfo: h } = e.options;
|
|
420
|
+
i.features.forEach((a) => {
|
|
421
|
+
const n = a.attributes.ZD_NAME;
|
|
422
|
+
if (n !== "高架支队") {
|
|
423
|
+
let l = new b({
|
|
424
|
+
rings: a.geometry.rings
|
|
425
|
+
});
|
|
426
|
+
l = w(l);
|
|
427
|
+
const u = new y({
|
|
428
|
+
geometry: l,
|
|
429
|
+
attributes: {
|
|
430
|
+
...a.attributes,
|
|
431
|
+
ObjectID: a.attributes.OBJECTID || a.attributes.ESRI_OID
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
if (o) {
|
|
435
|
+
if (o.type === "simple")
|
|
436
|
+
u.symbol = o.symbol;
|
|
437
|
+
else if (o.type === "unique-value") {
|
|
438
|
+
const p = u.getAttribute("ObjectID"), g = o.uniqueValueInfos.find(
|
|
439
|
+
(f) => String(f.value) === String(p)
|
|
440
|
+
);
|
|
441
|
+
u.symbol = g ? g.symbol : o.defaultSymbol;
|
|
442
|
+
}
|
|
443
|
+
} else
|
|
444
|
+
u.symbol = {
|
|
445
|
+
type: "simple-fill",
|
|
446
|
+
color: [227, 237, 255, 0.4],
|
|
447
|
+
outline: {
|
|
448
|
+
color: [255, 195, 153],
|
|
449
|
+
width: 2
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
if (r.push(u), h && n !== "边防港航支队" && n !== "机场支队") {
|
|
453
|
+
const p = new y({
|
|
454
|
+
geometry: l.centroid,
|
|
455
|
+
symbol: { ...h.symbol, text: n }
|
|
456
|
+
});
|
|
457
|
+
r.push(p);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}), this.detachmentLayer.addMany(r), this.detachmentLayerLoaded = !0;
|
|
461
|
+
}
|
|
385
462
|
}
|
|
386
463
|
export {
|
|
387
|
-
|
|
464
|
+
U as default
|
|
388
465
|
};
|
|
@@ -2,6 +2,9 @@ import { IFindSignalControlAreaParams, ILayerVisibleParams, IResult, IShowSignal
|
|
|
2
2
|
export default class SignalControlAreaController1 {
|
|
3
3
|
private view;
|
|
4
4
|
private hasGpu;
|
|
5
|
+
/** 支队图层 */
|
|
6
|
+
private detachmentLayer;
|
|
7
|
+
private detachmentLayerLoaded;
|
|
5
8
|
/** 区控虚线图层 */
|
|
6
9
|
private districtControllerDashLayer;
|
|
7
10
|
/** 区控实线图层,区控符号由半透明实线+不透明虚线组成 */
|
|
@@ -19,6 +22,7 @@ export default class SignalControlAreaController1 {
|
|
|
19
22
|
private subDistrictControllerOid;
|
|
20
23
|
private signalOid;
|
|
21
24
|
private popupEnabled;
|
|
25
|
+
private mapConfig;
|
|
22
26
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
23
27
|
/** 暂存等待绘制的区控graphic */
|
|
24
28
|
private districtGraphics;
|
|
@@ -78,4 +82,9 @@ export default class SignalControlAreaController1 {
|
|
|
78
82
|
* 重置所有graphic的置灰状态
|
|
79
83
|
*/
|
|
80
84
|
private resetSelectedSymbol;
|
|
85
|
+
/**
|
|
86
|
+
* 加载支队图层
|
|
87
|
+
* 现场环境用url创建FeatureLayer有各种问题,改为用url创建Graphic,再将Graphic添加到FeatureLayer
|
|
88
|
+
*/
|
|
89
|
+
private loadDetachmentLayer;
|
|
81
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const L=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/Graphic"),h=require("@arcgis/core/layers/FeatureLayer"),b=require("@turf/buffer"),C=require("@turf/convex"),w=require("@turf/helpers"),E=require("concaveman"),D=require("./district-controller.js"),y=require("./layer-symbol.js");function f(d){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const t in d)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(d,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>d[t]})}}return e.default=d,Object.freeze(e)}const F=f(L),p=f(w);class k{constructor(e){this.districtControllerOid=0,this.subDistrictControllerOid=0,this.signalOid=0,this.popupEnabled=!0,this.districtGraphics=[],this.subDistrictGraphics=[],this.signalGraphics=[],this.view=e,this.hasGpu=localStorage.getItem("gpu")!=="Unknown",this.districtControllerDashLayer=new h(y.districtDashLineLayerOptions),this.districtControllerDashLayer.spatialReference=e.spatialReference,this.districtControllerSolidLayer=new h(y.districtSolidLineLayerOptions),this.districtControllerSolidLayer.spatialReference=e.spatialReference,this.districtControllerSolidLayer.popupEnabled=this.popupEnabled,this.subDistrictControllerLayer=new h(y.subDistrictLayerOptions),this.subDistrictControllerLayer.spatialReference=e.spatialReference,this.subDistrictControllerLayer.popupEnabled=this.popupEnabled,this.signalMarkerLayer=new h(y.signalMarkerLayerOptions),this.signalMarkerLayer.spatialReference=e.spatialReference,this.signalMarkerLayer.popupEnabled=this.popupEnabled,this.signalPictureLayer=new h(y.signalPictureLayerOptions),this.signalPictureLayer.spatialReference=e.spatialReference,this.signalPictureLayer.popupEnabled=this.popupEnabled,this.signalClusterLayer=new h(y.signalClusterLayerOptions),this.signalClusterLayer.spatialReference=e.spatialReference,this.signalClusterLayer.popupEnabled=this.popupEnabled,this.view.map.addMany([this.districtControllerSolidLayer,this.districtControllerDashLayer,this.signalMarkerLayer,this.signalPictureLayer,this.signalClusterLayer,this.subDistrictControllerLayer]),this.clickHandler=this.view.on("click",this.viewHitTest.bind(this))}async showSignalControlArea(e){await this.clearSignalControlArea(),this.districtControllerDashLayer.visible=!1,this.districtControllerSolidLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.signalMarkerLayer.visible=!1,this.signalPictureLayer.visible=!1,this.signalClusterLayer.visible=!0;for(const t of e.areaList){const s=new D.default(t,e.style||"");this.generateGraphic(s,!0,e.style)}return await this.districtControllerDashLayer.applyEdits({addFeatures:this.districtGraphics}),await this.districtControllerSolidLayer.applyEdits({addFeatures:this.districtGraphics}),this.view.goTo(this.districtGraphics),this.districtGraphics=[],await this.subDistrictControllerLayer.applyEdits({addFeatures:this.subDistrictGraphics}),this.subDistrictGraphics=[],await this.signalMarkerLayer.applyEdits({addFeatures:this.signalGraphics}),await this.signalPictureLayer.applyEdits({addFeatures:this.signalGraphics}),await this.signalClusterLayer.applyEdits({addFeatures:this.signalGraphics}),this.signalGraphics=[],{status:0,message:"ok"}}async clearSignalControlArea(){this.districtGraphics=[],this.subDistrictGraphics=[],this.signalGraphics=[],this.districtControllerOid=0,this.subDistrictControllerOid=0,this.signalOid=0;let e=await this.districtControllerDashLayer.queryFeatures();return await this.districtControllerDashLayer.applyEdits({deleteFeatures:e.features}),this.districtControllerDashLayer.definitionExpression="1=1",e=await this.districtControllerSolidLayer.queryFeatures(),await this.districtControllerSolidLayer.applyEdits({deleteFeatures:e.features}),this.districtControllerSolidLayer.definitionExpression="1=1",e=await this.subDistrictControllerLayer.queryFeatures(),await this.subDistrictControllerLayer.applyEdits({deleteFeatures:e.features}),this.subDistrictControllerLayer.definitionExpression="1=1",e=await this.signalMarkerLayer.queryFeatures(),await this.signalMarkerLayer.applyEdits({deleteFeatures:e.features}),this.signalMarkerLayer.definitionExpression="1=1",e=await this.signalPictureLayer.queryFeatures(),await this.signalPictureLayer.applyEdits({deleteFeatures:e.features}),this.signalPictureLayer.definitionExpression="1=1",e=await this.signalClusterLayer.queryFeatures(),await this.signalClusterLayer.applyEdits({deleteFeatures:e.features}),this.signalClusterLayer.definitionExpression="1=1",{status:0,message:"ok"}}setLayerVisibility(e){switch(e.visible===!1&&this.view.closePopup(),e.id){case"district":this.districtControllerDashLayer.visible=e.visible,this.districtControllerSolidLayer.visible=e.visible;break;case"subDistrict":this.subDistrictControllerLayer.visible=e.visible;break;case"signal":this.signalMarkerLayer.visible=e.visible,this.signalPictureLayer.visible=e.visible;break;case"signalCluster":this.signalClusterLayer.visible=e.visible;break}return{status:0,message:"ok"}}async locateSignalControlArea(e){switch(e.type){case"district":{const i=this.districtControllerDashLayer.createQuery();i.where=`id = '${e.id}'`,i.returnGeometry=!0,i.outFields=["*"];const r=await this.districtControllerDashLayer.queryFeatures(i);return r.features.length>0?(await this.view.goTo(r.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到区控"}}case"subDistrict":const t=this.subDistrictControllerLayer.createQuery();t.where=`id = '${e.id}'`,t.returnGeometry=!0,t.outFields=["*"];const s=await this.subDistrictControllerLayer.queryFeatures(t);return s.features.length>0?(await this.view.goTo(s.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到子区"};case"signal":{const i=this.signalMarkerLayer.createQuery();i.where=`id = '${e.id}'`,i.returnGeometry=!0,i.outFields=["*"];const r=await this.signalMarkerLayer.queryFeatures(i);return r.features.length>0?(await this.view.goTo({target:r.features[0],scale:e.scale||1e3},{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到信号机"}}default:return{status:1,message:"未知类型"}}}async highlightSignalControlArea(e){var t;switch((t=this.view.popup)!=null&&t.visible&&this.view.popup.close(),e.type){case"district":{const s=this.districtControllerDashLayer.definitionExpression;this.districtControllerDashLayer.definitionExpression=`id = '${e.id}'`;const i=await this.districtControllerDashLayer.queryFeatures();return i.features.length>0?(this.districtControllerSolidLayer.definitionExpression=`id = '${e.id}'`,this.subDistrictControllerLayer.definitionExpression=`parentId = '${e.id}'`,this.signalMarkerLayer.definitionExpression=`districtId = '${e.id}'`,this.signalPictureLayer.definitionExpression=`districtId = '${e.id}'`,this.signalClusterLayer.definitionExpression=`districtId = '${e.id}'`,await this.view.goTo(i.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):(this.districtControllerDashLayer.definitionExpression=s,{status:1,message:"未找到区控"})}case"subDistrict":{const s=this.subDistrictControllerLayer.definitionExpression;this.subDistrictControllerLayer.definitionExpression=`id = '${e.id}'`;const i=await this.subDistrictControllerLayer.queryFeatures();if(i.features.length>0){this.signalMarkerLayer.definitionExpression=`subDistrictId = '${e.id}'`,this.signalPictureLayer.definitionExpression=`subDistrictId = '${e.id}'`,this.signalClusterLayer.definitionExpression=`subDistrictId = '${e.id}'`;const l=i.features[0].attributes.parentId;return this.districtControllerDashLayer.definitionExpression=`id = '${l}'`,this.districtControllerSolidLayer.definitionExpression=`id = '${l}'`,await this.view.goTo(i.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}else return this.subDistrictControllerLayer.definitionExpression=s,{status:1,message:"未找到子区"}}case"signal":{const s=this.signalMarkerLayer.definitionExpression;this.signalMarkerLayer.definitionExpression=`id = '${e.id}'`;const i=await this.signalMarkerLayer.queryFeatures();if(i.features.length>0){this.signalPictureLayer.definitionExpression=`id = '${e.id}'`,this.signalClusterLayer.definitionExpression=`id = '${e.id}'`;const r=i.features[0],{districtId:l,subDistrictId:o}=r.attributes;return this.districtControllerDashLayer.definitionExpression=`id = '${l}'`,this.districtControllerSolidLayer.definitionExpression=`id = '${l}'`,this.subDistrictControllerLayer.definitionExpression=`id = '${o}'`,await this.view.goTo({target:i.features,scale:e.scale||1e3},{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}else return this.signalMarkerLayer.definitionExpression=s,{status:1,message:"未找到信号机"}}default:return{status:1,message:"未知类型"}}}async resetHighlight(){this.districtControllerDashLayer.definitionExpression="1=1",this.districtControllerSolidLayer.definitionExpression="1=1",this.subDistrictControllerLayer.definitionExpression="1=1",this.signalMarkerLayer.definitionExpression="1=1",this.signalClusterLayer.definitionExpression="1=1",this.signalPictureLayer.definitionExpression="1=1";const e=await this.districtControllerDashLayer.queryFeatures();return this.view.goTo(e.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}generateGraphic(e,t,s){const i=e.getAllSignalCoordinates();let r=null;if(i.length>=2)if(i.length===2)r=p.lineString(i);else{if(t){const n=p.featureCollection(i.map(a=>p.point(a)));r=C(n)}else{const n=E(i,.5);n.length>=4&&(r=p.polygon([n]))}r||(r=p.lineString(i))}else if(i.length===1)r=p.point(i[0]);else return;const l=b(r.geometry,t?200:30,{units:"meters"}),o=new g({geometry:{type:"polyline",paths:l.geometry.coordinates},attributes:{ObjectID:t?this.districtControllerOid++:this.subDistrictControllerOid++,id:e.id,name:e.name,subDistrictCount:e.subDistrictCount,signalCount:e.signalCount,parentId:e.parentId,parentName:e.parentName,selected:s,type:t?"district":"subDistrict"}});t?this.districtGraphics.push(o):this.subDistrictGraphics.push(o);for(const n of e.subDistricts)this.generateGraphic(n,!1,s);e.signals.forEach(n=>{const a=new g({geometry:{type:"point",x:n.longitude,y:n.latitude},attributes:{ObjectID:this.signalOid++,id:n.id,name:n.name,signalId:n.signalId,nodeId:n.nodeId,isKey:n.isKey,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,type:"signal",selected:!0}});this.signalGraphics.push(a)})}async viewHitTest(e){var n;const s=(n=(await this.view.hitTest(e,{include:[this.districtControllerSolidLayer,this.subDistrictControllerLayer,this.signalMarkerLayer,this.signalPictureLayer,this.signalClusterLayer]})).results)==null?void 0:n.filter(a=>a.type==="graphic");if(s.length===0)return;const i=s[0].graphic;let r=null;i.geometry.type==="point"?r=i.geometry:i.geometry.type==="polyline"?r=i.geometry.extent.center:i.geometry.type==="polygon"&&(r=i.geometry.centroid),r!==null&&await this.view.goTo(r,{duration:1e3});const l=i.getAttribute("type"),o=i.getAttribute("id");switch(l){case"district":{let a=await this.districtControllerSolidLayer.queryFeatures();a.features.forEach(u=>{u.attributes.selected=u.attributes.id===o}),await this.districtControllerSolidLayer.applyEdits({updateFeatures:a.features}),a=await this.districtControllerDashLayer.queryFeatures(),a.features.forEach(u=>{u.attributes.selected=u.attributes.id===o}),await this.districtControllerDashLayer.applyEdits({updateFeatures:a.features});break}case"subDistrict":{let a=await this.subDistrictControllerLayer.queryFeatures();a.features.forEach(c=>{c.attributes.selected=c.attributes.id===o}),await this.subDistrictControllerLayer.applyEdits({updateFeatures:a.features}),a=await this.signalMarkerLayer.queryFeatures(),a.features.forEach(c=>{c.attributes.selected=c.attributes.subDistrictId===o});let u=await this.signalMarkerLayer.applyEdits({updateFeatures:a.features});console.log(u),a=await this.signalPictureLayer.queryFeatures(),a.features.forEach(c=>{c.attributes.selected=c.attributes.subDistrictId===o}),u=await this.signalPictureLayer.applyEdits({updateFeatures:a.features}),console.log(u);break}}F.when(()=>this.view.popup.visible===!1,async()=>{await this.resetSelectedSymbol(l)},{once:!0})}async resetSelectedSymbol(e){switch(e){case"district":{let t=await this.districtControllerSolidLayer.queryFeatures();t.features.forEach(s=>{s.attributes.selected=!0}),await this.districtControllerSolidLayer.applyEdits({updateFeatures:t.features}),t=await this.districtControllerDashLayer.queryFeatures(),t.features.forEach(s=>{s.attributes.selected=!0}),await this.districtControllerDashLayer.applyEdits({updateFeatures:t.features});break}case"subDistrict":{let t=await this.subDistrictControllerLayer.queryFeatures();t.features.forEach(s=>{s.attributes.selected=!0}),await this.subDistrictControllerLayer.applyEdits({updateFeatures:t.features}),t=await this.signalMarkerLayer.queryFeatures(),console.log("marker count",t.features.length),t.features.forEach(s=>{s.attributes.selected=!0}),await this.signalMarkerLayer.applyEdits({updateFeatures:t.features}),t=await this.signalPictureLayer.queryFeatures(),console.log("picture count",t.features.length),t.features.forEach(s=>{s.attributes.selected=!0}),await this.signalPictureLayer.applyEdits({updateFeatures:t.features});break}}}}exports.default=k;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("@arcgis/core/core/reactiveUtils"),E=require("@arcgis/core/geometry"),D=require("@arcgis/core/geometry/support/webMercatorUtils"),g=require("@arcgis/core/Graphic"),d=require("@arcgis/core/layers/FeatureLayer"),m=require("@arcgis/core/layers/GraphicsLayer"),F=require("@turf/buffer"),k=require("@turf/convex"),v=require("@turf/helpers"),S=require("axios"),G=require("concaveman"),q=require("../../stores/index.js"),x=require("./district-controller.js"),y=require("./layer-symbol.js");function L(h){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>h[t]})}}return e.default=h,Object.freeze(e)}const I=L(C),p=L(v);class M{constructor(e){this.detachmentLayerLoaded=!1,this.districtControllerOid=0,this.subDistrictControllerOid=0,this.signalOid=0,this.popupEnabled=!0,this.districtGraphics=[],this.subDistrictGraphics=[],this.signalGraphics=[],this.view=e,this.hasGpu=localStorage.getItem("gpu")!=="Unknown";const t=q.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(t.mapConfig)),this.detachmentLayer=new m,this.districtControllerDashLayer=new d(y.districtDashLineLayerOptions),this.districtControllerDashLayer.spatialReference=e.spatialReference,this.districtControllerSolidLayer=new d(y.districtSolidLineLayerOptions),this.districtControllerSolidLayer.spatialReference=e.spatialReference,this.districtControllerSolidLayer.popupEnabled=this.popupEnabled,this.subDistrictControllerLayer=new d(y.subDistrictLayerOptions),this.subDistrictControllerLayer.spatialReference=e.spatialReference,this.subDistrictControllerLayer.popupEnabled=this.popupEnabled,this.signalMarkerLayer=new d(y.signalMarkerLayerOptions),this.signalMarkerLayer.spatialReference=e.spatialReference,this.signalMarkerLayer.popupEnabled=this.popupEnabled,this.signalPictureLayer=new d(y.signalPictureLayerOptions),this.signalPictureLayer.spatialReference=e.spatialReference,this.signalPictureLayer.popupEnabled=this.popupEnabled,this.signalClusterLayer=new d(y.signalClusterLayerOptions),this.signalClusterLayer.spatialReference=e.spatialReference,this.signalClusterLayer.popupEnabled=this.popupEnabled,this.view.map.addMany([this.detachmentLayer,this.districtControllerSolidLayer,this.districtControllerDashLayer,this.signalMarkerLayer,this.signalPictureLayer,this.signalClusterLayer,this.subDistrictControllerLayer]),this.clickHandler=this.view.on("click",this.viewHitTest.bind(this))}async showSignalControlArea(e){this.detachmentLayerLoaded||await this.loadDetachmentLayer(),await this.clearSignalControlArea(),this.districtControllerDashLayer.visible=!1,this.districtControllerSolidLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.signalMarkerLayer.visible=!1,this.signalPictureLayer.visible=!1,this.signalClusterLayer.visible=!0;for(const t of e.areaList){const s=new x.default(t,e.style||"");this.generateGraphic(s,!0,e.style)}return await this.districtControllerDashLayer.applyEdits({addFeatures:this.districtGraphics}),await this.districtControllerSolidLayer.applyEdits({addFeatures:this.districtGraphics}),this.view.goTo(this.districtGraphics),this.districtGraphics=[],await this.subDistrictControllerLayer.applyEdits({addFeatures:this.subDistrictGraphics}),this.subDistrictGraphics=[],await this.signalMarkerLayer.applyEdits({addFeatures:this.signalGraphics}),await this.signalPictureLayer.applyEdits({addFeatures:this.signalGraphics}),await this.signalClusterLayer.applyEdits({addFeatures:this.signalGraphics}),this.signalGraphics=[],{status:0,message:"ok"}}async clearSignalControlArea(){this.districtGraphics=[],this.subDistrictGraphics=[],this.signalGraphics=[],this.districtControllerOid=0,this.subDistrictControllerOid=0,this.signalOid=0;let e=await this.districtControllerDashLayer.queryFeatures();return await this.districtControllerDashLayer.applyEdits({deleteFeatures:e.features}),this.districtControllerDashLayer.definitionExpression="1=1",e=await this.districtControllerSolidLayer.queryFeatures(),await this.districtControllerSolidLayer.applyEdits({deleteFeatures:e.features}),this.districtControllerSolidLayer.definitionExpression="1=1",e=await this.subDistrictControllerLayer.queryFeatures(),await this.subDistrictControllerLayer.applyEdits({deleteFeatures:e.features}),this.subDistrictControllerLayer.definitionExpression="1=1",e=await this.signalMarkerLayer.queryFeatures(),await this.signalMarkerLayer.applyEdits({deleteFeatures:e.features}),this.signalMarkerLayer.definitionExpression="1=1",e=await this.signalPictureLayer.queryFeatures(),await this.signalPictureLayer.applyEdits({deleteFeatures:e.features}),this.signalPictureLayer.definitionExpression="1=1",e=await this.signalClusterLayer.queryFeatures(),await this.signalClusterLayer.applyEdits({deleteFeatures:e.features}),this.signalClusterLayer.definitionExpression="1=1",{status:0,message:"ok"}}setLayerVisibility(e){switch(e.visible===!1&&this.view.closePopup(),e.id){case"district":this.districtControllerDashLayer.visible=e.visible,this.districtControllerSolidLayer.visible=e.visible;break;case"subDistrict":this.subDistrictControllerLayer.visible=e.visible;break;case"signal":this.signalMarkerLayer.visible=e.visible,this.signalPictureLayer.visible=e.visible;break;case"signalCluster":this.signalClusterLayer.visible=e.visible;break;case"shanghai_district":this.detachmentLayer.visible=e.visible;break}return{status:0,message:"ok"}}async locateSignalControlArea(e){switch(e.type){case"district":{const i=this.districtControllerDashLayer.createQuery();i.where=`id = '${e.id}'`,i.returnGeometry=!0,i.outFields=["*"];const r=await this.districtControllerDashLayer.queryFeatures(i);return r.features.length>0?(await this.view.goTo(r.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到区控"}}case"subDistrict":const t=this.subDistrictControllerLayer.createQuery();t.where=`id = '${e.id}'`,t.returnGeometry=!0,t.outFields=["*"];const s=await this.subDistrictControllerLayer.queryFeatures(t);return s.features.length>0?(await this.view.goTo(s.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到子区"};case"signal":{const i=this.signalMarkerLayer.createQuery();i.where=`id = '${e.id}'`,i.returnGeometry=!0,i.outFields=["*"];const r=await this.signalMarkerLayer.queryFeatures(i);return r.features.length>0?(await this.view.goTo({target:r.features[0],scale:e.scale||1e3},{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到信号机"}}default:return{status:1,message:"未知类型"}}}async highlightSignalControlArea(e){var t;switch((t=this.view.popup)!=null&&t.visible&&this.view.popup.close(),e.type){case"district":{const s=this.districtControllerDashLayer.definitionExpression;this.districtControllerDashLayer.definitionExpression=`id = '${e.id}'`;const i=await this.districtControllerDashLayer.queryFeatures();return i.features.length>0?(this.districtControllerSolidLayer.definitionExpression=`id = '${e.id}'`,this.subDistrictControllerLayer.definitionExpression=`parentId = '${e.id}'`,this.signalMarkerLayer.definitionExpression=`districtId = '${e.id}'`,this.signalPictureLayer.definitionExpression=`districtId = '${e.id}'`,this.signalClusterLayer.definitionExpression=`districtId = '${e.id}'`,await this.view.goTo(i.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):(this.districtControllerDashLayer.definitionExpression=s,{status:1,message:"未找到区控"})}case"subDistrict":{const s=this.subDistrictControllerLayer.definitionExpression;this.subDistrictControllerLayer.definitionExpression=`id = '${e.id}'`;const i=await this.subDistrictControllerLayer.queryFeatures();if(i.features.length>0){this.signalMarkerLayer.definitionExpression=`subDistrictId = '${e.id}'`,this.signalPictureLayer.definitionExpression=`subDistrictId = '${e.id}'`,this.signalClusterLayer.definitionExpression=`subDistrictId = '${e.id}'`;const l=i.features[0].attributes.parentId;return this.districtControllerDashLayer.definitionExpression=`id = '${l}'`,this.districtControllerSolidLayer.definitionExpression=`id = '${l}'`,await this.view.goTo(i.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}else return this.subDistrictControllerLayer.definitionExpression=s,{status:1,message:"未找到子区"}}case"signal":{const s=this.signalMarkerLayer.definitionExpression;this.signalMarkerLayer.definitionExpression=`id = '${e.id}'`;const i=await this.signalMarkerLayer.queryFeatures();if(i.features.length>0){this.signalPictureLayer.definitionExpression=`id = '${e.id}'`,this.signalClusterLayer.definitionExpression=`id = '${e.id}'`;const r=i.features[0],{districtId:l,subDistrictId:c}=r.attributes;return this.districtControllerDashLayer.definitionExpression=`id = '${l}'`,this.districtControllerSolidLayer.definitionExpression=`id = '${l}'`,this.subDistrictControllerLayer.definitionExpression=`id = '${c}'`,await this.view.goTo({target:i.features,scale:e.scale||1e3},{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}else return this.signalMarkerLayer.definitionExpression=s,{status:1,message:"未找到信号机"}}default:return{status:1,message:"未知类型"}}}async resetHighlight(){this.districtControllerDashLayer.definitionExpression="1=1",this.districtControllerSolidLayer.definitionExpression="1=1",this.subDistrictControllerLayer.definitionExpression="1=1",this.signalMarkerLayer.definitionExpression="1=1",this.signalClusterLayer.definitionExpression="1=1",this.signalPictureLayer.definitionExpression="1=1";const e=await this.districtControllerDashLayer.queryFeatures();return this.view.goTo(e.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}generateGraphic(e,t,s){const i=e.getAllSignalCoordinates();let r=null;if(i.length>=2)if(i.length===2)r=p.lineString(i);else{if(t){const a=p.featureCollection(i.map(n=>p.point(n)));r=k(a)}else{const a=G(i,.5);a.length>=4&&(r=p.polygon([a]))}r||(r=p.lineString(i))}else if(i.length===1)r=p.point(i[0]);else return;const l=F(r.geometry,t?200:30,{units:"meters"}),c=new g({geometry:{type:"polyline",paths:l.geometry.coordinates},attributes:{ObjectID:t?this.districtControllerOid++:this.subDistrictControllerOid++,id:e.id,name:e.name,subDistrictCount:e.subDistrictCount,signalCount:e.signalCount,parentId:e.parentId,parentName:e.parentName,selected:s,type:t?"district":"subDistrict"}});t?this.districtGraphics.push(c):this.subDistrictGraphics.push(c);for(const a of e.subDistricts)this.generateGraphic(a,!1,s);e.signals.forEach(a=>{const n=new g({geometry:{type:"point",x:a.longitude,y:a.latitude},attributes:{ObjectID:this.signalOid++,id:a.id,name:a.name,signalId:a.signalId,nodeId:a.nodeId,isKey:a.isKey,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,type:"signal",selected:!0}});this.signalGraphics.push(n)})}async viewHitTest(e){var a;const s=(a=(await this.view.hitTest(e,{include:[this.districtControllerSolidLayer,this.subDistrictControllerLayer,this.signalMarkerLayer,this.signalPictureLayer,this.signalClusterLayer]})).results)==null?void 0:a.filter(n=>n.type==="graphic");if(s.length===0)return;const i=s[0].graphic;let r=null;i.geometry.type==="point"?r=i.geometry:i.geometry.type==="polyline"?r=i.geometry.extent.center:i.geometry.type==="polygon"&&(r=i.geometry.centroid),r!==null&&await this.view.goTo(r,{duration:1e3});const l=i.getAttribute("type"),c=i.getAttribute("id");switch(l){case"district":{let n=await this.districtControllerSolidLayer.queryFeatures();n.features.forEach(o=>{o.attributes.selected=o.attributes.id===c}),await this.districtControllerSolidLayer.applyEdits({updateFeatures:n.features}),n=await this.districtControllerDashLayer.queryFeatures(),n.features.forEach(o=>{o.attributes.selected=o.attributes.id===c}),await this.districtControllerDashLayer.applyEdits({updateFeatures:n.features});break}case"subDistrict":{let n=await this.subDistrictControllerLayer.queryFeatures();n.features.forEach(u=>{u.attributes.selected=u.attributes.id===c}),await this.subDistrictControllerLayer.applyEdits({updateFeatures:n.features}),n=await this.signalMarkerLayer.queryFeatures(),n.features.forEach(u=>{u.attributes.selected=u.attributes.subDistrictId===c});let o=await this.signalMarkerLayer.applyEdits({updateFeatures:n.features});console.log(o),n=await this.signalPictureLayer.queryFeatures(),n.features.forEach(u=>{u.attributes.selected=u.attributes.subDistrictId===c}),o=await this.signalPictureLayer.applyEdits({updateFeatures:n.features}),console.log(o);break}}I.when(()=>this.view.popup.visible===!1,async()=>{await this.resetSelectedSymbol(l)},{once:!0})}async resetSelectedSymbol(e){switch(e){case"district":{let t=await this.districtControllerSolidLayer.queryFeatures();t.features.forEach(s=>{s.attributes.selected=!0}),await this.districtControllerSolidLayer.applyEdits({updateFeatures:t.features}),t=await this.districtControllerDashLayer.queryFeatures(),t.features.forEach(s=>{s.attributes.selected=!0}),await this.districtControllerDashLayer.applyEdits({updateFeatures:t.features});break}case"subDistrict":{let t=await this.subDistrictControllerLayer.queryFeatures();t.features.forEach(s=>{s.attributes.selected=!0}),await this.subDistrictControllerLayer.applyEdits({updateFeatures:t.features}),t=await this.signalMarkerLayer.queryFeatures(),console.log("marker count",t.features.length),t.features.forEach(s=>{s.attributes.selected=!0}),await this.signalMarkerLayer.applyEdits({updateFeatures:t.features}),t=await this.signalPictureLayer.queryFeatures(),console.log("picture count",t.features.length),t.features.forEach(s=>{s.attributes.selected=!0}),await this.signalPictureLayer.applyEdits({updateFeatures:t.features});break}}}async loadDetachmentLayer(){const e=this.mapConfig.baseLayers;if(!e)return;const t=e.find(a=>a.options.id==="shanghai_district");if(!t)return;const s=await S.get(`${t.url}/query`,{params:{where:"1=1",outFields:"*",f:"json",returnGeometry:!0}});if(s.status!==200)return;const i=s.data,r=[],{renderer:l,labelingInfo:c}=t.options;i.features.forEach(a=>{const n=a.attributes.ZD_NAME;if(n!=="高架支队"){let o=new E.Polygon({rings:a.geometry.rings});o=D.webMercatorToGeographic(o);const u=new g({geometry:o,attributes:{...a.attributes,ObjectID:a.attributes.OBJECTID||a.attributes.ESRI_OID}});if(l){if(l.type==="simple")u.symbol=l.symbol;else if(l.type==="unique-value"){const f=u.getAttribute("ObjectID"),b=l.uniqueValueInfos.find(w=>String(w.value)===String(f));u.symbol=b?b.symbol:l.defaultSymbol}}else u.symbol={type:"simple-fill",color:[227,237,255,.4],outline:{color:[255,195,153],width:2}};if(r.push(u),c&&n!=="边防港航支队"&&n!=="机场支队"){const f=new g({geometry:o.centroid,symbol:{...c.symbol,text:n}});r.push(f)}}}),this.detachmentLayer.addMany(r),this.detachmentLayerLoaded=!0}}exports.default=M;
|