gisviewer-vue3-arcgis 1.0.134 → 1.0.135

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.
@@ -4,6 +4,7 @@ interface ICross {
4
4
  parentId: string;
5
5
  latitude: number;
6
6
  longitude: number;
7
+ signalId: string;
7
8
  }
8
9
  export default class DistrictController {
9
10
  id: string;
@@ -1,4 +1,4 @@
1
- class r {
1
+ class i {
2
2
  constructor(t) {
3
3
  this.parentName = "", this.crosses = [], this.subDistricts = [], this.areaColor = [
4
4
  Math.floor(Math.random() * 255),
@@ -7,7 +7,7 @@ class r {
7
7
  ], this.crossCount = 0, this.subDistrictCount = 0, this.id = t.id, this.name = t.name, this.parentId = t.parentId;
8
8
  for (const s of t.children)
9
9
  if (s.children) {
10
- const o = new r(s);
10
+ const o = new i(s);
11
11
  o.parentName = this.name, o.areaColor = this.areaColor, this.subDistricts.push(o), this.subDistrictCount++, this.crossCount += o.crossCount;
12
12
  } else {
13
13
  const o = {
@@ -15,7 +15,8 @@ class r {
15
15
  name: s.name,
16
16
  parentId: s.parentId,
17
17
  latitude: Number(s.latitude),
18
- longitude: Number(s.longitude)
18
+ longitude: Number(s.longitude),
19
+ signalId: s.signalId
19
20
  };
20
21
  this.crosses.push(o), this.crossCount++;
21
22
  }
@@ -30,5 +31,5 @@ class r {
30
31
  }
31
32
  }
32
33
  export {
33
- r as default
34
+ i as default
34
35
  };
@@ -5,7 +5,8 @@ export default class SignalControlAreaController {
5
5
  private subDistrictControllerLayer;
6
6
  private crossLayer;
7
7
  private highlightLayer;
8
- private eventHandle?;
8
+ private watchHandle?;
9
+ private readonly crossScale;
9
10
  constructor(view: __esri.MapView | __esri.SceneView);
10
11
  showSignalControlArea(params: any): IResult;
11
12
  clearSignalControlArea(): IResult;
@@ -1,12 +1,13 @@
1
- import h from "@arcgis/core/Graphic";
1
+ import * as y from "@arcgis/core/core/reactiveUtils.js";
2
+ import n from "@arcgis/core/Graphic";
2
3
  import a from "@arcgis/core/layers/GraphicsLayer";
3
- import y from "@turf/buffer";
4
- import g from "@turf/convex";
4
+ import g from "@turf/buffer";
5
+ import d from "@turf/convex";
5
6
  import * as c from "@turf/helpers";
6
- import m from "./district-controller.mjs";
7
+ import p from "./district-controller.mjs";
7
8
  class C {
8
9
  constructor(e) {
9
- this.view = e, this.view.popup.visibleElements = {
10
+ this.crossScale = 1500, this.view = e, this.view.popup.visibleElements = {
10
11
  closeButton: !0,
11
12
  collapseButton: !1,
12
13
  actionBar: !0
@@ -34,19 +35,42 @@ class C {
34
35
  showSignalControlArea(e) {
35
36
  this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0;
36
37
  for (const t of e) {
37
- const r = new m(t);
38
+ const r = new p(t);
38
39
  this.drawArea(r, !0);
39
40
  }
40
- return { status: 0, message: "ok" };
41
+ return this.watchHandle = y.watch(
42
+ () => this.view.scale,
43
+ (t, r) => {
44
+ t > this.crossScale && r <= this.crossScale ? this.crossLayer.graphics.forEach((s) => {
45
+ s.symbol = {
46
+ type: "simple-marker",
47
+ color: s.getAttribute("color"),
48
+ size: 8,
49
+ outline: {
50
+ color: "white",
51
+ width: 1
52
+ }
53
+ };
54
+ }) : t <= this.crossScale && r > this.crossScale && this.crossLayer.graphics.forEach((s) => {
55
+ s.symbol = {
56
+ type: "picture-marker",
57
+ url: "/GisViewerAssets/images/xhj_1.png",
58
+ width: "37px",
59
+ height: "57px",
60
+ yoffset: "25px"
61
+ };
62
+ });
63
+ }
64
+ ), { status: 0, message: "ok" };
41
65
  }
42
66
  clearSignalControlArea() {
43
67
  var e;
44
- return this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), (e = this.eventHandle) == null || e.remove(), this.view.closePopup(), { status: 0, message: "ok" };
68
+ 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" };
45
69
  }
46
70
  async locateSignalControlArea(e) {
47
71
  const t = this.findAreaGraphic(e.id);
48
72
  if (t) {
49
- await this.view.goTo(t.geometry);
73
+ t.attributes.type === "cross" ? await this.view.goTo({ target: t.geometry, scale: 3e3 }) : await this.view.goTo(t.geometry);
50
74
  const r = t.geometry.type === "point" ? t.geometry : t.geometry.centroid;
51
75
  return this.view.openPopup({
52
76
  features: [t],
@@ -92,11 +116,11 @@ class C {
92
116
  const r = e.getAllCrossCoordinates();
93
117
  if (r.length > 2) {
94
118
  const i = c.featureCollection(
95
- r.map((d) => c.point(d))
96
- ), l = g(i);
119
+ r.map((u) => c.point(u))
120
+ ), l = d(i);
97
121
  if (!l)
98
122
  return;
99
- const u = y(
123
+ const m = g(
100
124
  l.geometry,
101
125
  // 区控面积更大,需要更大的缓冲半径
102
126
  t ? 200 : 30,
@@ -132,10 +156,10 @@ class C {
132
156
  label: "路口数量"
133
157
  }
134
158
  ];
135
- const n = new h({
159
+ const h = new n({
136
160
  geometry: {
137
161
  type: "polygon",
138
- rings: u.geometry.coordinates
162
+ rings: m.geometry.coordinates
139
163
  },
140
164
  symbol: {
141
165
  type: "simple-fill",
@@ -165,11 +189,11 @@ class C {
165
189
  ]
166
190
  }
167
191
  });
168
- t ? this.districtControllerLayer.add(n) : this.subDistrictControllerLayer.add(n);
192
+ t ? this.districtControllerLayer.add(h) : this.subDistrictControllerLayer.add(h);
169
193
  }
170
194
  for (const i of e.subDistricts)
171
195
  this.drawArea(i, !1);
172
- const s = e.crosses.map((i) => new h({
196
+ const s = e.crosses.map((i) => new n({
173
197
  geometry: {
174
198
  type: "point",
175
199
  x: i.longitude,
@@ -188,8 +212,12 @@ class C {
188
212
  type: "cross",
189
213
  id: i.id,
190
214
  name: i.name,
215
+ color: e.areaColor,
216
+ signalId: i.signalId,
191
217
  districtId: t ? e.id : e.parentId,
192
- subDistrictId: t ? "" : e.id
218
+ districtName: t ? e.name : e.parentName,
219
+ subDistrictId: t ? "" : e.id,
220
+ subDistrictName: t ? "" : e.name
193
221
  },
194
222
  popupTemplate: {
195
223
  title: i.name,
@@ -198,16 +226,20 @@ class C {
198
226
  type: "fields",
199
227
  fieldInfos: [
200
228
  {
201
- fieldName: "districtId",
202
- label: "区控编号"
229
+ fieldName: "districtName",
230
+ label: "区控名称"
203
231
  },
204
232
  {
205
- fieldName: "subDistrictId",
206
- label: "子区编号"
233
+ fieldName: "subDistrictName",
234
+ label: "子区名称"
207
235
  },
208
236
  {
209
237
  fieldName: "id",
210
238
  label: "路口编号"
239
+ },
240
+ {
241
+ fieldName: "signalId",
242
+ label: "信号机编号"
211
243
  }
212
244
  ]
213
245
  }
@@ -4,6 +4,7 @@ interface ICross {
4
4
  parentId: string;
5
5
  latitude: number;
6
6
  longitude: number;
7
+ signalId: string;
7
8
  }
8
9
  export default class DistrictController {
9
10
  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)};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(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;
@@ -5,7 +5,8 @@ export default class SignalControlAreaController {
5
5
  private subDistrictControllerLayer;
6
6
  private crossLayer;
7
7
  private highlightLayer;
8
- private eventHandle?;
8
+ private watchHandle?;
9
+ private readonly crossScale;
9
10
  constructor(view: __esri.MapView | __esri.SceneView);
10
11
  showSignalControlArea(params: any): IResult;
11
12
  clearSignalControlArea(): IResult;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/Graphic"),o=require("@arcgis/core/layers/GraphicsLayer"),y=require("@turf/buffer"),p=require("@turf/convex"),m=require("@turf/helpers"),f=require("./district-controller.js");function b(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const u=b(m);class L{constructor(e){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 i=new f.default(t);this.drawArea(i,!0)}return{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.eventHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);if(t){await this.view.goTo(t.geometry);const i=t.geometry.type==="point"?t.geometry:t.geometry.centroid;return this.view.openPopup({features:[t],location:i}),{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(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()),a=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),a.length>0&&this.highlightLayer.addMany(a),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(await this.view.goTo(t.length>0?t:i.length>0?i:a),{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){const r=u.featureCollection(i.map(g=>u.point(g))),n=p(r);if(!n)return;const d=y(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:d.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 r of e.subDistricts)this.drawArea(r,!1);const a=e.crosses.map(r=>new c({geometry:{type:"point",x:r.longitude,y:r.latitude},symbol:{type:"simple-marker",color:e.areaColor,size:8,outline:{color:"white",width:1}},attributes:{type:"cross",id:r.id,name:r.name,districtId:t?e.id:e.parentId,subDistrictId:t?"":e.id},popupTemplate:{title:r.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtId",label:"区控编号"},{fieldName:"subDistrictId",label:"子区编号"},{fieldName:"id",label:"路口编号"}]}]}}));this.crossLayer.addMany(a)}}exports.default=L;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils.js"),h=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 v=g(m),u=g(b);class w{constructor(e){this.crossScale=1500,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=v.watch(()=>this.view.scale,(t,r)=>{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}}}):t<=this.crossScale&&r>this.crossScale&&this.crossLayer.graphics.forEach(s=>{s.symbol={type:"picture-marker",url:"/GisViewerAssets/images/xhj_1.png",width:"37px",height:"57px",yoffset:"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);if(t){t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:3e3}):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:"未找到"}:(await this.view.goTo(t.length>0?t:r.length>0?r:s),{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(y=>u.point(y))),n=f(i);if(!n)return;const d=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 c=new h({geometry:{type:"polygon",rings:d.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(c):this.subDistrictControllerLayer.add(c)}for(const i of e.subDistricts)this.drawArea(i,!1);const s=e.crosses.map(i=>new h({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=w;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.134",
3
+ "version": "1.0.135",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [