gisviewer-vue3-arcgis 1.0.230 → 1.0.232

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.
@@ -1,67 +1,64 @@
1
1
  import { Polygon as f } from "@arcgis/core/geometry";
2
- import { webMercatorToGeographic as m } from "@arcgis/core/geometry/support/webMercatorUtils";
3
- import u from "@arcgis/core/Graphic";
4
- import y from "@arcgis/core/layers/GraphicsLayer";
5
- import D from "@turf/buffer";
6
- import w from "@turf/convex";
7
- import * as c from "@turf/helpers";
8
- import R from "concaveman";
9
- import S from "../../stores/index.mjs";
10
- import G from "./district-controller.mjs";
11
- import C from "./district-renderer.mjs";
12
- import I from "./signal-renderer.mjs";
13
- import L from "./sub-district-renderer.mjs";
14
- class T {
15
- constructor(t) {
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 = S.useAppDataStore;
18
- this.mapConfig = JSON.parse(JSON.stringify(e.mapConfig)), this.detachmentLayer = new y(), this.view.map.add(this.detachmentLayer), this.districtRenderer = new C(t, this.hasGpu), this.subDistrictRenderer = new L(t, this.hasGpu), this.signalRenderer = new I(t, this.hasGpu);
2
+ import { webMercatorToGeographic as y } from "@arcgis/core/geometry/support/webMercatorUtils";
3
+ import g from "@arcgis/core/Graphic";
4
+ import m from "@arcgis/core/layers/GraphicsLayer";
5
+ import p from "papaparse";
6
+ import R from "../../stores/index.mjs";
7
+ import D from "./district-controller.mjs";
8
+ import w from "./district-renderer.mjs";
9
+ import L from "./signal-renderer.mjs";
10
+ import C from "./sub-district-renderer.mjs";
11
+ class P {
12
+ constructor(e) {
13
+ this.detachmentLayerLoaded = !1, this.view = e, this.hasGpu = localStorage.getItem("gpu") !== "Unknown";
14
+ const t = R.useAppDataStore;
15
+ this.mapConfig = JSON.parse(JSON.stringify(t.mapConfig)), this.detachmentLayer = new m(), this.view.map.add(this.detachmentLayer), this.districtRenderer = new w(e, this.hasGpu), this.subDistrictRenderer = new C(e, this.hasGpu), this.signalRenderer = new L(e, this.hasGpu);
19
16
  }
20
17
  /**
21
18
  * 显示所有区控、子区、信号机
22
19
  * @param params
23
20
  * @returns
24
21
  */
25
- async showSignalControlArea(t) {
26
- this.detachmentLayerLoaded || await this.loadDetachmentLayer(), await this.clearSignalControlArea(), this.districtRenderer.setVisible(!1), this.subDistrictRenderer.setVisible(!1), this.signalRenderer.setClusterVisible(!1), this.signalRenderer.setPointVisible(!1);
27
- const e = [], s = [];
28
- for (const r of t.areaList) {
29
- const a = new G(
30
- r,
31
- t.style || ""
22
+ async showSignalControlArea(e) {
23
+ this.detachmentLayerLoaded || await this.loadDetachmentLayer(), this.roadLines || (await this.loadRoadLine(), this.subDistrictRenderer.roadLines = this.roadLines), await this.clearSignalControlArea(), this.districtRenderer.setVisible(!1), this.subDistrictRenderer.setVisible(!1), this.signalRenderer.setClusterVisible(!1), this.signalRenderer.setPointVisible(!1);
24
+ const t = [], s = [];
25
+ for (const a of e.areaList) {
26
+ const i = new D(
27
+ a,
28
+ e.style || ""
32
29
  );
33
- e.push(a), s.push(...a.subDistricts);
30
+ t.push(i), s.push(...i.subDistricts);
34
31
  }
35
- return this.districtRenderer.style = t.style || "", await this.districtRenderer.showDistricts(e), await this.subDistrictRenderer.showSubDistricts(s), await this.signalRenderer.showSignals(e), { status: 0, message: "ok" };
32
+ return this.districtRenderer.style = e.style || "", await this.districtRenderer.showDistricts(t), await this.subDistrictRenderer.showSubDistricts(s), await this.signalRenderer.showSignals(t), { status: 0, message: "ok" };
36
33
  }
37
34
  /**
38
35
  * 清空区控、子区、信号机
39
36
  * @returns
40
37
  */
41
38
  async clearSignalControlArea() {
42
- return this.districtGraphics = [], this.subDistrictGraphics = [], this.signalGraphics = [], this.districtControllerOid = 0, this.subDistrictControllerOid = 0, this.signalOid = 0, await this.districtRenderer.clearDistricts(), await this.subDistrictRenderer.clearSubDistricts(), await this.signalRenderer.clearSignals(), { status: 0, message: "ok" };
39
+ return await this.districtRenderer.clearDistricts(), await this.subDistrictRenderer.clearSubDistricts(), await this.signalRenderer.clearSignals(), { status: 0, message: "ok" };
43
40
  }
44
41
  /**
45
42
  * 设置区控、子区、信号机图层可见性
46
43
  * @param layerName
47
44
  * @param visible
48
45
  */
49
- setLayerVisibility(t) {
50
- switch (t.visible === !1 && this.view.closePopup(), t.id) {
46
+ setLayerVisibility(e) {
47
+ switch (e.visible === !1 && this.view.closePopup(), e.id) {
51
48
  case "district":
52
- this.districtRenderer.setVisible(t.visible);
49
+ this.districtRenderer.setVisible(e.visible);
53
50
  break;
54
51
  case "subDistrict":
55
- this.subDistrictRenderer.setVisible(t.visible);
52
+ this.subDistrictRenderer.setVisible(e.visible);
56
53
  break;
57
54
  case "signal":
58
- this.signalRenderer.setPointVisible(t.visible);
55
+ this.signalRenderer.setPointVisible(e.visible);
59
56
  break;
60
57
  case "signalCluster":
61
- this.signalRenderer.setClusterVisible(t.visible);
58
+ this.signalRenderer.setClusterVisible(e.visible);
62
59
  break;
63
60
  case "shanghai_district":
64
- this.detachmentLayer.visible = t.visible;
61
+ this.detachmentLayer.visible = e.visible;
65
62
  break;
66
63
  }
67
64
  return { status: 0, message: "ok" };
@@ -71,14 +68,14 @@ class T {
71
68
  * @param params
72
69
  * @returns
73
70
  */
74
- async locateSignalControlArea(t) {
75
- switch (t.type) {
71
+ async locateSignalControlArea(e) {
72
+ switch (e.type) {
76
73
  case "district":
77
- return await this.districtRenderer.locateDistrict(t.id);
74
+ return await this.districtRenderer.locateDistrict(e.id);
78
75
  case "subDistrict":
79
- return await this.subDistrictRenderer.locateSubDistrict(t.id);
76
+ return await this.subDistrictRenderer.locateSubDistrict(e.id);
80
77
  case "signal":
81
- return await this.signalRenderer.locateSignal(t.id);
78
+ return await this.signalRenderer.locateSignal(e.id);
82
79
  default:
83
80
  return { status: 1, message: "未知类型" };
84
81
  }
@@ -88,22 +85,17 @@ class T {
88
85
  * @param params
89
86
  * @returns
90
87
  */
91
- async highlightSignalControlArea(t) {
92
- switch (this.view.closePopup(), t.type) {
88
+ async highlightSignalControlArea(e) {
89
+ switch (this.view.closePopup(), e.type) {
93
90
  case "district":
94
- return await this.districtRenderer.highlightDistrict(t.id) ? (this.subDistrictRenderer.filter("district", t.id), this.signalRenderer.filter("district", t.id), { status: 0, message: "ok" }) : { status: 1, message: "未找到区控" };
91
+ return await this.districtRenderer.highlightDistrict(e.id) ? (this.subDistrictRenderer.filter("district", e.id), this.signalRenderer.filter("district", e.id), this.roadLines && this.roadLines.length > 0 && await this.subDistrictRenderer.showRoads(e.id), { status: 0, message: "ok" }) : { status: 1, message: "未找到区控" };
95
92
  case "subDistrict": {
96
- const { count: e, parentId: s } = await this.subDistrictRenderer.highlightSubDistrict(t.id);
97
- return e > 0 ? (this.districtRenderer.filter(s), this.signalRenderer.filter("subDistrict", t.id), { status: 0, message: "ok" }) : { status: 1, message: "未找到子区" };
93
+ const { count: t, parentId: s } = await this.subDistrictRenderer.highlightSubDistrict(e.id);
94
+ return t > 0 ? (this.districtRenderer.filter(s), this.signalRenderer.filter("subDistrict", e.id), { status: 0, message: "ok" }) : { status: 1, message: "未找到子区" };
98
95
  }
99
96
  case "signal": {
100
- const { districtId: e, subDistrictId: s, count: r } = await this.signalRenderer.highlightSignal(t.id);
101
- return r > 0 ? (this.districtRenderer.filter(e), this.subDistrictRenderer.filter("subDistrict", s), await this.view.goTo(
102
- { target: this.signalGraphics, scale: t.scale || 1e3 },
103
- {
104
- duration: this.hasGpu ? 1e3 : 0
105
- }
106
- ), { status: 0, message: "ok" }) : { status: 1, message: "未找到信号机" };
97
+ const { districtId: t, subDistrictId: s, count: a } = await this.signalRenderer.highlightSignal(e.id);
98
+ return a > 0 ? (this.districtRenderer.filter(t), this.subDistrictRenderer.filter("subDistrict", s), { status: 0, message: "ok" }) : { status: 1, message: "未找到信号机" };
107
99
  }
108
100
  default:
109
101
  return { status: 1, message: "未知类型" };
@@ -117,259 +109,77 @@ class T {
117
109
  return this.districtRenderer.resetFilter(), this.subDistrictRenderer.resetFilter(), this.signalRenderer.resetFilter(), { status: 0, message: "ok" };
118
110
  }
119
111
  /**
120
- * 生成区控、子区和信号机graphic
121
- * @param districtController
122
- * @param isDistrict 是否是区控
112
+ * 获取道路线
123
113
  * @returns
124
114
  */
125
- generateGraphic(t, e, s) {
126
- const r = t.getAllSignalCoordinates();
127
- let a = null;
128
- if (r.length >= 2)
129
- if (r.length === 2)
130
- a = c.lineString(r);
131
- else {
132
- if (e) {
133
- const i = c.featureCollection(
134
- r.map((o) => c.point(o))
135
- );
136
- a = w(i);
137
- } else {
138
- const i = R(r, 0.5);
139
- i.length >= 4 && (a = c.polygon([i]));
140
- }
141
- a || (a = c.lineString(r));
142
- }
143
- else if (r.length === 1)
144
- a = c.point(r[0]);
145
- else
115
+ async loadRoadLine() {
116
+ var t;
117
+ const e = (t = this.mapConfig.signalControlArea) == null ? void 0 : t.roadLayerUrl;
118
+ if (!e) {
119
+ console.warn("未配置道路线图层URL");
146
120
  return;
147
- const n = D(
148
- a.geometry,
149
- // 区控面积更大,需要更大的缓冲半径
150
- e ? 200 : 30,
151
- {
152
- units: "meters"
153
- }
154
- ), l = new u({
155
- geometry: {
156
- type: "polyline",
157
- paths: n.geometry.coordinates
158
- },
159
- attributes: {
160
- ObjectID: e ? this.districtControllerOid++ : this.subDistrictControllerOid++,
161
- id: t.id,
162
- name: t.name,
163
- subDistrictCount: t.subDistrictCount,
164
- signalCount: t.signalCount,
165
- parentId: t.parentId,
166
- parentName: t.parentName,
167
- selected: s,
168
- type: e ? "district" : "subDistrict"
169
- }
170
- });
171
- e ? this.districtGraphics.push(l) : this.subDistrictGraphics.push(l);
172
- for (const i of t.subDistricts)
173
- this.generateGraphic(i, !1, s);
174
- t.signals.forEach((i) => {
175
- const o = new u({
176
- geometry: {
177
- type: "point",
178
- x: i.longitude,
179
- y: i.latitude
121
+ }
122
+ try {
123
+ const a = await (await fetch(`/GisViewerAssets/${e}`)).text();
124
+ p.parse(a, {
125
+ header: !0,
126
+ skipEmptyLines: !0,
127
+ complete: (i) => {
128
+ const { data: r } = i;
129
+ this.roadLines = r.map((n) => ({
130
+ id: n.ROADSECT_ID,
131
+ fromNode: n.FROM_NODE_ID,
132
+ toNode: n.TO_NODE_ID,
133
+ coordinates: JSON.parse(n.GEOM).coordinates
134
+ }));
180
135
  },
181
- attributes: {
182
- ObjectID: this.signalOid++,
183
- id: i.id,
184
- name: i.name,
185
- signalId: i.signalId,
186
- nodeId: i.nodeId,
187
- isKey: i.isKey,
188
- districtId: e ? t.id : t.parentId,
189
- districtName: e ? t.name : t.parentName,
190
- subDistrictId: e ? "" : t.id,
191
- subDistrictName: e ? "" : t.name,
192
- type: "signal",
193
- selected: !0
136
+ error: (i) => {
137
+ console.error("道路线CSV解析失败:", i);
194
138
  }
195
139
  });
196
- this.signalGraphics.push(o);
197
- });
140
+ } catch (s) {
141
+ console.error("读取道路线CSV失败:", s);
142
+ }
198
143
  }
199
- // private async viewHitTest(event: __esri.ViewClickEvent) {
200
- // // 捕捉点击事件
201
- // const response = await this.view.hitTest(event, {
202
- // include: [
203
- // // this.districtControllerSolidLayer,
204
- // this.subDistrictControllerLayer,
205
- // this.signalMarkerLayer,
206
- // this.signalPictureLayer,
207
- // this.signalClusterLayer
208
- // ]
209
- // });
210
- // const graphicHits = response.results?.filter(
211
- // (hitResult) => hitResult.type === 'graphic'
212
- // );
213
- // if (graphicHits.length === 0) {
214
- // return;
215
- // }
216
- // const hitGraphic = (graphicHits[0] as __esri.GraphicHit).graphic;
217
- // let centerPoint: __esri.Point | null = null;
218
- // if (hitGraphic.geometry.type === 'point') {
219
- // centerPoint = hitGraphic.geometry as __esri.Point;
220
- // } else if (hitGraphic.geometry.type === 'polyline') {
221
- // centerPoint = hitGraphic.geometry.extent.center;
222
- // } else if (hitGraphic.geometry.type === 'polygon') {
223
- // centerPoint = (hitGraphic.geometry as __esri.Polygon).centroid;
224
- // }
225
- // if (centerPoint !== null)
226
- // await this.view.goTo(centerPoint, { duration: 1000 });
227
- // // 未选中的同级graphic置灰
228
- // const clickedType = hitGraphic.getAttribute('type');
229
- // const clickedId = hitGraphic.getAttribute('id');
230
- // switch (clickedType) {
231
- // case 'district': {
232
- // let result = await this.districtControllerSolidLayer.queryFeatures();
233
- // result.features.forEach((feature) => {
234
- // feature.attributes.selected = feature.attributes.id === clickedId;
235
- // });
236
- // await this.districtControllerSolidLayer.applyEdits({
237
- // updateFeatures: result.features
238
- // });
239
- // result = await this.districtControllerDashLayer.queryFeatures();
240
- // result.features.forEach((feature) => {
241
- // feature.attributes.selected = feature.attributes.id === clickedId;
242
- // });
243
- // await this.districtControllerDashLayer.applyEdits({
244
- // updateFeatures: result.features
245
- // });
246
- // break;
247
- // }
248
- // case 'subDistrict': {
249
- // let result = await this.subDistrictControllerLayer.queryFeatures();
250
- // result.features.forEach((feature) => {
251
- // feature.attributes.selected = feature.attributes.id === clickedId;
252
- // });
253
- // await this.subDistrictControllerLayer.applyEdits({
254
- // updateFeatures: result.features
255
- // });
256
- // // 其他子区的信号机置灰
257
- // result = await this.signalMarkerLayer.queryFeatures();
258
- // result.features.forEach((feature) => {
259
- // feature.attributes.selected =
260
- // feature.attributes.subDistrictId === clickedId;
261
- // });
262
- // let editResult = await this.signalMarkerLayer.applyEdits({
263
- // updateFeatures: result.features
264
- // });
265
- // result = await this.signalPictureLayer.queryFeatures();
266
- // result.features.forEach((feature) => {
267
- // feature.attributes.selected =
268
- // feature.attributes.subDistrictId === clickedId;
269
- // });
270
- // editResult = await this.signalPictureLayer.applyEdits({
271
- // updateFeatures: result.features
272
- // });
273
- // break;
274
- // }
275
- // }
276
- // reactiveUtils.when(
277
- // () => this.view.popup.visible === false,
278
- // async () => {
279
- // await this.resetSelectedSymbol(clickedType);
280
- // },
281
- // {
282
- // once: true
283
- // }
284
- // );
285
- // }
286
- /**
287
- * 重置所有graphic的置灰状态
288
- */
289
- // private async resetSelectedSymbol(type: string) {
290
- // switch (type) {
291
- // case 'district': {
292
- // let result = await this.districtControllerSolidLayer.queryFeatures();
293
- // result.features.forEach((feature) => {
294
- // feature.attributes.selected = true;
295
- // });
296
- // await this.districtControllerSolidLayer.applyEdits({
297
- // updateFeatures: result.features
298
- // });
299
- // result = await this.districtControllerDashLayer.queryFeatures();
300
- // result.features.forEach((feature) => {
301
- // feature.attributes.selected = true;
302
- // });
303
- // await this.districtControllerDashLayer.applyEdits({
304
- // updateFeatures: result.features
305
- // });
306
- // break;
307
- // }
308
- // case 'subDistrict': {
309
- // let result = await this.subDistrictControllerLayer.queryFeatures();
310
- // result.features.forEach((feature) => {
311
- // feature.attributes.selected = true;
312
- // });
313
- // await this.subDistrictControllerLayer.applyEdits({
314
- // updateFeatures: result.features
315
- // });
316
- // result = await this.signalMarkerLayer.queryFeatures();
317
- // result.features.forEach((feature) => {
318
- // feature.attributes.selected = true;
319
- // });
320
- // await this.signalMarkerLayer.applyEdits({
321
- // updateFeatures: result.features
322
- // });
323
- // result = await this.signalPictureLayer.queryFeatures();
324
- // result.features.forEach((feature) => {
325
- // feature.attributes.selected = true;
326
- // });
327
- // await this.signalPictureLayer.applyEdits({
328
- // updateFeatures: result.features
329
- // });
330
- // break;
331
- // }
332
- // }
333
- // }
334
144
  /**
335
145
  * 加载支队图层
336
146
  * 现场环境用url创建FeatureLayer有各种问题,
337
147
  * 改为图层导出为json,用json创建Graphic,再将Graphic添加到FeatureLayer
338
148
  */
339
149
  async loadDetachmentLayer() {
340
- const t = this.mapConfig.baseLayers;
341
- if (!t)
150
+ const e = this.mapConfig.baseLayers;
151
+ if (!e)
342
152
  return;
343
- const e = t.find(
153
+ const t = e.find(
344
154
  (s) => s.options.id === "shanghai_district"
345
155
  );
346
- if (e)
156
+ if (t)
347
157
  try {
348
- const r = await (await fetch(
158
+ const a = await (await fetch(
349
159
  "/GisViewerAssets/ShangHai/Layers/district.json"
350
- )).json(), a = [], { renderer: n, labelingInfo: l } = e.options;
351
- r.features.forEach((i) => {
352
- const o = i.attributes.ZD_NAME;
353
- if (o !== "高架支队") {
354
- let d = new f({
355
- rings: i.geometry.rings
160
+ )).json(), i = [], { renderer: r, labelingInfo: n } = t.options;
161
+ a.features.forEach((d) => {
162
+ const c = d.attributes.ZD_NAME;
163
+ if (c !== "高架支队") {
164
+ let l = new f({
165
+ rings: d.geometry.rings
356
166
  });
357
- d = m(d);
358
- const h = new u({
359
- geometry: d,
360
- attributes: i.attributes
167
+ l = y(l);
168
+ const o = new g({
169
+ geometry: l,
170
+ attributes: d.attributes
361
171
  });
362
- if (n) {
363
- if (n.type === "simple")
364
- h.symbol = n.symbol;
365
- else if (n.type === "unique-value") {
366
- const g = h.getAttribute("OBJECTID"), b = n.uniqueValueInfos.find(
367
- (p) => p.value == g
172
+ if (r) {
173
+ if (r.type === "simple")
174
+ o.symbol = r.symbol;
175
+ else if (r.type === "unique-value") {
176
+ const h = o.getAttribute("OBJECTID"), u = r.uniqueValueInfos.find(
177
+ (b) => b.value == h
368
178
  );
369
- h.symbol = b ? b.symbol : n.defaultSymbol;
179
+ o.symbol = u ? u.symbol : r.defaultSymbol;
370
180
  }
371
181
  } else
372
- h.symbol = {
182
+ o.symbol = {
373
183
  type: "simple-fill",
374
184
  color: [227, 237, 255, 0.4],
375
185
  outline: {
@@ -377,15 +187,15 @@ class T {
377
187
  width: 2
378
188
  }
379
189
  };
380
- if (a.push(h), l && o !== "边防港航支队" && o !== "机场支队") {
381
- const g = new u({
382
- geometry: d.centroid,
383
- symbol: { ...l.symbol, text: o }
190
+ if (i.push(o), n && c !== "边防港航支队" && c !== "机场支队") {
191
+ const h = new g({
192
+ geometry: l.centroid,
193
+ symbol: { ...n.symbol, text: c }
384
194
  });
385
- a.push(g);
195
+ i.push(h);
386
196
  }
387
197
  }
388
- }), this.detachmentLayer.addMany(a), this.detachmentLayerLoaded = !0;
198
+ }), this.detachmentLayer.addMany(i), this.detachmentLayerLoaded = !0;
389
199
  } catch (s) {
390
200
  console.error("加载支队图层失败:", s);
391
201
  return;
@@ -393,5 +203,5 @@ class T {
393
203
  }
394
204
  }
395
205
  export {
396
- T as default
206
+ P as default
397
207
  };
@@ -1,12 +1,15 @@
1
- import { IResult } from '../../../types';
1
+ import { IResult, IRoadLine } from '../../../types';
2
2
  import DistrictController from './district-controller';
3
3
  export default class SubDistrictRenderer {
4
4
  private view;
5
5
  private hasGpu;
6
6
  private clickHandler;
7
7
  private subDistrictPointLayer;
8
+ private subDistrictLineLayer;
9
+ roadLines: IRoadLine[];
8
10
  constructor(view: __esri.MapView | __esri.SceneView, hasGpu: boolean);
9
11
  showSubDistricts(controllers: DistrictController[]): Promise<void>;
12
+ showRoads(districtId: string): Promise<void>;
10
13
  clearSubDistricts(): Promise<void>;
11
14
  setVisible(visible: boolean): void;
12
15
  /**
@@ -23,8 +26,17 @@ export default class SubDistrictRenderer {
23
26
  count: number;
24
27
  parentId: string;
25
28
  }>;
29
+ /**
30
+ * 按照区控、子区id显示子区
31
+ * @param type 类型,district 或 subDistrict
32
+ * @param id
33
+ */
26
34
  filter(type: string, id: string): void;
35
+ /**
36
+ * 重置过滤器,显示所有子区
37
+ */
27
38
  resetFilter(): void;
28
- private currentRenderer;
39
+ private currentPointRenderer;
40
+ private currentLineRenderer;
29
41
  private viewHitTest;
30
42
  }