gisviewer-vue3-arcgis 1.0.237 → 1.0.239

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,7 +1,7 @@
1
1
  import { IResult, ISignalCountdownProps } from '../../../types';
2
2
  import SignalHoloFlow from './signal-holo-flow';
3
3
  export default class LSRSignalHoloFlow extends SignalHoloFlow {
4
- private stopLineLayer;
4
+ private waitingAreaLayer;
5
5
  private watchHandle;
6
6
  private countdownPanelProps;
7
7
  private currentPanelScale;
@@ -9,6 +9,7 @@ export default class LSRSignalHoloFlow extends SignalHoloFlow {
9
9
  private trajectoryDelayTime;
10
10
  /** 按照路口id->进口道路段id->停止线坐标保存的停止线 */
11
11
  private stopLineMap;
12
+ private waitingAreaMap;
12
13
  /** 信号机id->进口道id->灯组id */
13
14
  private lampGroupMap;
14
15
  constructor(view: __esri.MapView | __esri.SceneView, countdownPanelInfos: ISignalCountdownProps[]);
@@ -35,6 +36,8 @@ export default class LSRSignalHoloFlow extends SignalHoloFlow {
35
36
  */
36
37
  private updatePanelPosition;
37
38
  private doHoloSignalData;
39
+ private updateWaitingArea;
40
+ private getColor;
38
41
  private updateLampGroupPanelStatus;
39
42
  /**
40
43
  * 处理全息流信号灯数据
@@ -1,62 +1,70 @@
1
1
  import * as w from "@arcgis/core/core/reactiveUtils";
2
- import { Point as d } from "@arcgis/core/geometry";
3
- import * as u from "@arcgis/core/geometry/support/webMercatorUtils.js";
4
- import g from "@arcgis/core/layers/GraphicsLayer";
5
- import P from "./signal-holo-flow.mjs";
6
- class M extends P {
7
- constructor(e, s) {
8
- var l, i;
9
- super(e), this.stopLineLayer = new g(), this.watchHandle = null, this.trajectoryDelayTime = 2, this.stopLineMap = /* @__PURE__ */ new Map(), this.lampGroupMap = /* @__PURE__ */ new Map(), this.countdownPanelProps = s, this.view.map.add(this.stopLineLayer), this.trajectoryDelayTime = (i = (l = this.mapConfig.holoFlow) == null ? void 0 : l.signal) == null ? void 0 : i.delay, this.trajectoryDelayTime === void 0 && (this.trajectoryDelayTime = 2);
2
+ import { Point as u } from "@arcgis/core/geometry";
3
+ import * as g from "@arcgis/core/geometry/support/webMercatorUtils.js";
4
+ import L from "@arcgis/core/Graphic";
5
+ import b from "@arcgis/core/layers/GraphicsLayer";
6
+ import M from "./signal-holo-flow.mjs";
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);
10
11
  }
11
12
  /**
12
13
  * 读取停止线图层,将灯组面板沿着停止线放置
13
14
  * @returns
14
15
  */
15
16
  async initializeLayer() {
16
- var i, t;
17
+ var a, o, s, i, r;
17
18
  if (this.stopLineMap.size > 0)
18
19
  return;
19
20
  console.time("初始化停止线图层");
20
- let e = (t = (i = this.mapConfig.holoFlow) == null ? void 0 : i.signal) == null ? void 0 : t.stopLineLayer;
21
+ let e = (o = (a = this.mapConfig.holoFlow) == null ? void 0 : a.signal) == null ? void 0 : o.stopLineLayer;
21
22
  if (!e)
22
23
  return;
23
24
  e = this.mapConfig.assetsRoot + "/" + e;
24
- const l = await (await fetch(e)).json();
25
- for (const n of l.features) {
26
- const { roadId: a } = n.properties;
27
- let { destinationPoint: o } = n.properties;
28
- const { coordinates: r } = n.geometry;
29
- if (o) {
30
- if (typeof o == "string")
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;
28
+ let { destinationPoint: p } = l.properties;
29
+ const { coordinates: h } = l.geometry;
30
+ if (p) {
31
+ if (typeof p == "string")
31
32
  try {
32
- o = JSON.parse(o);
33
- } catch (c) {
34
- console.error("解析面板基准点失败", c);
33
+ p = JSON.parse(p);
34
+ } catch (f) {
35
+ console.error("解析面板基准点失败", f);
35
36
  continue;
36
37
  }
37
38
  } else {
38
- const c = r[0], h = r[r.length - 1], p = (c[0] + h[0]) / 2, f = (c[1] + h[1]) / 2;
39
- o = [p, f];
39
+ const f = h[0], m = h[h.length - 1], y = (f[0] + m[0]) / 2, P = (f[1] + m[1]) / 2;
40
+ p = [y, P];
40
41
  }
41
- this.stopLineMap.set(a, {
42
- coord: r,
43
- panelPoint: o
42
+ this.stopLineMap.set(`${d}_${c}`, {
43
+ coord: h,
44
+ panelPoint: p
44
45
  });
45
46
  }
46
- console.timeEnd("初始化停止线图层");
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 });
52
+ }
53
+ console.timeEnd("初始化待行区图层");
54
+ }
47
55
  }
48
56
  /**
49
57
  * 初始化灯组与进口道的关联关系
50
58
  */
