gisviewer-vue3-arcgis 1.0.221 → 1.0.222

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.
@@ -66,7 +66,7 @@ class m {
66
66
  this.signalCountdownPanelProps
67
67
  ) : this.signalHoloFlow = new s(this.view), await this.signalHoloFlow.initializeLayer();
68
68
  }
69
- await this.signalHoloFlow.handleSignalData(o);
69
+ await this.signalHoloFlow.handleHoloSignalData(o);
70
70
  }
71
71
  clearHoloSignal() {
72
72
  var o;
@@ -53,7 +53,7 @@ const N = {
53
53
  const c = {
54
54
  color: _(e)
55
55
  }, m = t.rotation < 0 ? t.rotation + 360 : t.rotation;
56
- return m > 135 && m < 315 && (c.transform = "rotate(180deg)"), c;
56
+ return m > 135 && m < 225 && (c.transform = "rotate(180deg)"), c;
57
57
  };
58
58
  return (e, c) => (n(), l("div", {
59
59
  class: "signal-countdown-panel",
@@ -4,12 +4,30 @@ export default class LSRSignalHoloFlow extends SignalHoloFlow {
4
4
  private stopLineLayer;
5
5
  private watchHandle;
6
6
  private countdownPanelProps;
7
+ /** 轨迹延迟时间 */
8
+ private trajectoryDelayTime;
7
9
  constructor(view: __esri.MapView | __esri.SceneView, countdownPanelInfos: ISignalCountdownProps[]);
8
10
  private stopLineMap;
11
+ /**
12
+ * 读取停止线图层,将灯组面板沿着停止线放置
13
+ * @returns
14
+ */
9
15
  initializeLayer(): Promise<void>;
10
16
  private currentPanelScale;
17
+ /**
18
+ * 根据地图比例尺计算灯组面板缩放比例
19
+ */
11
20
  private getPanelScale;
12
- handleSignalData(data: any): Promise<void>;
21
+ /**
22
+ * 地图移动时更新灯组面板位置
23
+ */
24
+ private updatePanelPosition;
25
+ /**
26
+ * 处理全息流信号灯数据
27
+ * @param data
28
+ * @returns
29
+ */
30
+ handleHoloSignalData(data: any): Promise<void>;
13
31
  clearSignal(): void;
14
32
  /**
15
33
  * 从停止线坐标计算面板旋转角度
@@ -1,164 +1,184 @@
1
- import * as g from "@arcgis/core/core/reactiveUtils";
2
- import { Point as h } from "@arcgis/core/geometry";
1
+ import * as u from "@arcgis/core/core/reactiveUtils";
2
+ import { Point as f } from "@arcgis/core/geometry";
3
3
  import * as d from "@arcgis/core/geometry/support/webMercatorUtils.js";
4
- import u from "@arcgis/core/layers/GraphicsLayer";
4
+ import g from "@arcgis/core/layers/GraphicsLayer";
5
5
  import y from "./signal-holo-flow.mjs";
6
6
  class b extends y {
7
- constructor(s, a) {
8
- super(s), this.stopLineLayer = new u(), this.watchHandle = null, this.stopLineMap = /* @__PURE__ */ new Map(), this.countdownPanelProps = a, this.view.map.add(this.stopLineLayer);
7
+ constructor(e, t) {
8
+ var a, l;
9
+ super(e), this.stopLineLayer = new g(), this.watchHandle = null, this.trajectoryDelayTime = 0, this.stopLineMap = /* @__PURE__ */ new Map(), this.countdownPanelProps = t, this.view.map.add(this.stopLineLayer), this.trajectoryDelayTime = ((l = (a = this.mapConfig.holoFlow) == null ? void 0 : a.signal) == null ? void 0 : l.delay) || 2;
9
10
  }
11
+ /**
12
+ * 读取停止线图层,将灯组面板沿着停止线放置
13
+ * @returns
14
+ */
10
15
  async initializeLayer() {
11
- var p, c;
16
+ var l, c;
12
17
  console.time("初始化停止线图层");
13
- let s = (c = (p = this.mapConfig.holoFlow) == null ? void 0 : p.signal) == null ? void 0 : c.stopLineLayer;
14
- if (!s)
18
+ let e = (c = (l = this.mapConfig.holoFlow) == null ? void 0 : l.signal) == null ? void 0 : c.stopLineLayer;
19
+ if (!e)
15
20
  return;
16
- s = this.mapConfig.assetsRoot + "/" + s;
17
- const l = await (await fetch(s)).json();
18
- for (const t of l.features) {
19
- const { roadId: o, nodeId: e } = t.properties;
20
- let { destinationPoint: n } = t.properties;
21
- const { coordinates: i } = t.geometry;
22
- if (n) {
23
- if (typeof n == "string")
21
+ e = this.mapConfig.assetsRoot + "/" + e;
22
+ const a = await (await fetch(e)).json();
23
+ for (const n of a.features) {
24
+ const { roadId: r, nodeId: o } = n.properties;
25
+ let { destinationPoint: s } = n.properties;
26
+ const { coordinates: i } = n.geometry;
27
+ if (s) {
28
+ if (typeof s == "string")
24
29
  try {
25
- n = JSON.parse(n);
26
- } catch (f) {
27
- console.error("解析面板基准点失败", f);
30
+ s = JSON.parse(s);
31
+ } catch (h) {
32
+ console.error("解析面板基准点失败", h);
28
33
  continue;
29
34
  }
30
35
  } else {
31
- const f = i[0], w = i[i.length - 1], P = (f[0] + w[0]) / 2, m = (f[1] + w[1]) / 2;
32
- n = [P, m];
36
+ const h = i[0], w = i[i.length - 1], P = (h[0] + w[0]) / 2, m = (h[1] + w[1]) / 2;
37
+ s = [P, m];
33
38
  }
34
- const r = this.stopLineMap.get(e);
35
- r ? r.set(o, {
39
+ const p = this.stopLineMap.get(o);
40
+ p ? p.set(r, {
36
41
  coord: i,
37
- panelPoint: n
42
+ panelPoint: s
38
43
  }) : this.stopLineMap.set(
39
- e,
44
+ o,
40
45
  /* @__PURE__ */ new Map([
41
- [o, { coord: i, panelPoint: n }]
46
+ [r, { coord: i, panelPoint: s }]
42
47
  ])
43
48
  );
44
49
  }
45
50
  console.timeEnd("初始化停止线图层");
46
51
  }
52
+ /**
53
+ * 根据地图比例尺计算灯组面板缩放比例
54
+ */
47
55
  getPanelScale() {
48
- const s = this.view.scale;
49
- let a = 1;
50
- return s < 1e3 ? a = 1 : s < 2e3 ? a = 0.8 : s < 4e3 ? a = 0.4 : a = 0, a;
56
+ const e = this.view.scale;
57
+ let t = 1;
58
+ return e < 1e3 ? t = 1 : e < 2e3 ? t = 0.8 : e < 4e3 ? t = 0.4 : t = 0, t;
59
+ }
60
+ /**
61
+ * 地图移动时更新灯组面板位置
62
+ */
63
+ updatePanelPosition() {
64
+ const e = this.getPanelScale();
65
+ for (const t of this.countdownPanelProps) {
66
+ e !== this.currentPanelScale && (t.scale = e);
67
+ const { mapPoint: a } = t;
68
+ let l = new f({
69
+ x: a[0],
70
+ y: a[1]
71
+ });
72
+ this.view.spatialReference.isWebMercator && (l = d.geographicToWebMercator(
73
+ l
74
+ ));
75
+ const c = this.view.toScreen(l);
76
+ if (t.position.left = c.x, t.position.top = c.y, this.view.type === "3d") {
77
+ const n = this.getPanelRotation(t.stopLine);
78
+ t.rotation = n;
79
+ }
80
+ }
81
+ this.currentPanelScale = e;
51
82
  }
52
- async handleSignalData(s) {
53
- this.watchHandle || (this.watchHandle = g.watch(
83
+ /**
84
+ * 处理全息流信号灯数据
85
+ * @param data
86
+ * @returns
87
+ */
88
+ async handleHoloSignalData(e) {
89
+ this.watchHandle || (this.watchHandle = u.watch(
54
90
  () => this.view.extent,
55
- () => {
56
- const t = this.getPanelScale();
57
- for (const o of this.countdownPanelProps) {
58
- t !== this.currentPanelScale && (o.scale = t);
59
- const { mapPoint: e } = o;
60
- let n = new h({
61
- x: e[0],
62
- y: e[1]
63
- });
64
- this.view.spatialReference.isWebMercator && (n = d.geographicToWebMercator(
65
- n
66
- ));
67
- const i = this.view.toScreen(n);
68
- if (o.position.left = i.x, o.position.top = i.y, this.view.type === "3d") {
69
- const r = this.getPanelRotation(o.stopLine);
70
- o.rotation = r;
91
+ () => this.updatePanelPosition()
92
+ )), setTimeout(() => {
93
+ const t = e.crossId, a = this.stopLineMap.get(t);
94
+ if (!a) {
95
+ console.log(`没有找到路口${t}`);
96
+ return;
97
+ }
98
+ const l = e.phaseCountDownList, c = /* @__PURE__ */ new Map();
99
+ for (const n of l) {
100
+ let r = "";
101
+ for (let p of n.roadIdList)
102
+ if (p.startsWith("-") && (p = p.slice(1)), a.has(p)) {
103
+ r = p;
104
+ break;
71
105
  }
106
+ if (!r) {
107
+ console.log(`没有找到对应的进口道${t}--${r}`);
108
+ continue;
72
109
  }
73
- this.currentPanelScale = t;
110
+ let o = c.get(r);
111
+ if (o || (o = {}, c.set(r, o)), !n.direction)
112
+ continue;
113
+ const s = n.direction.toLowerCase(), i = n.color === 1 ? "red" : n.color === 2 ? "yellow" : "green";
114
+ s === "u" ? (o.uNumber = n.leftTime, o.uColor = i) : s === "l" ? (o.lNumber = n.leftTime, o.lColor = i) : s === "s" ? (o.sNumber = n.leftTime, o.sColor = i) : s === "r" && (o.rNumber = n.leftTime, o.rColor = i);
74
115
  }
75
- ));
76
- const a = s.crossId, l = this.stopLineMap.get(a);
77
- if (!l)
78
- return;
79
- const p = s.phaseCountDownList, c = /* @__PURE__ */ new Map();
80
- for (const t of p) {
81
- let o = "";
82
- for (let r of t.roadIdList)
83
- if (r.startsWith("-") && (r = r.slice(1)), l.has(r)) {
84
- o = r;
85
- break;
116
+ c.forEach((n, r) => {
117
+ const o = a.get(r);
118
+ if (!o)
119
+ return;
120
+ const s = this.countdownPanelProps.find(
121
+ (i) => i.crossId === t && i.roadId === r
122
+ );
123
+ if (s)
124
+ s.lampStatus = n;
125
+ else {
126
+ let i = new f({
127
+ x: o.panelPoint[0],
128
+ y: o.panelPoint[1]
129
+ });
130
+ this.view.spatialReference.isWebMercator && (i = d.geographicToWebMercator(
131
+ i
132
+ ));
133
+ const p = this.view.toScreen(i), h = this.getPanelRotation(o.coord);
134
+ this.countdownPanelProps.push({
135
+ displayMode: "complex",
136
+ crossId: t,
137
+ roadId: r,
138
+ mapPoint: o.panelPoint,
139
+ // 定位点地理坐标
140
+ stopLine: o.coord,
141
+ // 关联的停止线坐标
142
+ position: { left: p.x, top: p.y },
143
+ // 定位点屏幕坐标
144
+ rotation: h,
145
+ // 面板旋转角度
146
+ scale: this.getPanelScale(),
147
+ lampStatus: n
148
+ // 灯组状态
149
+ });
86
150
  }
87
- if (!o)
88
- continue;
89
- let e = c.get(o);
90
- if (e || (e = {}, c.set(o, e)), !t.direction) {
91
- console.log(`没有找到对应的方向${a}--${JSON.stringify(t)}`);
92
- continue;
93
- }
94
- const n = t.direction.toLowerCase(), i = t.color === 1 ? "red" : t.color === 2 ? "yellow" : "green";
95
- n === "u" ? (e.uNumber = t.leftTime, e.uColor = i) : n === "l" ? (e.lNumber = t.leftTime, e.lColor = i) : n === "s" ? (e.sNumber = t.leftTime, e.sColor = i) : n === "r" && (e.rNumber = t.leftTime, e.rColor = i);
96
- }
97
- c.forEach((t, o) => {
98
- const e = l.get(o);
99
- if (!e)
100
- return;
101
- const n = this.countdownPanelProps.find(
102
- (i) => i.crossId === a && i.roadId === o
103
- );
104
- if (n)
105
- n.lampStatus = t;
106
- else {
107
- let i = new h({
108
- x: e.panelPoint[0],
109
- y: e.panelPoint[1]
110
- });
111
- this.view.spatialReference.isWebMercator && (i = d.geographicToWebMercator(
112
- i
113
- ));
114
- const r = this.view.toScreen(i), f = this.getPanelRotation(e.coord);
115
- this.countdownPanelProps.push({
116
- displayMode: "complex",
117
- crossId: a,
118
- roadId: o,
119
- mapPoint: e.panelPoint,
120
- // 定位点地理坐标
121
- stopLine: e.coord,
122
- // 关联的停止线坐标
123
- position: { left: r.x, top: r.y },
124
- // 定位点屏幕坐标
125
- rotation: f,
126
- // 面板旋转角度
127
- scale: this.getPanelScale(),
128
- lampStatus: t
129
- // 灯组状态
130
- });
131
- }
132
- });
151
+ });
152
+ }, this.trajectoryDelayTime * 1e3);
133
153
  }
134
154
  clearSignal() {
135
- var s;
136
- this.stopLineLayer.removeAll(), this.countdownPanelProps.length = 0, (s = this.watchHandle) == null || s.remove(), this.watchHandle = null;
155
+ var e;
156
+ this.stopLineLayer.removeAll(), this.countdownPanelProps.length = 0, (e = this.watchHandle) == null || e.remove(), this.watchHandle = null;
137
157
  }
138
158
  /**
139
159
  * 从停止线坐标计算面板旋转角度
140
160
  * @param coordinates
141
161
  * @returns
142
162
  */
143
- getPanelRotation(s) {
144
- const a = s[0];
145
- let l = new h({
146
- x: a[0],
147
- y: a[1]
163
+ getPanelRotation(e) {
164
+ const t = e[0];
165
+ let a = new f({
166
+ x: t[0],
167
+ y: t[1]
148
168
  });
149
- this.view.spatialReference.isWebMercator && (l = d.geographicToWebMercator(
150
- l
169
+ this.view.spatialReference.isWebMercator && (a = d.geographicToWebMercator(
170
+ a
151
171
  ));
152
- const p = this.view.toScreen(l), c = s[s.length - 1];
153
- let t = new h({
172
+ const l = this.view.toScreen(a), c = e[e.length - 1];
173
+ let n = new f({
154
174
  x: c[0],
155
175
  y: c[1]
156
176
  });
157
- this.view.spatialReference.isWebMercator && (t = d.geographicToWebMercator(
158
- t
177
+ this.view.spatialReference.isWebMercator && (n = d.geographicToWebMercator(
178
+ n
159
179
  ));
160
- const o = this.view.toScreen(t), e = o.x - p.x, n = o.y - p.y;
161
- return Math.atan2(n, e) * (180 / Math.PI);
180
+ const r = this.view.toScreen(n), o = r.x - l.x, s = r.y - l.y;
181
+ return Math.atan2(s, o) * (180 / Math.PI);
162
182
  }
163
183
  }
164
184
  export {
@@ -16,7 +16,7 @@ export default class SignalHoloFlow {
16
16
  * */
17
17
  initializeLayer(): Promise<void>;
18
18
  private initializePlateBackground;
19
- handleSignalData(data: any): Promise<void>;
19
+ handleHoloSignalData(data: any): Promise<void>;
20
20
  /**
21
21
  * 清除实时信号相关图层
22
22
  * */
@@ -121,7 +121,7 @@ class C {
121
121
  };
122
122
  });
123
123
  }
124
- async handleSignalData(e) {
124
+ async handleHoloSignalData(e) {
125
125
  const { crossId: t, lat: a, lon: s, rtStage: n, channelsConfig: i } = e;
126
126
  await this.updateCountdown(t, a, s, n), !(!this.phaseLineLayer || !i) && ((!this.currentPhaseMap.has(t) || this.currentPhaseMap.get(t) !== n.stagePhase) && await this.updatePhaseLine(
127
127
  t,
@@ -1,23 +1,24 @@
1
1
  import C from "@arcgis/core/Basemap";
2
- import d from "@arcgis/core/config";
2
+ import g from "@arcgis/core/config";
3
3
  import * as k from "@arcgis/core/core/reactiveUtils";
4
- import { Polygon as L, Polyline as W, Point as P } from "@arcgis/core/geometry";
4
+ import { Polygon as L, Polyline as W, Point as T } from "@arcgis/core/geometry";
5
5
  import * as w from "@arcgis/core/geometry/support/webMercatorUtils";
6
6
  import z from "@arcgis/core/layers/FeatureLayer";
7
7
  import x from "@arcgis/core/layers/GeoJSONLayer";
8
- import I from "@arcgis/core/layers/MapImageLayer";
9
- import R from "@arcgis/core/layers/TileLayer";
10
- import H from "@arcgis/core/layers/WebTileLayer";
11
- import G from "@arcgis/core/Map";
12
- import O from "@arcgis/core/views/MapView";
13
- import S from "@arcgis/core/views/SceneView";
14
- import B from "@turf/destination";
15
- import * as N from "@turf/helpers";
16
- import E from "./custom-layer/custom-wmts-layer.mjs";
17
- function T(h, t) {
18
- return h && (h.startsWith("http://") || h.startsWith("https://") ? h : t + h);
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";
18
+ function P(h, e) {
19
+ return h && (h.startsWith("http://") || h.startsWith("https://") ? h : e + h);
19
20
  }
20
- class X {
21
+ class ee {
21
22
  constructor() {
22
23
  this.mapConfig = {}, this.watchHandleMap = /* @__PURE__ */ new Map(), this.handleIndex = 0, this.zoomWatchHandle = null;
23
24
  }
@@ -26,19 +27,19 @@ class X {
26
27
  * @param params 容器
27
28
  * @returns view
28
29
  */
29
- async initialize(t) {
30
- var p, u, b, v;
31
- this.mapConfig = t.mapConfig;
32
- const { container: i, markerClickCallback: o, mapClickCallback: r } = t;
33
- d.assetsPath = `${this.mapConfig.assetsRoot}/ArcgisAssets`, d.fontsUrl = `${this.mapConfig.assetsRoot}/fonts`, d.apiKey = "AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";
34
- const s = new G();
35
- if (((p = this.mapConfig) == null ? void 0 : p.mapOptions.mode.toLowerCase()) === "2d" ? (this.view = new O({
30
+ async initialize(e) {
31
+ var p, u, b, y;
32
+ this.mapConfig = e.mapConfig;
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({
36
37
  map: s,
37
38
  container: i,
38
39
  ...this.mapConfig.mapOptions
39
- }), this.view.on("drag", (e) => {
40
- e.button === 2 && e.stopPropagation();
41
- })) : this.view = new S({
40
+ }), this.view.on("drag", (t) => {
41
+ t.button === 2 && t.stopPropagation();
42
+ })) : this.view = new B({
42
43
  map: s,
43
44
  container: i,
44
45
  environment: {
@@ -56,16 +57,16 @@ class X {
56
57
  }, this.view.popup.dockOptions = {
57
58
  buttonEnabled: !1,
58
59
  breakpoint: !1
59
- }, this.view.on("click", async (e) => {
60
- var y, M;
60
+ }, this.view.on("click", async (t) => {
61
+ var v, M;
61
62
  if (r) {
62
- let a = e.mapPoint;
63
+ let a = t.mapPoint;
63
64
  a.spatialReference.isWebMercator && (a = w.webMercatorToGeographic(
64
65
  a
65
66
  )), r(
66
67
  [a.x, a.y],
67
- [e.screenPoint.x, e.screenPoint.y],
68
- e
68
+ [t.screenPoint.x, t.screenPoint.y],
69
+ t
69
70
  );
70
71
  }
71
72
  if (this.view.type === "3d") {
@@ -78,7 +79,7 @@ class X {
78
79
  tilt: a.tilt,
79
80
  position: m.toJSON()
80
81
  };
81
- console.log(f), (y = navigator.clipboard) == null || y.writeText(JSON.stringify(f));
82
+ console.log(f), (v = navigator.clipboard) == null || v.writeText(JSON.stringify(f));
82
83
  } else
83
84
  console.log(a.toJSON());
84
85
  console.log(this.view.zoom, this.view.scale);
@@ -92,7 +93,7 @@ class X {
92
93
  scale: this.view.scale
93
94
  });
94
95
  }
95
- const n = (M = (await this.view.hitTest(e)).results) == null ? void 0 : M.filter(
96
+ const n = (M = (await this.view.hitTest(t)).results) == null ? void 0 : M.filter(
96
97
  (a) => a.type === "graphic"
97
98
  );
98
99
  n.length > 0 && n.forEach((a) => {
@@ -102,51 +103,59 @@ class X {
102
103
  m.attributes.type,
103
104
  m.attributes.id,
104
105
  m.attributes,
105
- e
106
+ t
106
107
  );
107
108
  });
108
- }), (b = this.mapConfig) != null && b.baseLayers ? this.mapConfig.baseLayers.forEach((e) => {
109
- const c = T(e.url, this.mapConfig.assetsRoot);
110
- switch (e.type.toLowerCase()) {
109
+ }), (b = this.mapConfig) != null && b.baseLayers ? this.mapConfig.baseLayers.forEach((t) => {
110
+ const c = P(t.url, this.mapConfig.assetsRoot);
111
+ switch (t.type.toLowerCase()) {
111
112
  case "webTile".toLowerCase(): {
112
- const n = new H({
113
+ const n = new G({
113
114
  urlTemplate: c,
114
- ...e.options
115
+ ...t.options
115
116
  });
116
117
  s.add(n);
117
118
  break;
118
119
  }
119
120
  case "tile": {
120
- const n = new R({
121
+ const n = new H({
121
122
  url: c,
122
- ...e.options
123
+ ...t.options
123
124
  });
124
125
  s.add(n);
125
126
  break;
126
127
  }
127
128
  case "customWMTS".toLowerCase(): {
128
- const n = new E({
129
+ const n = new A({
129
130
  urlTemplate: c,
130
- ...e.options
131
+ ...t.options
131
132
  });
132
133
  s.add(n);
133
134
  break;
134
135
  }
135
136
  case "mapImage".toLowerCase(): {
136
- const n = new I({
137
+ const n = new R({
137
138
  url: c,
138
- ...e.options
139
+ ...t.options
139
140
  });
140
141
  s.add(n);
141
142
  break;
142
143
  }
143
144
  case "arcgis": {
144
- const n = new C(e.options);
145
+ const n = new C(t.options);
145
146
  s.basemap = n;
146
147
  break;
147
148
  }
148
149
  case "feature": {
149
- const n = new z({ url: c, ...e.options });
150
+ const n = new z({ url: c, ...t.options });
151
+ s.add(n);
152
+ break;
153
+ }
154
+ case "3dtiles": {
155
+ const n = new I({
156
+ url: c,
157
+ ...t.options
158
+ });
150
159
  s.add(n);
151
160
  break;
152
161
  }
@@ -156,41 +165,41 @@ class X {
156
165
  id: "arcgis/light-gray",
157
166
  language: "zh-CN"
158
167
  }
159
- }), (v = this.mapConfig) != null && v.hdLayers) {
160
- const e = this.mapConfig.hdLayers.map(
168
+ }), (y = this.mapConfig) != null && y.hdLayers) {
169
+ const t = this.mapConfig.hdLayers.map(
161
170
  (c) => (
162
171
  // 图层文件为GeoJson格式, renderer和symbol使用autocast配置
163
172
  new x({
164
- url: T(c.url, this.mapConfig.assetsRoot),
173
+ url: P(c.url, this.mapConfig.assetsRoot),
165
174
  ...c.options,
166
175
  title: c.options.id
167
176
  })
168
177
  )
169
178
  );
170
- s.addMany(e);
179
+ s.addMany(t);
171
180
  }
172
181
  this.view.ui.remove("attribution"), await this.view.when();
173
- const g = this.mapConfig.camera;
182
+ const d = this.mapConfig.camera;
174
183
  let l;
175
184
  if (this.view.type === "2d") {
176
- let e = this.view.center;
177
- this.view.spatialReference.isWebMercator && (e = w.webMercatorToGeographic(
178
- e
179
- )), l = { center: [e.x, e.y], zoom: this.view.zoom };
185
+ let t = this.view.center;
186
+ this.view.spatialReference.isWebMercator && (t = w.webMercatorToGeographic(
187
+ t
188
+ )), l = { center: [t.x, t.y], zoom: this.view.zoom };
180
189
  } else {
181
- let e = this.view.camera.position;
182
- this.view.spatialReference.isWebMercator && (e = w.webMercatorToGeographic(
183
- e
190
+ let t = this.view.camera.position;
191
+ this.view.spatialReference.isWebMercator && (t = w.webMercatorToGeographic(
192
+ t
184
193
  )), l = {
185
- position: e,
194
+ position: t,
186
195
  heading: this.view.camera.heading,
187
196
  tilt: this.view.camera.tilt
188
197
  };
189
198
  }
190
- return g ? g.home = l : this.mapConfig.camera = { home: l }, this.view;
199
+ return d ? d.home = l : this.mapConfig.camera = { home: l }, this.view;
191
200
  }
192
- setLayerVisibility(t) {
193
- const { id: i, visible: o } = t, r = this.view.map.findLayerById(i);
201
+ setLayerVisibility(e) {
202
+ const { id: i, visible: o } = e, r = this.view.map.findLayerById(i);
194
203
  return r ? (r.visible = o, { status: 0, message: "ok" }) : { status: -1, message: "未找到图层" };
195
204
  }
196
205
  /**
@@ -198,49 +207,49 @@ class X {
198
207
  * @param params
199
208
  * @returns
200
209
  */
201
- async setMapCenter(t) {
210
+ async setMapCenter(e) {
202
211
  var i;
203
212
  if (!this.view)
204
213
  return { status: -1, message: "未初始化" };
205
- if (t.center || t.target) {
206
- switch ((i = t.target) == null ? void 0 : i.type) {
214
+ if (e.center || e.target) {
215
+ switch ((i = e.target) == null ? void 0 : i.type) {
207
216
  case "point":
208
- t.target = new P(t.target);
217
+ e.target = new T(e.target);
209
218
  break;
210
219
  case "polyline":
211
- t.target = new W(t.target);
220
+ e.target = new W(e.target);
212
221
  break;
213
222
  case "polygon":
214
- t.target = new L(t.target);
223
+ e.target = new L(e.target);
215
224
  break;
216
225
  }
217
- await this.view.goTo(t, { duration: (t.duration || 0) * 1e3 });
226
+ await this.view.goTo(e, { duration: (e.duration || 0) * 1e3 });
218
227
  }
219
228
  return { status: 0, message: "成功" };
220
229
  }
221
230
  /**
222
231
  * 在一定的高度,以一定的角度去观察某个坐标
223
232
  * */
224
- async lookAt(t) {
233
+ async lookAt(e) {
225
234
  if (this.view.type === "2d")
226
235
  return;
227
- const i = t.tilt || 0, o = t.heading || 0;
236
+ const i = e.tilt || 0, o = e.heading || 0;
228
237
  if (i === 0)
229
238
  await this.view.goTo(
230
239
  {
231
240
  position: {
232
- x: t.center[0],
233
- y: t.center[1],
234
- z: t.height
241
+ x: e.center[0],
242
+ y: e.center[1],
243
+ z: e.height
235
244
  },
236
245
  heading: o,
237
246
  tilt: 0
238
247
  },
239
- { duration: (t.duration || 2) * 1e3 }
248
+ { duration: (e.duration || 2) * 1e3 }
240
249
  );
241
250
  else {
242
- const r = Math.tan(i * Math.PI / 180) * t.height, s = B(
243
- N.point(t.center),
251
+ const r = Math.tan(i * Math.PI / 180) * e.height, s = N(
252
+ E.point(e.center),
244
253
  r,
245
254
  o + 180,
246
255
  {
@@ -252,19 +261,19 @@ class X {
252
261
  position: {
253
262
  x: s.geometry.coordinates[0],
254
263
  y: s.geometry.coordinates[1],
255
- z: t.height
264
+ z: e.height
256
265
  },
257
266
  heading: o,
258
267
  tilt: i
259
268
  },
260
- { duration: (t.duration || 2) * 1e3 }
269
+ { duration: (e.duration || 2) * 1e3 }
261
270
  );
262
271
  }
263
272
  }
264
- async setMapCamera(t) {
273
+ async setMapCamera(e) {
265
274
  if (!this.view)
266
275
  return { status: -1, message: "未初始化" };
267
- const { name: i, duration: o = 0 } = t, { camera: r } = this.mapConfig;
276
+ const { name: i, duration: o = 0 } = e, { camera: r } = this.mapConfig;
268
277
  if (!r)
269
278
  return { status: -1, message: "未配置camera" };
270
279
  const s = r[i];
@@ -273,20 +282,20 @@ class X {
273
282
  /**
274
283
  * 经纬度转像素坐标,在地图移动时回调
275
284
  * */
276
- requestCoordinateTransform(t, i) {
285
+ requestCoordinateTransform(e, i) {
277
286
  let o = 0;
278
- const s = 1e3 / 30, g = k.watch(
287
+ const s = 1e3 / 30, d = k.watch(
279
288
  () => this.view.center,
280
289
  () => {
281
- const l = this.transformPoints(t), p = Date.now();
290
+ const l = this.transformPoints(e), p = Date.now();
282
291
  p - o > s && (i(l), o = p);
283
292
  }
284
293
  );
285
- return this.handleIndex++, this.watchHandleMap.set(this.handleIndex, g), { handle: this.handleIndex, points: this.transformPoints(t) };
294
+ return this.handleIndex++, this.watchHandleMap.set(this.handleIndex, d), { handle: this.handleIndex, points: this.transformPoints(e) };
286
295
  }
287
- transformPoints(t) {
288
- return t.map((i) => {
289
- const o = new P({
296
+ transformPoints(e) {
297
+ return e.map((i) => {
298
+ const o = new T({
290
299
  x: i[0],
291
300
  y: i[1]
292
301
  }), r = this.view.toScreen(o);
@@ -296,15 +305,15 @@ class X {
296
305
  /**
297
306
  * 停止坐标转换回调
298
307
  * */
299
- cancelCoordinateTransform(t) {
300
- const i = this.watchHandleMap.get(t);
301
- i && (i.remove(), this.watchHandleMap.delete(t));
308
+ cancelCoordinateTransform(e) {
309
+ const i = this.watchHandleMap.get(e);
310
+ i && (i.remove(), this.watchHandleMap.delete(e));
302
311
  }
303
312
  /**
304
313
  * 设置地图zoom范围
305
314
  * */
306
- setMapZoomRange(t) {
307
- const { min: i, max: o } = t;
315
+ setMapZoomRange(e) {
316
+ const { min: i, max: o } = e;
308
317
  !i && !o || (this.zoomWatchHandle && this.zoomWatchHandle.remove(), this.zoomWatchHandle = k.watch(
309
318
  () => this.view.zoom,
310
319
  (r) => {
@@ -314,5 +323,5 @@ class X {
314
323
  }
315
324
  }
316
325
  export {
317
- X as default
326
+ ee as default
318
327
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue"),t=require("../../../types/index.js"),s=require("../../stores/index.js"),n=require("./signal-holo-flow.js"),r=require("./signal-holo-flow-lsr.js"),c=require("./trace-holo-flow.js");class h{constructor(e,o){this.view=e,this.signalCountdownPanelProps=o}async init(){this.traceHoloFlow=new c.default(this.view),await this.traceHoloFlow.init()}handleVehicleTraceData(e){this.traceHoloFlow.handleVehicleTraceData(e)}toggleTrafficObject(e){switch(e.name.toLowerCase()){case"groundVehicle".toLowerCase():this.traceHoloFlow.toggleGroundVehicle(e.visible);break;case"elevatedVehicle".toLowerCase():this.traceHoloFlow.toggleElevatedVehicle(e.visible);break}}clearHoloTrace(){this.traceHoloFlow.clearTrace()}toggleTrafficInfo(e){this.traceHoloFlow.toggleTrafficInfo(e)}togglePause(e){this.traceHoloFlow.togglePause(e)}updatePanelContent(e){let o=t.EVehiclePlateState.None;switch(e){case"none":o=t.EVehiclePlateState.None;break;case"plateNumber":o=t.EVehiclePlateState.PlateNumber;break;case"vehicleId":o=t.EVehiclePlateState.Id;break;case"mix":o=t.EVehiclePlateState.Mix;break}this.traceHoloFlow.updatePanelContent(o)}async handleSignalData(e){var o,l;if(!this.signalHoloFlow){const a=s.default.useAppDataStore;((l=(o=i.toRaw(a.mapConfig).holoFlow)==null?void 0:o.signal)==null?void 0:l.style)==="LSR"?this.signalHoloFlow=new r.default(this.view,this.signalCountdownPanelProps):this.signalHoloFlow=new n.default(this.view),await this.signalHoloFlow.initializeLayer()}await this.signalHoloFlow.handleSignalData(e)}clearHoloSignal(){var e;(e=this.signalHoloFlow)==null||e.clearSignal()}setInterpolate(e){this.traceHoloFlow.setInterpolate(e)}downloadTrackLog(){this.traceHoloFlow.downloadLog()}}exports.default=h;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue"),t=require("../../../types/index.js"),s=require("../../stores/index.js"),n=require("./signal-holo-flow.js"),r=require("./signal-holo-flow-lsr.js"),c=require("./trace-holo-flow.js");class h{constructor(e,o){this.view=e,this.signalCountdownPanelProps=o}async init(){this.traceHoloFlow=new c.default(this.view),await this.traceHoloFlow.init()}handleVehicleTraceData(e){this.traceHoloFlow.handleVehicleTraceData(e)}toggleTrafficObject(e){switch(e.name.toLowerCase()){case"groundVehicle".toLowerCase():this.traceHoloFlow.toggleGroundVehicle(e.visible);break;case"elevatedVehicle".toLowerCase():this.traceHoloFlow.toggleElevatedVehicle(e.visible);break}}clearHoloTrace(){this.traceHoloFlow.clearTrace()}toggleTrafficInfo(e){this.traceHoloFlow.toggleTrafficInfo(e)}togglePause(e){this.traceHoloFlow.togglePause(e)}updatePanelContent(e){let o=t.EVehiclePlateState.None;switch(e){case"none":o=t.EVehiclePlateState.None;break;case"plateNumber":o=t.EVehiclePlateState.PlateNumber;break;case"vehicleId":o=t.EVehiclePlateState.Id;break;case"mix":o=t.EVehiclePlateState.Mix;break}this.traceHoloFlow.updatePanelContent(o)}async handleSignalData(e){var o,l;if(!this.signalHoloFlow){const a=s.default.useAppDataStore;((l=(o=i.toRaw(a.mapConfig).holoFlow)==null?void 0:o.signal)==null?void 0:l.style)==="LSR"?this.signalHoloFlow=new r.default(this.view,this.signalCountdownPanelProps):this.signalHoloFlow=new n.default(this.view),await this.signalHoloFlow.initializeLayer()}await this.signalHoloFlow.handleHoloSignalData(e)}clearHoloSignal(){var e;(e=this.signalHoloFlow)==null||e.clearSignal()}setInterpolate(e){this.traceHoloFlow.setInterpolate(e)}downloadTrackLog(){this.traceHoloFlow.downloadLog()}}exports.default=h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),v={key:0,class:"signal-countdown-container"},N=["src"],h={key:1,class:"signal-countdown-container"},w=["src"],V={key:2,class:"signal-countdown-container"},C=["src"],b={key:3,class:"signal-countdown-container"},E=["src"],_=e.defineComponent({__name:"signal-countdown-panel",props:{displayMode:{},crossId:{},roadId:{},mapPoint:{},stopLine:{},scale:{},position:{},rotation:{},lampStatus:{}},setup(a){const t=a,r=e.computed(()=>({top:`${t.position.top}px`,left:`${t.position.left}px`,"transform-origin":"bottom center",transform:`translateX(-50%) translateY(-100%) rotate(${t.rotation}deg) scale(${t.scale})`})),c=e.computed(()=>`/GisViewerAssets/Images/SignalLamp/u-${t.lampStatus.uColor}.png`),i=e.computed(()=>l(t.lampStatus.uColor)),u=e.computed(()=>`/GisViewerAssets/Images/SignalLamp/l-${t.lampStatus.lColor}.png`),m=e.computed(()=>l(t.lampStatus.lColor)),d=e.computed(()=>`/GisViewerAssets/Images/SignalLamp/s-${t.lampStatus.sColor}.png`),p=e.computed(()=>l(t.lampStatus.sColor)),g=e.computed(()=>`/GisViewerAssets/Images/SignalLamp/r-${t.lampStatus.rColor}.png`),S=e.computed(()=>l(t.lampStatus.rColor)),y=o=>{switch(o){case"red":return"red";case"yellow":return"rgb(255, 192, 2)";case"green":return"lime";default:return"white"}},l=o=>{const n={color:y(o)},s=t.rotation<0?t.rotation+360:t.rotation;return s>135&&s<315&&(n.transform="rotate(180deg)"),n};return(o,n)=>(e.openBlock(),e.createElementBlock("div",{class:"signal-countdown-panel",style:e.normalizeStyle(r.value)},[o.lampStatus.uColor?(e.openBlock(),e.createElementBlock("div",v,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(i.value)},e.toDisplayString(o.lampStatus.uNumber),5),e.createElementVNode("div",null,[e.createElementVNode("img",{src:c.value,width:"20px",height:"20px"},null,8,N)])])):e.createCommentVNode("",!0),o.lampStatus.lColor?(e.openBlock(),e.createElementBlock("div",h,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(m.value)},e.toDisplayString(o.lampStatus.lNumber),5),e.createElementVNode("div",null,[e.createElementVNode("img",{src:u.value,width:"20px",height:"20px"},null,8,w)])])):e.createCommentVNode("",!0),o.lampStatus.sColor?(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(p.value)},e.toDisplayString(o.lampStatus.sNumber),5),e.createElementVNode("div",null,[e.createElementVNode("img",{src:d.value,width:"20px",height:"20px"},null,8,C)])])):e.createCommentVNode("",!0),o.lampStatus.rColor!==void 0?(e.openBlock(),e.createElementBlock("div",b,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(S.value)},e.toDisplayString(o.lampStatus.rNumber),5),e.createElementVNode("div",null,[e.createElementVNode("img",{src:g.value,width:"20px",height:"20px"},null,8,E)])])):e.createCommentVNode("",!0)],4))}});exports.default=_;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),v={key:0,class:"signal-countdown-container"},N=["src"],h={key:1,class:"signal-countdown-container"},w=["src"],V={key:2,class:"signal-countdown-container"},C=["src"],b={key:3,class:"signal-countdown-container"},E=["src"],_=e.defineComponent({__name:"signal-countdown-panel",props:{displayMode:{},crossId:{},roadId:{},mapPoint:{},stopLine:{},scale:{},position:{},rotation:{},lampStatus:{}},setup(a){const t=a,r=e.computed(()=>({top:`${t.position.top}px`,left:`${t.position.left}px`,"transform-origin":"bottom center",transform:`translateX(-50%) translateY(-100%) rotate(${t.rotation}deg) scale(${t.scale})`})),c=e.computed(()=>`/GisViewerAssets/Images/SignalLamp/u-${t.lampStatus.uColor}.png`),i=e.computed(()=>l(t.lampStatus.uColor)),u=e.computed(()=>`/GisViewerAssets/Images/SignalLamp/l-${t.lampStatus.lColor}.png`),m=e.computed(()=>l(t.lampStatus.lColor)),d=e.computed(()=>`/GisViewerAssets/Images/SignalLamp/s-${t.lampStatus.sColor}.png`),p=e.computed(()=>l(t.lampStatus.sColor)),g=e.computed(()=>`/GisViewerAssets/Images/SignalLamp/r-${t.lampStatus.rColor}.png`),S=e.computed(()=>l(t.lampStatus.rColor)),y=o=>{switch(o){case"red":return"red";case"yellow":return"rgb(255, 192, 2)";case"green":return"lime";default:return"white"}},l=o=>{const n={color:y(o)},s=t.rotation<0?t.rotation+360:t.rotation;return s>135&&s<225&&(n.transform="rotate(180deg)"),n};return(o,n)=>(e.openBlock(),e.createElementBlock("div",{class:"signal-countdown-panel",style:e.normalizeStyle(r.value)},[o.lampStatus.uColor?(e.openBlock(),e.createElementBlock("div",v,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(i.value)},e.toDisplayString(o.lampStatus.uNumber),5),e.createElementVNode("div",null,[e.createElementVNode("img",{src:c.value,width:"20px",height:"20px"},null,8,N)])])):e.createCommentVNode("",!0),o.lampStatus.lColor?(e.openBlock(),e.createElementBlock("div",h,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(m.value)},e.toDisplayString(o.lampStatus.lNumber),5),e.createElementVNode("div",null,[e.createElementVNode("img",{src:u.value,width:"20px",height:"20px"},null,8,w)])])):e.createCommentVNode("",!0),o.lampStatus.sColor?(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(p.value)},e.toDisplayString(o.lampStatus.sNumber),5),e.createElementVNode("div",null,[e.createElementVNode("img",{src:d.value,width:"20px",height:"20px"},null,8,C)])])):e.createCommentVNode("",!0),o.lampStatus.rColor!==void 0?(e.openBlock(),e.createElementBlock("div",b,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(S.value)},e.toDisplayString(o.lampStatus.rNumber),5),e.createElementVNode("div",null,[e.createElementVNode("img",{src:g.value,width:"20px",height:"20px"},null,8,E)])])):e.createCommentVNode("",!0)],4))}});exports.default=_;
@@ -4,12 +4,30 @@ export default class LSRSignalHoloFlow extends SignalHoloFlow {
4
4
  private stopLineLayer;
5
5
  private watchHandle;
6
6
  private countdownPanelProps;
7
+ /** 轨迹延迟时间 */
8
+ private trajectoryDelayTime;
7
9
  constructor(view: __esri.MapView | __esri.SceneView, countdownPanelInfos: ISignalCountdownProps[]);
8
10
  private stopLineMap;
11
+ /**
12
+ * 读取停止线图层,将灯组面板沿着停止线放置
13
+ * @returns
14
+ */
9
15
  initializeLayer(): Promise<void>;
10
16
  private currentPanelScale;
17
+ /**
18
+ * 根据地图比例尺计算灯组面板缩放比例
19
+ */
11
20
  private getPanelScale;
12
- handleSignalData(data: any): Promise<void>;
21
+ /**
22
+ * 地图移动时更新灯组面板位置
23
+ */
24
+ private updatePanelPosition;
25
+ /**
26
+ * 处理全息流信号灯数据
27
+ * @param data
28
+ * @returns
29
+ */
30
+ handleHoloSignalData(data: any): Promise<void>;
13
31
  clearSignal(): void;
14
32
  /**
15
33
  * 从停止线坐标计算面板旋转角度
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),L=require("@arcgis/core/geometry/support/webMercatorUtils.js"),M=require("@arcgis/core/layers/GraphicsLayer"),S=require("./signal-holo-flow.js");function P(f){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const n in f)if(n!=="default"){const l=Object.getOwnPropertyDescriptor(f,n);Object.defineProperty(o,n,l.get?l:{enumerable:!0,get:()=>f[n]})}}return o.default=f,Object.freeze(o)}const b=P(y),d=P(L);class v extends S.default{constructor(o,n){super(o),this.stopLineLayer=new M,this.watchHandle=null,this.stopLineMap=new Map,this.countdownPanelProps=n,this.view.map.add(this.stopLineLayer)}async initializeLayer(){var p,c;console.time("初始化停止线图层");let o=(c=(p=this.mapConfig.holoFlow)==null?void 0:p.signal)==null?void 0:c.stopLineLayer;if(!o)return;o=this.mapConfig.assetsRoot+"/"+o;const l=await(await fetch(o)).json();for(const t of l.features){const{roadId:i,nodeId:e}=t.properties;let{destinationPoint:s}=t.properties;const{coordinates:a}=t.geometry;if(s){if(typeof s=="string")try{s=JSON.parse(s)}catch(h){console.error("解析面板基准点失败",h);continue}}else{const h=a[0],w=a[a.length-1],g=(h[0]+w[0])/2,m=(h[1]+w[1])/2;s=[g,m]}const r=this.stopLineMap.get(e);r?r.set(i,{coord:a,panelPoint:s}):this.stopLineMap.set(e,new Map([[i,{coord:a,panelPoint:s}]]))}console.timeEnd("初始化停止线图层")}getPanelScale(){const o=this.view.scale;let n=1;return o<1e3?n=1:o<2e3?n=.8:o<4e3?n=.4:n=0,n}async handleSignalData(o){this.watchHandle||(this.watchHandle=b.watch(()=>this.view.extent,()=>{const t=this.getPanelScale();for(const i of this.countdownPanelProps){t!==this.currentPanelScale&&(i.scale=t);const{mapPoint:e}=i;let s=new u.Point({x:e[0],y:e[1]});this.view.spatialReference.isWebMercator&&(s=d.geographicToWebMercator(s));const a=this.view.toScreen(s);if(i.position.left=a.x,i.position.top=a.y,this.view.type==="3d"){const r=this.getPanelRotation(i.stopLine);i.rotation=r}}this.currentPanelScale=t}));const n=o.crossId,l=this.stopLineMap.get(n);if(!l)return;const p=o.phaseCountDownList,c=new Map;for(const t of p){let i="";for(let r of t.roadIdList)if(r.startsWith("-")&&(r=r.slice(1)),l.has(r)){i=r;break}if(!i)continue;let e=c.get(i);if(e||(e={},c.set(i,e)),!t.direction){console.log(`没有找到对应的方向${n}--${JSON.stringify(t)}`);continue}const s=t.direction.toLowerCase(),a=t.color===1?"red":t.color===2?"yellow":"green";s==="u"?(e.uNumber=t.leftTime,e.uColor=a):s==="l"?(e.lNumber=t.leftTime,e.lColor=a):s==="s"?(e.sNumber=t.leftTime,e.sColor=a):s==="r"&&(e.rNumber=t.leftTime,e.rColor=a)}c.forEach((t,i)=>{const e=l.get(i);if(!e)return;const s=this.countdownPanelProps.find(a=>a.crossId===n&&a.roadId===i);if(s)s.lampStatus=t;else{let a=new u.Point({x:e.panelPoint[0],y:e.panelPoint[1]});this.view.spatialReference.isWebMercator&&(a=d.geographicToWebMercator(a));const r=this.view.toScreen(a),h=this.getPanelRotation(e.coord);this.countdownPanelProps.push({displayMode:"complex",crossId:n,roadId:i,mapPoint:e.panelPoint,stopLine:e.coord,position:{left:r.x,top:r.y},rotation:h,scale:this.getPanelScale(),lampStatus:t})}})}clearSignal(){var o;this.stopLineLayer.removeAll(),this.countdownPanelProps.length=0,(o=this.watchHandle)==null||o.remove(),this.watchHandle=null}getPanelRotation(o){const n=o[0];let l=new u.Point({x:n[0],y:n[1]});this.view.spatialReference.isWebMercator&&(l=d.geographicToWebMercator(l));const p=this.view.toScreen(l),c=o[o.length-1];let t=new u.Point({x:c[0],y:c[1]});this.view.spatialReference.isWebMercator&&(t=d.geographicToWebMercator(t));const i=this.view.toScreen(t),e=i.x-p.x,s=i.y-p.y;return Math.atan2(s,e)*(180/Math.PI)}}exports.default=v;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),L=require("@arcgis/core/geometry/support/webMercatorUtils.js"),M=require("@arcgis/core/layers/GraphicsLayer"),S=require("./signal-holo-flow.js");function w(f){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const e in f)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(f,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>f[e]})}}return t.default=f,Object.freeze(t)}const b=w(m),d=w(L);class v extends S.default{constructor(t,e){var i,l;super(t),this.stopLineLayer=new M,this.watchHandle=null,this.trajectoryDelayTime=0,this.stopLineMap=new Map,this.countdownPanelProps=e,this.view.map.add(this.stopLineLayer),this.trajectoryDelayTime=((l=(i=this.mapConfig.holoFlow)==null?void 0:i.signal)==null?void 0:l.delay)||2}async initializeLayer(){var l,c;console.time("初始化停止线图层");let t=(c=(l=this.mapConfig.holoFlow)==null?void 0:l.signal)==null?void 0:c.stopLineLayer;if(!t)return;t=this.mapConfig.assetsRoot+"/"+t;const i=await(await fetch(t)).json();for(const n of i.features){const{roadId:r,nodeId:o}=n.properties;let{destinationPoint:a}=n.properties;const{coordinates:s}=n.geometry;if(a){if(typeof a=="string")try{a=JSON.parse(a)}catch(h){console.error("解析面板基准点失败",h);continue}}else{const h=s[0],P=s[s.length-1],g=(h[0]+P[0])/2,y=(h[1]+P[1])/2;a=[g,y]}const p=this.stopLineMap.get(o);p?p.set(r,{coord:s,panelPoint:a}):this.stopLineMap.set(o,new Map([[r,{coord:s,panelPoint:a}]]))}console.timeEnd("初始化停止线图层")}getPanelScale(){const t=this.view.scale;let e=1;return t<1e3?e=1:t<2e3?e=.8:t<4e3?e=.4:e=0,e}updatePanelPosition(){const t=this.getPanelScale();for(const e of this.countdownPanelProps){t!==this.currentPanelScale&&(e.scale=t);const{mapPoint:i}=e;let l=new u.Point({x:i[0],y:i[1]});this.view.spatialReference.isWebMercator&&(l=d.geographicToWebMercator(l));const c=this.view.toScreen(l);if(e.position.left=c.x,e.position.top=c.y,this.view.type==="3d"){const n=this.getPanelRotation(e.stopLine);e.rotation=n}}this.currentPanelScale=t}async handleHoloSignalData(t){this.watchHandle||(this.watchHandle=b.watch(()=>this.view.extent,()=>this.updatePanelPosition())),setTimeout(()=>{const e=t.crossId,i=this.stopLineMap.get(e);if(!i){console.log(`没有找到路口${e}`);return}const l=t.phaseCountDownList,c=new Map;for(const n of l){let r="";for(let p of n.roadIdList)if(p.startsWith("-")&&(p=p.slice(1)),i.has(p)){r=p;break}if(!r){console.log(`没有找到对应的进口道${e}--${r}`);continue}let o=c.get(r);if(o||(o={},c.set(r,o)),!n.direction)continue;const a=n.direction.toLowerCase(),s=n.color===1?"red":n.color===2?"yellow":"green";a==="u"?(o.uNumber=n.leftTime,o.uColor=s):a==="l"?(o.lNumber=n.leftTime,o.lColor=s):a==="s"?(o.sNumber=n.leftTime,o.sColor=s):a==="r"&&(o.rNumber=n.leftTime,o.rColor=s)}c.forEach((n,r)=>{const o=i.get(r);if(!o)return;const a=this.countdownPanelProps.find(s=>s.crossId===e&&s.roadId===r);if(a)a.lampStatus=n;else{let s=new u.Point({x:o.panelPoint[0],y:o.panelPoint[1]});this.view.spatialReference.isWebMercator&&(s=d.geographicToWebMercator(s));const p=this.view.toScreen(s),h=this.getPanelRotation(o.coord);this.countdownPanelProps.push({displayMode:"complex",crossId:e,roadId:r,mapPoint:o.panelPoint,stopLine:o.coord,position:{left:p.x,top:p.y},rotation:h,scale:this.getPanelScale(),lampStatus:n})}})},this.trajectoryDelayTime*1e3)}clearSignal(){var t;this.stopLineLayer.removeAll(),this.countdownPanelProps.length=0,(t=this.watchHandle)==null||t.remove(),this.watchHandle=null}getPanelRotation(t){const e=t[0];let i=new u.Point({x:e[0],y:e[1]});this.view.spatialReference.isWebMercator&&(i=d.geographicToWebMercator(i));const l=this.view.toScreen(i),c=t[t.length-1];let n=new u.Point({x:c[0],y:c[1]});this.view.spatialReference.isWebMercator&&(n=d.geographicToWebMercator(n));const r=this.view.toScreen(n),o=r.x-l.x,a=r.y-l.y;return Math.atan2(a,o)*(180/Math.PI)}}exports.default=v;
@@ -16,7 +16,7 @@ export default class SignalHoloFlow {
16
16
  * */
17
17
  initializeLayer(): Promise<void>;
18
18
  private initializePlateBackground;
19
- handleSignalData(data: any): Promise<void>;
19
+ handleHoloSignalData(data: any): Promise<void>;
20
20
  /**
21
21
  * 清除实时信号相关图层
22
22
  * */
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),p=require("@arcgis/core/layers/FeatureLayer"),g=require("vue"),y=require("../../stores/index.js");function w(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const f=w(d);class m{constructor(e){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=80,this.canvasHeight=40,this.view=(e.type==="2d",e);const t=y.default.useAppDataStore;this.mapConfig=g.toRaw(t.mapConfig)}async initializeLayer(){try{await this.initializePlateBackground()}catch(e){console.log("倒计时背景图片加载失败",e)}if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,s=(await(await fetch(e)).json()).features.map((i,n)=>({geometry:{type:"polyline",paths:[i.geometry.coordinates]},attributes:{ObjectID:n+1,id:i.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:s,geometryType:"polyline",objectIdField:"ObjectID",outFields:["*"],fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"color",alias:"color",type:"string"}],renderer:{type:"unique-value",field:"color",defaultSymbol:{type:"simple-line",color:"lightblue",width:"2px",style:"none"},uniqueValueInfos:[{value:"green",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[19,255,69,.8]},width:1,height:.5}]}},{value:"red",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[254,5,9,.8]},width:1,height:.5}]}},{value:"yellow",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[255,215,0,.8]},width:1,height:.5}]}}]}}),this.view.map.add(this.phaseLineLayer)}}async initializePlateBackground(){return new Promise((e,t)=>{const a=new Image;a.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`,a.onload=()=>{this.plateBackground=a,e()},a.onerror=s=>{t(s)}})}async handleSignalData(e){const{crossId:t,lat:a,lon:s,rtStage:i,channelsConfig:n}=e;await this.updateCountdown(t,a,s,i),!(!this.phaseLineLayer||!n)&&((!this.currentPhaseMap.has(t)||this.currentPhaseMap.get(t)!==i.stagePhase)&&await this.updatePhaseLine(t,i.channelsConfig,n),this.currentPhaseMap.set(t,i.stagePhase))}clearSignal(){this.phaseLineLayer&&(this.phaseLineLayer.visible=!1),this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(e=>{this.view.container.removeChild(e.backgroundCanvas),this.view.container.removeChild(e.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(e,t,a,s){if(this.isDeletingCanvas)return;const i=this.countdownCanvasMap.get(e);if(i)this.drawCountdownText(i.countdownCanvas,s);else try{const n=new u.Point({longitude:a,latitude:t,z:10}),o=this.view.toScreen(n),l=this.createCountdownCanvas();if(!l)return;const h=l[0],c=l[1];h.style.left=o.x+"px",h.style.top=o.y+"px",c.style.left=o.x+"px",c.style.top=o.y+"px",this.countdownCanvasMap.set(e,{backgroundCanvas:h,countdownCanvas:c,mapPoint:n}),this.drawCountdownText(c,s)}catch(n){console.log("倒计时canvas创建失败",e,n)}this.countdownWatchHandel||(this.countdownWatchHandel=f.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(n=>{const o=this.view.toScreen(n.mapPoint);n.backgroundCanvas.style.left=o.x+"px",n.backgroundCanvas.style.top=o.y+"px",n.countdownCanvas.style.left=o.x+"px",n.countdownCanvas.style.top=o.y+"px"})}))}drawCountdownText(e,t){const a=e.getContext("2d");a.clearRect(0,0,e.width,e.height),a.font="24px Digital",a.textBaseline="middle",a.textAlign="center",a.fillStyle=t.stageRemainingTime<=t.stageAllRedTime?"red":t.stageRemainingTime<=t.stageAllRedTime+t.stageYellowTime?"yellow":"lime",a.fillText(t.stageRemainingTime.toFixed(0),e.width/2,e.height/2)}async updatePhaseLine(e,t,a){const s=this.phaseLineLayer.source.filter(i=>i.getAttribute("id").includes(e));s.forEach(i=>{const n=i.getAttribute("id");this.isLaneInChannels(n,t)?i.setAttribute("color","green"):this.isLaneInChannels(n,a)?i.setAttribute("color","red"):i.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:s})}isLaneInChannels(e,t){const a=e.split("+"),s=a[1],i=a[2];for(let n=0;n<t.length;n++)for(let o=0;o<t[n].laneSnList.length;o++){const l=t[n].laneSnList[o].toFixed(0);if(s===l[0]&&i===l[1])return!0}return!1}createCountdownCanvas(){const e=document.createElement("canvas");e.width=this.canvasWidth,e.height=this.canvasHeight,e.style.position="absolute",e.style.transform="translate(-50%, -50%)";const t=e.getContext("2d");this.plateBackground?t.drawImage(this.plateBackground,0,0,this.canvasWidth,this.canvasHeight):(t.strokeStyle="rgba(0, 255, 0, 1)",t.lineWidth=1,t.strokeRect(0,0,this.canvasWidth,this.canvasHeight),t.fillStyle="rgba(0, 0, 0, 1)",t.fillRect(0,0,this.canvasWidth,this.canvasHeight)),this.view.container.appendChild(e);const a=document.createElement("canvas");return a.width=this.canvasWidth-10,a.height=this.canvasHeight-10,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",this.view.container.appendChild(a),[e,a]}}exports.default=m;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),p=require("@arcgis/core/layers/FeatureLayer"),g=require("vue"),y=require("../../stores/index.js");function w(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const f=w(d);class m{constructor(e){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=80,this.canvasHeight=40,this.view=(e.type==="2d",e);const t=y.default.useAppDataStore;this.mapConfig=g.toRaw(t.mapConfig)}async initializeLayer(){try{await this.initializePlateBackground()}catch(e){console.log("倒计时背景图片加载失败",e)}if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,s=(await(await fetch(e)).json()).features.map((i,n)=>({geometry:{type:"polyline",paths:[i.geometry.coordinates]},attributes:{ObjectID:n+1,id:i.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:s,geometryType:"polyline",objectIdField:"ObjectID",outFields:["*"],fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"color",alias:"color",type:"string"}],renderer:{type:"unique-value",field:"color",defaultSymbol:{type:"simple-line",color:"lightblue",width:"2px",style:"none"},uniqueValueInfos:[{value:"green",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[19,255,69,.8]},width:1,height:.5}]}},{value:"red",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[254,5,9,.8]},width:1,height:.5}]}},{value:"yellow",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[255,215,0,.8]},width:1,height:.5}]}}]}}),this.view.map.add(this.phaseLineLayer)}}async initializePlateBackground(){return new Promise((e,t)=>{const a=new Image;a.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`,a.onload=()=>{this.plateBackground=a,e()},a.onerror=s=>{t(s)}})}async handleHoloSignalData(e){const{crossId:t,lat:a,lon:s,rtStage:i,channelsConfig:n}=e;await this.updateCountdown(t,a,s,i),!(!this.phaseLineLayer||!n)&&((!this.currentPhaseMap.has(t)||this.currentPhaseMap.get(t)!==i.stagePhase)&&await this.updatePhaseLine(t,i.channelsConfig,n),this.currentPhaseMap.set(t,i.stagePhase))}clearSignal(){this.phaseLineLayer&&(this.phaseLineLayer.visible=!1),this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(e=>{this.view.container.removeChild(e.backgroundCanvas),this.view.container.removeChild(e.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(e,t,a,s){if(this.isDeletingCanvas)return;const i=this.countdownCanvasMap.get(e);if(i)this.drawCountdownText(i.countdownCanvas,s);else try{const n=new u.Point({longitude:a,latitude:t,z:10}),o=this.view.toScreen(n),r=this.createCountdownCanvas();if(!r)return;const h=r[0],c=r[1];h.style.left=o.x+"px",h.style.top=o.y+"px",c.style.left=o.x+"px",c.style.top=o.y+"px",this.countdownCanvasMap.set(e,{backgroundCanvas:h,countdownCanvas:c,mapPoint:n}),this.drawCountdownText(c,s)}catch(n){console.log("倒计时canvas创建失败",e,n)}this.countdownWatchHandel||(this.countdownWatchHandel=f.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(n=>{const o=this.view.toScreen(n.mapPoint);n.backgroundCanvas.style.left=o.x+"px",n.backgroundCanvas.style.top=o.y+"px",n.countdownCanvas.style.left=o.x+"px",n.countdownCanvas.style.top=o.y+"px"})}))}drawCountdownText(e,t){const a=e.getContext("2d");a.clearRect(0,0,e.width,e.height),a.font="24px Digital",a.textBaseline="middle",a.textAlign="center",a.fillStyle=t.stageRemainingTime<=t.stageAllRedTime?"red":t.stageRemainingTime<=t.stageAllRedTime+t.stageYellowTime?"yellow":"lime",a.fillText(t.stageRemainingTime.toFixed(0),e.width/2,e.height/2)}async updatePhaseLine(e,t,a){const s=this.phaseLineLayer.source.filter(i=>i.getAttribute("id").includes(e));s.forEach(i=>{const n=i.getAttribute("id");this.isLaneInChannels(n,t)?i.setAttribute("color","green"):this.isLaneInChannels(n,a)?i.setAttribute("color","red"):i.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:s})}isLaneInChannels(e,t){const a=e.split("+"),s=a[1],i=a[2];for(let n=0;n<t.length;n++)for(let o=0;o<t[n].laneSnList.length;o++){const r=t[n].laneSnList[o].toFixed(0);if(s===r[0]&&i===r[1])return!0}return!1}createCountdownCanvas(){const e=document.createElement("canvas");e.width=this.canvasWidth,e.height=this.canvasHeight,e.style.position="absolute",e.style.transform="translate(-50%, -50%)";const t=e.getContext("2d");this.plateBackground?t.drawImage(this.plateBackground,0,0,this.canvasWidth,this.canvasHeight):(t.strokeStyle="rgba(0, 255, 0, 1)",t.lineWidth=1,t.strokeRect(0,0,this.canvasWidth,this.canvasHeight),t.fillStyle="rgba(0, 0, 0, 1)",t.fillRect(0,0,this.canvasWidth,this.canvasHeight)),this.view.container.appendChild(e);const a=document.createElement("canvas");return a.width=this.canvasWidth-10,a.height=this.canvasHeight-10,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",this.view.container.appendChild(a),[e,a]}}exports.default=m;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("@arcgis/core/Basemap"),d=require("@arcgis/core/config"),L=require("@arcgis/core/core/reactiveUtils"),g=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/MapImageLayer"),I=require("@arcgis/core/layers/TileLayer"),S=require("@arcgis/core/layers/WebTileLayer"),R=require("@arcgis/core/Map"),H=require("@arcgis/core/views/MapView"),_=require("@arcgis/core/views/SceneView"),G=require("@turf/destination"),j=require("@turf/helpers"),B=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),f=b(z),N=b(j);function q(c,e){return c&&(c.startsWith("http://")||c.startsWith("https://")?c:e+c)}class U{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;d.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,d.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,d.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const a=new R;if(((u=this.mapConfig)==null?void 0:u.mapOptions.mode.toLowerCase())==="2d"?(this.view=new H({map:a,container:t,...this.mapConfig.mapOptions}),this.view.on("drag",i=>{i.button===2&&i.stopPropagation()})):this.view=new _({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 C,P;if(n){let o=i.mapPoint;o.spatialReference.isWebMercator&&(o=f.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=f.webMercatorToGeographic(o.position),w={heading:o.heading,tilt:o.tilt,position:p.toJSON()};console.log(w),(C=navigator.clipboard)==null||C.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=f.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 S({urlTemplate:l,...i.options});a.add(r);break}case"tile":{const r=new I({url:l,...i.options});a.add(r);break}case"customWMTS".toLowerCase():{const r=new B.default({urlTemplate:l,...i.options});a.add(r);break}case"mapImage".toLowerCase():{const r=new x({url:l,...i.options});a.add(r);break}case"arcgis":{const r=new k(i.options);a.basemap=r;break}case"feature":{const r=new W({url:l,...i.options});a.add(r);break}}}):a.basemap=new k({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 m=this.mapConfig.camera;let h;if(this.view.type==="2d"){let i=this.view.center;this.view.spatialReference.isWebMercator&&(i=f.webMercatorToGeographic(i)),h={center:[i.x,i.y],zoom:this.view.zoom}}else{let i=this.view.camera.position;this.view.spatialReference.isWebMercator&&(i=f.webMercatorToGeographic(i)),h={position:i,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return m?m.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 g.Point(e.target);break;case"polyline":e.target=new g.Polyline(e.target);break;case"polygon":e.target=new g.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=G(N.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,m=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,m),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(t=>{const s=new g.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=U;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.221",
3
+ "version": "1.0.222",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [