gisviewer-vue3-arcgis 1.0.216 → 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.
@@ -48,11 +48,11 @@ class v {
48
48
  return;
49
49
  }
50
50
  const e = i.map((s) => {
51
- const { vehicleId: o, heading: r, localTimestamp: h } = s, l = Number(s.x), n = Number(s.y), a = new p({
51
+ const { vehicleId: r, heading: o, localTimestamp: l } = s, n = Number(s.x), h = Number(s.y), a = new p({
52
52
  geometry: {
53
53
  type: "point",
54
- x: l,
55
- y: n
54
+ x: n,
55
+ y: h
56
56
  },
57
57
  attributes: {
58
58
  ...s,
@@ -60,9 +60,9 @@ class v {
60
60
  },
61
61
  symbol: this.hasGpu ? this.createCIMSymbol(s) : this.createMarkerSymbol()
62
62
  });
63
- return this.hasGpu && (a.visible = !1, this.historyPositionMap.set(o, [
64
- { pos: [l, n, 0], heading: r, time: h }
65
- ]), this.vehicleObjectMap.set(o, {
63
+ return this.hasGpu && (a.visible = !1, this.historyPositionMap.set(r, [
64
+ { pos: [n, h, 0], heading: o, time: l }
65
+ ]), this.vehicleObjectMap.set(r, {
66
66
  graphic: a,
67
67
  data: s,
68
68
  waitForDelete: !1,
@@ -80,18 +80,18 @@ class v {
80
80
  }
81
81
  const e = [];
82
82
  i.forEach((s) => {
83
- const { vehicleId: o, heading: r, localTimestamp: h } = s, l = Number(s.x), n = Number(s.y);
83
+ const { vehicleId: r, heading: o, localTimestamp: l } = s, n = Number(s.x), h = Number(s.y);
84
84
  if (this.hasGpu) {
85
- const a = this.vehicleObjectMap.get(o);
85
+ const a = this.vehicleObjectMap.get(r);
86
86
  a ? (a.data = s, a.graphic.attributes = {
87
87
  ...s,
88
88
  type: "trackVehicle"
89
89
  }, this.historyPositionMap.get(
90
- o
90
+ r
91
91
  ).push({
92
- pos: [l, n, 0],
93
- heading: r,
94
- time: h
92
+ pos: [n, h, 0],
93
+ heading: o,
94
+ time: l
95
95
  })) : e.push(s);
96
96
  } else {
97
97
  const a = this.vehicleLayer.graphics.find(
@@ -99,8 +99,8 @@ class v {
99
99
  );
100
100
  a ? a.geometry = {
101
101
  type: "point",
102
- x: l,
103
- y: n
102
+ x: n,
103
+ y: h
104
104
  } : e.push(s);
105
105
  }
106
106
  }), this.addVehicles(e), t();
@@ -156,27 +156,30 @@ class v {
156
156
  if (!t || !e || !e.isMoving && t.length <= 2)
157
157
  return;
158
158
  e.isMoving = !0, (e.graphic.getAttribute("roadLayer") || "1") === "1" ? e.graphic.visible = this.showGroundVehicle : e.graphic.visible = this.showElevatedVehicle, e.segmentStartTime || (e.segmentStartTime = Date.now(), e.segmentTotalTime = t[1].time - t[0].time);
159
- const o = Date.now() - e.segmentStartTime, r = Math.min(
159
+ const r = Date.now() - e.segmentStartTime, o = Math.min(
160
160
  1,
161
- o / e.segmentTotalTime
161
+ r / e.segmentTotalTime
162
162
  );
163
- if (r === 1)
163
+ if (o === 1)
164
164
  if (t.shift(), t.length === 1) {
165
165
  e.waitForDelete ? (this.vehicleLayer.remove(e.graphic), this.vehicleObjectMap.delete(i), this.historyPositionMap.delete(i)) : (e.segmentStartTime = void 0, e.segmentTotalTime = void 0, e.graphic.visible = !1, e.isMoving = !1);
166
166
  return;
167
- } else
168
- e.segmentStartTime = Date.now(), e.segmentTotalTime = t[1].time - t[0].time, Math.abs(t[1].heading - t[0].heading) > 180 && (t[1].heading > t[0].heading ? t[0].heading += 360 : t[1].heading += 360), e.graphic.geometry = {
167
+ } else {
168
+ e.segmentStartTime = Date.now();
169
+ const l = r - e.segmentTotalTime;
170
+ e.segmentTotalTime = t[1].time - t[0].time - l, Math.abs(t[1].heading - t[0].heading) > 180 && (t[1].heading > t[0].heading ? t[0].heading += 360 : t[1].heading += 360), e.graphic.geometry = {
169
171
  type: "point",
170
172
  x: t[0].pos[0],
171
173
  y: t[0].pos[1]
172
174
  };
175
+ }
173
176
  else {
174
- const h = t[0].pos[0] + (t[1].pos[0] - t[0].pos[0]) * r, l = t[0].pos[1] + (t[1].pos[1] - t[0].pos[1]) * r, n = t[0].heading + (t[1].heading - t[0].heading) * r;
177
+ const l = t[0].pos[0] + (t[1].pos[0] - t[0].pos[0]) * o, n = t[0].pos[1] + (t[1].pos[1] - t[0].pos[1]) * o, h = t[0].heading + (t[1].heading - t[0].heading) * o;
175
178
  e.graphic.geometry = {
176
179
  type: "point",
177
- x: h,
178
- y: l
179
- }, e.data.heading = n, e.graphic.symbol = this.hasGpu ? this.createCIMSymbol(e.data) : this.createMarkerSymbol();
180
+ x: l,
181
+ y: n
182
+ }, e.data.heading = h, e.graphic.symbol = this.hasGpu ? this.createCIMSymbol(e.data) : this.createMarkerSymbol();
180
183
  }
181
184
  }
182
185
  /**
@@ -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 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 "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", this.districtControllerDashLayer = new c(
13
- C
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
- w
22
+ S
16
23
  ), this.districtControllerSolidLayer.spatialReference = t.spatialReference, this.districtControllerSolidLayer.popupEnabled = this.popupEnabled, this.subDistrictControllerLayer = new c(
17
- E
24
+ x
18
25
  ), this.subDistrictControllerLayer.spatialReference = t.spatialReference, this.subDistrictControllerLayer.popupEnabled = this.popupEnabled, this.signalMarkerLayer = new c(
19
- D
26
+ I
20
27
  ), this.signalMarkerLayer.spatialReference = t.spatialReference, this.signalMarkerLayer.popupEnabled = this.popupEnabled, this.signalPictureLayer = new c(
21
- F
28
+ q
22
29
  ), this.signalPictureLayer.spatialReference = t.spatialReference, this.signalPictureLayer.popupEnabled = this.popupEnabled, this.signalClusterLayer = new c(
23
- k
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 i of t.areaList) {
41
- const s = new b(
42
- i,
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 e = this.districtControllerDashLayer.createQuery();
113
- e.where = `id = '${t.id}'`, e.returnGeometry = !0, e.outFields = ["*"];
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
- e
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 i = this.subDistrictControllerLayer.createQuery();
123
- i.where = `id = '${t.id}'`, i.returnGeometry = !0, i.outFields = ["*"];
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
- i
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 e = this.signalMarkerLayer.createQuery();
132
- e.where = `id = '${t.id}'`, e.returnGeometry = !0, e.outFields = ["*"];
133
- const r = await this.signalMarkerLayer.queryFeatures(e);
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 i;
152
- switch ((i = this.view.popup) != null && i.visible && this.view.popup.close(), t.type) {
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 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, {
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 e = await this.subDistrictControllerLayer.queryFeatures();
165
- if (e.features.length > 0) {
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 l = e.features[0].attributes.parentId;
168
- return this.districtControllerDashLayer.definitionExpression = `id = '${l}'`, this.districtControllerSolidLayer.definitionExpression = `id = '${l}'`, await this.view.goTo(e.features, {
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 e = await this.signalMarkerLayer.queryFeatures();
178
- if (e.features.length > 0) {
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 = 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 },
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, i, s) {
212
- const e = t.getAllSignalCoordinates();
222
+ generateGraphic(t, e, s) {
223
+ const i = t.getAllSignalCoordinates();
213
224
  let r = null;
214
- if (e.length >= 2)
215
- if (e.length === 2)
216
- r = d.lineString(e);
225
+ if (i.length >= 2)
226
+ if (i.length === 2)
227
+ r = d.lineString(i);
217
228
  else {
218
- if (i) {
219
- const n = d.featureCollection(
220
- e.map((a) => d.point(a))
229
+ if (e) {
230
+ const a = d.featureCollection(
231
+ i.map((n) => d.point(n))
221
232
  );
222
- r = f(n);
233
+ r = D(a);
223
234
  } else {
224
- const n = L(e, 0.5);
225
- n.length >= 4 && (r = d.polygon([n]));
235
+ const a = F(i, 0.5);
236
+ a.length >= 4 && (r = d.polygon([a]));
226
237
  }
227
- r || (r = d.lineString(e));
238
+ r || (r = d.lineString(i));
228
239
  }
229
- else if (e.length === 1)
230
- r = d.point(e[0]);
240
+ else if (i.length === 1)
241
+ r = d.point(i[0]);
231
242
  else
232
243
  return;
233
- const l = g(
244
+ const o = E(
234
245
  r.geometry,
235
246
  // 区控面积更大,需要更大的缓冲半径
236
- i ? 200 : 30,
247
+ e ? 200 : 30,
237
248
  {
238
249
  units: "meters"
239
250
  }
240
- ), o = new y({
251
+ ), h = new y({
241
252
  geometry: {
242
253
  type: "polyline",
243
- paths: l.geometry.coordinates
254
+ paths: o.geometry.coordinates
244
255
  },
245
256
  attributes: {
246
- ObjectID: i ? this.districtControllerOid++ : this.subDistrictControllerOid++,
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: i ? "district" : "subDistrict"
265
+ type: e ? "district" : "subDistrict"
255
266
  }
256
267
  });
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({
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: n.longitude,
265
- y: n.latitude
275
+ x: a.longitude,
276
+ y: a.latitude
266
277
  },
267
278
  attributes: {
268
279
  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,
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(a);
293
+ this.signalGraphics.push(n);
283
294
  });
284
295
  }
285
296
  async viewHitTest(t) {
286
- var n;
287
- const s = (n = (await this.view.hitTest(t, {
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 : n.filter(
296
- (a) => a.type === "graphic"
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 e = s[0].graphic;
311
+ const i = s[0].graphic;
301
312
  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) {
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 a = await this.districtControllerSolidLayer.queryFeatures();
307
- a.features.forEach((u) => {
308
- u.attributes.selected = u.attributes.id === o;
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: a.features
311
- }), a = await this.districtControllerDashLayer.queryFeatures(), a.features.forEach((u) => {
312
- u.attributes.selected = u.attributes.id === o;
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: a.features
325
+ updateFeatures: n.features
315
326
  });
316
327
  break;
317
328
  }
318
329
  case "subDistrict": {
319
- let a = await this.subDistrictControllerLayer.queryFeatures();
320
- a.features.forEach((h) => {
321
- h.attributes.selected = h.attributes.id === o;
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: a.features
324
- }), a = await this.signalMarkerLayer.queryFeatures(), a.features.forEach((h) => {
325
- h.attributes.selected = h.attributes.subDistrictId === o;
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 u = await this.signalMarkerLayer.applyEdits({
328
- updateFeatures: a.features
338
+ let l = await this.signalMarkerLayer.applyEdits({
339
+ updateFeatures: n.features
329
340
  });
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);
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
- p.when(
349
+ L.when(
339
350
  () => this.view.popup.visible === !1,
340
351
  async () => {
341
- await this.resetSelectedSymbol(l);
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 i = await this.districtControllerSolidLayer.queryFeatures();
355
- i.features.forEach((s) => {
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: i.features
359
- }), i = await this.districtControllerDashLayer.queryFeatures(), i.features.forEach((s) => {
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: i.features
373
+ updateFeatures: e.features
363
374
  });
364
375
  break;
365
376
  }
366
377
  case "subDistrict": {
367
- let i = await this.subDistrictControllerLayer.queryFeatures();
368
- i.features.forEach((s) => {
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: i.features
372
- }), i = await this.signalMarkerLayer.queryFeatures(), console.log("marker count", i.features.length), i.features.forEach((s) => {
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: i.features
376
- }), i = await this.signalPictureLayer.queryFeatures(), console.log("picture count", i.features.length), i.features.forEach((s) => {
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: i.features
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
- P as default
464
+ U as default
388
465
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("@arcgis/core/Graphic"),g=require("@arcgis/core/layers/GraphicsLayer"),m=require("vue"),u=require("../../stores/index.js");class y{constructor(i){this.hasGpu=!1,this.appDataStore=u.default.useAppDataStore,this.logTable=[["uuid","ptcId","plateno","timestamp","localTimestamp","timestamp_str","speed","laneNo","objHeight","objLength","latitude","longitude","ptcType","vehicleType","vehicleColor","plateColor","sbdm","heading","fixAngle","roadLayer","status","step","receiveTimestamp"]],this.needInterpolate=!0,this.isPaused=!1,this.showVehiclePlate=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.view=i,this.mapConfig=m.toRaw(this.appDataStore.mapConfig),this.vehicleLayer=new g({id:"vehicleLayer"}),this.view.map.add(this.vehicleLayer);const t=localStorage.getItem("gpu");this.hasGpu=t!=="Unknown",this.hasGpu&&(this.rafSignal=requestAnimationFrame(()=>this.render()))}getLog(){return this.logTable}async init(){}addVehicles(i){return new Promise(t=>{if(this.isPaused){t();return}const e=i.map(s=>{const{vehicleId:o,heading:r,localTimestamp:h}=s,l=Number(s.x),n=Number(s.y),a=new p({geometry:{type:"point",x:l,y:n},attributes:{...s,type:"trackVehicle"},symbol:this.hasGpu?this.createCIMSymbol(s):this.createMarkerSymbol()});return this.hasGpu&&(a.visible=!1,this.historyPositionMap.set(o,[{pos:[l,n,0],heading:r,time:h}]),this.vehicleObjectMap.set(o,{graphic:a,data:s,waitForDelete:!1,isMoving:!1})),a});this.vehicleLayer.addMany(e),t()})}updateVehicles(i){return new Promise(t=>{if(this.isPaused){t();return}const e=[];i.forEach(s=>{const{vehicleId:o,heading:r,localTimestamp:h}=s,l=Number(s.x),n=Number(s.y);if(this.hasGpu){const a=this.vehicleObjectMap.get(o);a?(a.data=s,a.graphic.attributes={...s,type:"trackVehicle"},this.historyPositionMap.get(o).push({pos:[l,n,0],heading:r,time:h})):e.push(s)}else{const a=this.vehicleLayer.graphics.find(c=>c.getAttribute("vehicleId")==s.vehicleId);a?a.geometry={type:"point",x:l,y:n}:e.push(s)}}),this.addVehicles(e),t()})}deleteVehicles(i){this.isPaused||(this.hasGpu?i.forEach(t=>{const e=this.vehicleObjectMap.get(t);e&&(e.waitForDelete=!0)}):i.forEach(t=>{const e=this.vehicleLayer.graphics.find(s=>s.getAttribute("vehicleId")==t);e&&this.vehicleLayer.remove(e)}))}clearVehicles(){this.vehicleLayer.removeAll(),this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}toggleGroundVehicle(i){this.showGroundVehicle=i}toggleElevatedVehicle(i){this.showElevatedVehicle=i}toggleTrafficInfo(i){i.name==="vehiclePlate"&&(this.showVehiclePlate=i.visible)}togglePause(i){this.isPaused=i,this.isPaused&&this.rafSignal?cancelAnimationFrame(this.rafSignal):this.rafSignal=requestAnimationFrame(()=>this.render())}updatePanelContent(i){console.log(i)}setInterpolate(i){this.needInterpolate=i}render(){this.isPaused||this.vehicleObjectMap.forEach((i,t)=>{this.updatePosition(t)}),this.rafSignal=requestAnimationFrame(()=>this.render())}updatePosition(i){const t=this.historyPositionMap.get(i),e=this.vehicleObjectMap.get(i);if(!t||!e||!e.isMoving&&t.length<=2)return;e.isMoving=!0,(e.graphic.getAttribute("roadLayer")||"1")==="1"?e.graphic.visible=this.showGroundVehicle:e.graphic.visible=this.showElevatedVehicle,e.segmentStartTime||(e.segmentStartTime=Date.now(),e.segmentTotalTime=t[1].time-t[0].time);const o=Date.now()-e.segmentStartTime,r=Math.min(1,o/e.segmentTotalTime);if(r===1)if(t.shift(),t.length===1){e.waitForDelete?(this.vehicleLayer.remove(e.graphic),this.vehicleObjectMap.delete(i),this.historyPositionMap.delete(i)):(e.segmentStartTime=void 0,e.segmentTotalTime=void 0,e.graphic.visible=!1,e.isMoving=!1);return}else e.segmentStartTime=Date.now(),e.segmentTotalTime=t[1].time-t[0].time,Math.abs(t[1].heading-t[0].heading)>180&&(t[1].heading>t[0].heading?t[0].heading+=360:t[1].heading+=360),e.graphic.geometry={type:"point",x:t[0].pos[0],y:t[0].pos[1]};else{const h=t[0].pos[0]+(t[1].pos[0]-t[0].pos[0])*r,l=t[0].pos[1]+(t[1].pos[1]-t[0].pos[1])*r,n=t[0].heading+(t[1].heading-t[0].heading)*r;e.graphic.geometry={type:"point",x:h,y:l},e.data.heading=n,e.graphic.symbol=this.hasGpu?this.createCIMSymbol(e.data):this.createMarkerSymbol()}}createCIMSymbol(i){const t=this.getPlateFontColor(i.plateColor),e=this.getCarPic(i.vehicleColor,i.speed);return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:"$feature.showName",returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:this.showVehiclePlate,size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-8,ymin:-8,xmax:8,ymax:8},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:4,horizontalAlignment:"Center",offsetX:0,offsetY:8,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:t.backgroundColor}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:t.fillColor}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:e.size,rotation:i.heading,rotateClockwise:!0,textureFilter:"Picture",url:`${this.mapConfig.assetsRoot}Images/${e.pic}`}]}}}}createMarkerSymbol(){return{type:"simple-marker",color:"green",size:5,outline:{color:"white",width:1}}}getCarPic(i,t){if(this.view.scale>=1e3){let e="point_green.png";return t&&(t<=4.2?e="point_red.png":t<=8.4?e="point_yellow.png":e="point_green.png"),{pic:e,size:15}}else{let e="grey";switch(typeof i=="string"&&(i=i.toLowerCase()),i){case"a":case 1:e="white";break;case"b":case 2:e="grey";break;case"c":case 3:e="yellow";break;case"d":case 4:e="pink";break;case"e":case 5:e="red";break;case"f":case 10:e="purple";break;case"g":case 6:e="green";break;case"h":case 7:e="blue";break;case"i":case 8:e="brown";break;case"j":case 9:e="black";break}return{pic:"/car/"+e+".png",size:20}}}getPlateFontColor(i){let t=[255,255,255,255],e=[169,169,169,255];switch(i){case 0:t=[0,0,0,255],e=[255,255,255,255];break;case 1:t=[0,0,0,255],e=[244,164,96,255];break;case 2:t=[255,255,255,255],e=[65,105,225,255];break;case 3:t=[255,255,255,255],e=[0,0,0,255];break;case 15:t=[244,164,96,255],e=[0,250,154,255];break;case 16:t=[0,0,0,255],e=[0,250,154,255];break}return{fillColor:t,backgroundColor:e}}}exports.default=y;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("@arcgis/core/Graphic"),g=require("@arcgis/core/layers/GraphicsLayer"),m=require("vue"),u=require("../../stores/index.js");class y{constructor(i){this.hasGpu=!1,this.appDataStore=u.default.useAppDataStore,this.logTable=[["uuid","ptcId","plateno","timestamp","localTimestamp","timestamp_str","speed","laneNo","objHeight","objLength","latitude","longitude","ptcType","vehicleType","vehicleColor","plateColor","sbdm","heading","fixAngle","roadLayer","status","step","receiveTimestamp"]],this.needInterpolate=!0,this.isPaused=!1,this.showVehiclePlate=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.view=i,this.mapConfig=m.toRaw(this.appDataStore.mapConfig),this.vehicleLayer=new g({id:"vehicleLayer"}),this.view.map.add(this.vehicleLayer);const t=localStorage.getItem("gpu");this.hasGpu=t!=="Unknown",this.hasGpu&&(this.rafSignal=requestAnimationFrame(()=>this.render()))}getLog(){return this.logTable}async init(){}addVehicles(i){return new Promise(t=>{if(this.isPaused){t();return}const e=i.map(s=>{const{vehicleId:r,heading:o,localTimestamp:l}=s,n=Number(s.x),h=Number(s.y),a=new p({geometry:{type:"point",x:n,y:h},attributes:{...s,type:"trackVehicle"},symbol:this.hasGpu?this.createCIMSymbol(s):this.createMarkerSymbol()});return this.hasGpu&&(a.visible=!1,this.historyPositionMap.set(r,[{pos:[n,h,0],heading:o,time:l}]),this.vehicleObjectMap.set(r,{graphic:a,data:s,waitForDelete:!1,isMoving:!1})),a});this.vehicleLayer.addMany(e),t()})}updateVehicles(i){return new Promise(t=>{if(this.isPaused){t();return}const e=[];i.forEach(s=>{const{vehicleId:r,heading:o,localTimestamp:l}=s,n=Number(s.x),h=Number(s.y);if(this.hasGpu){const a=this.vehicleObjectMap.get(r);a?(a.data=s,a.graphic.attributes={...s,type:"trackVehicle"},this.historyPositionMap.get(r).push({pos:[n,h,0],heading:o,time:l})):e.push(s)}else{const a=this.vehicleLayer.graphics.find(c=>c.getAttribute("vehicleId")==s.vehicleId);a?a.geometry={type:"point",x:n,y:h}:e.push(s)}}),this.addVehicles(e),t()})}deleteVehicles(i){this.isPaused||(this.hasGpu?i.forEach(t=>{const e=this.vehicleObjectMap.get(t);e&&(e.waitForDelete=!0)}):i.forEach(t=>{const e=this.vehicleLayer.graphics.find(s=>s.getAttribute("vehicleId")==t);e&&this.vehicleLayer.remove(e)}))}clearVehicles(){this.vehicleLayer.removeAll(),this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}toggleGroundVehicle(i){this.showGroundVehicle=i}toggleElevatedVehicle(i){this.showElevatedVehicle=i}toggleTrafficInfo(i){i.name==="vehiclePlate"&&(this.showVehiclePlate=i.visible)}togglePause(i){this.isPaused=i,this.isPaused&&this.rafSignal?cancelAnimationFrame(this.rafSignal):this.rafSignal=requestAnimationFrame(()=>this.render())}updatePanelContent(i){console.log(i)}setInterpolate(i){this.needInterpolate=i}render(){this.isPaused||this.vehicleObjectMap.forEach((i,t)=>{this.updatePosition(t)}),this.rafSignal=requestAnimationFrame(()=>this.render())}updatePosition(i){const t=this.historyPositionMap.get(i),e=this.vehicleObjectMap.get(i);if(!t||!e||!e.isMoving&&t.length<=2)return;e.isMoving=!0,(e.graphic.getAttribute("roadLayer")||"1")==="1"?e.graphic.visible=this.showGroundVehicle:e.graphic.visible=this.showElevatedVehicle,e.segmentStartTime||(e.segmentStartTime=Date.now(),e.segmentTotalTime=t[1].time-t[0].time);const r=Date.now()-e.segmentStartTime,o=Math.min(1,r/e.segmentTotalTime);if(o===1)if(t.shift(),t.length===1){e.waitForDelete?(this.vehicleLayer.remove(e.graphic),this.vehicleObjectMap.delete(i),this.historyPositionMap.delete(i)):(e.segmentStartTime=void 0,e.segmentTotalTime=void 0,e.graphic.visible=!1,e.isMoving=!1);return}else{e.segmentStartTime=Date.now();const l=r-e.segmentTotalTime;e.segmentTotalTime=t[1].time-t[0].time-l,Math.abs(t[1].heading-t[0].heading)>180&&(t[1].heading>t[0].heading?t[0].heading+=360:t[1].heading+=360),e.graphic.geometry={type:"point",x:t[0].pos[0],y:t[0].pos[1]}}else{const l=t[0].pos[0]+(t[1].pos[0]-t[0].pos[0])*o,n=t[0].pos[1]+(t[1].pos[1]-t[0].pos[1])*o,h=t[0].heading+(t[1].heading-t[0].heading)*o;e.graphic.geometry={type:"point",x:l,y:n},e.data.heading=h,e.graphic.symbol=this.hasGpu?this.createCIMSymbol(e.data):this.createMarkerSymbol()}}createCIMSymbol(i){const t=this.getPlateFontColor(i.plateColor),e=this.getCarPic(i.vehicleColor,i.speed);return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:"$feature.showName",returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:this.showVehiclePlate,size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-8,ymin:-8,xmax:8,ymax:8},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:4,horizontalAlignment:"Center",offsetX:0,offsetY:8,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:t.backgroundColor}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:t.fillColor}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:e.size,rotation:i.heading,rotateClockwise:!0,textureFilter:"Picture",url:`${this.mapConfig.assetsRoot}Images/${e.pic}`}]}}}}createMarkerSymbol(){return{type:"simple-marker",color:"green",size:5,outline:{color:"white",width:1}}}getCarPic(i,t){if(this.view.scale>=1e3){let e="point_green.png";return t&&(t<=4.2?e="point_red.png":t<=8.4?e="point_yellow.png":e="point_green.png"),{pic:e,size:15}}else{let e="grey";switch(typeof i=="string"&&(i=i.toLowerCase()),i){case"a":case 1:e="white";break;case"b":case 2:e="grey";break;case"c":case 3:e="yellow";break;case"d":case 4:e="pink";break;case"e":case 5:e="red";break;case"f":case 10:e="purple";break;case"g":case 6:e="green";break;case"h":case 7:e="blue";break;case"i":case 8:e="brown";break;case"j":case 9:e="black";break}return{pic:"/car/"+e+".png",size:20}}}getPlateFontColor(i){let t=[255,255,255,255],e=[169,169,169,255];switch(i){case 0:t=[0,0,0,255],e=[255,255,255,255];break;case 1:t=[0,0,0,255],e=[244,164,96,255];break;case 2:t=[255,255,255,255],e=[65,105,225,255];break;case 3:t=[255,255,255,255],e=[0,0,0,255];break;case 15:t=[244,164,96,255],e=[0,250,154,255];break;case 16:t=[0,0,0,255],e=[0,250,154,255];break}return{fillColor:t,backgroundColor:e}}}exports.default=y;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.216",
3
+ "version": "1.0.218",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [