gisviewer-vue3-arcgis 1.0.142 → 1.0.144

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.
Files changed (35) hide show
  1. package/es/src/gis-map/gis-map.vue.d.ts +0 -17
  2. package/es/src/gis-map/gis-map.vue.mjs +113 -118
  3. package/es/src/gis-map/index.d.ts +0 -17
  4. package/es/src/gis-map/stores/appData.d.ts +1 -0
  5. package/es/src/gis-map/stores/appData.mjs +2 -1
  6. package/es/src/gis-map/utils/map-initializer.mjs +6 -6
  7. package/es/src/gis-map/utils/open-drive-renderer/index.mjs +231 -215
  8. package/es/src/gis-map/utils/signal-control-area-controller/index.mjs +3 -3
  9. package/es/src/gis-map/utils/sketchView.d.ts +14 -14
  10. package/es/src/gis-map/utils/sketchView.mjs +173 -164
  11. package/es/src/gis-map/utils/sketchViewTool.d.ts +16 -16
  12. package/es/src/gis-map/utils/sketchViewTool.mjs +39 -39
  13. package/es/style.css +1 -1
  14. package/lib/src/gis-map/gis-map.vue.d.ts +0 -17
  15. package/lib/src/gis-map/gis-map.vue.js +1 -1
  16. package/lib/src/gis-map/index.d.ts +0 -17
  17. package/lib/src/gis-map/stores/appData.d.ts +1 -0
  18. package/lib/src/gis-map/stores/appData.js +1 -1
  19. package/lib/src/gis-map/utils/map-initializer.js +1 -1
  20. package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
  21. package/lib/src/gis-map/utils/sketchView.d.ts +14 -14
  22. package/lib/src/gis-map/utils/sketchView.js +1 -1
  23. package/lib/src/gis-map/utils/sketchViewTool.d.ts +16 -16
  24. package/lib/src/gis-map/utils/sketchViewTool.js +1 -1
  25. package/package.json +1 -1
  26. package/es/_virtual/_plugin-vue_export-helper.mjs +0 -9
  27. package/es/src/gis-map/utils/components/sketch-tool.vue.d.ts +0 -18
  28. package/es/src/gis-map/utils/components/sketch-tool.vue.mjs +0 -7
  29. package/es/src/gis-map/utils/components/sketch-tool.vue2.mjs +0 -48
  30. package/es/src/gis-map/utils/components/sketch-tool.vue3.mjs +0 -4
  31. package/lib/_virtual/_plugin-vue_export-helper.js +0 -1
  32. package/lib/src/gis-map/utils/components/sketch-tool.vue.d.ts +0 -18
  33. package/lib/src/gis-map/utils/components/sketch-tool.vue.js +0 -1
  34. package/lib/src/gis-map/utils/components/sketch-tool.vue2.js +0 -1
  35. package/lib/src/gis-map/utils/components/sketch-tool.vue3.js +0 -1
@@ -1,9 +1,9 @@
1
+ import Graphic from '@arcgis/core/Graphic.js';
1
2
  import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
2
3
  import MapView from '@arcgis/core/views/MapView';
3
4
  import SceneView from '@arcgis/core/views/SceneView';
4
- import SketchViewModel from '@arcgis/core/widgets/Sketch/SketchViewModel';
5
5
  import Sketch from '@arcgis/core/widgets/Sketch';
6
- import Graphic from '@arcgis/core/Graphic.js';
6
+ import SketchViewModel from '@arcgis/core/widgets/Sketch/SketchViewModel';
7
7
  import * as turf from '@turf/turf';
8
8
  interface sketchViewOptions {
9
9
  /**
@@ -17,7 +17,7 @@ interface sketchViewOptions {
17
17
  /**
18
18
  * 绘制工具显示的元素
19
19
  */
20
- sketchvisibleElements?: {};
20
+ sketchVisibleElements?: {};
21
21
  /**
22
22
  * 绘制工具显示的位置
23
23
  */
@@ -28,7 +28,7 @@ interface sketchViewOptions {
28
28
  * @type {boolean}
29
29
  * @memberof sketchViewOptions
30
30
  */
31
- defaultsketchVisible?: boolean;
31
+ defaultSketchVisible?: boolean;
32
32
  sketchViewModelItemSymbol?: {
33
33
  polylineSymbol?: any;
34
34
  polygonSymbol?: any;
@@ -45,7 +45,7 @@ declare type dimensionTypeFace = 'distance' | 'area' | 'angle' | null;
45
45
  export default class sketchViewTool {
46
46
  private viewer;
47
47
  graphicsLayer: GraphicsLayer;
48
- TextgraphicsLayer: GraphicsLayer;
48
+ textGraphicsLayer: GraphicsLayer;
49
49
  sketchViewModel: SketchViewModel;
50
50
  sketch: Sketch;
51
51
  options: sketchViewOptions;
@@ -78,12 +78,12 @@ export default class sketchViewTool {
78
78
  dimensionType: dimensionTypeFace;
79
79
  constructor(view: MapView | SceneView, options?: sketchViewOptions);
80
80
  init(): void;
81
- on(callcack?: (type: string, state: string, event: any) => void): void;
82
- onCreate(event: __esri.SketchCreateEvent, callcack?: (type: string, state: string, event?: any) => void): void;
81
+ on(callback?: (type: string, state: string, event: any) => void): void;
82
+ onCreate(event: __esri.SketchCreateEvent, callback?: (type: string, state: string, event?: any) => void): void;
83
83
  onCreateToCancel(): void;
84
- onUpdate(event: __esri.SketchUpdateEvent, callcack?: (type: string, state: string, event?: any) => void): void;
85
- onDelete(event: __esri.SketchDeleteEvent, callcack?: (type: string, state: string, event: any) => void): void;
86
- addpolyline(paths: number[][][]): void;
84
+ onUpdate(event: __esri.SketchUpdateEvent, callback?: (type: string, state: string, event?: any) => void): void;
85
+ onDelete(event: __esri.SketchDeleteEvent, callback?: (type: string, state: string, event: any) => void): void;
86
+ addPolyline(paths: number[][][]): void;
87
87
  createPolylineGraphic(paths: number[][], lineSymbol: any, attributes: any): Graphic;
88
88
  createDom(): HTMLDivElement | undefined;
89
89
  removeDom(): void;
@@ -145,8 +145,8 @@ export default class sketchViewTool {
145
145
  */
146
146
  calculatePointHeading(path: number[][], direction?: string): number;
147
147
  drawPolylinePoint(drawStartGraphic: __esri.Geometry, parentId: string, actions?: string): void;
148
- updatePpolylinePoint(drawStartGraphic: Graphic[]): void;
149
- delPpolylinePoint(drawStartGraphic: Graphic[]): void;
148
+ updatePolylinePoint(drawStartGraphic: Graphic[]): void;
149
+ deletePolylinePoint(drawStartGraphic: Graphic[]): void;
150
150
  /**
151
151
  * 添加或者更新标记点
152
152
  *
@@ -186,7 +186,7 @@ export default class sketchViewTool {
186
186
  * 获取当前绘制的图形的长度
187
187
  * @returns
188
188
  */
189
- getDrawgraphicLength(): string | 0;
189
+ getDrawGraphicLength(): string | 0;
190
190
  /**
191
191
  * 获取两点的角度
192
192
  *
@@ -204,7 +204,7 @@ export default class sketchViewTool {
204
204
  * @returns
205
205
  * @memberof sketchViewTool
206
206
  */
207
- getbearing(startPoint: ITPoint, endPoint: ITPoint): number;
207
+ getBearing(startPoint: ITPoint, endPoint: ITPoint): number;
208
208
  /**
209
209
  * 获取两点的距离
210
210
  * @param startPoint
@@ -243,11 +243,11 @@ export default class sketchViewTool {
243
243
  /**
244
244
  * 开启图层捕捉
245
245
  */
246
- turnonlayerSnap(): void;
246
+ turnOnLayerSnap(): void;
247
247
  /**
248
248
  * 关闭图层捕捉
249
249
  */
250
- turnofflayerSnap(): void;
250
+ turnOffLayerSnap(): void;
251
251
  setDimensionType(Type: dimensionTypeFace): void;
252
252
  /**
253
253
  * 删除指定的图形
@@ -1,23 +1,23 @@
1
- import g from "@arcgis/core/layers/GraphicsLayer";
2
- import x from "@arcgis/core/widgets/Sketch/SketchViewModel";
3
- import P from "@arcgis/core/widgets/Sketch";
4
- import * as p from "@arcgis/core/geometry/support/webMercatorUtils.js";
5
1
  import * as y from "@arcgis/core/geometry/geometryEngine.js";
2
+ import g from "@arcgis/core/geometry/Polyline.js";
3
+ import * as p from "@arcgis/core/geometry/support/webMercatorUtils.js";
6
4
  import m from "@arcgis/core/Graphic.js";
7
- import u from "@arcgis/core/geometry/Polyline.js";
5
+ import u from "@arcgis/core/layers/GraphicsLayer";
6
+ import G from "@arcgis/core/widgets/Sketch";
7
+ import x from "@arcgis/core/widgets/Sketch/SketchViewModel";
8
8
  import * as c from "@turf/turf";
9
- const G = {
9
+ const P = {
10
10
  maxAllowedGraphics: 0,
11
11
  GraphicsLayer: {},
12
- sketchvisibleElements: {},
12
+ sketchVisibleElements: {},
13
13
  sketchPosition: "top-left",
14
- defaultsketchVisible: !0,
14
+ defaultSketchVisible: !0,
15
15
  sketchViewModelItemSymbol: {}
16
16
  }, f = {
17
17
  type: "simple-line",
18
18
  color: "#556DEA",
19
19
  width: 2
20
- }, b = {
20
+ }, M = {
21
21
  type: "simple-fill",
22
22
  // autocasts as new SimpleFillSymbol()
23
23
  color: [227, 139, 79, 0.4],
@@ -30,9 +30,9 @@ const G = {
30
30
  class $ {
31
31
  constructor(t, e) {
32
32
  this.isDraw = !1, this.drawStartGraphicId = null, this.drawPointGraphic = /* @__PURE__ */ new Map(), this.dimensionType = null, this.viewer = t, this.options = {
33
- ...G,
33
+ ...P,
34
34
  ...e
35
- }, this.graphicsLayer = new g({ ...this.options.GraphicsLayer }), this.TextgraphicsLayer = new g(), this.viewer.map.layers.add(this.graphicsLayer), this.viewer.map.layers.add(this.TextgraphicsLayer), this.init();
35
+ }, this.graphicsLayer = new u({ ...this.options.GraphicsLayer }), this.textGraphicsLayer = new u(), this.viewer.map.layers.add(this.graphicsLayer), this.viewer.map.layers.add(this.textGraphicsLayer), this.init();
36
36
  }
37
37
  init() {
38
38
  this.sketchViewModel = new x({
@@ -40,15 +40,15 @@ class $ {
40
40
  view: this.viewer,
41
41
  updateOnGraphicClick: !0,
42
42
  polylineSymbol: f,
43
- polygonSymbol: b,
43
+ polygonSymbol: M,
44
44
  ...this.options.sketchViewModelItemSymbol
45
45
  });
46
46
  const t = this.findLayerById("TrafficToolMarkings"), e = [];
47
- t && e.push({ layer: t, enabled: !0 }), this.sketch = new P({
47
+ t && e.push({ layer: t, enabled: !0 }), this.sketch = new G({
48
48
  view: this.viewer,
49
49
  viewModel: this.sketchViewModel,
50
50
  layer: this.graphicsLayer,
51
- visible: this.options.defaultsketchVisible,
51
+ visible: this.options.defaultSketchVisible,
52
52
  snappingOptions: {
53
53
  // autocasts to SnappingOptions()
54
54
  enabled: !0,
@@ -57,7 +57,7 @@ class $ {
57
57
  featureSources: e
58
58
  }
59
59
  }), this.sketch.visibleElements = {
60
- ...this.options.sketchvisibleElements
60
+ ...this.options.sketchVisibleElements
61
61
  }, this.viewer.ui.add(this.sketch, this.options.sketchPosition);
62
62
  const i = this;
63
63
  this.viewer.on("pointer-move", function(s) {
@@ -67,7 +67,7 @@ class $ {
67
67
  };
68
68
  if (i.isDraw && i.dimensionType == "distance") {
69
69
  i.tipsDom || (i.tipsDom = i.createDom());
70
- const o = i.getDrawgraphicLength();
70
+ const o = i.getDrawGraphicLength();
71
71
  i.tipsDom.innerText = `${o}米`, i.tipsDom.style.left = `${r.x}px`, i.tipsDom.style.top = `${r.y + 3}px`, i.tipsDom.style.pointerEvents = "none";
72
72
  }
73
73
  });
@@ -100,7 +100,7 @@ class $ {
100
100
  this.dimensionType == "distance" && (this.drawPolylinePoint(i, s), this.drawStartGraphic = i);
101
101
  }
102
102
  if (t.state === "complete" && t.graphic.geometry.type === "polyline" && this.dimensionType == "distance") {
103
- const i = this.getDrawgraphicLength(), s = `${this.drawStartGraphicId}-end`, r = p.webMercatorToGeographic(
103
+ const i = this.getDrawGraphicLength(), s = `${this.drawStartGraphicId}-end`, r = p.webMercatorToGeographic(
104
104
  t.graphic.geometry
105
105
  ), o = r.paths[0], n = this.getGeometryXY(r, o.length - 1);
106
106
  this.addOrUpdateMarkPoint(`总长度:${i}米`, n, s), this.drawStartGraphic = null, this.removeDom(), this.isDraw = !1, this.drawStartGraphicId = null;
@@ -111,34 +111,34 @@ class $ {
111
111
  this.removeDom(), this.isDraw = !1, this.drawStartGraphic = null;
112
112
  const t = this.drawStartGraphicId;
113
113
  this.drawPointGraphic.forEach((e, i) => {
114
- new RegExp(`^${t}-`).test(i) && (this.TextgraphicsLayer.remove(e), this.drawPointGraphic.delete(i));
114
+ new RegExp(`^${t}-`).test(i) && (this.textGraphicsLayer.remove(e), this.drawPointGraphic.delete(i));
115
115
  }), this.drawStartGraphicId = null;
116
116
  }
117
117
  onUpdate(t, e) {
118
- console.log("update", t), this.updatePpolylinePoint(
118
+ console.log("update", t), this.updatePolylinePoint(
119
119
  t.graphics.filter((i) => i.geometry.type === "polyline")
120
120
  ), e && e("update", t.state, t.graphics);
121
121
  }
122
122
  onDelete(t, e) {
123
- console.log("delete", t), this.delPpolylinePoint(
123
+ console.log("delete", t), this.deletePolylinePoint(
124
124
  t.graphics.filter((i) => i.geometry.type === "polyline")
125
125
  ), e && e("delete", "complete", t.graphics);
126
126
  }
127
- addpolyline(t) {
128
- const e = [], i = f, s = {
127
+ addPolyline(t) {
128
+ const e = [], i = {
129
129
  type: "draw",
130
130
  id: new Date().getTime().toString()
131
131
  };
132
- t.map((r) => {
132
+ t.map((s) => {
133
133
  e.push(
134
- this.createPolylineGraphic(r, i, {
135
- ...s
134
+ this.createPolylineGraphic(s, f, {
135
+ ...i
136
136
  })
137
137
  );
138
138
  }), this.graphicsLayer.addMany(e);
139
139
  }
140
140
  createPolylineGraphic(t, e, i) {
141
- const s = new u({
141
+ const s = new g({
142
142
  paths: [t]
143
143
  }), r = p.geographicToWebMercator(s);
144
144
  return new m({
@@ -218,7 +218,7 @@ class $ {
218
218
  this.sketch.visible = !0;
219
219
  }
220
220
  removeAll() {
221
- this.graphicsLayer.removeAll(), this.TextgraphicsLayer.removeAll(), this.drawPointGraphic.clear();
221
+ this.graphicsLayer.removeAll(), this.textGraphicsLayer.removeAll(), this.drawPointGraphic.clear();
222
222
  }
223
223
  calculateDistance(t, e = "meters") {
224
224
  return y.geodesicLength(
@@ -287,7 +287,7 @@ class $ {
287
287
  );
288
288
  }
289
289
  }
290
- updatePpolylinePoint(t) {
290
+ updatePolylinePoint(t) {
291
291
  for (let e = 0; e < t.length; e++) {
292
292
  console.log(t[e]);
293
293
  const i = t[e].getAttribute("id"), s = p.webMercatorToGeographic(
@@ -296,7 +296,7 @@ class $ {
296
296
  this.drawPolylinePoint(s, i, "update");
297
297
  }
298
298
  }
299
- delPpolylinePoint(t) {
299
+ deletePolylinePoint(t) {
300
300
  var e;
301
301
  for (let i = 0; i < t.length; i++) {
302
302
  const s = t[i].getAttribute("id"), r = `${s}-start`, o = `${s}-end`, n = [r, o];
@@ -306,7 +306,7 @@ class $ {
306
306
  }
307
307
  ), n.map((a) => {
308
308
  const h = this.drawPointGraphic.get(a);
309
- h && (this.TextgraphicsLayer.remove(h), this.drawPointGraphic.delete(a));
309
+ h && (this.textGraphicsLayer.remove(h), this.drawPointGraphic.delete(a));
310
310
  });
311
311
  }
312
312
  }
@@ -323,19 +323,19 @@ class $ {
323
323
  addOrUpdateMarkPoint(t, e, i, s = {}) {
324
324
  if (this.drawPointGraphic.has(i)) {
325
325
  const o = this.drawPointGraphic.get(i);
326
- this.TextgraphicsLayer.remove(o);
326
+ this.textGraphicsLayer.remove(o);
327
327
  const n = this.createTextGraphic(t, e, {
328
328
  ...s,
329
329
  id: i
330
330
  });
331
- this.drawPointGraphic.set(i, n), this.TextgraphicsLayer.add(n);
331
+ this.drawPointGraphic.set(i, n), this.textGraphicsLayer.add(n);
332
332
  return;
333
333
  }
334
334
  const r = this.createTextGraphic(t, e, {
335
335
  ...s,
336
336
  id: i
337
337
  });
338
- this.drawPointGraphic.set(i, r), this.TextgraphicsLayer.add(r);
338
+ this.drawPointGraphic.set(i, r), this.textGraphicsLayer.add(r);
339
339
  }
340
340
  /**
341
341
  * 获取图形的点位
@@ -387,7 +387,7 @@ class $ {
387
387
  * 获取当前绘制的图形的长度
388
388
  * @returns
389
389
  */
390
- getDrawgraphicLength() {
390
+ getDrawGraphicLength() {
391
391
  return this.drawStartGraphic ? this.calculateDistance(this.drawStartGraphic, "meters").toFixed(2) : 0;
392
392
  }
393
393
  /**
@@ -410,7 +410,7 @@ class $ {
410
410
  * @returns
411
411
  * @memberof sketchViewTool
412
412
  */
413
- getbearing(t, e) {
413
+ getBearing(t, e) {
414
414
  return c.bearing(
415
415
  c.point([t.x, t.y]),
416
416
  c.point([e.x, e.y])
@@ -424,7 +424,7 @@ class $ {
424
424
  * @returns
425
425
  */
426
426
  getPointLength(t, e = "meters") {
427
- const i = new u({
427
+ const i = new g({
428
428
  paths: [t]
429
429
  });
430
430
  return y.geodesicLength(i, e);
@@ -474,13 +474,13 @@ class $ {
474
474
  /**
475
475
  * 开启图层捕捉
476
476
  */
477
- turnonlayerSnap() {
477
+ turnOnLayerSnap() {
478
478
  this.sketchViewModel.snappingOptions.enabled = !0;
479
479
  }
480
480
  /**
481
481
  * 关闭图层捕捉
482
482
  */
483
- turnofflayerSnap() {
483
+ turnOffLayerSnap() {
484
484
  this.sketchViewModel.snappingOptions.enabled = !1;
485
485
  }
486
486
  setDimensionType(t) {
@@ -495,7 +495,7 @@ class $ {
495
495
  }
496
496
  destroy() {
497
497
  var t, e;
498
- this.viewer.map.remove(this.graphicsLayer), this.viewer.map.remove(this.TextgraphicsLayer), (t = this.sketch) == null || t.destroy(), (e = this.sketchViewModel) == null || e.destroy();
498
+ this.viewer.map.remove(this.graphicsLayer), this.viewer.map.remove(this.textGraphicsLayer), (t = this.sketch) == null || t.destroy(), (e = this.sketchViewModel) == null || e.destroy();
499
499
  }
500
500
  }
501
501
  export {
package/es/style.css CHANGED
@@ -1 +1 @@
1
- .gis-viewer{overflow:auto;scrollbar-width:none;-ms-overflow-style:none;&::-webkit-scrollbar{display:none}}.gisviewer-sketch-tool-position[data-v-ac0f5d06]{position:absolute;top:10px;right:10px;z-index:1000}.gisviewer-sketch-tool[data-v-ac0f5d06]{display:flex;flex-direction:row}.geometry-button-selected[data-v-ac0f5d06]{background:#4c4c4c;color:#fff}
1
+ .gis-viewer{overflow:auto;scrollbar-width:none;-ms-overflow-style:none;&::-webkit-scrollbar{display:none}}
@@ -30,7 +30,6 @@ declare const _sfc_main: import("vue").DefineComponent<{
30
30
  openDriveRenderer: OpenDriveRenderer;
31
31
  signalControlAreaController: SignalControlAreaController;
32
32
  showLogDiv: import("vue").Ref<boolean>;
33
- showGroupSelect: import("vue").Ref<boolean>;
34
33
  mapViewer: import("vue").ComputedRef<MapView | SceneView>;
35
34
  startSaveTrackLog: () => void;
36
35
  downloadTrackLog: () => void;
@@ -89,22 +88,6 @@ declare const _sfc_main: import("vue").DefineComponent<{
89
88
  resetHighlightSignalControlArea: () => import("../types").IResult;
90
89
  props: any;
91
90
  emit: (event: "mapLoaded" | "markerClick" | "mapClick", ...args: any[]) => void;
92
- sketchTool: import("vue").DefineComponent<{
93
- view: {
94
- type: null;
95
- required: true;
96
- };
97
- }, {
98
- props: any;
99
- sketchVM: __esri.SketchViewModel;
100
- resetButtonHandler: () => void;
101
- geometrySelectionHandler: (event: any) => void;
102
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
103
- view: {
104
- type: null;
105
- required: true;
106
- };
107
- }>>, {}, {}>;
108
91
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mapLoaded" | "markerClick" | "mapClick")[], "mapLoaded" | "markerClick" | "mapClick", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
109
92
  config: {
110
93
  type: StringConstructor;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),y=require("./stores/index.js");require("./style/index.css");const Ce=require("./utils/components/sketch-tool.vue.js"),Oe=require("./utils/holo-flow/index.js"),ke=require("./utils/map-initializer.js"),C=require("./utils/open-drive-renderer/index.js"),Te=require("./utils/overlay.js"),Ae=require("./utils/queue-length.js"),O=require("./utils/road-config-tool/index.js"),De=require("./utils/signal-control-area-controller/index.js"),Le=require("./utils/traffic-flow.js"),Ie={class:"gis-viewer"},be={style:{position:"absolute",bottom:"10px",left:"10px"}},qe=a.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(k,{expose:T,emit:A}){const f=a.ref(null);let c,l,i,r,n,o,m,t,s;const d=a.ref(!1),D=a.ref(!1);a.onMounted(async()=>{if(y.registerStore(),!f.value)return;document.addEventListener("keydown",g=>{g.ctrlKey&&g.key==="i"&&(d.value=!d.value)});const e=a.getCurrentInstance(),{$gisviewerAssetsRoot:u}=e.appContext.config.globalProperties,S=await(await fetch(h.config)).json();S.assetsRoot=h.assetsRoot||u;const he=y.default.useAppDataStore;he.mapConfig=S,l=new ke.default,c=await l.initialize({container:f.value,markerClickCallback:(g,w,v,Se)=>{p("markerClick",g,w,v,Se)},mapClickCallback:(g,w,v)=>{p("mapClick",g,w,v)}}),n=new Oe.default(c),await n.init(),p("mapLoaded")}),a.onUnmounted(()=>{s==null||s.clearSignalControlArea(),t==null||t.clearOpenDrive(),n==null||n.clearHoloTrace(),n==null||n.clearHoloSignal(),r==null||r.disconnectTrafficFlow()});const L=a.computed(()=>c),I=()=>{const e=y.default.useAppDataStore;e.saveTrackLog=!0},b=()=>{n.downloadTrackLog()},q=async e=>await l.setMapCenter(e),_=async e=>await l.setMapCamera(e),x=async e=>await l.lookAt(e),V=e=>l.setLayerVisibility(e),H=(e,u)=>l.requestCoordinateTransform(e,u),M=e=>{l.cancelCoordinateTransform(e)},N=e=>{l.setMapZoomRange(e)},B=e=>(i||(i=new O.default(c)),i.showLaneNumber(e)),E=()=>{i==null||i.clearLaneNumber()},j=async e=>(i||(i=new O.default(c)),await i.initializeSearch(e)),z=async()=>i==null?void 0:i.calCrossIndicatorArea(),P=async()=>{},Q=async(e,u)=>{r||(r=new Le.default(c)),r.connectTrafficFlow(e,u)},F=()=>{r==null||r.disconnectTrafficFlow()},Z=e=>{n.handleVehicleTraceData(e)},G=()=>{n.clearHoloTrace()},K=e=>{n.setInterpolate(e)},U=async e=>{await n.handleSignalData(e)},J=()=>{n.clearHoloSignal()},R=e=>{r==null||r.toggleTrafficInfo(e),n.toggleTrafficInfo(e)},W=e=>{n.togglePause(e)},X=e=>{r==null||r.toggleTrafficObject(e),n.toggleTrafficObject(e)},Y=e=>{n.updatePanelContent(e)},$=async e=>(o||(o=new Te.default(c)),o.addOverlays(e)),ee=e=>o==null?void 0:o.removeOverlaysByType(e),te=e=>o==null?void 0:o.removeOverlaysById(e),ae=()=>o==null?void 0:o.removeAllOverlays(),ne=()=>{o==null||o.showAllOverlays()},re=e=>{m||(m=new Ae.default(c)),m.updateQueueLength(e)},oe=()=>{m==null||m.removeQueueLength()},se=async(e,u)=>(t||(t=new C.default(c)),await t.showOpenDriveFromServer(e,u)),ce=async e=>(t||(t=new C.default(c)),await t.clearOpenDrive(),await t.showOpenDriveFromFile(e)),ie=async()=>await(t==null?void 0:t.clearOpenDrive()),le=async e=>t?await(t==null?void 0:t.findSumo(e)):{status:-1,message:"未加载OpenDrive地图"},ue=async e=>t?t.selectSumo(e):{status:-1,message:"未加载OpenDrive地图"},me=async e=>t?t.unselectSumo(e):{status:-1,message:"未加载OpenDrive地图"},ge=async e=>t?await t.getSumoInfo(e):{status:-1,message:"未加载OpenDrive地图"},fe=async e=>t?await(t==null?void 0:t.splitLane(e)):{status:-1,message:"未加载OpenDrive地图"},de=e=>(s||(s=new De.default(c)),s.showSignalControlArea(e)),pe=()=>{s==null||s.clearSignalControlArea()},we=async e=>s?await s.locateSignalControlArea(e):{status:-1,message:"未加载信号控制区"},ve=async e=>s?await s.highlightSignalControlArea(e):{status:-1,message:"未加载信号控制区"},ye=()=>s?s.resetHighlight():{status:-1,message:"未加载信号控制区"},h=k,p=A;return T({mapViewer:L,setLayerVisibility:V,setMapCenter:q,lookAt:x,setMapCamera:_,setMapZoomRange:N,requestCoordinateTransform:H,cancelCoordinateTransform:M,addOverlays:$,showAllOverlays:ne,removeOverlaysByType:ee,removeOverlaysById:te,removeAllOverlays:ae,showLaneNumber:B,clearLaneNumber:E,initializeAreaTool:j,calCrossIndicatorArea:z,calRoadIndicatorArea:P,connectCarFlow:Q,disconnectCarFlow:F,handleHoloVehicleTraceData:Z,clearHoloTrace:G,handleHoloSignalData:U,clearHoloSignal:J,setInterpolate:K,toggleTrafficInfo:R,toggleTrafficObject:X,toggleVehicleInfo:Y,togglePause:W,updateQueueLength:re,removeQueueLength:oe,showOpenDriveFromServer:se,showOpenDriveFromFile:ce,clearOpenDrive:ie,findSumoInOpenDrive:le,selectSumoInOpenDrive:ue,unselectSumoInOpenDrive:me,getSumoInfo:ge,splitOpenDriveLane:fe,showSignalControlArea:de,clearSignalControlArea:pe,locateSignalControlArea:we,highlightSignalControlArea:ve,resetHighlightSignalControlArea:ye}),(e,u)=>(a.openBlock(),a.createElementBlock("div",Ie,[a.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:f},[a.withDirectives(a.createElementVNode("div",be,[a.createElementVNode("button",{style:{"margin-right":"10px"},onClick:I}," 开始记录 "),a.createElementVNode("button",{onClick:b},"下载日志")],512),[[a.vShow,d.value]]),D.value?(a.openBlock(),a.createBlock(Ce.default,{key:0,view:a.unref(c)},null,8,["view"])):a.createCommentVNode("",!0)],512)]))}});exports.default=qe;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),y=require("./stores/index.js");require("./style/index.css");const Se=require("./utils/holo-flow/index.js"),Ce=require("./utils/map-initializer.js"),C=require("./utils/open-drive-renderer/index.js"),Oe=require("./utils/overlay.js"),ke=require("./utils/queue-length.js"),O=require("./utils/road-config-tool/index.js"),Te=require("./utils/signal-control-area-controller/index.js"),Ae=require("./utils/traffic-flow.js"),De={class:"gis-viewer"},Le={style:{position:"absolute",bottom:"10px",left:"10px"}},Ie=o.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(k,{expose:T,emit:A}){const d=o.ref(null);let i,l,c,n,a,r,g,t,s;const p=o.ref(!1);o.onMounted(async()=>{if(y.registerStore(),!d.value)return;document.addEventListener("keydown",m=>{m.ctrlKey&&m.key==="i"&&(p.value=!p.value)});const e=o.getCurrentInstance(),{$gisviewerAssetsRoot:u}=e.appContext.config.globalProperties,S=await(await fetch(h.config)).json();S.assetsRoot=h.assetsRoot||u;const ye=y.default.useAppDataStore;ye.mapConfig=S,l=new Ce.default,i=await l.initialize({container:d.value,markerClickCallback:(m,w,v,he)=>{f("markerClick",m,w,v,he)},mapClickCallback:(m,w,v)=>{f("mapClick",m,w,v)}}),a=new Se.default(i),await a.init(),f("mapLoaded")}),o.onUnmounted(()=>{s==null||s.clearSignalControlArea(),t==null||t.clearOpenDrive(),a==null||a.clearHoloTrace(),a==null||a.clearHoloSignal(),n==null||n.disconnectTrafficFlow()});const D=o.computed(()=>i),L=()=>{const e=y.default.useAppDataStore;e.saveTrackLog=!0},I=()=>{a.downloadTrackLog()},b=async e=>await l.setMapCenter(e),q=async e=>await l.setMapCamera(e),_=async e=>await l.lookAt(e),x=e=>l.setLayerVisibility(e),H=(e,u)=>l.requestCoordinateTransform(e,u),V=e=>{l.cancelCoordinateTransform(e)},M=e=>{l.setMapZoomRange(e)},N=e=>(c||(c=new O.default(i)),c.showLaneNumber(e)),B=()=>{c==null||c.clearLaneNumber()},E=async e=>(c||(c=new O.default(i)),await c.initializeSearch(e)),j=async()=>c==null?void 0:c.calCrossIndicatorArea(),z=async()=>{},P=async(e,u)=>{n||(n=new Ae.default(i)),n.connectTrafficFlow(e,u)},Q=()=>{n==null||n.disconnectTrafficFlow()},F=e=>{a.handleVehicleTraceData(e)},Z=()=>{a.clearHoloTrace()},K=e=>{a.setInterpolate(e)},U=async e=>{await a.handleSignalData(e)},G=()=>{a.clearHoloSignal()},J=e=>{n==null||n.toggleTrafficInfo(e),a.toggleTrafficInfo(e)},R=e=>{a.togglePause(e)},W=e=>{n==null||n.toggleTrafficObject(e),a.toggleTrafficObject(e)},X=e=>{a.updatePanelContent(e)},Y=async e=>(r||(r=new Oe.default(i)),r.addOverlays(e)),$=e=>r==null?void 0:r.removeOverlaysByType(e),ee=e=>r==null?void 0:r.removeOverlaysById(e),te=()=>r==null?void 0:r.removeAllOverlays(),ae=()=>{r==null||r.showAllOverlays()},ne=e=>{g||(g=new ke.default(i)),g.updateQueueLength(e)},re=()=>{g==null||g.removeQueueLength()},se=async(e,u)=>(t||(t=new C.default(i)),await t.showOpenDriveFromServer(e,u)),oe=async e=>(t||(t=new C.default(i)),await t.clearOpenDrive(),await t.showOpenDriveFromFile(e)),ce=async()=>await(t==null?void 0:t.clearOpenDrive()),ie=async e=>t?await(t==null?void 0:t.findSumo(e)):{status:-1,message:"未加载OpenDrive地图"},le=async e=>t?t.selectSumo(e):{status:-1,message:"未加载OpenDrive地图"},ue=async e=>t?t.unselectSumo(e):{status:-1,message:"未加载OpenDrive地图"},ge=async e=>t?await t.getSumoInfo(e):{status:-1,message:"未加载OpenDrive地图"},me=async e=>t?await(t==null?void 0:t.splitLane(e)):{status:-1,message:"未加载OpenDrive地图"},de=e=>(s||(s=new Te.default(i)),s.showSignalControlArea(e)),pe=()=>{s==null||s.clearSignalControlArea()},fe=async e=>s?await s.locateSignalControlArea(e):{status:-1,message:"未加载信号控制区"},we=async e=>s?await s.highlightSignalControlArea(e):{status:-1,message:"未加载信号控制区"},ve=()=>s?s.resetHighlight():{status:-1,message:"未加载信号控制区"},h=k,f=A;return T({mapViewer:D,setLayerVisibility:x,setMapCenter:b,lookAt:_,setMapCamera:q,setMapZoomRange:M,requestCoordinateTransform:H,cancelCoordinateTransform:V,addOverlays:Y,showAllOverlays:ae,removeOverlaysByType:$,removeOverlaysById:ee,removeAllOverlays:te,showLaneNumber:N,clearLaneNumber:B,initializeAreaTool:E,calCrossIndicatorArea:j,calRoadIndicatorArea:z,connectCarFlow:P,disconnectCarFlow:Q,handleHoloVehicleTraceData:F,clearHoloTrace:Z,handleHoloSignalData:U,clearHoloSignal:G,setInterpolate:K,toggleTrafficInfo:J,toggleTrafficObject:W,toggleVehicleInfo:X,togglePause:R,updateQueueLength:ne,removeQueueLength:re,showOpenDriveFromServer:se,showOpenDriveFromFile:oe,clearOpenDrive:ce,findSumoInOpenDrive:ie,selectSumoInOpenDrive:le,unselectSumoInOpenDrive:ue,getSumoInfo:ge,splitOpenDriveLane:me,showSignalControlArea:de,clearSignalControlArea:pe,locateSignalControlArea:fe,highlightSignalControlArea:we,resetHighlightSignalControlArea:ve}),(e,u)=>(o.openBlock(),o.createElementBlock("div",De,[o.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:d},[o.withDirectives(o.createElementVNode("div",Le,[o.createElementVNode("button",{style:{"margin-right":"10px"},onClick:L}," 开始记录 "),o.createElementVNode("button",{onClick:I},"下载日志")],512),[[o.vShow,p.value]])],512)]))}});exports.default=Ie;
@@ -19,7 +19,6 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
19
19
  openDriveRenderer: import("./utils/open-drive-renderer").default;
20
20
  signalControlAreaController: import("./utils/signal-control-area-controller").default;
21
21
  showLogDiv: import("vue").Ref<boolean>;
22
- showGroupSelect: import("vue").Ref<boolean>;
23
22
  mapViewer: import("vue").ComputedRef<__esri.MapView | __esri.SceneView>;
24
23
  startSaveTrackLog: () => void;
25
24
  downloadTrackLog: () => void;
@@ -78,22 +77,6 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
78
77
  resetHighlightSignalControlArea: () => import("../types").IResult;
79
78
  props: any;
80
79
  emit: (event: "mapLoaded" | "markerClick" | "mapClick", ...args: any[]) => void;
81
- sketchTool: import("vue").DefineComponent<{
82
- view: {
83
- type: null;
84
- required: true;
85
- };
86
- }, {
87
- props: any;
88
- sketchVM: __esri.SketchViewModel;
89
- resetButtonHandler: () => void;
90
- geometrySelectionHandler: (event: any) => void;
91
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
92
- view: {
93
- type: null;
94
- required: true;
95
- };
96
- }>>, {}, {}>;
97
80
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mapLoaded" | "markerClick" | "mapClick")[], "mapLoaded" | "markerClick" | "mapClick", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
98
81
  config: {
99
82
  type: StringConstructor;
@@ -1,4 +1,5 @@
1
1
  export declare const useAppDataStore: import("pinia").StoreDefinition<"appData", {
2
2
  mapConfig: {};
3
3
  saveTrackLog: boolean;
4
+ isSketching: boolean;
4
5
  }, {}, {}>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("pinia"),t=e.defineStore("appData",{state:()=>({mapConfig:{},saveTrackLog:!1})});exports.useAppDataStore=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("pinia"),t=e.defineStore("appData",{state:()=>({mapConfig:{},saveTrackLog:!1,isSketching:!1})});exports.useAppDataStore=t;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),y=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/GeoJSONLayer"),O=require("@arcgis/core/layers/TileLayer"),S=require("@arcgis/core/layers/WebTileLayer"),L=require("@arcgis/core/Map"),x=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.js"),C=require("./custom-layer/custom-wmts-layer.js");function b(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:()=>r[i]})}}return e.default=r,Object.freeze(e)}const T=b(q),p=b(z),G=b(I);function k(r,e){return r&&(r.startsWith("http://")||r.startsWith("https://")?r:e+r)}class N{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){const i=_.default.useAppDataStore,t=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=t;const{container:o,markerClickCallback:n,mapClickCallback:f}=e;y.assetsPath=`${t.assetsRoot}/ArcgisAssets`,y.fontsUrl=`${t.assetsRoot}/fonts`,y.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const c=new L;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new x({map:c,container:o,...t.mapOptions}):this.view=new R({map:c,container:o,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...t==null?void 0:t.mapOptions}),this.view.on("click",async s=>{var v,M;if(f){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),f([a.x,a.y],[s.screenPoint.x,s.screenPoint.y],s)}if(this.view.type==="3d"){const a=this.view.camera;if(this.view.spatialReference.isWebMercator){const u=p.webMercatorToGeographic(a.position),d={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(d),(v=navigator.clipboard)==null||v.writeText(JSON.stringify(d))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const l=(M=(await this.view.hitTest(s)).results)==null?void 0:M.filter(a=>a.type==="graphic");l.length>0&&l.forEach(a=>{var d;const u=a.graphic;(d=u.attributes)!=null&&d.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),t!=null&&t.baseLayers?t.baseLayers.forEach(s=>{const h=k(s.url,t.assetsRoot);switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const l=new S({urlTemplate:h,...s.options});c.add(l);break}case"tile":{const l=new O({url:h,...s.options});c.add(l);break}case"customWMTS".toLowerCase():{const l=new C.default({urlTemplate:h,...s.options});c.add(l);break}case"arcgis":{const l=new P(s.options);c.basemap=l;break}}}):c.basemap=new P({style:{id:"arcgis/dark-gray",language:"zh-CN"}}),t!=null&&t.hdLayers){const s=t.hdLayers.map(h=>new W({url:k(h.url,t.assetsRoot),...h.options,title:h.options.id}));c.addMany(s)}this.view.ui.remove("attribution"),this.view.ui.add("compass","top-left"),await this.view.when();const w=this.mapConfig.camera;let m;if(this.view.type==="2d"){let s=this.view.center;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={position:s,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return w?w.home=m:this.mapConfig.camera={home:m},this.view}setLayerVisibility(e){const{id:i,visible:t}=e,o=this.view.map.findLayerById(i);return o?(o.visible=t,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.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 i=e.tilt||0,t=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:t,tilt:0},{duration:(e.duration||2)*1e3});else{const o=Math.tan(i*Math.PI/180)*e.height,n=H(G.point(e.center),o,t+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:t,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:t=0}=e,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const n=o[i];return n?(await this.view.goTo(n,{duration:t*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let t=0;const n=1e3/30,f=T.watch(()=>this.view.center,()=>{const c=this.transformPoints(e),w=Date.now();w-t>n&&(i(c),t=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const t=new g.Point({x:i[0],y:i[1]}),o=this.view.toScreen(t);return[o.x,o.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:t}=e;!i&&!t||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),t&&o>=t&&(this.view.zoom=t)}))}}exports.default=N;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),y=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/GeoJSONLayer"),O=require("@arcgis/core/layers/TileLayer"),S=require("@arcgis/core/layers/WebTileLayer"),L=require("@arcgis/core/Map"),x=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.js"),C=require("./custom-layer/custom-wmts-layer.js");function b(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:()=>r[i]})}}return e.default=r,Object.freeze(e)}const T=b(q),p=b(z),G=b(I);function k(r,e){return r&&(r.startsWith("http://")||r.startsWith("https://")?r:e+r)}class N{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){const i=_.default.useAppDataStore,t=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=t;const{container:o,markerClickCallback:n,mapClickCallback:f}=e;y.assetsPath=`${t.assetsRoot}/ArcgisAssets`,y.fontsUrl=`${t.assetsRoot}/fonts`,y.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const c=new L;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new x({map:c,container:o,...t.mapOptions}):this.view=new R({map:c,container:o,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...t==null?void 0:t.mapOptions}),this.view.on("click",async s=>{var v,M;if(f){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),f([a.x,a.y],[s.screenPoint.x,s.screenPoint.y],s)}if(this.view.type==="3d"){const a=this.view.camera;if(this.view.spatialReference.isWebMercator){const u=p.webMercatorToGeographic(a.position),d={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(d),(v=navigator.clipboard)==null||v.writeText(JSON.stringify(d))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const l=(M=(await this.view.hitTest(s)).results)==null?void 0:M.filter(a=>a.type==="graphic");l.length>0&&l.forEach(a=>{var d;const u=a.graphic;(d=u.attributes)!=null&&d.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),t!=null&&t.baseLayers?t.baseLayers.forEach(s=>{const h=k(s.url,t.assetsRoot);switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const l=new S({urlTemplate:h,...s.options});c.add(l);break}case"tile":{const l=new O({url:h,...s.options});c.add(l);break}case"customWMTS".toLowerCase():{const l=new C.default({urlTemplate:h,...s.options});c.add(l);break}case"arcgis":{const l=new P(s.options);c.basemap=l;break}}}):c.basemap=new P({style:{id:"arcgis/light-gray",language:"zh-CN"}}),t!=null&&t.hdLayers){const s=t.hdLayers.map(h=>new W({url:k(h.url,t.assetsRoot),...h.options,title:h.options.id}));c.addMany(s)}this.view.ui.remove("attribution"),this.view.ui.add("compass","top-left"),await this.view.when();const w=this.mapConfig.camera;let m;if(this.view.type==="2d"){let s=this.view.center;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={position:s,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return w?w.home=m:this.mapConfig.camera={home:m},this.view}setLayerVisibility(e){const{id:i,visible:t}=e,o=this.view.map.findLayerById(i);return o?(o.visible=t,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.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 i=e.tilt||0,t=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:t,tilt:0},{duration:(e.duration||2)*1e3});else{const o=Math.tan(i*Math.PI/180)*e.height,n=H(G.point(e.center),o,t+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:t,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:t=0}=e,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const n=o[i];return n?(await this.view.goTo(n,{duration:t*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let t=0;const n=1e3/30,f=T.watch(()=>this.view.center,()=>{const c=this.transformPoints(e),w=Date.now();w-t>n&&(i(c),t=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const t=new g.Point({x:i[0],y:i[1]}),o=this.view.toScreen(t);return[o.x,o.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:t}=e;!i&&!t||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),t&&o>=t&&(this.view.zoom=t)}))}}exports.default=N;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("@arcgis/core/Graphic"),M=require("@arcgis/core/core/promiseUtils"),$=require("@arcgis/core/geometry"),P=require("@arcgis/core/geometry/geometryEngine"),S=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),g=require("axios"),J=require("md5"),G=require("pako"),A=require("../common-utils.js");function O(b){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(b){for(const t in b)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(b,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>b[t]})}}return e.default=b,Object.freeze(e)}const C=O(M),N=O(P);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new S({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new S({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.drawLayer=new v({id:"Draw"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:J(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var h,y;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await g.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(d){return{status:-1,message:d.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;A.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const a=await(await fetch(l)).arrayBuffer(),r=G.inflate(a,{to:"string"}),c=JSON.parse(r);await this.showAllLanes(c,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((y=e.options)==null?void 0:y.showRoadName)||!0);const m=o.data.result.junctions;if(this.showJunction(m),e.options&&e.options.centerMap!==!1){const d=A.default.transformPointProjection([0,0]);await this.view.goTo(d)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await g.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=G.inflate(n,{to:"string"}),r=JSON.parse(a);return await this.showAllLanes(r,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:c,refLine:m}=r;let h=r.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const y=new p({geometry:{type:"polyline",paths:[m]},attributes:{ObjectID:l++,roadId:c,roadName:h}});this.allRefLineGraphics.push(y),r.laneSections.sort((d,f)=>Number(d.id)-Number(f.id));for(let d=0;d<r.laneSections.length;d++){const f=r.laneSections[d],u=Number(f.id);for(const w of f.lanePaths){const I=Number(w.id);if(I===0)continue;const F=w.type,L=w.innerPath.concat(w.outerPath.reverse());if(L.length<=3){console.warn(`lane ${I} has less than 3 points`);continue}L.push(w.innerPath[0]);const j=new $.Polygon({rings:[L]});if(j){const k=new p({geometry:j,attributes:{ObjectID:l++,id:`${c}+${u}+${I}`,fromNode:r.fromNode,toNode:r.toNode,roadId:c,roadName:r.name,sectionId:u,sectionIndex:d,laneId:I,type:F,sumoId:""}});this.allLaneGraphics.push(k),n.push(k)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const r=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:r})}if(this.allRefLineGraphics.length>0){const r=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:r})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const o=new p({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=C.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(n===this.currentSectionCode||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const r=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),c=N.union(r.map(u=>u.geometry)),m=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),y=this.junctionNames.get(m)||m,d=this.junctionNames.get(h)||h;this.highlightGraphic=new p({geometry:c,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:n,selected:!1,fromNodeName:y,toNodeName:d,laneCount:r.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic);const f=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:f})}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=C.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(r=>r.type==="graphic");if(o.length===0)return;const s=o[0].graphic,l=s.getAttribute("type"),n=s.getAttribute("id");if(l==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,c=await g.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:c.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1);const r=s.getAttribute("crossId");s.symbol.url=r?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(l==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,c=await g.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",c.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:c.data.result}))}});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await g.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s){const l=`${i}+${s.getAttribute("sectionId")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await g.get(n,{params:{id:l,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${l}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("+");if(s.length>2)return{status:-1,message:"id格式错误"};const l=s.length===2?Number(s[1]):void 0,n=s[0].split("#");if(n.length>2)return{status:-1,message:"id格式错误"};const a=n[0],r=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:r,laneId:l,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new p({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(r=>{const c=Number(r.attributes.sectionId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(r=>Number(r.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(r=>{const c=Number(r.attributes.laneId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(r=>Number(r.attributes.laneId)===o)}const l=s.map(a=>a.geometry),n=N.union(l);if(e.flash){const a=new p({geometry:n,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(a)}return await this.view.goTo(n,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&this.sectionLayer.remove(t)}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s.length>0){const l=N.union(s.map(a=>a.geometry)),n=new p({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(n),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=D;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/Graphic"),M=require("@arcgis/core/core/promiseUtils"),$=require("@arcgis/core/geometry"),P=require("@arcgis/core/geometry/geometryEngine"),S=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),f=require("axios"),J=require("md5"),G=require("pako"),x=require("vue"),T=require("../../stores/index.js"),A=require("../common-utils.js");function O(g){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(g){for(const i in g)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(g,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:()=>g[i]})}}return e.default=g,Object.freeze(e)}const C=O(M),N=O(P);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new S({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new S({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new w({id:"OpenDriveJunction"}),this.sectionLayer=new w({id:"OpenDriveSection"}),this.highlightLayer=new w({id:"OpenDriveHighlight"}),this.flashLayer=new w({id:"OpenDriveFlash"}),this.drawLayer=new w({id:"Draw"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const t=await(await fetch(e)).text();return{status:0,message:"ok",result:J(t)}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var h,p;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const i=await this.makeMd5FromFile(e.file);if(i.status!==0)return i;this.projectName=i.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const t=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await f.post(t,{},{params:{url:e.file,projectName:this.projectName}})}catch(u){return{status:-1,message:u.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;A.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let a=o.data.result.json;a.startsWith(window.location.protocol)||(a=`${window.location.protocol}//${e.server}${a}`);const r=await(await fetch(a)).arrayBuffer(),n=G.inflate(r,{to:"string"}),c=JSON.parse(n);await this.showAllLanes(c,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);const b=o.data.result.junctions;if(this.showJunction(b),e.options&&e.options.centerMap!==!1){const u=A.default.transformPointProjection([0,0]);await this.view.goTo(u)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,i){const t=`http://${e}/api/openDrive/analyzeXodr`,o=await f.get(t,{headers:{projectName:i},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const l=await(await fetch(s)).arrayBuffer(),r=G.inflate(l,{to:"string"}),n=JSON.parse(r);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,i,t){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=t,new Promise(s=>{let a=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const l=[];for(const n of e){if(!i&&n.junction!=="-1")continue;const{id:c,refLine:b}=n;let h=n.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const p=new m({geometry:{type:"polyline",paths:[b]},attributes:{ObjectID:a++,roadId:c,roadName:h}});this.allRefLineGraphics.push(p),n.laneSections.sort((u,y)=>Number(u.id)-Number(y.id));for(let u=0;u<n.laneSections.length;u++){const y=n.laneSections[u],v=Number(y.id);for(const d of y.lanePaths){const I=Number(d.id);if(I===0)continue;const F=d.type,L=d.innerPath.concat(d.outerPath.reverse());if(L.length<=3){console.warn(`lane ${I} has less than 3 points`);continue}L.push(d.innerPath[0]);const k=new $.Polygon({rings:[L]});if(k){const j=new m({geometry:k,attributes:{ObjectID:a++,id:`${c}+${v}+${I}`,fromNode:n.fromNode,toNode:n.toNode,roadId:c,roadName:n.name,sectionId:v,sectionIndex:u,laneId:I,type:F,sumoId:""}});this.allLaneGraphics.push(j),l.push(j)}}}}const r=setInterval(()=>{if(l.length>0||this.allRefLineGraphics.length>0){if(l.length>0){const n=l.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(r),s()},10)})}showJunction(e){const i=[];for(const t of e){if(!t)continue;this.junctionNames.set(t.id,t.name),t.nodeType=t.type;const o=new m({geometry:{type:"point",x:t.coordinates[0],y:t.coordinates[1]},attributes:{...t,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:t.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30},popupTemplate:{title:t.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});i.push(o)}this.junctionLayer.addMany(i)}monitorMouseMove(){const e=C.debounce(async t=>{var l;const s=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.filter(r=>r.type==="graphic");if(s.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const a=s[0];if(this.hitGraphic=a.graphic,a.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(r===this.currentSectionCode||this.sectionLayer.graphics.findIndex(d=>d.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const c=this.allLaneGraphics.filter(d=>`${d.attributes.roadId}+${d.attributes.sectionId}`===r),b=N.union(c.map(d=>d.geometry)),h=this.hitGraphic.getAttribute("fromNode"),p=this.hitGraphic.getAttribute("toNode"),u=this.junctionNames.get(h)||h,y=this.junctionNames.get(p)||p;this.highlightGraphic=new m({geometry:b,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:r,selected:!1,fromNodeName:u,toNodeName:y,laneCount:c.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic);const v=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:v})}else if(a.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})});const i=T.default.useAppDataStore;x.watch(()=>i.isSketching,()=>{var t;i.isSketching?(t=this.mouseMoveHandler)==null||t.remove():this.mouseMoveHandler=this.view.on("pointer-move",async o=>{e(o).catch(()=>{})})})}monitorMouseClick(){const e=C.debounce(async i=>{var r;const o=(r=(await this.view.hitTest(i,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:r.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,a=s.getAttribute("type"),l=s.getAttribute("id");if(a==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,c=await f.get(n,{params:{id:l,projectName:this.projectName}});c.status===200&&c.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:l,details:c.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:l,details:void 0}),s.setAttribute("selected",!1);const n=s.getAttribute("crossId");s.symbol.url=n?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(a==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:l,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,c=await f.get(n,{params:{id:l,projectName:this.projectName}});c.status===200&&c.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",c.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:l,details:c.data.result}))}});this.mouseClickHandler=this.view.on("immediate-click",async i=>{e(i).catch(()=>{})})}increasePictureMarkerSize(e,i){const t=setInterval(()=>{const o=e.symbol,s=o.width;s<i?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(t)},20)}decreasePictureMarkerSize(e,i){const t=setInterval(()=>{const o=e.symbol,s=o.width;s>i?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(t)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const i=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,t=await f.get(i,{params:{id:e.id,projectName:this.projectName}});return t.status===200?t.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const i=e.id.split("#");let t=i[0];t.startsWith("-")&&(t=t.slice(1));let o=0;i.length===2&&(o=Number(i[1]));const s=this.allLaneGraphics.find(a=>a.getAttribute("roadId")===t&&a.getAttribute("sectionIndex")===o);if(s){const a=`${t}+${s.getAttribute("sectionId")}`,l=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,r=await f.get(l,{params:{id:a,projectName:this.projectName}});return r.status===200?r.data:{status:-1,message:`路段信息查询失败: ${a}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var i,t;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(i=this.mouseMoveHandler)==null||i.remove(),this.mouseMoveHandler=void 0,(t=this.mouseClickHandler)==null||t.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:i,id:t}=e,o=e.flash===void 0?!0:e.flash;if(i==="junction")return await this.findJunction(t,o);if(i==="edge"){const s=t.split("+");if(s.length>2)return{status:-1,message:"id格式错误"};const a=s.length===2?Number(s[1]):void 0,l=s[0].split("#");if(l.length>2)return{status:-1,message:"id格式错误"};const r=l[0],n=l.length===2?Number(l[1]):void 0;return await this.findLane({roadsectId:r,segmentId:n,laneId:a,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,i){const t=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!t)return{status:-1,message:"未找到。请检查路口编号"};if(i){const o=new m({geometry:t.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(t.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:i,segmentId:t,laneId:o}=e;i.startsWith("-")&&(i=i.slice(1));let s=this.allLaneGraphics.filter(r=>r.attributes.roadId===i);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(t!==void 0){const r=[];if(s.forEach(n=>{const c=Number(n.attributes.sectionId);r.indexOf(c)===-1&&r.push(c)}),r.sort((n,c)=>n-c),t>r.length-1)return{status:-1,message:"未找到。请检查基本段编号"};t=r[t],s=s.filter(n=>Number(n.attributes.sectionId)===t)}if(o!==void 0){const r=[];if(s.forEach(n=>{const c=Number(n.attributes.laneId);r.indexOf(c)===-1&&r.push(c)}),r.sort((n,c)=>n-c),o>r.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=r[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const a=s.map(r=>r.geometry),l=N.union(a);if(e.flash){const r=new m({geometry:l,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(r)}return await this.view.goTo(l,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let i=0,t=!0;const o=setInterval(()=>{t?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(t=!1,i++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(t=!0)),i>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(i=>{if((!e||!e.id||e.id===""||e.id===i.getAttribute("id"))&&i.getAttribute("selected")){i.setAttribute("selected",!1);const t=i.getAttribute("crossId");i.symbol.url=t?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(i,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const i=this.sectionLayer.graphics.find(t=>t.getAttribute("edgeId")===e.id);i&&this.sectionLayer.remove(i)}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(i=>{if(e.id===i.getAttribute("id"))return i.setAttribute("selected",!0),i.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(i,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const i=e.id.split("#");let t=i[0];t.startsWith("-")&&(t=t.slice(1));let o=0;i.length===2&&(o=Number(i[1]));const s=this.allLaneGraphics.filter(a=>a.getAttribute("roadId")===t&&a.getAttribute("sectionIndex")===o);if(s.length>0){const a=N.union(s.map(r=>r.geometry)),l=new m({geometry:a,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(l),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=D;