51
59
  initializeLampGroup(e) {
52
- const { sigId: s, lampGroupList: l } = e, i = [];
53
- l.forEach((t) => {
54
- const { lampGroupNo: n, lampGroupType: a, crossFlowList: o, pedList: r } = t;
55
- if (o.length > 0)
56
- for (const c of o) {
57
- if (a === 81)
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)
58
66
  continue;
59
- const h = c.upSectionId;
67
+ const d = c.upSectionId;
60
68
  let p = "s";
61
69
  switch (c.turn) {
62
70
  case 1:
@@ -72,14 +80,14 @@ class M extends P {
72
80
  p = "u";
73
81
  break;
74
82
  }
75
- i.push({
76
- lampGroupId: n,
77
- roadId: h,
83
+ a.push({
84
+ lampGroupId: s,
85
+ roadId: d,
78
86
  dir: p
79
87
  });
80
88
  }
81
- r.length > 0;
82
- }), this.lampGroupMap.set(s, i);
89
+ l.length > 0;
90
+ }), this.lampGroupMap.set(t, a);
83
91
  }
84
92
  /**
85
93
  * 处理统一信控平台信号灯数据
@@ -90,151 +98,190 @@ class M extends P {
90
98
  () => this.view.extent,
91
99
  () => this.updatePanelPosition()
92
100
  ));
93
- const { sigId: s, runningStatus: l } = e.data.basicInfo, i = this.lampGroupMap.get(s);
94
- if (!i)
101
+ const { sigId: t, runningStatus: n } = e.data.basicInfo, a = this.lampGroupMap.get(t);
102
+ if (!a)
95
103
  return { status: -1, message: "灯组未初始化" };
96
- const t = /* @__PURE__ */ new Map();
97
- let n = !1;
98
- switch (String(l)) {
104
+ const o = /* @__PURE__ */ new Map();
105
+ let s = !1;
106
+ switch (String(n)) {
99
107
  case "4": {
100
- n = !0, i.forEach((a) => {
101
- const { roadId: o, dir: r } = a;
102
- t.set(o, {
103
- ...t.get(o) || {},
104
- [`${r}Number`]: "",
105
- [`${r}Color`]: "yellow"
108
+ s = !0, a.forEach((i) => {
109
+ const { roadId: r, dir: l } = i;
110
+ o.set(r, {
111
+ ...o.get(r) || {},
112
+ [`${l}Number`]: "",
113
+ [`${l}Color`]: "yellow"
106
114
  });
107
115
  });
108
116
  break;
109
117
  }
110
118
  case "5": {
111
- i.forEach((a) => {
112
- const { roadId: o, dir: r } = a;
113
- t.set(o, {
114
- ...t.get(o) || {},
115
- [`${r}Number`]: "",
116
- [`${r}Color`]: "red"
119
+ a.forEach((i) => {
120
+ const { roadId: r, dir: l } = i;
121
+ o.set(r, {
122
+ ...o.get(r) || {},
123
+ [`${l}Number`]: "",
124
+ [`${l}Color`]: "red"
117
125
  });
118
126
  });
119
127
  break;
120
128
  }
121
129
  case "6":
122
130
  case "9": {
123
- i.forEach((a) => {
124
- const { roadId: o, dir: r } = a;
125
- t.set(o, {
126
- ...t.get(o) || {},
127
- [`${r}Number`]: "",
128
- [`${r}Color`]: "off"
131
+ a.forEach((i) => {
132
+ const { roadId: r, dir: l } = i;
133
+ o.set(r, {
134
+ ...o.get(r) || {},
135
+ [`${l}Number`]: "",
136
+ [`${l}Color`]: "off"
129
137
  });
130
138
  });
131
139
  break;
132
140
  }
133
141
  default: {
134
- const { curSigColorInfo: a } = e.data;
135
- a.forEach((o) => {
136
- const r = String(o.lamgroupId), { color: c, leftTime: h } = o, p = i.find(
137
- (f) => f.lampGroupId === r
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
138
146
  );
139
147
  if (p) {
140
- const { roadId: f, dir: m } = p;
141
- t.set(f, {
142
- ...t.get(f) || {},
143
- [`${m}Number`]: h,
144
- [`${m}Color`]: c === 1 ? "red" : c === 2 ? "yellow" : "green"
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"
145
153
  });
146
154
  }
147
155
  });
148
156
  }
149
157
  }
150
- return this.updateLampGroupPanelStatus(s, t, n), { status: 0, message: "ok" };
158
+ return this.updateLampGroupPanelStatus(t, o, s), { status: 0, message: "ok" };
151
159
  }
152
160
  /**
153
161
  * 根据地图比例尺计算灯组面板缩放比例
154
162
  */
155
163
  getPanelScale() {
156
164
  const e = this.view.scale;
157
- let s = 1;
158
- return e < 500 ? s = 1.2 : e < 1e3 ? s = 1 : e < 2e3 ? s = 0.8 : e < 4e3 ? s = 0.4 : s = 0, s;
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;
159
167
  }
160
168
  /**
161
169
  * 地图移动时更新灯组面板位置
162
170
  */
163
171
  updatePanelPosition() {
164
172
  const e = this.getPanelScale();
165
- for (const s of this.countdownPanelProps) {
166
- e !== this.currentPanelScale && (s.scale = e);
167
- const { mapPoint: l } = s;
168
- let i = new d({
169
- x: l[0],
170
- y: l[1]
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]
171
179
  });
172
- this.view.spatialReference.isWebMercator && (i = u.geographicToWebMercator(
173
- i
180
+ this.view.spatialReference.isWebMercator && (a = g.geographicToWebMercator(
181
+ a
174
182
  ));
175
- const t = this.view.toScreen(i);
176
- if (s.position.left = t.x, s.position.top = t.y, this.view.type === "3d") {
177
- const n = this.getPanelRotation(s.stopLine);
178
- s.rotation = n;
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;
179
187
  }
180
188
  }
181
189
  this.currentPanelScale = e;
182
190
  }
183
191
  doHoloSignalData(e) {
184
- const s = e.crossId, l = e.phaseCountDownList, i = /* @__PURE__ */ new Map();
185
- for (const t of l) {
186
- let n = "";
187
- for (let c of t.roadIdList)
188
- if (c.startsWith("-") && (c = c.slice(1)), this.stopLineMap.has(c)) {
189
- n = c;
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}`;
190
198
  break;
191
199
  }
192
- if (!n) {
193
- console.log(`没有找到对应的进口道${s}--${n}`);
200
+ if (!s) {
201
+ console.log(`没有找到对应的进口道${t}--${s}`);
194
202
  continue;
195
203
  }
196
- let a = i.get(n);
197
- if (a || (a = {}, i.set(n, a)), !t.direction)
204
+ let i = a.get(s);
205
+ if (i || (i = {}, a.set(s, i)), !o.direction)
198
206
  continue;
199
- const o = t.direction.toLowerCase(), r = t.color === 1 ? "red" : t.color === 2 ? "yellow" : "green";
200
- o === "u" ? (a.uNumber = t.leftTime, a.uColor = r) : o === "l" ? (a.lNumber = t.leftTime, a.lColor = r) : o === "s" ? (a.sNumber = t.leftTime, a.sColor = r) : o === "r" && (a.rNumber = t.leftTime, a.rColor = r);
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);
201
209
  }
202
- this.updateLampGroupPanelStatus(s, i);
210
+ this.updateLampGroupPanelStatus(t, a), this.updateWaitingArea(t, a);
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"
218
+ );
219
+ if (s)
220
+ s.attributes.color !== n.lColor && (s.attributes.color = n.lColor, s.symbol = {
221
+ type: "simple-fill",
222
+ color: this.getColor(n.lColor),
223
+ outline: {
224
+ color: this.getColor(n.lColor)
225
+ }
226
+ });
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 },
231
+ attributes: {
232
+ roadId: a,
233
+ direction: "l",
234
+ color: n.lColor
235
+ },
236
+ symbol: {
237
+ type: "simple-fill",
238
+ color: this.getColor(n.lColor),
239
+ outline: {
240
+ color: this.getColor(n.lColor)
241
+ }
242
+ }
243
+ }), this.waitingAreaLayer.add(s));
244
+ }
245
+ }
246
+ });
247
+ }
248
+ getColor(e) {
249
+ return e === "green" ? [0, 255, 0, 0.8] : e === "yellow" ? [255, 192, 2, 0.8] : [255, 0, 0, 0.8];
203
250
  }
204
- updateLampGroupPanelStatus(e, s, l = !1) {
205
- s.forEach((i, t) => {
206
- const n = this.stopLineMap.get(t);
207
- if (!n)
251
+ updateLampGroupPanelStatus(e, t, n = !1) {
252
+ t.forEach((a, o) => {
253
+ const s = this.stopLineMap.get(o);
254
+ if (!s)
208
255
  return;
209
- const a = this.countdownPanelProps.find(
210
- (o) => o.roadId === t
256
+ const i = this.countdownPanelProps.find(
257
+ (r) => r.roadId === o
211
258
  );
212
- if (a)
213
- a.lampStatus = i, a.flash = l;
259
+ if (i)
260
+ i.lampStatus = a, i.flash = n;
214
261
  else {
215
- let o = new d({
216
- x: n.panelPoint[0],
217
- y: n.panelPoint[1]
262
+ let r = new u({
263
+ x: s.panelPoint[0],
264
+ y: s.panelPoint[1]
218
265
  });
219
- this.view.spatialReference.isWebMercator && (o = u.geographicToWebMercator(
220
- o
266
+ this.view.spatialReference.isWebMercator && (r = g.geographicToWebMercator(
267
+ r
221
268
  ));
222
- const r = this.view.toScreen(o), c = this.getPanelRotation(n.coord);
269
+ const l = this.view.toScreen(r), c = this.getPanelRotation(s.coord);
223
270
  this.countdownPanelProps.push({
224
271
  displayMode: "complex",
225
- flash: l,
272
+ flash: n,
226
273
  crossId: e,
227
- roadId: t,
228
- mapPoint: n.panelPoint,
274
+ roadId: o,
275
+ mapPoint: s.panelPoint,
229
276
  // 定位点地理坐标
230
- stopLine: n.coord,
277
+ stopLine: s.coord,
231
278
  // 关联的停止线坐标
232
- position: { left: r.x, top: r.y },
279
+ position: { left: l.x, top: l.y },
233
280
  // 定位点屏幕坐标
234
281
  rotation: c,
235
282
  // 面板旋转角度
236
283
  scale: this.getPanelScale(),
237
- lampStatus: i
284
+ lampStatus: a
238
285
  // 灯组状态
239
286
  });
240
287
  }
@@ -256,7 +303,7 @@ class M extends P {
256
303
  }
257
304
  clearSignal() {
258
305
  var e;
259
- this.stopLineLayer.removeAll(), this.countdownPanelProps.length = 0, (e = this.watchHandle) == null || e.remove(), this.watchHandle = null;
306
+ this.waitingAreaLayer.removeAll(), this.countdownPanelProps.length = 0, (e = this.watchHandle) == null || e.remove(), this.watchHandle = null;
260
307
  }
261
308
  /**
262
309
  * 从停止线坐标计算面板旋转角度
@@ -264,26 +311,26 @@ class M extends P {
264
311
  * @returns
265
312
  */
266
313
  getPanelRotation(e) {
267
- const s = e[0];
268
- let l = new d({
269
- x: s[0],
270
- y: s[1]
271
- });
272
- this.view.spatialReference.isWebMercator && (l = u.geographicToWebMercator(
273
- l
274
- ));
275
- const i = this.view.toScreen(l), t = e[e.length - 1];
276
- let n = new d({
314
+ const t = e[0];
315
+ let n = new u({
277
316
  x: t[0],
278
317
  y: t[1]
279
318
  });
280
- this.view.spatialReference.isWebMercator && (n = u.geographicToWebMercator(
319
+ this.view.spatialReference.isWebMercator && (n = g.geographicToWebMercator(
281
320
  n
282
321
  ));
283
- const a = this.view.toScreen(n), o = a.x - i.x, r = a.y - i.y;
284
- return Math.atan2(r, o) * (180 / Math.PI);
322
+ const a = this.view.toScreen(n), o = e[e.length - 1];
323
+ let s = new u({
324
+ x: o[0],
325
+ y: o[1]
326
+ });
327
+ this.view.spatialReference.isWebMercator && (s = g.geographicToWebMercator(
328
+ s
329
+ ));
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);
285
332
  }
286
333
  }
287
334
  export {
288
- M as default
335
+ v as default
289
336
  };
@@ -1,24 +1,24 @@
1
1
  import C from "@arcgis/core/Basemap";
2
- import g from "@arcgis/core/config";
2
+ import d from "@arcgis/core/config";
3
3
  import * as k from "@arcgis/core/core/reactiveUtils";
4
- import { Polygon as L, Polyline as W, Point as T } from "@arcgis/core/geometry";
4
+ import { Multipoint as L, Polygon as W, Polyline as z, Point as T } from "@arcgis/core/geometry";
5
5
  import * as w from "@arcgis/core/geometry/support/webMercatorUtils";
6
- import z from "@arcgis/core/layers/FeatureLayer";
7
- import x from "@arcgis/core/layers/GeoJSONLayer";
8
- import I from "@arcgis/core/layers/IntegratedMesh3DTilesLayer";
9
- import R from "@arcgis/core/layers/MapImageLayer";
10
- import H from "@arcgis/core/layers/TileLayer";
11
- import G from "@arcgis/core/layers/WebTileLayer";
12
- import O from "@arcgis/core/Map";
13
- import S from "@arcgis/core/views/MapView";
14
- import B from "@arcgis/core/views/SceneView";
15
- import N from "@turf/destination";
16
- import * as E from "@turf/helpers";
17
- import A from "./custom-layer/custom-wmts-layer.mjs";
6
+ import x from "@arcgis/core/layers/FeatureLayer";
7
+ import I from "@arcgis/core/layers/GeoJSONLayer";
8
+ import R from "@arcgis/core/layers/IntegratedMesh3DTilesLayer";
9
+ import H from "@arcgis/core/layers/MapImageLayer";
10
+ import G from "@arcgis/core/layers/TileLayer";
11
+ import O from "@arcgis/core/layers/WebTileLayer";
12
+ import S from "@arcgis/core/Map";
13
+ import B from "@arcgis/core/views/MapView";
14
+ import N from "@arcgis/core/views/SceneView";
15
+ import E from "@turf/destination";
16
+ import * as A from "@turf/helpers";
17
+ import J from "./custom-layer/custom-wmts-layer.mjs";
18
18
  function P(h, e) {
19
19
  return h && (h.startsWith("http://") || h.startsWith("https://") ? h : e + h);
20
20
  }
21
- class ee {
21
+ class te {
22
22
  constructor() {
23
23
  this.mapConfig = {}, this.watchHandleMap = /* @__PURE__ */ new Map(), this.handleIndex = 0, this.zoomWatchHandle = null;
24
24
  }
@@ -31,15 +31,15 @@ class ee {
31
31
  var p, u, b, y;
32
32
  this.mapConfig = e.mapConfig;
33
33
  const { container: i, markerClickCallback: o, mapClickCallback: r } = e;
34
- g.assetsPath = `${this.mapConfig.assetsRoot}/ArcgisAssets`, g.fontsUrl = `${this.mapConfig.assetsRoot}/fonts`, g.apiKey = "AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";
35
- const s = new O();
36
- if (((p = this.mapConfig) == null ? void 0 : p.mapOptions.mode.toLowerCase()) === "2d" ? (this.view = new S({
34
+ d.assetsPath = `${this.mapConfig.assetsRoot}/ArcgisAssets`, d.fontsUrl = `${this.mapConfig.assetsRoot}/fonts`, d.apiKey = "AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";
35
+ const s = new S();
36
+ if (((p = this.mapConfig) == null ? void 0 : p.mapOptions.mode.toLowerCase()) === "2d" ? (this.view = new B({
37
37
  map: s,
38
38
  container: i,
39
39
  ...this.mapConfig.mapOptions
40
40
  }), this.view.on("drag", (t) => {
41
41
  t.button === 2 && t.stopPropagation();
42
- })) : this.view = new B({
42
+ })) : this.view = new N({
43
43
  map: s,
44
44
  container: i,
45
45
  environment: {
@@ -110,7 +110,7 @@ class ee {
110
110
  const c = P(t.url, this.mapConfig.assetsRoot);
111
111
  switch (t.type.toLowerCase()) {
112
112
  case "webTile".toLowerCase(): {
113
- const n = new G({
113
+ const n = new O({
114
114
  urlTemplate: c,
115
115
  ...t.options
116
116
  });
@@ -118,7 +118,7 @@ class ee {
118
118
  break;
119
119
  }
120
120
  case "tile": {
121
- const n = new H({
121
+ const n = new G({
122
122
  url: c,
123
123
  ...t.options
124
124
  });
@@ -126,7 +126,7 @@ class ee {
126
126
  break;
127
127
  }
128
128
  case "customWMTS".toLowerCase(): {
129
- const n = new A({
129
+ const n = new J({
130
130
  urlTemplate: c,
131
131
  ...t.options
132
132
  });
@@ -134,7 +134,7 @@ class ee {
134
134
  break;
135
135
  }
136
136
  case "mapImage".toLowerCase(): {
137
- const n = new R({
137
+ const n = new H({
138
138
  url: c,
139
139
  ...t.options
140
140
  });
@@ -147,12 +147,12 @@ class ee {
147
147
  break;
148
148
  }
149
149
  case "feature": {
150
- const n = new z({ url: c, ...t.options });
150
+ const n = new x({ url: c, ...t.options });
151
151
  s.add(n);
152
152
  break;
153
153
  }
154
154
  case "3dtiles": {
155
- const n = new I({
155
+ const n = new R({
156
156
  url: c,
157
157
  ...t.options
158
158
  });
@@ -169,7 +169,7 @@ class ee {
169
169
  const t = this.mapConfig.hdLayers.map(
170
170
  (c) => (
171
171
  // 图层文件为GeoJson格式, renderer和symbol使用autocast配置
172
- new x({
172
+ new I({
173
173
  url: P(c.url, this.mapConfig.assetsRoot),
174
174
  ...c.options,
175
175
  title: c.options.id
@@ -179,7 +179,7 @@ class ee {
179
179
  s.addMany(t);
180
180
  }
181
181
  this.view.ui.remove("attribution"), await this.view.when();
182
- const d = this.mapConfig.camera;
182
+ const g = this.mapConfig.camera;
183
183
  let l;
184
184
  if (this.view.type === "2d") {
185
185
  let t = this.view.center;
@@ -196,7 +196,7 @@ class ee {
196
196
  tilt: this.view.camera.tilt
197
197
  };
198
198
  }
199
- return d ? d.home = l : this.mapConfig.camera = { home: l }, this.view;
199
+ return g ? g.home = l : this.mapConfig.camera = { home: l }, this.view;
200
200
  }
201
201
  setLayerVisibility(e) {
202
202
  const { id: i, visible: o } = e, r = this.view.map.findLayerById(i);
@@ -212,14 +212,17 @@ class ee {
212
212
  if (!this.view)
213
213
  return { status: -1, message: "未初始化" };
214
214
  if (e.center || e.target) {
215
- switch ((i = e.target) == null ? void 0 : i.type) {
215
+ switch ((i = e.target) == null ? void 0 : i.type.toLowerCase()) {
216
216
  case "point":
217
217
  e.target = new T(e.target);
218
218
  break;
219
219
  case "polyline":
220
- e.target = new W(e.target);
220
+ e.target = new z(e.target);
221
221
  break;
222
222
  case "polygon":
223
+ e.target = new W(e.target);
224
+ break;
225
+ case "multipoint":
223
226
  e.target = new L(e.target);
224
227
  break;
225
228
  }
@@ -248,8 +251,8 @@ class ee {
248
251
  { duration: (e.duration || 2) * 1e3 }
249
252
  );
250
253
  else {
251
- const r = Math.tan(i * Math.PI / 180) * e.height, s = N(
252
- E.point(e.center),
254
+ const r = Math.tan(i * Math.PI / 180) * e.height, s = E(
255
+ A.point(e.center),
253
256
  r,
254
257
  o + 180,
255
258
  {
@@ -284,14 +287,14 @@ class ee {
284
287
  * */
285
288
  requestCoordinateTransform(e, i) {
286
289
  let o = 0;
287
- const s = 1e3 / 30, d = k.watch(
290
+ const s = 1e3 / 30, g = k.watch(
288
291
  () => this.view.center,
289
292
  () => {
290
293
  const l = this.transformPoints(e), p = Date.now();
291
294
  p - o > s && (i(l), o = p);
292
295
  }
293
296
  );
294
- return this.handleIndex++, this.watchHandleMap.set(this.handleIndex, d), { handle: this.handleIndex, points: this.transformPoints(e) };
297
+ return this.handleIndex++, this.watchHandleMap.set(this.handleIndex, g), { handle: this.handleIndex, points: this.transformPoints(e) };
295
298
  }
296
299
  transformPoints(e) {
297
300
  return e.map((i) => {
@@ -323,5 +326,5 @@ class ee {
323
326
  }
324
327
  }
325
328
  export {
326
- ee as default
329
+ te as default
327
330
  };
@@ -1,7 +1,7 @@
1
1
  import { IResult, ISignalCountdownProps } from '../../../types';
2
2
  import SignalHoloFlow from './signal-holo-flow';
3
3
  export default class LSRSignalHoloFlow extends SignalHoloFlow {
4
- private stopLineLayer;
4
+ private waitingAreaLayer;
5
5
  private watchHandle;
6
6
  private countdownPanelProps;
7
7
  private currentPanelScale;
@@ -9,6 +9,7 @@ export default class LSRSignalHoloFlow extends SignalHoloFlow {
9
9
  private trajectoryDelayTime;
10
10
  /** 按照路口id->进口道路段id->停止线坐标保存的停止线 */
11
11
  private stopLineMap;
12
+ private waitingAreaMap;
12
13
  /** 信号机id->进口道id->灯组id */
13
14
  private lampGroupMap;
14
15
  constructor(view: __esri.MapView | __esri.SceneView, countdownPanelInfos: ISignalCountdownProps[]);
@@ -35,6 +36,8 @@ export default class LSRSignalHoloFlow extends SignalHoloFlow {
35
36
  */
36
37
  private updatePanelPosition;
37
38
  private doHoloSignalData;
39
+ private updateWaitingArea;
40
+ private getColor;
38
41
  private updateLampGroupPanelStatus;
39
42
  /**
40
43
  * 处理全息流信号灯数据
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/core/reactiveUtils"),d=require("@arcgis/core/geometry"),S=require("@arcgis/core/geometry/support/webMercatorUtils.js"),b=require("@arcgis/core/layers/GraphicsLayer"),L=require("./signal-holo-flow.js");function P(u){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const t in u)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(u,t);Object.defineProperty(e,t,l.get?l:{enumerable:!0,get:()=>u[t]})}}return e.default=u,Object.freeze(e)}const w=P(y),m=P(S);class M extends L.default{constructor(e,t){var l,i;super(e),this.stopLineLayer=new b,this.watchHandle=null,this.trajectoryDelayTime=2,this.stopLineMap=new Map,this.lampGroupMap=new Map,this.countdownPanelProps=t,this.view.map.add(this.stopLineLayer),this.trajectoryDelayTime=(i=(l=this.mapConfig.holoFlow)==null?void 0:l.signal)==null?void 0:i.delay,this.trajectoryDelayTime===void 0&&(this.trajectoryDelayTime=2)}async initializeLayer(){var i,o;if(this.stopLineMap.size>0)return;console.time("初始化停止线图层");let e=(o=(i=this.mapConfig.holoFlow)==null?void 0:i.signal)==null?void 0:o.stopLineLayer;if(!e)return;e=this.mapConfig.assetsRoot+"/"+e;const l=await(await fetch(e)).json();for(const n of l.features){const{roadId:s}=n.properties;let{destinationPoint:a}=n.properties;const{coordinates:r}=n.geometry;if(a){if(typeof a=="string")try{a=JSON.parse(a)}catch(c){console.error("解析面板基准点失败",c);continue}}else{const c=r[0],h=r[r.length-1],p=(c[0]+h[0])/2,f=(c[1]+h[1])/2;a=[p,f]}this.stopLineMap.set(s,{coord:r,panelPoint:a})}console.timeEnd("初始化停止线图层")}initializeLampGroup(e){const{sigId:t,lampGroupList:l}=e,i=[];l.forEach(o=>{const{lampGroupNo:n,lampGroupType:s,crossFlowList:a,pedList:r}=o;if(a.length>0)for(const c of a){if(s===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}i.push({lampGroupId:n,roadId:h,dir:p})}r.length>0}),this.lampGroupMap.set(t,i)}handleUniSignalData(e){this.watchHandle||(this.watchHandle=w.watch(()=>this.view.extent,()=>this.updatePanelPosition()));const{sigId:t,runningStatus:l}=e.data.basicInfo,i=this.lampGroupMap.get(t);if(!i)return{status:-1,message:"灯组未初始化"};const o=new Map;let n=!1;switch(String(l)){case"4":{n=!0,i.forEach(s=>{const{roadId:a,dir:r}=s;o.set(a,{...o.get(a)||{},[`${r}Number`]:"",[`${r}Color`]:"yellow"})});break}case"5":{i.forEach(s=>{const{roadId:a,dir:r}=s;o.set(a,{...o.get(a)||{},[`${r}Number`]:"",[`${r}Color`]:"red"})});break}case"6":case"9":{i.forEach(s=>{const{roadId:a,dir:r}=s;o.set(a,{...o.get(a)||{},[`${r}Number`]:"",[`${r}Color`]:"off"})});break}default:{const{curSigColorInfo:s}=e.data;s.forEach(a=>{const r=String(a.lamgroupId),{color:c,leftTime:h}=a,p=i.find(f=>f.lampGroupId===r);if(p){const{roadId:f,dir:g}=p;o.set(f,{...o.get(f)||{},[`${g}Number`]:h,[`${g}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:l}=t;let i=new d.Point({x:l[0],y:l[1]});this.view.spatialReference.isWebMercator&&(i=m.geographicToWebMercator(i));const o=this.view.toScreen(i);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,l=e.phaseCountDownList,i=new Map;for(const o of l){let n="";for(let c of o.roadIdList)if(c.startsWith("-")&&(c=c.slice(1)),this.stopLineMap.has(c)){n=c;break}if(!n){console.log(`没有找到对应的进口道${t}--${n}`);continue}let s=i.get(n);if(s||(s={},i.set(n,s)),!o.direction)continue;const a=o.direction.toLowerCase(),r=o.color===1?"red":o.color===2?"yellow":"green";a==="u"?(s.uNumber=o.leftTime,s.uColor=r):a==="l"?(s.lNumber=o.leftTime,s.lColor=r):a==="s"?(s.sNumber=o.leftTime,s.sColor=r):a==="r"&&(s.rNumber=o.leftTime,s.rColor=r)}this.updateLampGroupPanelStatus(t,i)}updateLampGroupPanelStatus(e,t,l=!1){t.forEach((i,o)=>{const n=this.stopLineMap.get(o);if(!n)return;const s=this.countdownPanelProps.find(a=>a.roadId===o);if(s)s.lampStatus=i,s.flash=l;else{let a=new d.Point({x:n.panelPoint[0],y:n.panelPoint[1]});this.view.spatialReference.isWebMercator&&(a=m.geographicToWebMercator(a));const r=this.view.toScreen(a),c=this.getPanelRotation(n.coord);this.countdownPanelProps.push({displayMode:"complex",flash:l,crossId:e,roadId:o,mapPoint:n.panelPoint,stopLine:n.coord,position:{left:r.x,top:r.y},rotation:c,scale:this.getPanelScale(),lampStatus:i})}})}async handleHoloSignalData(e){this.watchHandle||(this.watchHandle=w.watch(()=>this.view.extent,()=>this.updatePanelPosition())),this.trajectoryDelayTime===0?this.doHoloSignalData(e):setTimeout(()=>this.doHoloSignalData(e),this.trajectoryDelayTime*1e3)}clearSignal(){var e;this.stopLineLayer.removeAll(),this.countdownPanelProps.length=0,(e=this.watchHandle)==null||e.remove(),this.watchHandle=null}getPanelRotation(e){const t=e[0];let l=new d.Point({x:t[0],y:t[1]});this.view.spatialReference.isWebMercator&&(l=m.geographicToWebMercator(l));const i=this.view.toScreen(l),o=e[e.length-1];let n=new d.Point({x:o[0],y:o[1]});this.view.spatialReference.isWebMercator&&(n=m.geographicToWebMercator(n));const s=this.view.toScreen(n),a=s.x-i.x,r=s.y-i.y;return Math.atan2(r,a)*(180/Math.PI)}}exports.default=M;
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 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("@arcgis/core/Basemap"),g=require("@arcgis/core/config"),L=require("@arcgis/core/core/reactiveUtils"),d=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GeoJSONLayer"),x=require("@arcgis/core/layers/IntegratedMesh3DTilesLayer"),I=require("@arcgis/core/layers/MapImageLayer"),S=require("@arcgis/core/layers/TileLayer"),R=require("@arcgis/core/layers/WebTileLayer"),H=require("@arcgis/core/Map"),_=require("@arcgis/core/views/MapView"),G=require("@arcgis/core/views/SceneView"),j=require("@turf/destination"),B=require("@turf/helpers"),N=require("./custom-layer/custom-wmts-layer.js");function b(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>c[t]})}}return e.default=c,Object.freeze(e)}const T=b(L),m=b(z),U=b(B);function q(c,e){return c&&(c.startsWith("http://")||c.startsWith("https://")?c:e+c)}class E{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){var u,y,v,M;this.mapConfig=e.mapConfig;const{container:t,markerClickCallback:s,mapClickCallback:n}=e;g.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,g.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,g.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const a=new H;if(((u=this.mapConfig)==null?void 0:u.mapOptions.mode.toLowerCase())==="2d"?(this.view=new _({map:a,container:t,...this.mapConfig.mapOptions}),this.view.on("drag",i=>{i.button===2&&i.stopPropagation()})):this.view=new G({map:a,container:t,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(y=this.mapConfig)==null?void 0:y.mapOptions}),this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1,featureNavigation:!0},this.view.popup.dockOptions={buttonEnabled:!1,breakpoint:!1},this.view.on("click",async i=>{var k,P;if(n){let o=i.mapPoint;o.spatialReference.isWebMercator&&(o=m.webMercatorToGeographic(o)),n([o.x,o.y],[i.screenPoint.x,i.screenPoint.y],i)}if(this.view.type==="3d"){const o=this.view.camera;if(this.view.spatialReference.isWebMercator){const p=m.webMercatorToGeographic(o.position),w={heading:o.heading,tilt:o.tilt,position:p.toJSON()};console.log(w),(k=navigator.clipboard)==null||k.writeText(JSON.stringify(w))}else console.log(o.toJSON());console.log(this.view.zoom,this.view.scale)}else{let o=this.view.center;this.view.spatialReference.isWebMercator&&(o=m.webMercatorToGeographic(o)),console.log({center:o.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const r=(P=(await this.view.hitTest(i)).results)==null?void 0:P.filter(o=>o.type==="graphic");r.length>0&&r.forEach(o=>{var w;const p=o.graphic;(w=p.attributes)!=null&&w.type&&s&&s(p.attributes.type,p.attributes.id,p.attributes,i)})}),(v=this.mapConfig)!=null&&v.baseLayers?this.mapConfig.baseLayers.forEach(i=>{const l=q(i.url,this.mapConfig.assetsRoot);switch(i.type.toLowerCase()){case"webTile".toLowerCase():{const r=new R({urlTemplate:l,...i.options});a.add(r);break}case"tile":{const r=new S({url:l,...i.options});a.add(r);break}case"customWMTS".toLowerCase():{const r=new N.default({urlTemplate:l,...i.options});a.add(r);break}case"mapImage".toLowerCase():{const r=new I({url:l,...i.options});a.add(r);break}case"arcgis":{const r=new C(i.options);a.basemap=r;break}case"feature":{const r=new W({url:l,...i.options});a.add(r);break}case"3dtiles":{const r=new x({url:l,...i.options});a.add(r);break}}}):a.basemap=new C({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(M=this.mapConfig)!=null&&M.hdLayers){const i=this.mapConfig.hdLayers.map(l=>new O({url:q(l.url,this.mapConfig.assetsRoot),...l.options,title:l.options.id}));a.addMany(i)}this.view.ui.remove("attribution"),await this.view.when();const f=this.mapConfig.camera;let h;if(this.view.type==="2d"){let i=this.view.center;this.view.spatialReference.isWebMercator&&(i=m.webMercatorToGeographic(i)),h={center:[i.x,i.y],zoom:this.view.zoom}}else{let i=this.view.camera.position;this.view.spatialReference.isWebMercator&&(i=m.webMercatorToGeographic(i)),h={position:i,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return f?f.home=h:this.mapConfig.camera={home:h},this.view}setLayerVisibility(e){const{id:t,visible:s}=e,n=this.view.map.findLayerById(t);return n?(n.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var t;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((t=e.target)==null?void 0:t.type){case"point":e.target=new d.Point(e.target);break;case"polyline":e.target=new d.Polyline(e.target);break;case"polygon":e.target=new d.Polygon(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const t=e.tilt||0,s=e.heading||0;if(t===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:s,tilt:0},{duration:(e.duration||2)*1e3});else{const n=Math.tan(t*Math.PI/180)*e.height,a=j(U.point(e.center),n,s+180,{units:"meters"});await this.view.goTo({position:{x:a.geometry.coordinates[0],y:a.geometry.coordinates[1],z:e.height},heading:s,tilt:t},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:t,duration:s=0}=e,{camera:n}=this.mapConfig;if(!n)return{status:-1,message:"未配置camera"};const a=n[t];return a?(await this.view.goTo(a,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,t){let s=0;const a=1e3/30,f=T.watch(()=>this.view.center,()=>{const h=this.transformPoints(e),u=Date.now();u-s>a&&(t(h),s=u)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(t=>{const s=new d.Point({x:t[0],y:t[1]}),n=this.view.toScreen(s);return[n.x,n.y]})}cancelCoordinateTransform(e){const t=this.watchHandleMap.get(e);t&&(t.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:t,max:s}=e;!t&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,n=>{t&&n<=t&&(this.view.zoom=t),s&&n>=s&&(this.view.zoom=s)}))}}exports.default=E;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),g=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),f=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GeoJSONLayer"),x=require("@arcgis/core/layers/IntegratedMesh3DTilesLayer"),I=require("@arcgis/core/layers/MapImageLayer"),S=require("@arcgis/core/layers/TileLayer"),R=require("@arcgis/core/layers/WebTileLayer"),H=require("@arcgis/core/Map"),_=require("@arcgis/core/views/MapView"),G=require("@arcgis/core/views/SceneView"),j=require("@turf/destination"),B=require("@turf/helpers"),N=require("./custom-layer/custom-wmts-layer.js");function b(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>c[t]})}}return e.default=c,Object.freeze(e)}const T=b(q),m=b(z),U=b(B);function L(c,e){return c&&(c.startsWith("http://")||c.startsWith("https://")?c:e+c)}class E{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){var u,y,v,M;this.mapConfig=e.mapConfig;const{container:t,markerClickCallback:s,mapClickCallback:n}=e;g.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,g.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,g.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const a=new H;if(((u=this.mapConfig)==null?void 0:u.mapOptions.mode.toLowerCase())==="2d"?(this.view=new _({map:a,container:t,...this.mapConfig.mapOptions}),this.view.on("drag",i=>{i.button===2&&i.stopPropagation()})):this.view=new G({map:a,container:t,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(y=this.mapConfig)==null?void 0:y.mapOptions}),this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1,featureNavigation:!0},this.view.popup.dockOptions={buttonEnabled:!1,breakpoint:!1},this.view.on("click",async i=>{var k,C;if(n){let o=i.mapPoint;o.spatialReference.isWebMercator&&(o=m.webMercatorToGeographic(o)),n([o.x,o.y],[i.screenPoint.x,i.screenPoint.y],i)}if(this.view.type==="3d"){const o=this.view.camera;if(this.view.spatialReference.isWebMercator){const p=m.webMercatorToGeographic(o.position),w={heading:o.heading,tilt:o.tilt,position:p.toJSON()};console.log(w),(k=navigator.clipboard)==null||k.writeText(JSON.stringify(w))}else console.log(o.toJSON());console.log(this.view.zoom,this.view.scale)}else{let o=this.view.center;this.view.spatialReference.isWebMercator&&(o=m.webMercatorToGeographic(o)),console.log({center:o.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const r=(C=(await this.view.hitTest(i)).results)==null?void 0:C.filter(o=>o.type==="graphic");r.length>0&&r.forEach(o=>{var w;const p=o.graphic;(w=p.attributes)!=null&&w.type&&s&&s(p.attributes.type,p.attributes.id,p.attributes,i)})}),(v=this.mapConfig)!=null&&v.baseLayers?this.mapConfig.baseLayers.forEach(i=>{const l=L(i.url,this.mapConfig.assetsRoot);switch(i.type.toLowerCase()){case"webTile".toLowerCase():{const r=new R({urlTemplate:l,...i.options});a.add(r);break}case"tile":{const r=new S({url:l,...i.options});a.add(r);break}case"customWMTS".toLowerCase():{const r=new N.default({urlTemplate:l,...i.options});a.add(r);break}case"mapImage".toLowerCase():{const r=new I({url:l,...i.options});a.add(r);break}case"arcgis":{const r=new P(i.options);a.basemap=r;break}case"feature":{const r=new W({url:l,...i.options});a.add(r);break}case"3dtiles":{const r=new x({url:l,...i.options});a.add(r);break}}}):a.basemap=new P({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(M=this.mapConfig)!=null&&M.hdLayers){const i=this.mapConfig.hdLayers.map(l=>new O({url:L(l.url,this.mapConfig.assetsRoot),...l.options,title:l.options.id}));a.addMany(i)}this.view.ui.remove("attribution"),await this.view.when();const d=this.mapConfig.camera;let h;if(this.view.type==="2d"){let i=this.view.center;this.view.spatialReference.isWebMercator&&(i=m.webMercatorToGeographic(i)),h={center:[i.x,i.y],zoom:this.view.zoom}}else{let i=this.view.camera.position;this.view.spatialReference.isWebMercator&&(i=m.webMercatorToGeographic(i)),h={position:i,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return d?d.home=h:this.mapConfig.camera={home:h},this.view}setLayerVisibility(e){const{id:t,visible:s}=e,n=this.view.map.findLayerById(t);return n?(n.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var t;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((t=e.target)==null?void 0:t.type.toLowerCase()){case"point":e.target=new f.Point(e.target);break;case"polyline":e.target=new f.Polyline(e.target);break;case"polygon":e.target=new f.Polygon(e.target);break;case"multipoint":e.target=new f.Multipoint(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const t=e.tilt||0,s=e.heading||0;if(t===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:s,tilt:0},{duration:(e.duration||2)*1e3});else{const n=Math.tan(t*Math.PI/180)*e.height,a=j(U.point(e.center),n,s+180,{units:"meters"});await this.view.goTo({position:{x:a.geometry.coordinates[0],y:a.geometry.coordinates[1],z:e.height},heading:s,tilt:t},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:t,duration:s=0}=e,{camera:n}=this.mapConfig;if(!n)return{status:-1,message:"未配置camera"};const a=n[t];return a?(await this.view.goTo(a,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,t){let s=0;const a=1e3/30,d=T.watch(()=>this.view.center,()=>{const h=this.transformPoints(e),u=Date.now();u-s>a&&(t(h),s=u)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,d),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(t=>{const s=new f.Point({x:t[0],y:t[1]}),n=this.view.toScreen(s);return[n.x,n.y]})}cancelCoordinateTransform(e){const t=this.watchHandleMap.get(e);t&&(t.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:t,max:s}=e;!t&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,n=>{t&&n<=t&&(this.view.zoom=t),s&&n>=s&&(this.view.zoom=s)}))}}exports.default=E;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.237",
3
+ "version": "1.0.239",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [