gisviewer-vue3-arcgis 1.0.140 → 1.0.141

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.
@@ -9,13 +9,6 @@ export default class SignalControlAreaController {
9
9
  private readonly crossScale;
10
10
  constructor(view: __esri.MapView | __esri.SceneView);
11
11
  showSignalControlArea(params: any): IResult;
12
- /**
13
- * 生成路口点符号。在不同比例尺下,使用不同的符号
14
- * @param attributes
15
- * @param symbolType
16
- * @returns
17
- */
18
- private getCrossGraphicSymbol;
19
12
  clearSignalControlArea(): IResult;
20
13
  locateSignalControlArea(params: {
21
14
  id: string;
@@ -38,4 +31,11 @@ export default class SignalControlAreaController {
38
31
  * @returns
39
32
  */
40
33
  private drawArea;
34
+ /**
35
+ * 生成路口点符号。在不同比例尺下,使用不同的符号
36
+ * @param attributes
37
+ * @param symbolType
38
+ * @returns
39
+ */
40
+ private getCrossGraphicSymbol;
41
41
  }
@@ -1,12 +1,12 @@
1
- import * as y from "@arcgis/core/core/reactiveUtils.js";
2
- import u from "@arcgis/core/Graphic";
1
+ import * as p from "@arcgis/core/core/reactiveUtils.js";
2
+ import y from "@arcgis/core/Graphic";
3
3
  import o from "@arcgis/core/layers/GraphicsLayer";
4
- import p from "@turf/buffer";
4
+ import g from "@turf/buffer";
5
5
  import d from "@turf/concave";
6
6
  import f from "@turf/convex";
7
- import * as h from "@turf/helpers";
7
+ import * as n from "@turf/helpers";
8
8
  import b from "./district-controller.mjs";
9
- class G {
9
+ class x {
10
10
  constructor(e) {
11
11
  this.crossScale = 3e3, this.view = e, this.view.popup.visibleElements = {
12
12
  closeButton: !0,
@@ -39,61 +39,33 @@ class G {
39
39
  const i = new b(t);
40
40
  this.drawArea(i, !0);
41
41
  }
42
- return this.watchHandle = y.watch(
42
+ return this.watchHandle = p.watch(
43
43
  () => this.view.scale,
44
44
  (t, i) => {
45
- t > this.crossScale && i <= this.crossScale ? (this.crossLayer.graphics.forEach((r) => {
46
- r.symbol = this.getCrossGraphicSymbol(
47
- r.attributes,
45
+ t > this.crossScale && i <= this.crossScale ? (this.crossLayer.graphics.forEach((s) => {
46
+ s.symbol = this.getCrossGraphicSymbol(
47
+ s.attributes,
48
48
  "marker"
49
49
  );
50
- }), this.highlightLayer.graphics.forEach((r) => {
51
- r.getAttribute("type") === "cross" && (r.symbol = this.getCrossGraphicSymbol(
52
- r.attributes,
50
+ }), this.highlightLayer.graphics.forEach((s) => {
51
+ s.getAttribute("type") === "cross" && (s.symbol = this.getCrossGraphicSymbol(
52
+ s.attributes,
53
53
  "marker"
54
54
  ));
55
- })) : t <= this.crossScale && i > this.crossScale && (this.crossLayer.graphics.forEach((r) => {
56
- r.symbol = this.getCrossGraphicSymbol(
57
- r.attributes,
55
+ })) : t <= this.crossScale && i > this.crossScale && (this.crossLayer.graphics.forEach((s) => {
56
+ s.symbol = this.getCrossGraphicSymbol(
57
+ s.attributes,
58
58
  "picture"
59
59
  );
60
- }), this.highlightLayer.graphics.forEach((r) => {
61
- r.getAttribute("type") === "cross" && (r.symbol = this.getCrossGraphicSymbol(
62
- r.attributes,
60
+ }), this.highlightLayer.graphics.forEach((s) => {
61
+ s.getAttribute("type") === "cross" && (s.symbol = this.getCrossGraphicSymbol(
62
+ s.attributes,
63
63
  "picture"
64
64
  ));
65
65
  }));
66
66
  }
67
67
  ), { status: 0, message: "ok" };
68
68
  }
69
- /**
70
- * 生成路口点符号。在不同比例尺下,使用不同的符号
71
- * @param attributes
72
- * @param symbolType
73
- * @returns
74
- */
75
- getCrossGraphicSymbol(e, t) {
76
- const { isKey: i, color: r } = e;
77
- if (t === "marker")
78
- return {
79
- type: "simple-marker",
80
- style: i ? "diamond" : "circle",
81
- color: r,
82
- size: i ? 16 : 8,
83
- outline: {
84
- color: i ? "red" : "white",
85
- width: i ? 2 : 1
86
- }
87
- };
88
- if (t === "picture")
89
- return {
90
- type: "picture-marker",
91
- url: `/GisViewerAssets/Images/xhj_${i ? 4 : 1}.png`,
92
- width: i ? "55px" : "37px",
93
- height: i ? "85px" : "57px",
94
- yoffset: i ? "37px" : "25px"
95
- };
96
- }
97
69
  clearSignalControlArea() {
98
70
  var e;
99
71
  return this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), (e = this.watchHandle) == null || e.remove(), this.view.closePopup(), { status: 0, message: "ok" };
@@ -114,15 +86,15 @@ class G {
114
86
  }
115
87
  async highlightSignalControlArea(e) {
116
88
  this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.crossLayer.visible = !1;
117
- const t = this.districtControllerLayer.graphics.filter((s) => s.getAttribute("id") === e.id).toArray().map((s) => s.clone()), i = this.subDistrictControllerLayer.graphics.filter(
118
- (s) => s.getAttribute("id") === e.id || s.getAttribute("parentId") === e.id
119
- ).toArray().map((s) => s.clone()), r = this.crossLayer.graphics.filter(
120
- (s) => s.getAttribute("id") === e.id || s.getAttribute("districtId") === e.id || s.getAttribute("subDistrictId") === e.id
121
- ).toArray().map((s) => s.clone());
122
- return t.length > 0 && this.highlightLayer.addMany(t), i.length > 0 && (this.highlightLayer.addMany(i), this.showPopup(i[0])), r.length > 0 && this.highlightLayer.addMany(r), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (t.length > 0 ? (await this.view.goTo(t), this.showPopup(t[0])) : i.length > 0 ? (await this.view.goTo(i), this.showPopup(i[0])) : (r.length > 1 ? await this.view.goTo(r) : await this.view.goTo({
123
- target: r[0].geometry,
89
+ const t = this.districtControllerLayer.graphics.filter((r) => r.getAttribute("id") === e.id).toArray().map((r) => r.clone()), i = this.subDistrictControllerLayer.graphics.filter(
90
+ (r) => r.getAttribute("id") === e.id || r.getAttribute("parentId") === e.id
91
+ ).toArray().map((r) => r.clone()), s = this.crossLayer.graphics.filter(
92
+ (r) => r.getAttribute("id") === e.id || r.getAttribute("districtId") === e.id || r.getAttribute("subDistrictId") === e.id
93
+ ).toArray().map((r) => r.clone());
94
+ return t.length > 0 && this.highlightLayer.addMany(t), i.length > 0 && (this.highlightLayer.addMany(i), this.showPopup(i[0])), s.length > 0 && this.highlightLayer.addMany(s), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (t.length > 0 ? (await this.view.goTo(t), this.showPopup(t[0])) : i.length > 0 ? (await this.view.goTo(i), this.showPopup(i[0])) : (s.length > 1 ? await this.view.goTo(s) : await this.view.goTo({
95
+ target: s[0].geometry,
124
96
  scale: 1500
125
- }), this.showPopup(r[0])), { status: 0, message: "ok" });
97
+ }), this.showPopup(s[0])), { status: 0, message: "ok" });
126
98
  }
127
99
  resetHighlight() {
128
100
  return this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0, this.crossLayer.visible = !0, { status: 0, message: "ok" };
@@ -149,21 +121,21 @@ class G {
149
121
  drawArea(e, t) {
150
122
  const i = e.getAllCrossCoordinates();
151
123
  if (i.length >= 2) {
152
- let s = null;
124
+ let r = null;
153
125
  if (i.length === 2)
154
- s = h.lineString(i);
126
+ r = n.lineString(i);
155
127
  else if (i.length > 2) {
156
- const c = h.featureCollection(
157
- i.map((g) => h.point(g))
128
+ const c = n.featureCollection(
129
+ i.map((u) => n.point(u))
158
130
  );
159
- s = d(c, { maxEdge: 400, units: "meters" }), s || (s = f(c));
131
+ r = d(c, { maxEdge: 400, units: "meters" }), r || (r = f(c));
160
132
  }
161
- if (!s) {
133
+ if (!r) {
162
134
  console.log("生成区控面失败", e);
163
135
  return;
164
136
  }
165
- const a = p(
166
- s.geometry,
137
+ const a = g(
138
+ r.geometry,
167
139
  // 区控面积更大,需要更大的缓冲半径
168
140
  t ? 200 : 30,
169
141
  {
@@ -202,7 +174,7 @@ class G {
202
174
  parentName: e.parentName,
203
175
  crossCount: e.crossCount,
204
176
  subDistrictCount: e.subDistrictCount
205
- }, n = new u({
177
+ }, h = new y({
206
178
  geometry: {
207
179
  type: "polygon",
208
180
  rings: a.geometry.coordinates
@@ -227,33 +199,33 @@ class G {
227
199
  ]
228
200
  }
229
201
  });
230
- t ? this.districtControllerLayer.add(n) : this.subDistrictControllerLayer.add(n);
202
+ t ? this.districtControllerLayer.add(h) : this.subDistrictControllerLayer.add(h);
231
203
  }
232
- for (const s of e.subDistricts)
233
- this.drawArea(s, !1);
234
- const r = e.crosses.map((s) => {
204
+ for (const r of e.subDistricts)
205
+ this.drawArea(r, !1);
206
+ const s = e.crosses.map((r) => {
235
207
  const a = {
236
208
  type: "cross",
237
- id: s.id,
238
- name: s.name,
209
+ id: r.id,
210
+ name: r.name,
239
211
  color: e.areaColor,
240
- signalId: s.signalId,
212
+ signalId: r.signalId,
241
213
  districtId: t ? e.id : e.parentId,
242
214
  districtName: t ? e.name : e.parentName,
243
215
  subDistrictId: t ? "" : e.id,
244
216
  subDistrictName: t ? "" : e.name,
245
- isKey: s.isKey
217
+ isKey: r.isKey
246
218
  };
247
- return new u({
219
+ return new y({
248
220
  geometry: {
249
221
  type: "point",
250
- x: s.longitude,
251
- y: s.latitude
222
+ x: r.longitude,
223
+ y: r.latitude
252
224
  },
253
225
  symbol: this.getCrossGraphicSymbol(a, "marker"),
254
226
  attributes: a,
255
227
  popupTemplate: {
256
- title: s.name,
228
+ title: r.name,
257
229
  content: [
258
230
  {
259
231
  type: "fields",
@@ -280,9 +252,121 @@ class G {
280
252
  }
281
253
  });
282
254
  });
283
- this.crossLayer.addMany(r);
255
+ this.crossLayer.addMany(s);
256
+ }
257
+ /**
258
+ * 生成路口点符号。在不同比例尺下,使用不同的符号
259
+ * @param attributes
260
+ * @param symbolType
261
+ * @returns
262
+ */
263
+ getCrossGraphicSymbol(e, t) {
264
+ const { isKey: i, color: s } = e;
265
+ if (t === "marker")
266
+ return {
267
+ type: "simple-marker",
268
+ style: i ? "diamond" : "circle",
269
+ color: s,
270
+ size: i ? 16 : 8,
271
+ outline: {
272
+ color: i ? "red" : "white",
273
+ width: i ? 2 : 1
274
+ }
275
+ };
276
+ if (t === "picture")
277
+ return {
278
+ // type: 'picture-marker',
279
+ // url: `/GisViewerAssets/Images/xhj_${isKey ? 4 : 1}.png`,
280
+ // width: isKey ? '55px' : '37px',
281
+ // height: isKey ? '85px' : '57px',
282
+ // yoffset: isKey ? '37px' : '25px'
283
+ type: "cim",
284
+ data: {
285
+ type: "CIMSymbolReference",
286
+ primitiveOverrides: [
287
+ {
288
+ // 将textGraphic的TextString替换为graphic.attributes.showName
289
+ type: "CIMPrimitiveOverride",
290
+ primitiveName: "textGraphic",
291
+ propertyName: "TextString",
292
+ valueExpressionInfo: {
293
+ type: "CIMExpressionInfo",
294
+ title: "Custom",
295
+ expression: 'Replace($feature.name, "与", "/") + " " + $feature.signalId',
296
+ returnType: "Default"
297
+ }
298
+ }
299
+ ],
300
+ symbol: {
301
+ type: "CIMPointSymbol",
302
+ symbolLayers: [
303
+ // 车辆号牌
304
+ {
305
+ type: "CIMVectorMarker",
306
+ size: 32,
307
+ colorLocked: !0,
308
+ anchorPointUnits: "Relative",
309
+ frame: { xmin: -16, ymin: -16, xmax: 16, ymax: 16 },
310
+ markerGraphics: [
311
+ {
312
+ type: "CIMMarkerGraphic",
313
+ primitiveName: "textGraphic",
314
+ geometry: { x: 0, y: 0 },
315
+ symbol: {
316
+ type: "CIMTextSymbol",
317
+ height: 12,
318
+ horizontalAlignment: "Center",
319
+ offsetX: 0,
320
+ offsetY: i ? 30 : 22,
321
+ haloSize: 1,
322
+ haloSymbol: {
323
+ type: "CIMPolygonSymbol",
324
+ symbolLayers: [
325
+ {
326
+ type: "CIMSolidFill",
327
+ enable: !0,
328
+ color: [255, 255, 255, 255]
329
+ }
330
+ ]
331
+ },
332
+ symbol: {
333
+ type: "CIMPolygonSymbol",
334
+ symbolLayers: [
335
+ {
336
+ type: "CIMSolidFill",
337
+ enable: !0,
338
+ color: [0, 0, 0, 255]
339
+ }
340
+ ]
341
+ },
342
+ verticalAlignment: "Center"
343
+ },
344
+ textString: ""
345
+ }
346
+ ],
347
+ scaleSymbolsProportionally: !0,
348
+ respectFrame: !0
349
+ },
350
+ // 车辆图标
351
+ {
352
+ type: "CIMPictureMarker",
353
+ enable: !0,
354
+ anchorPoint: {
355
+ x: 0,
356
+ y: 0
357
+ },
358
+ anchorPointUnits: "Relative",
359
+ size: i ? 45 : 30,
360
+ rotateClockwise: !0,
361
+ textureFilter: "Picture",
362
+ url: `/GisViewerAssets/Images/xhj_${i ? 4 : 1}.png`
363
+ }
364
+ ]
365
+ }
366
+ }
367
+ };
284
368
  }
285
369
  }
286
370
  export {
287
- G as default
371
+ x as default
288
372
  };
@@ -9,13 +9,6 @@ export default class SignalControlAreaController {
9
9
  private readonly crossScale;
10
10
  constructor(view: __esri.MapView | __esri.SceneView);
11
11
  showSignalControlArea(params: any): IResult;
12
- /**
13
- * 生成路口点符号。在不同比例尺下,使用不同的符号
14
- * @param attributes
15
- * @param symbolType
16
- * @returns
17
- */
18
- private getCrossGraphicSymbol;
19
12
  clearSignalControlArea(): IResult;
20
13
  locateSignalControlArea(params: {
21
14
  id: string;
@@ -38,4 +31,11 @@ export default class SignalControlAreaController {
38
31
  * @returns
39
32
  */
40
33
  private drawArea;
34
+ /**
35
+ * 生成路口点符号。在不同比例尺下,使用不同的符号
36
+ * @param attributes
37
+ * @param symbolType
38
+ * @returns
39
+ */
40
+ private getCrossGraphicSymbol;
41
41
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils.js"),g=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),f=require("@turf/buffer"),b=require("@turf/concave"),L=require("@turf/convex"),w=require("@turf/helpers"),v=require("./district-controller.js");function y(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const A=y(m),h=y(w);class C{constructor(e){this.crossScale=3e3,this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0},this.districtControllerLayer=new l({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new l({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new l({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new l({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}showSignalControlArea(e){this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const t of e){const i=new v.default(t);this.drawArea(i,!0)}return this.watchHandle=A.watch(()=>this.view.scale,(t,i)=>{t>this.crossScale&&i<=this.crossScale?(this.crossLayer.graphics.forEach(r=>{r.symbol=this.getCrossGraphicSymbol(r.attributes,"marker")}),this.highlightLayer.graphics.forEach(r=>{r.getAttribute("type")==="cross"&&(r.symbol=this.getCrossGraphicSymbol(r.attributes,"marker"))})):t<=this.crossScale&&i>this.crossScale&&(this.crossLayer.graphics.forEach(r=>{r.symbol=this.getCrossGraphicSymbol(r.attributes,"picture")}),this.highlightLayer.graphics.forEach(r=>{r.getAttribute("type")==="cross"&&(r.symbol=this.getCrossGraphicSymbol(r.attributes,"picture"))}))}),{status:0,message:"ok"}}getCrossGraphicSymbol(e,t){const{isKey:i,color:r}=e;if(t==="marker")return{type:"simple-marker",style:i?"diamond":"circle",color:r,size:i?16:8,outline:{color:i?"red":"white",width:i?2:1}};if(t==="picture")return{type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i?4:1}.png`,width:i?"55px":"37px",height:i?"85px":"57px",yoffset:i?"37px":"25px"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.watchHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);return t?(t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry),this.showPopup(t),{status:0,message:"ok"}):{status:1,message:"未找到"}}showPopup(e){const t=e.geometry.type==="point"?e.geometry:e.geometry.centroid;this.view.openPopup({features:[e],location:t})}async highlightSignalControlArea(e){this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;const t=this.districtControllerLayer.graphics.filter(s=>s.getAttribute("id")===e.id).toArray().map(s=>s.clone()),i=this.subDistrictControllerLayer.graphics.filter(s=>s.getAttribute("id")===e.id||s.getAttribute("parentId")===e.id).toArray().map(s=>s.clone()),r=this.crossLayer.graphics.filter(s=>s.getAttribute("id")===e.id||s.getAttribute("districtId")===e.id||s.getAttribute("subDistrictId")===e.id).toArray().map(s=>s.clone());return t.length>0&&this.highlightLayer.addMany(t),i.length>0&&(this.highlightLayer.addMany(i),this.showPopup(i[0])),r.length>0&&this.highlightLayer.addMany(r),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?(await this.view.goTo(t),this.showPopup(t[0])):i.length>0?(await this.view.goTo(i),this.showPopup(i[0])):(r.length>1?await this.view.goTo(r):await this.view.goTo({target:r[0].geometry,scale:1500}),this.showPopup(r[0])),{status:0,message:"ok"})}resetHighlight(){return this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0,this.crossLayer.visible=!0,{status:0,message:"ok"}}findAreaGraphic(e){let t=this.districtControllerLayer.graphics.find(i=>i.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(i=>i.attributes.id===e)),t||(t=this.crossLayer.graphics.find(i=>i.attributes.id===e)),t}drawArea(e,t){const i=e.getAllCrossCoordinates();if(i.length>=2){let s=null;if(i.length===2)s=h.lineString(i);else if(i.length>2){const u=h.featureCollection(i.map(d=>h.point(d)));s=b(u,{maxEdge:400,units:"meters"}),s||(s=L(u))}if(!s){console.log("生成区控面失败",e);return}const o=f(s.geometry,t?200:30,{units:"meters"});let n;t?n=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:n=[{fieldName:"parentName",label:"所属区控"},{fieldName:"crossCount",label:"路口数量"}];const p={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},c=new g({geometry:{type:"polygon",rings:o.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:p,popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:n}]}});t?this.districtControllerLayer.add(c):this.subDistrictControllerLayer.add(c)}for(const s of e.subDistricts)this.drawArea(s,!1);const r=e.crosses.map(s=>{const o={type:"cross",id:s.id,name:s.name,color:e.areaColor,signalId:s.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,isKey:s.isKey};return new g({geometry:{type:"point",x:s.longitude,y:s.latitude},symbol:this.getCrossGraphicSymbol(o,"marker"),attributes:o,popupTemplate:{title:s.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}})});this.crossLayer.addMany(r)}}exports.default=C;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils.js"),y=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),b=require("@turf/buffer"),f=require("@turf/concave"),L=require("@turf/convex"),v=require("@turf/helpers"),C=require("./district-controller.js");function m(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const w=m(d),h=m(v);class S{constructor(e){this.crossScale=3e3,this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0},this.districtControllerLayer=new l({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new l({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new l({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new l({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}showSignalControlArea(e){this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const t of e){const i=new C.default(t);this.drawArea(i,!0)}return this.watchHandle=w.watch(()=>this.view.scale,(t,i)=>{t>this.crossScale&&i<=this.crossScale?(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker"))})):t<=this.crossScale&&i>this.crossScale&&(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture"))}))}),{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.watchHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);return t?(t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry),this.showPopup(t),{status:0,message:"ok"}):{status:1,message:"未找到"}}showPopup(e){const t=e.geometry.type==="point"?e.geometry:e.geometry.centroid;this.view.openPopup({features:[e],location:t})}async highlightSignalControlArea(e){this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;const t=this.districtControllerLayer.graphics.filter(r=>r.getAttribute("id")===e.id).toArray().map(r=>r.clone()),i=this.subDistrictControllerLayer.graphics.filter(r=>r.getAttribute("id")===e.id||r.getAttribute("parentId")===e.id).toArray().map(r=>r.clone()),s=this.crossLayer.graphics.filter(r=>r.getAttribute("id")===e.id||r.getAttribute("districtId")===e.id||r.getAttribute("subDistrictId")===e.id).toArray().map(r=>r.clone());return t.length>0&&this.highlightLayer.addMany(t),i.length>0&&(this.highlightLayer.addMany(i),this.showPopup(i[0])),s.length>0&&this.highlightLayer.addMany(s),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?(await this.view.goTo(t),this.showPopup(t[0])):i.length>0?(await this.view.goTo(i),this.showPopup(i[0])):(s.length>1?await this.view.goTo(s):await this.view.goTo({target:s[0].geometry,scale:1500}),this.showPopup(s[0])),{status:0,message:"ok"})}resetHighlight(){return this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0,this.crossLayer.visible=!0,{status:0,message:"ok"}}findAreaGraphic(e){let t=this.districtControllerLayer.graphics.find(i=>i.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(i=>i.attributes.id===e)),t||(t=this.crossLayer.graphics.find(i=>i.attributes.id===e)),t}drawArea(e,t){const i=e.getAllCrossCoordinates();if(i.length>=2){let r=null;if(i.length===2)r=h.lineString(i);else if(i.length>2){const u=h.featureCollection(i.map(p=>h.point(p)));r=f(u,{maxEdge:400,units:"meters"}),r||(r=L(u))}if(!r){console.log("生成区控面失败",e);return}const o=b(r.geometry,t?200:30,{units:"meters"});let n;t?n=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:n=[{fieldName:"parentName",label:"所属区控"},{fieldName:"crossCount",label:"路口数量"}];const g={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},c=new y({geometry:{type:"polygon",rings:o.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:g,popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:n}]}});t?this.districtControllerLayer.add(c):this.subDistrictControllerLayer.add(c)}for(const r of e.subDistricts)this.drawArea(r,!1);const s=e.crosses.map(r=>{const o={type:"cross",id:r.id,name:r.name,color:e.areaColor,signalId:r.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,isKey:r.isKey};return new y({geometry:{type:"point",x:r.longitude,y:r.latitude},symbol:this.getCrossGraphicSymbol(o,"marker"),attributes:o,popupTemplate:{title:r.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}})});this.crossLayer.addMany(s)}getCrossGraphicSymbol(e,t){const{isKey:i,color:s}=e;if(t==="marker")return{type:"simple-marker",style:i?"diamond":"circle",color:s,size:i?16:8,outline:{color:i?"red":"white",width:i?2:1}};if(t==="picture")return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?30:22,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:i?45:30,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/xhj_${i?4:1}.png`}]}}}}}exports.default=S;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.140",
3
+ "version": "1.0.141",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [