gisviewer-vue3-arcgis 1.0.242 → 1.0.243

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,54 +1,54 @@
1
- import * as w from "@arcgis/core/core/reactiveUtils";
1
+ import * as m from "@arcgis/core/core/reactiveUtils";
2
2
  import { Point as u } from "@arcgis/core/geometry";
3
3
  import * as g from "@arcgis/core/geometry/support/webMercatorUtils.js";
4
4
  import L from "@arcgis/core/Graphic";
5
5
  import b from "@arcgis/core/layers/GraphicsLayer";
6
6
  import M from "./signal-holo-flow.mjs";
7
7
  class v extends M {
8
- constructor(e, t) {
9
- var n, a;
10
- super(e), this.waitingAreaLayer = new b(), this.watchHandle = null, this.trajectoryDelayTime = 2, this.stopLineMap = /* @__PURE__ */ new Map(), this.waitingAreaMap = /* @__PURE__ */ new Map(), this.lampGroupMap = /* @__PURE__ */ new Map(), this.countdownPanelProps = t, this.view.map.add(this.waitingAreaLayer), this.trajectoryDelayTime = (a = (n = this.mapConfig.holoFlow) == null ? void 0 : n.signal) == null ? void 0 : a.delay, this.trajectoryDelayTime === void 0 && (this.trajectoryDelayTime = 2);
8
+ constructor(e, o) {
9
+ var s, n;
10
+ super(e), this.waitingAreaLayer = new b(), this.watchHandle = null, this.trajectoryDelayTime = 2, this.stopLineMap = /* @__PURE__ */ new Map(), this.waitingAreaMap = /* @__PURE__ */ new Map(), this.lampGroupMap = /* @__PURE__ */ new Map(), this.countdownPanelProps = o, this.view.map.add(this.waitingAreaLayer), this.trajectoryDelayTime = (n = (s = this.mapConfig.holoFlow) == null ? void 0 : s.signal) == null ? void 0 : n.delay, this.trajectoryDelayTime === void 0 && (this.trajectoryDelayTime = 2);
11
11
  }
12
12
  /**
13
13
  * 读取停止线图层,将灯组面板沿着停止线放置
14
14
  * @returns
15
15
  */
16
16
  async initializeLayer() {
17
- var a, o, s, i, r;
17
+ var n, a, i, r, t;
18
18
  if (this.stopLineMap.size > 0)
19
19
  return;
20
20
  console.time("初始化停止线图层");
21
- let e = (o = (a = this.mapConfig.holoFlow) == null ? void 0 : a.signal) == null ? void 0 : o.stopLineLayer;
21
+ let e = (a = (n = this.mapConfig.holoFlow) == null ? void 0 : n.signal) == null ? void 0 : a.stopLineLayer;
22
22
  if (!e)
23
23
  return;
24
24
  e = this.mapConfig.assetsRoot + "/" + e;
25
- let t = await fetch(e), n = await t.json();
26
- for (const l of n.features) {
27
- const { roadId: c, nodeId: d } = l.properties;
25
+ let o = await fetch(e), s = await o.json();
26
+ for (const l of s.features) {
27
+ const { roadId: c, nodeId: h } = l.properties;
28
28
  let { destinationPoint: p } = l.properties;
29
- const { coordinates: h } = l.geometry;
29
+ const { coordinates: f } = l.geometry;
30
30
  if (p) {
31
31
  if (typeof p == "string")
32
32
  try {
33
33
  p = JSON.parse(p);
34
- } catch (f) {
35
- console.error("解析面板基准点失败", f);
34
+ } catch (d) {
35
+ console.error("解析面板基准点失败", d);
36
36
  continue;
37
37
  }
38
38
  } else {
39
- const f = h[0], m = h[h.length - 1], y = (f[0] + m[0]) / 2, P = (f[1] + m[1]) / 2;
39
+ const d = f[0], w = f[f.length - 1], y = (d[0] + w[0]) / 2, P = (d[1] + w[1]) / 2;
40
40
  p = [y, P];
41
41
  }
42
- this.stopLineMap.set(`${d}_${c}`, {
43
- coord: h,
42
+ this.stopLineMap.set(`${h}_${c}`, {
43
+ coord: f,
44
44
  panelPoint: p
45
45
  });
46
46
  }
47
- if (console.timeEnd("初始化停止线图层"), console.time("初始化待行区图层"), e = (i = (s = this.mapConfig.holoFlow) == null ? void 0 : s.signal) == null ? void 0 : i.waitingAreaLayer, !!e) {
48
- e = this.mapConfig.assetsRoot + "/" + e, t = await fetch(e), n = await t.json();
49
- for (const l of n.features) {
50
- const { roadId: c, direction: d, nodeId: p } = l.properties, { coordinates: h } = l.geometry, f = `${p}_${c}`;
51
- this.waitingAreaMap.has(f) || this.waitingAreaMap.set(f, []), (r = this.waitingAreaMap.get(f)) == null || r.push({ coord: h, direction: d });
47
+ if (console.timeEnd("初始化停止线图层"), console.time("初始化待行区图层"), e = (r = (i = this.mapConfig.holoFlow) == null ? void 0 : i.signal) == null ? void 0 : r.waitingAreaLayer, !!e) {
48
+ e = this.mapConfig.assetsRoot + "/" + e, o = await fetch(e), s = await o.json();
49
+ for (const l of s.features) {
50
+ const { roadId: c, direction: h, nodeId: p } = l.properties, { coordinates: f } = l.geometry, d = `${p}_${c}`;
51
+ this.waitingAreaMap.has(d) || this.waitingAreaMap.set(d, []), (t = this.waitingAreaMap.get(d)) == null || t.push({ coord: f, direction: h });
52
52
  }
53
53
  console.timeEnd("初始化待行区图层");
54
54
  }
@@ -57,14 +57,14 @@ class v extends M {
57
57
  * 初始化灯组与进口道的关联关系
58
58
  */
59
59
  initializeLampGroup(e) {
60
- const { sigId: t, lampGroupList: n } = e, a = [];
61
- n.forEach((o) => {
62
- const { lampGroupNo: s, lampGroupType: i, crossFlowList: r, pedList: l } = o;
63
- if (r.length > 0)
64
- for (const c of r) {
65
- if (i === 81)
60
+ const { sigId: o, lampGroupList: s } = e, n = [];
61
+ s.forEach((a) => {
62
+ const { lampGroupNo: i, lampGroupType: r, crossFlowList: t, pedList: l } = a;
63
+ if (t.length > 0)
64
+ for (const c of t) {
65
+ if (r === 81)
66
66
  continue;
67
- const d = c.upSectionId;
67
+ const h = c.upSectionId;
68
68
  let p = "s";
69
69
  switch (c.turn) {
70
70
  case 1:
@@ -80,35 +80,35 @@ class v extends M {
80
80
  p = "u";
81
81
  break;
82
82
  }
83
- a.push({
84
- lampGroupId: s,
85
- roadId: d,
83
+ n.push({
84
+ lampGroupId: i,
85
+ roadId: h,
86
86
  dir: p
87
87
  });
88
88
  }
89
89
  l.length > 0;
90
- }), this.lampGroupMap.set(t, a);
90
+ }), this.lampGroupMap.set(o, n);
91
91
  }
92
92
  /**
93
93
  * 处理统一信控平台信号灯数据
94
94
  * @param data
95
95
  */
96
96
  handleUniSignalData(e) {
97
- this.watchHandle || (this.watchHandle = w.watch(
97
+ this.watchHandle || (this.watchHandle = m.watch(
98
98
  () => this.view.extent,
99
99
  () => this.updatePanelPosition()
100
100
  ));
101
- const { sigId: t, runningStatus: n } = e.data.basicInfo, a = this.lampGroupMap.get(t);
102
- if (!a)
101
+ const { sigId: o, runningStatus: s } = e.data.basicInfo, n = this.lampGroupMap.get(o);
102
+ if (!n)
103
103
  return { status: -1, message: "灯组未初始化" };
104
- const o = /* @__PURE__ */ new Map();
105
- let s = !1;
106
- switch (String(n)) {
104
+ const a = /* @__PURE__ */ new Map();
105
+ let i = !1;
106
+ switch (String(s)) {
107
107
  case "4": {
108
- s = !0, a.forEach((i) => {
109
- const { roadId: r, dir: l } = i;
110
- o.set(r, {
111
- ...o.get(r) || {},
108
+ i = !0, n.forEach((r) => {
109
+ const { roadId: t, dir: l } = r;
110
+ a.set(t, {
111
+ ...a.get(t) || {},
112
112
  [`${l}Number`]: "",
113
113
  [`${l}Color`]: "yellow"
114
114
  });
@@ -116,10 +116,10 @@ class v extends M {
116
116
  break;
117
117
  }
118
118
  case "5": {
119
- a.forEach((i) => {
120
- const { roadId: r, dir: l } = i;
121
- o.set(r, {
122
- ...o.get(r) || {},
119
+ n.forEach((r) => {
120
+ const { roadId: t, dir: l } = r;
121
+ a.set(t, {
122
+ ...a.get(t) || {},
123
123
  [`${l}Number`]: "",
124
124
  [`${l}Color`]: "red"
125
125
  });
@@ -128,10 +128,10 @@ class v extends M {
128
128
  }
129
129
  case "6":
130
130
  case "9": {
131
- a.forEach((i) => {
132
- const { roadId: r, dir: l } = i;
133
- o.set(r, {
134
- ...o.get(r) || {},
131
+ n.forEach((r) => {
132
+ const { roadId: t, dir: l } = r;
133
+ a.set(t, {
134
+ ...a.get(t) || {},
135
135
  [`${l}Number`]: "",
136
136
  [`${l}Color`]: "off"
137
137
  });
@@ -139,108 +139,108 @@ class v extends M {
139
139
  break;
140
140
  }
141
141
  default: {
142
- const { curSigColorInfo: i } = e.data;
143
- i.forEach((r) => {
144
- const l = String(r.lamgroupId), { color: c, leftTime: d } = r, p = a.find(
145
- (h) => h.lampGroupId === l
142
+ const { curSigColorInfo: r } = e.data;
143
+ r.forEach((t) => {
144
+ const l = String(t.lamgroupId), { color: c, leftTime: h } = t, p = n.find(
145
+ (f) => f.lampGroupId === l
146
146
  );
147
147
  if (p) {
148
- const { roadId: h, dir: f } = p;
149
- o.set(h, {
150
- ...o.get(h) || {},
151
- [`${f}Number`]: d,
152
- [`${f}Color`]: c === 1 ? "red" : c === 2 ? "yellow" : "green"
148
+ const { roadId: f, dir: d } = p;
149
+ a.set(f, {
150
+ ...a.get(f) || {},
151
+ [`${d}Number`]: h,
152
+ [`${d}Color`]: c === 1 ? "red" : c === 2 ? "yellow" : "green"
153
153
  });
154
154
  }
155
155
  });
156
156
  }
157
157
  }
158
- return this.updateLampGroupPanelStatus(t, o, s), { status: 0, message: "ok" };
158
+ return this.updateLampGroupPanelStatus(o, a, i), { status: 0, message: "ok" };
159
159
  }
160
160
  /**
161
161
  * 根据地图比例尺计算灯组面板缩放比例
162
162
  */
163
163
  getPanelScale() {
164
164
  const e = this.view.scale;
165
- let t = 1;
166
- return e < 500 ? t = 1.2 : e < 1e3 ? t = 1 : e < 2e3 ? t = 0.8 : e < 4e3 ? t = 0.4 : t = 0, t;
165
+ let o = 1;
166
+ return e < 500 ? o = 1.2 : e < 1e3 ? o = 1 : e < 2e3 ? o = 0.8 : e < 4e3 ? o = 0.4 : o = 0, o;
167
167
  }
168
168
  /**
169
169
  * 地图移动时更新灯组面板位置
170
170
  */
171
171
  updatePanelPosition() {
172
172
  const e = this.getPanelScale();
173
- for (const t of this.countdownPanelProps) {
174
- e !== this.currentPanelScale && (t.scale = e);
175
- const { mapPoint: n } = t;
176
- let a = new u({
177
- x: n[0],
178
- y: n[1]
173
+ for (const o of this.countdownPanelProps) {
174
+ e !== this.currentPanelScale && (o.scale = e);
175
+ const { mapPoint: s } = o;
176
+ let n = new u({
177
+ x: s[0],
178
+ y: s[1]
179
179
  });
180
- this.view.spatialReference.isWebMercator && (a = g.geographicToWebMercator(
181
- a
180
+ this.view.spatialReference.isWebMercator && (n = g.geographicToWebMercator(
181
+ n
182
182
  ));
183
- const o = this.view.toScreen(a);
184
- if (t.position.left = o.x, t.position.top = o.y, this.view.type === "3d") {
185
- const s = this.getPanelRotation(t.stopLine);
186
- t.rotation = s;
183
+ const a = this.view.toScreen(n);
184
+ if (o.position.left = a.x, o.position.top = a.y, this.view.type === "3d") {
185
+ const i = this.getPanelRotation(o.stopLine);
186
+ o.rotation = i;
187
187
  }
188
188
  }
189
189
  this.currentPanelScale = e;
190
190
  }
191
191
  doHoloSignalData(e) {
192
- const t = e.crossId, n = e.phaseCountDownList, a = /* @__PURE__ */ new Map();
193
- for (const o of n) {
194
- let s = "";
195
- for (let c of o.roadIdList)
196
- if (c.startsWith("-") && (c = c.slice(1)), this.stopLineMap.has(`${t}_${c}`)) {
197
- s = `${t}_${c}`;
192
+ const o = e.crossId, s = e.showWaitingArea === !0, n = e.phaseCountDownList, a = /* @__PURE__ */ new Map();
193
+ for (const i of n) {
194
+ let r = "";
195
+ for (let h of i.roadIdList)
196
+ if (h.startsWith("-") && (h = h.slice(1)), this.stopLineMap.has(`${o}_${h}`)) {
197
+ r = `${o}_${h}`;
198
198
  break;
199
199
  }
200
- if (!s) {
201
- console.log(`没有找到对应的进口道${t}--${s}`);
200
+ if (!r) {
201
+ console.log(`没有找到对应的进口道${o}--${r}`);
202
202
  continue;
203
203
  }
204
- let i = a.get(s);
205
- if (i || (i = {}, a.set(s, i)), !o.direction)
204
+ let t = a.get(r);
205
+ if (t || (t = {}, a.set(r, t)), !i.direction)
206
206
  continue;
207
- const r = o.direction.toLowerCase(), l = o.color === 1 ? "red" : o.color === 2 ? "yellow" : "green";
208
- r === "u" ? (i.uNumber = o.leftTime, i.uColor = l) : r === "l" ? (i.lNumber = o.leftTime, i.lColor = l) : r === "s" ? (i.sNumber = o.leftTime, i.sColor = l) : r === "r" && (i.rNumber = o.leftTime, i.rColor = l);
207
+ const l = i.direction.toLowerCase(), c = i.color === 1 ? "red" : i.color === 2 ? "yellow" : "green";
208
+ l === "u" ? (t.uNumber = i.leftTime, t.uColor = c) : l === "l" ? (t.lNumber = i.leftTime, t.lColor = c) : l === "s" ? (t.sNumber = i.leftTime, t.sColor = c) : l === "r" && (t.rNumber = i.leftTime, t.rColor = c);
209
209
  }
210
- this.updateLampGroupPanelStatus(t, a), this.updateWaitingArea(t, a);
210
+ this.updateLampGroupPanelStatus(o, a), s && this.updateWaitingArea(o, a);
211
211
  }
212
- updateWaitingArea(e, t) {
213
- t.forEach((n, a) => {
214
- var o;
215
- if (n.lColor) {
216
- let s = this.waitingAreaLayer.graphics.find(
217
- (i) => i.attributes.roadId === a && i.attributes.direction === "l"
212
+ updateWaitingArea(e, o) {
213
+ o.forEach((s, n) => {
214
+ var a;
215
+ if (s.lColor) {
216
+ let i = this.waitingAreaLayer.graphics.find(
217
+ (r) => r.attributes.roadId === n && r.attributes.direction === "l"
218
218
  );
219
- if (s)
220
- s.attributes.color !== n.lColor && (s.attributes.color = n.lColor, s.symbol = {
219
+ if (i)
220
+ i.attributes.color !== s.lColor && (i.attributes.color = s.lColor, i.symbol = {
221
221
  type: "simple-fill",
222
- color: this.getColor(n.lColor),
222
+ color: this.getColor(s.lColor),
223
223
  outline: {
224
- color: this.getColor(n.lColor)
224
+ color: this.getColor(s.lColor)
225
225
  }
226
226
  });
227
227
  else {
228
- const i = (o = this.waitingAreaMap.get(a)) == null ? void 0 : o.find((r) => r.direction === "l");
229
- i && (s = new L({
230
- geometry: { type: "polygon", rings: i.coord },
228
+ const r = (a = this.waitingAreaMap.get(n)) == null ? void 0 : a.find((t) => t.direction === "l");
229
+ r && (i = new L({
230
+ geometry: { type: "polygon", rings: r.coord },
231
231
  attributes: {
232
- roadId: a,
232
+ roadId: n,
233
233
  direction: "l",
234
- color: n.lColor
234
+ color: s.lColor
235
235
  },
236
236
  symbol: {
237
237
  type: "simple-fill",
238
- color: this.getColor(n.lColor),
238
+ color: this.getColor(s.lColor),
239
239
  outline: {
240
- color: this.getColor(n.lColor)
240
+ color: this.getColor(s.lColor)
241
241
  }
242
242
  }
243
- }), this.waitingAreaLayer.add(s));
243
+ }), this.waitingAreaLayer.add(i));
244
244
  }
245
245
  }
246
246
  });
@@ -248,40 +248,40 @@ class v extends M {
248
248
  getColor(e) {
249
249
  return e === "green" ? [0, 255, 0, 0.8] : e === "yellow" ? [255, 192, 2, 0.8] : [255, 0, 0, 0.8];
250
250
  }
251
- updateLampGroupPanelStatus(e, t, n = !1) {
252
- t.forEach((a, o) => {
253
- const s = this.stopLineMap.get(o);
254
- if (!s)
251
+ updateLampGroupPanelStatus(e, o, s = !1) {
252
+ o.forEach((n, a) => {
253
+ const i = this.stopLineMap.get(a);
254
+ if (!i)
255
255
  return;
256
- const i = this.countdownPanelProps.find(
257
- (r) => r.roadId === o
256
+ const r = this.countdownPanelProps.find(
257
+ (t) => t.roadId === a
258
258
  );
259
- if (i)
260
- i.lampStatus = a, i.flash = n;
259
+ if (r)
260
+ r.lampStatus = n, r.flash = s;
261
261
  else {
262
- let r = new u({
263
- x: s.panelPoint[0],
264
- y: s.panelPoint[1]
262
+ let t = new u({
263
+ x: i.panelPoint[0],
264
+ y: i.panelPoint[1]
265
265
  });
266
- this.view.spatialReference.isWebMercator && (r = g.geographicToWebMercator(
267
- r
266
+ this.view.spatialReference.isWebMercator && (t = g.geographicToWebMercator(
267
+ t
268
268
  ));
269
- const l = this.view.toScreen(r), c = this.getPanelRotation(s.coord);
269
+ const l = this.view.toScreen(t), c = this.getPanelRotation(i.coord);
270
270
  this.countdownPanelProps.push({
271
271
  displayMode: "complex",
272
- flash: n,
272
+ flash: s,
273
273
  crossId: e,
274
- roadId: o,
275
- mapPoint: s.panelPoint,
274
+ roadId: a,
275
+ mapPoint: i.panelPoint,
276
276
  // 定位点地理坐标
277
- stopLine: s.coord,
277
+ stopLine: i.coord,
278
278
  // 关联的停止线坐标
279
279
  position: { left: l.x, top: l.y },
280
280
  // 定位点屏幕坐标
281
281
  rotation: c,
282
282
  // 面板旋转角度
283
283
  scale: this.getPanelScale(),
284
- lampStatus: a
284
+ lampStatus: n
285
285
  // 灯组状态
286
286
  });
287
287
  }
@@ -293,7 +293,7 @@ class v extends M {
293
293
  * @returns
294
294
  */
295
295
  async handleHoloSignalData(e) {
296
- this.watchHandle || (this.watchHandle = w.watch(
296
+ this.watchHandle || (this.watchHandle = m.watch(
297
297
  () => this.view.extent,
298
298
  () => this.updatePanelPosition()
299
299
  )), this.trajectoryDelayTime === 0 ? this.doHoloSignalData(e) : setTimeout(
@@ -311,15 +311,7 @@ class v extends M {
311
311
  * @returns
312
312
  */
313
313
  getPanelRotation(e) {
314
- const t = e[0];
315
- let n = new u({
316
- x: t[0],
317
- y: t[1]
318
- });
319
- this.view.spatialReference.isWebMercator && (n = g.geographicToWebMercator(
320
- n
321
- ));
322
- const a = this.view.toScreen(n), o = e[e.length - 1];
314
+ const o = e[0];
323
315
  let s = new u({
324
316
  x: o[0],
325
317
  y: o[1]
@@ -327,8 +319,16 @@ class v extends M {
327
319
  this.view.spatialReference.isWebMercator && (s = g.geographicToWebMercator(
328
320
  s
329
321
  ));
330
- const i = this.view.toScreen(s), r = i.x - a.x, l = i.y - a.y;
331
- return Math.atan2(l, r) * (180 / Math.PI);
322
+ const n = this.view.toScreen(s), a = e[e.length - 1];
323
+ let i = new u({
324
+ x: a[0],
325
+ y: a[1]
326
+ });
327
+ this.view.spatialReference.isWebMercator && (i = g.geographicToWebMercator(
328
+ i
329
+ ));
330
+ const r = this.view.toScreen(i), t = r.x - n.x, l = r.y - n.y;
331
+ return Math.atan2(l, t) * (180 / Math.PI);
332
332
  }
333
333
  }
334
334
  export {
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),S=require("@arcgis/core/geometry/support/webMercatorUtils.js"),C=require("@arcgis/core/Graphic"),I=require("@arcgis/core/layers/GraphicsLayer"),v=require("./signal-holo-flow.js");function P(d){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const t in d)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(d,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>d[t]})}}return e.default=d,Object.freeze(e)}const y=P(M),w=P(S);class G extends v.default{constructor(e,t){var a,s;super(e),this.waitingAreaLayer=new I,this.watchHandle=null,this.trajectoryDelayTime=2,this.stopLineMap=new Map,this.waitingAreaMap=new Map,this.lampGroupMap=new Map,this.countdownPanelProps=t,this.view.map.add(this.waitingAreaLayer),this.trajectoryDelayTime=(s=(a=this.mapConfig.holoFlow)==null?void 0:a.signal)==null?void 0:s.delay,this.trajectoryDelayTime===void 0&&(this.trajectoryDelayTime=2)}async initializeLayer(){var s,o,n,i,r;if(this.stopLineMap.size>0)return;console.time("初始化停止线图层");let e=(o=(s=this.mapConfig.holoFlow)==null?void 0:s.signal)==null?void 0:o.stopLineLayer;if(!e)return;e=this.mapConfig.assetsRoot+"/"+e;let t=await fetch(e),a=await t.json();for(const l of a.features){const{roadId:c,nodeId:u}=l.properties;let{destinationPoint:p}=l.properties;const{coordinates:h}=l.geometry;if(p){if(typeof p=="string")try{p=JSON.parse(p)}catch(f){console.error("解析面板基准点失败",f);continue}}else{const f=h[0],m=h[h.length-1],b=(f[0]+m[0])/2,L=(f[1]+m[1])/2;p=[b,L]}this.stopLineMap.set(`${u}_${c}`,{coord:h,panelPoint:p})}if(console.timeEnd("初始化停止线图层"),console.time("初始化待行区图层"),e=(i=(n=this.mapConfig.holoFlow)==null?void 0:n.signal)==null?void 0:i.waitingAreaLayer,!!e){e=this.mapConfig.assetsRoot+"/"+e,t=await fetch(e),a=await t.json();for(const l of a.features){const{roadId:c,direction:u,nodeId:p}=l.properties,{coordinates:h}=l.geometry,f=`${p}_${c}`;this.waitingAreaMap.has(f)||this.waitingAreaMap.set(f,[]),(r=this.waitingAreaMap.get(f))==null||r.push({coord:h,direction:u})}console.timeEnd("初始化待行区图层")}}initializeLampGroup(e){const{sigId:t,lampGroupList:a}=e,s=[];a.forEach(o=>{const{lampGroupNo:n,lampGroupType:i,crossFlowList:r,pedList:l}=o;if(r.length>0)for(const c of r){if(i===81)continue;const u=c.upSectionId;let p="s";switch(c.turn){case 1:p="s";break;case 2:p="l";break;case 4:p="r";break;case 8:p="u";break}s.push({lampGroupId:n,roadId:u,dir:p})}l.length>0}),this.lampGroupMap.set(t,s)}handleUniSignalData(e){this.watchHandle||(this.watchHandle=y.watch(()=>this.view.extent,()=>this.updatePanelPosition()));const{sigId:t,runningStatus:a}=e.data.basicInfo,s=this.lampGroupMap.get(t);if(!s)return{status:-1,message:"灯组未初始化"};const o=new Map;let n=!1;switch(String(a)){case"4":{n=!0,s.forEach(i=>{const{roadId:r,dir:l}=i;o.set(r,{...o.get(r)||{},[`${l}Number`]:"",[`${l}Color`]:"yellow"})});break}case"5":{s.forEach(i=>{const{roadId:r,dir:l}=i;o.set(r,{...o.get(r)||{},[`${l}Number`]:"",[`${l}Color`]:"red"})});break}case"6":case"9":{s.forEach(i=>{const{roadId:r,dir:l}=i;o.set(r,{...o.get(r)||{},[`${l}Number`]:"",[`${l}Color`]:"off"})});break}default:{const{curSigColorInfo:i}=e.data;i.forEach(r=>{const l=String(r.lamgroupId),{color:c,leftTime:u}=r,p=s.find(h=>h.lampGroupId===l);if(p){const{roadId:h,dir:f}=p;o.set(h,{...o.get(h)||{},[`${f}Number`]:u,[`${f}Color`]:c===1?"red":c===2?"yellow":"green"})}})}}return this.updateLampGroupPanelStatus(t,o,n),{status:0,message:"ok"}}getPanelScale(){const e=this.view.scale;let t=1;return e<500?t=1.2:e<1e3?t=1:e<2e3?t=.8:e<4e3?t=.4:t=0,t}updatePanelPosition(){const e=this.getPanelScale();for(const t of this.countdownPanelProps){e!==this.currentPanelScale&&(t.scale=e);const{mapPoint:a}=t;let s=new g.Point({x:a[0],y:a[1]});this.view.spatialReference.isWebMercator&&(s=w.geographicToWebMercator(s));const o=this.view.toScreen(s);if(t.position.left=o.x,t.position.top=o.y,this.view.type==="3d"){const n=this.getPanelRotation(t.stopLine);t.rotation=n}}this.currentPanelScale=e}doHoloSignalData(e){const t=e.crossId,a=e.phaseCountDownList,s=new Map;for(const o of a){let n="";for(let c of o.roadIdList)if(c.startsWith("-")&&(c=c.slice(1)),this.stopLineMap.has(`${t}_${c}`)){n=`${t}_${c}`;break}if(!n){console.log(`没有找到对应的进口道${t}--${n}`);continue}let i=s.get(n);if(i||(i={},s.set(n,i)),!o.direction)continue;const r=o.direction.toLowerCase(),l=o.color===1?"red":o.color===2?"yellow":"green";r==="u"?(i.uNumber=o.leftTime,i.uColor=l):r==="l"?(i.lNumber=o.leftTime,i.lColor=l):r==="s"?(i.sNumber=o.leftTime,i.sColor=l):r==="r"&&(i.rNumber=o.leftTime,i.rColor=l)}this.updateLampGroupPanelStatus(t,s),this.updateWaitingArea(t,s)}updateWaitingArea(e,t){t.forEach((a,s)=>{var o;if(a.lColor){let n=this.waitingAreaLayer.graphics.find(i=>i.attributes.roadId===s&&i.attributes.direction==="l");if(n)n.attributes.color!==a.lColor&&(n.attributes.color=a.lColor,n.symbol={type:"simple-fill",color:this.getColor(a.lColor),outline:{color:this.getColor(a.lColor)}});else{const i=(o=this.waitingAreaMap.get(s))==null?void 0:o.find(r=>r.direction==="l");i&&(n=new C({geometry:{type:"polygon",rings:i.coord},attributes:{roadId:s,direction:"l",color:a.lColor},symbol:{type:"simple-fill",color:this.getColor(a.lColor),outline:{color:this.getColor(a.lColor)}}}),this.waitingAreaLayer.add(n))}}})}getColor(e){return e==="green"?[0,255,0,.8]:e==="yellow"?[255,192,2,.8]:[255,0,0,.8]}updateLampGroupPanelStatus(e,t,a=!1){t.forEach((s,o)=>{const n=this.stopLineMap.get(o);if(!n)return;const i=this.countdownPanelProps.find(r=>r.roadId===o);if(i)i.lampStatus=s,i.flash=a;else{let r=new g.Point({x:n.panelPoint[0],y:n.panelPoint[1]});this.view.spatialReference.isWebMercator&&(r=w.geographicToWebMercator(r));const l=this.view.toScreen(r),c=this.getPanelRotation(n.coord);this.countdownPanelProps.push({displayMode:"complex",flash:a,crossId:e,roadId:o,mapPoint:n.panelPoint,stopLine:n.coord,position:{left:l.x,top:l.y},rotation:c,scale:this.getPanelScale(),lampStatus:s})}})}async handleHoloSignalData(e){this.watchHandle||(this.watchHandle=y.watch(()=>this.view.extent,()=>this.updatePanelPosition())),this.trajectoryDelayTime===0?this.doHoloSignalData(e):setTimeout(()=>this.doHoloSignalData(e),this.trajectoryDelayTime*1e3)}clearSignal(){var e;this.waitingAreaLayer.removeAll(),this.countdownPanelProps.length=0,(e=this.watchHandle)==null||e.remove(),this.watchHandle=null}getPanelRotation(e){const t=e[0];let a=new g.Point({x:t[0],y:t[1]});this.view.spatialReference.isWebMercator&&(a=w.geographicToWebMercator(a));const s=this.view.toScreen(a),o=e[e.length-1];let n=new g.Point({x:o[0],y:o[1]});this.view.spatialReference.isWebMercator&&(n=w.geographicToWebMercator(n));const i=this.view.toScreen(n),r=i.x-s.x,l=i.y-s.y;return Math.atan2(l,r)*(180/Math.PI)}}exports.default=G;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),S=require("@arcgis/core/geometry/support/webMercatorUtils.js"),C=require("@arcgis/core/Graphic"),I=require("@arcgis/core/layers/GraphicsLayer"),v=require("./signal-holo-flow.js");function P(d){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const t in d)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(d,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>d[t]})}}return e.default=d,Object.freeze(e)}const y=P(M),w=P(S);class G extends v.default{constructor(e,t){var a,r;super(e),this.waitingAreaLayer=new I,this.watchHandle=null,this.trajectoryDelayTime=2,this.stopLineMap=new Map,this.waitingAreaMap=new Map,this.lampGroupMap=new Map,this.countdownPanelProps=t,this.view.map.add(this.waitingAreaLayer),this.trajectoryDelayTime=(r=(a=this.mapConfig.holoFlow)==null?void 0:a.signal)==null?void 0:r.delay,this.trajectoryDelayTime===void 0&&(this.trajectoryDelayTime=2)}async initializeLayer(){var r,s,i,n,o;if(this.stopLineMap.size>0)return;console.time("初始化停止线图层");let e=(s=(r=this.mapConfig.holoFlow)==null?void 0:r.signal)==null?void 0:s.stopLineLayer;if(!e)return;e=this.mapConfig.assetsRoot+"/"+e;let t=await fetch(e),a=await t.json();for(const l of a.features){const{roadId:c,nodeId:h}=l.properties;let{destinationPoint:p}=l.properties;const{coordinates:f}=l.geometry;if(p){if(typeof p=="string")try{p=JSON.parse(p)}catch(u){console.error("解析面板基准点失败",u);continue}}else{const u=f[0],m=f[f.length-1],b=(u[0]+m[0])/2,L=(u[1]+m[1])/2;p=[b,L]}this.stopLineMap.set(`${h}_${c}`,{coord:f,panelPoint:p})}if(console.timeEnd("初始化停止线图层"),console.time("初始化待行区图层"),e=(n=(i=this.mapConfig.holoFlow)==null?void 0:i.signal)==null?void 0:n.waitingAreaLayer,!!e){e=this.mapConfig.assetsRoot+"/"+e,t=await fetch(e),a=await t.json();for(const l of a.features){const{roadId:c,direction:h,nodeId:p}=l.properties,{coordinates:f}=l.geometry,u=`${p}_${c}`;this.waitingAreaMap.has(u)||this.waitingAreaMap.set(u,[]),(o=this.waitingAreaMap.get(u))==null||o.push({coord:f,direction:h})}console.timeEnd("初始化待行区图层")}}initializeLampGroup(e){const{sigId:t,lampGroupList:a}=e,r=[];a.forEach(s=>{const{lampGroupNo:i,lampGroupType:n,crossFlowList:o,pedList:l}=s;if(o.length>0)for(const c of o){if(n===81)continue;const h=c.upSectionId;let p="s";switch(c.turn){case 1:p="s";break;case 2:p="l";break;case 4:p="r";break;case 8:p="u";break}r.push({lampGroupId:i,roadId:h,dir:p})}l.length>0}),this.lampGroupMap.set(t,r)}handleUniSignalData(e){this.watchHandle||(this.watchHandle=y.watch(()=>this.view.extent,()=>this.updatePanelPosition()));const{sigId:t,runningStatus:a}=e.data.basicInfo,r=this.lampGroupMap.get(t);if(!r)return{status:-1,message:"灯组未初始化"};const s=new Map;let i=!1;switch(String(a)){case"4":{i=!0,r.forEach(n=>{const{roadId:o,dir:l}=n;s.set(o,{...s.get(o)||{},[`${l}Number`]:"",[`${l}Color`]:"yellow"})});break}case"5":{r.forEach(n=>{const{roadId:o,dir:l}=n;s.set(o,{...s.get(o)||{},[`${l}Number`]:"",[`${l}Color`]:"red"})});break}case"6":case"9":{r.forEach(n=>{const{roadId:o,dir:l}=n;s.set(o,{...s.get(o)||{},[`${l}Number`]:"",[`${l}Color`]:"off"})});break}default:{const{curSigColorInfo:n}=e.data;n.forEach(o=>{const l=String(o.lamgroupId),{color:c,leftTime:h}=o,p=r.find(f=>f.lampGroupId===l);if(p){const{roadId:f,dir:u}=p;s.set(f,{...s.get(f)||{},[`${u}Number`]:h,[`${u}Color`]:c===1?"red":c===2?"yellow":"green"})}})}}return this.updateLampGroupPanelStatus(t,s,i),{status:0,message:"ok"}}getPanelScale(){const e=this.view.scale;let t=1;return e<500?t=1.2:e<1e3?t=1:e<2e3?t=.8:e<4e3?t=.4:t=0,t}updatePanelPosition(){const e=this.getPanelScale();for(const t of this.countdownPanelProps){e!==this.currentPanelScale&&(t.scale=e);const{mapPoint:a}=t;let r=new g.Point({x:a[0],y:a[1]});this.view.spatialReference.isWebMercator&&(r=w.geographicToWebMercator(r));const s=this.view.toScreen(r);if(t.position.left=s.x,t.position.top=s.y,this.view.type==="3d"){const i=this.getPanelRotation(t.stopLine);t.rotation=i}}this.currentPanelScale=e}doHoloSignalData(e){const t=e.crossId,a=e.showWaitingArea===!0,r=e.phaseCountDownList,s=new Map;for(const i of r){let n="";for(let h of i.roadIdList)if(h.startsWith("-")&&(h=h.slice(1)),this.stopLineMap.has(`${t}_${h}`)){n=`${t}_${h}`;break}if(!n){console.log(`没有找到对应的进口道${t}--${n}`);continue}let o=s.get(n);if(o||(o={},s.set(n,o)),!i.direction)continue;const l=i.direction.toLowerCase(),c=i.color===1?"red":i.color===2?"yellow":"green";l==="u"?(o.uNumber=i.leftTime,o.uColor=c):l==="l"?(o.lNumber=i.leftTime,o.lColor=c):l==="s"?(o.sNumber=i.leftTime,o.sColor=c):l==="r"&&(o.rNumber=i.leftTime,o.rColor=c)}this.updateLampGroupPanelStatus(t,s),a&&this.updateWaitingArea(t,s)}updateWaitingArea(e,t){t.forEach((a,r)=>{var s;if(a.lColor){let i=this.waitingAreaLayer.graphics.find(n=>n.attributes.roadId===r&&n.attributes.direction==="l");if(i)i.attributes.color!==a.lColor&&(i.attributes.color=a.lColor,i.symbol={type:"simple-fill",color:this.getColor(a.lColor),outline:{color:this.getColor(a.lColor)}});else{const n=(s=this.waitingAreaMap.get(r))==null?void 0:s.find(o=>o.direction==="l");n&&(i=new C({geometry:{type:"polygon",rings:n.coord},attributes:{roadId:r,direction:"l",color:a.lColor},symbol:{type:"simple-fill",color:this.getColor(a.lColor),outline:{color:this.getColor(a.lColor)}}}),this.waitingAreaLayer.add(i))}}})}getColor(e){return e==="green"?[0,255,0,.8]:e==="yellow"?[255,192,2,.8]:[255,0,0,.8]}updateLampGroupPanelStatus(e,t,a=!1){t.forEach((r,s)=>{const i=this.stopLineMap.get(s);if(!i)return;const n=this.countdownPanelProps.find(o=>o.roadId===s);if(n)n.lampStatus=r,n.flash=a;else{let o=new g.Point({x:i.panelPoint[0],y:i.panelPoint[1]});this.view.spatialReference.isWebMercator&&(o=w.geographicToWebMercator(o));const l=this.view.toScreen(o),c=this.getPanelRotation(i.coord);this.countdownPanelProps.push({displayMode:"complex",flash:a,crossId:e,roadId:s,mapPoint:i.panelPoint,stopLine:i.coord,position:{left:l.x,top:l.y},rotation:c,scale:this.getPanelScale(),lampStatus:r})}})}async handleHoloSignalData(e){this.watchHandle||(this.watchHandle=y.watch(()=>this.view.extent,()=>this.updatePanelPosition())),this.trajectoryDelayTime===0?this.doHoloSignalData(e):setTimeout(()=>this.doHoloSignalData(e),this.trajectoryDelayTime*1e3)}clearSignal(){var e;this.waitingAreaLayer.removeAll(),this.countdownPanelProps.length=0,(e=this.watchHandle)==null||e.remove(),this.watchHandle=null}getPanelRotation(e){const t=e[0];let a=new g.Point({x:t[0],y:t[1]});this.view.spatialReference.isWebMercator&&(a=w.geographicToWebMercator(a));const r=this.view.toScreen(a),s=e[e.length-1];let i=new g.Point({x:s[0],y:s[1]});this.view.spatialReference.isWebMercator&&(i=w.geographicToWebMercator(i));const n=this.view.toScreen(i),o=n.x-r.x,l=n.y-r.y;return Math.atan2(l,o)*(180/Math.PI)}}exports.default=G;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.242",
3
+ "version": "1.0.243",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [