gisviewer-vue3-arcgis 1.0.217 → 1.0.219

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