gisviewer-vue3-arcgis 1.0.137 → 1.0.139

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.
@@ -5,6 +5,7 @@ interface ICross {
5
5
  latitude: number;
6
6
  longitude: number;
7
7
  signalId: string;
8
+ isKey: boolean;
8
9
  }
9
10
  export default class DistrictController {
10
11
  id: string;
@@ -16,7 +16,8 @@ class i {
16
16
  parentId: s.parentId,
17
17
  latitude: Number(s.latitude),
18
18
  longitude: Number(s.longitude),
19
- signalId: s.signalId
19
+ signalId: s.signalId,
20
+ isKey: s.isKey === 1
20
21
  };
21
22
  this.crosses.push(o), this.crossCount++;
22
23
  }
@@ -13,6 +13,7 @@ export default class SignalControlAreaController {
13
13
  locateSignalControlArea(params: {
14
14
  id: string;
15
15
  }): Promise<IResult>;
16
+ private showPopup;
16
17
  highlightSignalControlArea(params: {
17
18
  id: string;
18
19
  }): Promise<IResult>;
@@ -1,9 +1,9 @@
1
- import * as m from "@arcgis/core/core/reactiveUtils.js";
1
+ import * as g from "@arcgis/core/core/reactiveUtils.js";
2
2
  import n from "@arcgis/core/Graphic";
3
- import a from "@arcgis/core/layers/GraphicsLayer";
4
- import u from "@turf/buffer";
3
+ import o from "@arcgis/core/layers/GraphicsLayer";
4
+ import m from "@turf/buffer";
5
5
  import d from "@turf/convex";
6
- import * as c from "@turf/helpers";
6
+ import * as l from "@turf/helpers";
7
7
  import p from "./district-controller.mjs";
8
8
  class C {
9
9
  constructor(e) {
@@ -11,19 +11,19 @@ class C {
11
11
  closeButton: !0,
12
12
  collapseButton: !1,
13
13
  actionBar: !0
14
- }, this.districtControllerLayer = new a({
14
+ }, this.districtControllerLayer = new o({
15
15
  id: "districtControllerLayer",
16
16
  maxScale: 144447,
17
17
  minScale: 1155582
18
- }), this.subDistrictControllerLayer = new a({
18
+ }), this.subDistrictControllerLayer = new o({
19
19
  id: "subDistrictControllerLayer",
20
20
  maxScale: 0,
21
21
  minScale: 144447
22
- }), this.crossLayer = new a({
22
+ }), this.crossLayer = new o({
23
23
  id: "crossLayer",
24
24
  maxScale: 0,
25
25
  minScale: 36112
26
- }), this.highlightLayer = new a({
26
+ }), this.highlightLayer = new o({
27
27
  id: "highlightLayer"
28
28
  }), this.view.map.addMany([
29
29
  this.districtControllerLayer,
@@ -34,49 +34,52 @@ class C {
34
34
  }
35
35
  showSignalControlArea(e) {
36
36
  this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0;
37
- for (const t of e) {
38
- const r = new p(t);
37
+ for (const i of e) {
38
+ const r = new p(i);
39
39
  this.drawArea(r, !0);
40
40
  }
41
- return this.watchHandle = m.watch(
41
+ return this.watchHandle = g.watch(
42
42
  () => this.view.scale,
43
- (t, r) => {
44
- if (t > this.crossScale && r <= this.crossScale)
45
- this.crossLayer.graphics.forEach((s) => {
46
- s.symbol = {
47
- type: "simple-marker",
48
- color: s.getAttribute("color"),
49
- size: 8,
50
- outline: {
51
- color: "white",
52
- width: 1
53
- }
54
- };
55
- }), this.highlightLayer.graphics.forEach((s) => {
56
- s.getAttribute("type") === "cross" && (s.symbol = {
57
- type: "simple-marker",
58
- color: s.getAttribute("color"),
59
- size: 8,
60
- outline: {
61
- color: "white",
62
- width: 1
63
- }
64
- });
43
+ (i, r) => {
44
+ i > this.crossScale && r <= this.crossScale ? (this.crossLayer.graphics.forEach((t) => {
45
+ t.symbol = {
46
+ type: "simple-marker",
47
+ style: t.getAttribute("isKey") ? "diamond" : "circle",
48
+ color: t.getAttribute("color"),
49
+ size: t.getAttribute("isKey") ? 16 : 8,
50
+ outline: {
51
+ color: t.getAttribute("isKey") ? "red" : "white",
52
+ width: t.getAttribute("isKey") ? 2 : 1
53
+ }
54
+ };
55
+ }), this.highlightLayer.graphics.forEach((t) => {
56
+ t.getAttribute("type") === "cross" && (t.symbol = {
57
+ type: "simple-marker",
58
+ style: t.getAttribute("isKey") ? "diamond" : "circle",
59
+ color: t.getAttribute("color"),
60
+ size: t.getAttribute("isKey") ? 16 : 8,
61
+ outline: {
62
+ color: t.getAttribute("isKey") ? "red" : "white",
63
+ width: t.getAttribute("isKey") ? 2 : 1
64
+ }
65
65
  });
66
- else if (t <= this.crossScale && r > this.crossScale) {
67
- const s = {
66
+ })) : i <= this.crossScale && r > this.crossScale && (this.crossLayer.graphics.forEach((t) => {
67
+ t.symbol = {
68
68
  type: "picture-marker",
69
- url: "/GisViewerAssets/Images/xhj_1.png",
70
- width: "37px",
71
- height: "57px",
72
- yoffset: "25px"
69
+ url: `/GisViewerAssets/Images/xhj_${t.getAttribute("isKey") ? 4 : 1}.png`,
70
+ width: t.getAttribute("isKey") ? "55px" : "37px",
71
+ height: t.getAttribute("isKey") ? "85px" : "57px",
72
+ yoffset: t.getAttribute("isKey") ? "37px" : "25px"
73
73
  };
74
- this.crossLayer.graphics.forEach((i) => {
75
- i.symbol = s;
76
- }), this.highlightLayer.graphics.forEach((i) => {
77
- i.getAttribute("type") === "cross" && (i.symbol = s);
74
+ }), this.highlightLayer.graphics.forEach((t) => {
75
+ t.getAttribute("type") === "cross" && (t.symbol = {
76
+ type: "picture-marker",
77
+ url: `/GisViewerAssets/Images/xhj_${t.getAttribute("isKey") ? 4 : 1}.png`,
78
+ width: t.getAttribute("isKey") ? "55px" : "37px",
79
+ height: t.getAttribute("isKey") ? "85px" : "57px",
80
+ yoffset: t.getAttribute("isKey") ? "37px" : "25px"
78
81
  });
79
- }
82
+ }));
80
83
  }
81
84
  ), { status: 0, message: "ok" };
82
85
  }
@@ -85,31 +88,30 @@ class C {
85
88
  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" };
86
89
  }
87
90
  async locateSignalControlArea(e) {
88
- const t = this.findAreaGraphic(e.id);
89
- if (t) {
90
- t.attributes.type === "cross" ? await this.view.goTo({
91
- target: t.geometry,
92
- scale: 1500
93
- }) : await this.view.goTo(t.geometry);
94
- const r = t.geometry.type === "point" ? t.geometry : t.geometry.centroid;
95
- return this.view.openPopup({
96
- features: [t],
97
- location: r
98
- }), { status: 0, message: "ok" };
99
- } else
100
- return { status: 1, message: "未找到" };
91
+ const i = this.findAreaGraphic(e.id);
92
+ return i ? (i.attributes.type === "cross" ? await this.view.goTo({
93
+ target: i.geometry,
94
+ scale: 1500
95
+ }) : await this.view.goTo(i.geometry), this.showPopup(i), { status: 0, message: "ok" }) : { status: 1, message: "未找到" };
96
+ }
97
+ showPopup(e) {
98
+ const i = e.geometry.type === "point" ? e.geometry : e.geometry.centroid;
99
+ this.view.openPopup({
100
+ features: [e],
101
+ location: i
102
+ });
101
103
  }
102
104
  async highlightSignalControlArea(e) {
103
105
  this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.crossLayer.visible = !1;
104
- const t = this.districtControllerLayer.graphics.filter((i) => i.getAttribute("id") === e.id).toArray().map((i) => i.clone()), r = this.subDistrictControllerLayer.graphics.filter(
105
- (i) => i.getAttribute("id") === e.id || i.getAttribute("parentId") === e.id
106
- ).toArray().map((i) => i.clone()), s = this.crossLayer.graphics.filter(
107
- (i) => i.getAttribute("id") === e.id || i.getAttribute("districtId") === e.id || i.getAttribute("subDistrictId") === e.id
108
- ).toArray().map((i) => i.clone());
109
- return t.length > 0 && this.highlightLayer.addMany(t), r.length > 0 && this.highlightLayer.addMany(r), s.length > 0 && this.highlightLayer.addMany(s), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (t.length > 0 ? await this.view.goTo(t) : r.length > 0 ? await this.view.goTo(r) : s.length > 1 ? await this.view.goTo(s) : await this.view.goTo({
110
- target: s[0].geometry,
106
+ const i = this.districtControllerLayer.graphics.filter((s) => s.getAttribute("id") === e.id).toArray().map((s) => s.clone()), r = this.subDistrictControllerLayer.graphics.filter(
107
+ (s) => s.getAttribute("id") === e.id || s.getAttribute("parentId") === e.id
108
+ ).toArray().map((s) => s.clone()), t = this.crossLayer.graphics.filter(
109
+ (s) => s.getAttribute("id") === e.id || s.getAttribute("districtId") === e.id || s.getAttribute("subDistrictId") === e.id
110
+ ).toArray().map((s) => s.clone());
111
+ return i.length > 0 && this.highlightLayer.addMany(i), r.length > 0 && (this.highlightLayer.addMany(r), this.showPopup(r[0])), t.length > 0 && this.highlightLayer.addMany(t), this.highlightLayer.graphics.length === 0 ? { status: 1, message: "未找到" } : (i.length > 0 ? (await this.view.goTo(i), this.showPopup(i[0])) : r.length > 0 ? (await this.view.goTo(r), this.showPopup(r[0])) : (t.length > 1 ? await this.view.goTo(t) : await this.view.goTo({
112
+ target: t[0].geometry,
111
113
  scale: 1500
112
- }), { status: 0, message: "ok" });
114
+ }), this.showPopup(t[0])), { status: 0, message: "ok" });
113
115
  }
114
116
  resetHighlight() {
115
117
  return this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0, this.crossLayer.visible = !0, { status: 0, message: "ok" };
@@ -120,12 +122,12 @@ class C {
120
122
  * @returns
121
123
  */
122
124
  findAreaGraphic(e) {
123
- let t = this.districtControllerLayer.graphics.find(
125
+ let i = this.districtControllerLayer.graphics.find(
124
126
  (r) => r.attributes.id === e
125
127
  );
126
- return t || (t = this.subDistrictControllerLayer.graphics.find(
128
+ return i || (i = this.subDistrictControllerLayer.graphics.find(
127
129
  (r) => r.attributes.id === e
128
- )), t || (t = this.crossLayer.graphics.find((r) => r.attributes.id === e)), t;
130
+ )), i || (i = this.crossLayer.graphics.find((r) => r.attributes.id === e)), i;
129
131
  }
130
132
  /**
131
133
  * 绘制区控与子区
@@ -133,24 +135,30 @@ class C {
133
135
  * @param isDistrict 是否是区控
134
136
  * @returns
135
137
  */
136
- drawArea(e, t) {
138
+ drawArea(e, i) {
137
139
  const r = e.getAllCrossCoordinates();
138
- if (r.length > 2) {
139
- const i = c.featureCollection(
140
- r.map((y) => c.point(y))
141
- ), l = d(i);
142
- if (!l)
140
+ if (r.length >= 2) {
141
+ let s = null;
142
+ if (r.length === 2)
143
+ s = l.lineString(r);
144
+ else if (r.length > 2) {
145
+ const u = l.featureCollection(
146
+ r.map((c) => l.point(c))
147
+ );
148
+ s = d(u);
149
+ }
150
+ if (!s)
143
151
  return;
144
- const g = u(
145
- l.geometry,
152
+ const y = m(
153
+ s.geometry,
146
154
  // 区控面积更大,需要更大的缓冲半径
147
- t ? 200 : 30,
155
+ i ? 200 : 30,
148
156
  {
149
157
  units: "meters"
150
158
  }
151
159
  );
152
- let o;
153
- t ? o = [
160
+ let a;
161
+ i ? a = [
154
162
  {
155
163
  fieldName: "id",
156
164
  label: "区控编号"
@@ -163,14 +171,10 @@ class C {
163
171
  fieldName: "subDistrictCount",
164
172
  label: "子区数量"
165
173
  }
166
- ] : o = [
174
+ ] : a = [
167
175
  {
168
176
  fieldName: "parentName",
169
- label: "区控名称"
170
- },
171
- {
172
- fieldName: "id",
173
- label: "子区编号"
177
+ label: "所属区控"
174
178
  },
175
179
  {
176
180
  fieldName: "crossCount",
@@ -180,15 +184,15 @@ class C {
180
184
  const h = new n({
181
185
  geometry: {
182
186
  type: "polygon",
183
- rings: g.geometry.coordinates
187
+ rings: y.geometry.coordinates
184
188
  },
185
189
  symbol: {
186
190
  type: "simple-fill",
187
- color: [...e.areaColor, t ? 0.6 : 0.8],
191
+ color: [...e.areaColor, i ? 0.6 : 0.8],
188
192
  outline: {
189
193
  color: e.areaColor,
190
194
  width: 2,
191
- style: t ? "solid" : "long-dash"
195
+ style: i ? "solid" : "long-dash"
192
196
  }
193
197
  },
194
198
  attributes: {
@@ -201,47 +205,49 @@ class C {
201
205
  subDistrictCount: e.subDistrictCount
202
206
  },
203
207
  popupTemplate: {
204
- title: e.name,
208
+ title: `${i ? "区控" : "子区"} ${e.name}`,
205
209
  content: [
206
210
  {
207
211
  type: "fields",
208
- fieldInfos: o
212
+ fieldInfos: a
209
213
  }
210
214
  ]
211
215
  }
212
216
  });
213
- t ? this.districtControllerLayer.add(h) : this.subDistrictControllerLayer.add(h);
217
+ i ? this.districtControllerLayer.add(h) : this.subDistrictControllerLayer.add(h);
214
218
  }
215
- for (const i of e.subDistricts)
216
- this.drawArea(i, !1);
217
- const s = e.crosses.map((i) => new n({
219
+ for (const s of e.subDistricts)
220
+ this.drawArea(s, !1);
221
+ const t = e.crosses.map((s) => new n({
218
222
  geometry: {
219
223
  type: "point",
220
- x: i.longitude,
221
- y: i.latitude
224
+ x: s.longitude,
225
+ y: s.latitude
222
226
  },
223
227
  symbol: {
224
228
  type: "simple-marker",
229
+ style: s.isKey ? "diamond" : "circle",
225
230
  color: e.areaColor,
226
- size: 8,
231
+ size: s.isKey ? 16 : 8,
227
232
  outline: {
228
- color: "white",
229
- width: 1
233
+ color: s.isKey ? "red" : "white",
234
+ width: s.isKey ? 2 : 1
230
235
  }
231
236
  },
232
237
  attributes: {
233
238
  type: "cross",
234
- id: i.id,
235
- name: i.name,
239
+ id: s.id,
240
+ name: s.name,
236
241
  color: e.areaColor,
237
- signalId: i.signalId,
238
- districtId: t ? e.id : e.parentId,
239
- districtName: t ? e.name : e.parentName,
240
- subDistrictId: t ? "" : e.id,
241
- subDistrictName: t ? "" : e.name
242
+ signalId: s.signalId,
243
+ districtId: i ? e.id : e.parentId,
244
+ districtName: i ? e.name : e.parentName,
245
+ subDistrictId: i ? "" : e.id,
246
+ subDistrictName: i ? "" : e.name,
247
+ isKey: s.isKey
242
248
  },
243
249
  popupTemplate: {
244
- title: i.name,
250
+ title: s.name,
245
251
  content: [
246
252
  {
247
253
  type: "fields",
@@ -267,7 +273,7 @@ class C {
267
273
  ]
268
274
  }
269
275
  }));
270
- this.crossLayer.addMany(s);
276
+ this.crossLayer.addMany(t);
271
277
  }
272
278
  }
273
279
  export {
@@ -5,6 +5,7 @@ interface ICross {
5
5
  latitude: number;
6
6
  longitude: number;
7
7
  signalId: string;
8
+ isKey: boolean;
8
9
  }
9
10
  export default class DistrictController {
10
11
  id: string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class e{constructor(s){this.parentName="",this.crosses=[],this.subDistricts=[],this.areaColor=[Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255)],this.crossCount=0,this.subDistrictCount=0,this.id=s.id,this.name=s.name,this.parentId=s.parentId;for(const t of s.children)if(t.children){const o=new e(t);o.parentName=this.name,o.areaColor=this.areaColor,this.subDistricts.push(o),this.subDistrictCount++,this.crossCount+=o.crossCount}else{const o={id:t.id,name:t.name,parentId:t.parentId,latitude:Number(t.latitude),longitude:Number(t.longitude),signalId:t.signalId};this.crosses.push(o),this.crossCount++}}getAllCrossCoordinates(){const s=[];for(const t of this.crosses)s.push([t.longitude,t.latitude]);for(const t of this.subDistricts)s.push(...t.getAllCrossCoordinates());return s}}exports.default=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class e{constructor(t){this.parentName="",this.crosses=[],this.subDistricts=[],this.areaColor=[Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255)],this.crossCount=0,this.subDistrictCount=0,this.id=t.id,this.name=t.name,this.parentId=t.parentId;for(const s of t.children)if(s.children){const o=new e(s);o.parentName=this.name,o.areaColor=this.areaColor,this.subDistricts.push(o),this.subDistrictCount++,this.crossCount+=o.crossCount}else{const o={id:s.id,name:s.name,parentId:s.parentId,latitude:Number(s.latitude),longitude:Number(s.longitude),signalId:s.signalId,isKey:s.isKey===1};this.crosses.push(o),this.crossCount++}}getAllCrossCoordinates(){const t=[];for(const s of this.crosses)t.push([s.longitude,s.latitude]);for(const s of this.subDistricts)t.push(...s.getAllCrossCoordinates());return t}}exports.default=e;
@@ -13,6 +13,7 @@ export default class SignalControlAreaController {
13
13
  locateSignalControlArea(params: {
14
14
  id: string;
15
15
  }): Promise<IResult>;
16
+ private showPopup;
16
17
  highlightSignalControlArea(params: {
17
18
  id: string;
18
19
  }): Promise<IResult>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils.js"),c=require("@arcgis/core/Graphic"),o=require("@arcgis/core/layers/GraphicsLayer"),p=require("@turf/buffer"),f=require("@turf/convex"),b=require("@turf/helpers"),L=require("./district-controller.js");function g(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const w=g(m),u=g(b);class v{constructor(e){this.crossScale=3e3,this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0},this.districtControllerLayer=new o({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new o({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new o({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new o({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 r=new L.default(t);this.drawArea(r,!0)}return this.watchHandle=w.watch(()=>this.view.scale,(t,r)=>{if(t>this.crossScale&&r<=this.crossScale)this.crossLayer.graphics.forEach(s=>{s.symbol={type:"simple-marker",color:s.getAttribute("color"),size:8,outline:{color:"white",width:1}}}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol={type:"simple-marker",color:s.getAttribute("color"),size:8,outline:{color:"white",width:1}})});else if(t<=this.crossScale&&r>this.crossScale){const s={type:"picture-marker",url:"/GisViewerAssets/Images/xhj_1.png",width:"37px",height:"57px",yoffset:"25px"};this.crossLayer.graphics.forEach(i=>{i.symbol=s}),this.highlightLayer.graphics.forEach(i=>{i.getAttribute("type")==="cross"&&(i.symbol=s)})}}),{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);if(t){t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry);const r=t.geometry.type==="point"?t.geometry:t.geometry.centroid;return this.view.openPopup({features:[t],location:r}),{status:0,message:"ok"}}else return{status:1,message:"未找到"}}async highlightSignalControlArea(e){this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;const t=this.districtControllerLayer.graphics.filter(i=>i.getAttribute("id")===e.id).toArray().map(i=>i.clone()),r=this.subDistrictControllerLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("parentId")===e.id).toArray().map(i=>i.clone()),s=this.crossLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("districtId")===e.id||i.getAttribute("subDistrictId")===e.id).toArray().map(i=>i.clone());return t.length>0&&this.highlightLayer.addMany(t),r.length>0&&this.highlightLayer.addMany(r),s.length>0&&this.highlightLayer.addMany(s),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?await this.view.goTo(t):r.length>0?await this.view.goTo(r):s.length>1?await this.view.goTo(s):await this.view.goTo({target:s[0].geometry,scale:1500}),{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(r=>r.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(r=>r.attributes.id===e)),t||(t=this.crossLayer.graphics.find(r=>r.attributes.id===e)),t}drawArea(e,t){const r=e.getAllCrossCoordinates();if(r.length>2){const i=u.featureCollection(r.map(d=>u.point(d))),n=f(i);if(!n)return;const y=p(n.geometry,t?200:30,{units:"meters"});let l;t?l=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:l=[{fieldName:"parentName",label:"区控名称"},{fieldName:"id",label:"子区编号"},{fieldName:"crossCount",label:"路口数量"}];const h=new c({geometry:{type:"polygon",rings:y.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:{type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},popupTemplate:{title:e.name,content:[{type:"fields",fieldInfos:l}]}});t?this.districtControllerLayer.add(h):this.subDistrictControllerLayer.add(h)}for(const i of e.subDistricts)this.drawArea(i,!1);const s=e.crosses.map(i=>new c({geometry:{type:"point",x:i.longitude,y:i.latitude},symbol:{type:"simple-marker",color:e.areaColor,size:8,outline:{color:"white",width:1}},attributes:{type:"cross",id:i.id,name:i.name,color:e.areaColor,signalId:i.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}}));this.crossLayer.addMany(s)}}exports.default=v;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils.js"),u=require("@arcgis/core/Graphic"),o=require("@arcgis/core/layers/GraphicsLayer"),b=require("@turf/buffer"),p=require("@turf/convex"),f=require("@turf/helpers"),A=require("./district-controller.js");function c(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const w=c(m),n=c(f);class L{constructor(e){this.crossScale=3e3,this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0},this.districtControllerLayer=new o({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new o({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new o({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new o({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 r=new A.default(t);this.drawArea(r,!0)}return this.watchHandle=w.watch(()=>this.view.scale,(t,r)=>{t>this.crossScale&&r<=this.crossScale?(this.crossLayer.graphics.forEach(i=>{i.symbol={type:"simple-marker",style:i.getAttribute("isKey")?"diamond":"circle",color:i.getAttribute("color"),size:i.getAttribute("isKey")?16:8,outline:{color:i.getAttribute("isKey")?"red":"white",width:i.getAttribute("isKey")?2:1}}}),this.highlightLayer.graphics.forEach(i=>{i.getAttribute("type")==="cross"&&(i.symbol={type:"simple-marker",style:i.getAttribute("isKey")?"diamond":"circle",color:i.getAttribute("color"),size:i.getAttribute("isKey")?16:8,outline:{color:i.getAttribute("isKey")?"red":"white",width:i.getAttribute("isKey")?2:1}})})):t<=this.crossScale&&r>this.crossScale&&(this.crossLayer.graphics.forEach(i=>{i.symbol={type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i.getAttribute("isKey")?4:1}.png`,width:i.getAttribute("isKey")?"55px":"37px",height:i.getAttribute("isKey")?"85px":"57px",yoffset:i.getAttribute("isKey")?"37px":"25px"}}),this.highlightLayer.graphics.forEach(i=>{i.getAttribute("type")==="cross"&&(i.symbol={type:"picture-marker",url:`/GisViewerAssets/Images/xhj_${i.getAttribute("isKey")?4:1}.png`,width:i.getAttribute("isKey")?"55px":"37px",height:i.getAttribute("isKey")?"85px":"57px",yoffset:i.getAttribute("isKey")?"37px":"25px"})}))}),{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(s=>s.getAttribute("id")===e.id).toArray().map(s=>s.clone()),r=this.subDistrictControllerLayer.graphics.filter(s=>s.getAttribute("id")===e.id||s.getAttribute("parentId")===e.id).toArray().map(s=>s.clone()),i=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),r.length>0&&(this.highlightLayer.addMany(r),this.showPopup(r[0])),i.length>0&&this.highlightLayer.addMany(i),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?(await this.view.goTo(t),this.showPopup(t[0])):r.length>0?(await this.view.goTo(r),this.showPopup(r[0])):(i.length>1?await this.view.goTo(i):await this.view.goTo({target:i[0].geometry,scale:1500}),this.showPopup(i[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(r=>r.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(r=>r.attributes.id===e)),t||(t=this.crossLayer.graphics.find(r=>r.attributes.id===e)),t}drawArea(e,t){const r=e.getAllCrossCoordinates();if(r.length>=2){let s=null;if(r.length===2)s=n.lineString(r);else if(r.length>2){const g=n.featureCollection(r.map(d=>n.point(d)));s=p(g)}if(!s)return;const y=b(s.geometry,t?200:30,{units:"meters"});let l;t?l=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:l=[{fieldName:"parentName",label:"所属区控"},{fieldName:"crossCount",label:"路口数量"}];const h=new u({geometry:{type:"polygon",rings:y.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:{type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:l}]}});t?this.districtControllerLayer.add(h):this.subDistrictControllerLayer.add(h)}for(const s of e.subDistricts)this.drawArea(s,!1);const i=e.crosses.map(s=>new u({geometry:{type:"point",x:s.longitude,y:s.latitude},symbol:{type:"simple-marker",style:s.isKey?"diamond":"circle",color:e.areaColor,size:s.isKey?16:8,outline:{color:s.isKey?"red":"white",width:s.isKey?2:1}},attributes:{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},popupTemplate:{title:s.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}}));this.crossLayer.addMany(i)}}exports.default=L;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.137",
3
+ "version": "1.0.139",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [