gisviewer-vue3-arcgis 1.0.144 → 1.0.146

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.
@@ -8,7 +8,13 @@ class i {
8
8
  for (const s of t.children)
9
9
  if (s.children) {
10
10
  const o = new i(s);
11
- o.parentName = this.name, o.areaColor = this.areaColor, this.subDistricts.push(o), this.subDistrictCount++, this.crossCount += o.crossCount;
11
+ o.parentName = this.name;
12
+ const e = this.areaColor[0], n = this.areaColor[1], a = this.areaColor[2], r = Math.random() * 200 - 100;
13
+ o.areaColor = [
14
+ e + r,
15
+ n + r,
16
+ a + r
17
+ ], this.subDistricts.push(o), this.subDistrictCount++, this.crossCount += o.crossCount;
12
18
  } else {
13
19
  const o = {
14
20
  id: s.id,
@@ -1,11 +1,11 @@
1
1
  import * as g from "@arcgis/core/core/reactiveUtils.js";
2
2
  import y from "@arcgis/core/Graphic";
3
3
  import o from "@arcgis/core/layers/GraphicsLayer";
4
- import d from "@turf/buffer";
5
- import f from "@turf/concave";
4
+ import f from "@turf/buffer";
5
+ import b from "@turf/concave";
6
6
  import m from "@turf/convex";
7
7
  import * as h from "@turf/helpers";
8
- import b from "./district-controller.mjs";
8
+ import d from "./district-controller.mjs";
9
9
  class x {
10
10
  constructor(e) {
11
11
  this.crossScale = 3e3, this.view = e, this.view.popup.visibleElements = {
@@ -36,7 +36,7 @@ class x {
36
36
  showSignalControlArea(e) {
37
37
  this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0;
38
38
  for (const t of e) {
39
- const r = new b(t);
39
+ const r = new d(t);
40
40
  this.drawArea(r, !0);
41
41
  }
42
42
  return this.watchHandle = g.watch(
@@ -126,15 +126,15 @@ class x {
126
126
  i = h.lineString(r);
127
127
  else if (r.length > 2) {
128
128
  const n = h.featureCollection(
129
- r.map((p) => h.point(p))
129
+ r.map((u) => h.point(u))
130
130
  );
131
- t ? i = m(n) : (i = f(n, { maxEdge: 400, units: "meters" }), i || (i = m(n)));
131
+ t ? i = m(n) : (i = b(n, { maxEdge: 400, units: "meters" }), i || (i = m(n)));
132
132
  }
133
133
  if (!i) {
134
134
  console.log("生成区控面失败", e);
135
135
  return;
136
136
  }
137
- const a = d(
137
+ const a = f(
138
138
  i.geometry,
139
139
  // 区控面积更大,需要更大的缓冲半径
140
140
  t ? 200 : 30,
@@ -166,7 +166,7 @@ class x {
166
166
  label: "路口数量"
167
167
  }
168
168
  ];
169
- const u = {
169
+ const p = {
170
170
  type: "signalControlArea",
171
171
  id: e.id,
172
172
  name: e.name,
@@ -188,7 +188,7 @@ class x {
188
188
  style: t ? "solid" : "long-dash"
189
189
  }
190
190
  },
191
- attributes: u,
191
+ attributes: p,
192
192
  popupTemplate: {
193
193
  title: `${t ? "区控" : "子区"} ${e.name}`,
194
194
  content: [
@@ -263,23 +263,23 @@ class x {
263
263
  getCrossGraphicSymbol(e, t) {
264
264
  const { isKey: r, color: s } = e;
265
265
  if (t === "marker")
266
- return {
266
+ return r ? {
267
+ type: "picture-marker",
268
+ url: "/GisViewerAssets/Images/icon_star.png",
269
+ width: "30px",
270
+ height: "30px"
271
+ } : {
267
272
  type: "simple-marker",
268
- style: r ? "diamond" : "circle",
273
+ style: "circle",
269
274
  color: s,
270
- size: r ? 16 : 8,
275
+ size: 8,
271
276
  outline: {
272
- color: r ? "red" : "white",
273
- width: r ? 2 : 1
277
+ color: "white",
278
+ width: 1
274
279
  }
275
280
  };
276
281
  if (t === "picture")
277
282
  return {
278
- // type: 'picture-marker',
279
- // url: `/GisViewerAssets/Images/xhj_${isKey ? 4 : 1}.png`,
280
- // width: isKey ? '55px' : '37px',
281
- // height: isKey ? '85px' : '57px',
282
- // yoffset: isKey ? '37px' : '25px'
283
283
  type: "cim",
284
284
  data: {
285
285
  type: "CIMSymbolReference",
@@ -5,6 +5,7 @@ import SceneView from '@arcgis/core/views/SceneView';
5
5
  import Sketch from '@arcgis/core/widgets/Sketch';
6
6
  import SketchViewModel from '@arcgis/core/widgets/Sketch/SketchViewModel';
7
7
  interface sketchViewOptions {
8
+ creationMode?: 'single' | 'continuous' | 'update' | undefined;
8
9
  /**
9
10
  * 最大允许绘制的图形数量
10
11
  */
@@ -203,7 +204,6 @@ export default class SketchView {
203
204
  * @param num 数量
204
205
  */
205
206
  setMaxAllowedGraphics(num: number): void;
206
- deepClone(obj: any): void;
207
207
  destroy(): void;
208
208
  }
209
209
  export {};
@@ -5,11 +5,11 @@ import f from "@arcgis/core/layers/GraphicsLayer";
5
5
  import G from "@arcgis/core/widgets/Sketch";
6
6
  import P from "@arcgis/core/widgets/Sketch/SketchViewModel";
7
7
  import S from "@arcgis/core/geometry/Polygon.js";
8
- import b from "@arcgis/core/geometry/Polyline.js";
8
+ import k from "@arcgis/core/geometry/Polyline.js";
9
9
  import * as d from "@turf/helpers";
10
- import k from "@turf/intersect";
11
- import { v4 as A } from "uuid";
12
- import M from "../stores/index.mjs";
10
+ import b from "@turf/intersect";
11
+ import { v4 as M } from "uuid";
12
+ import A from "../stores/index.mjs";
13
13
  function u(c, t = []) {
14
14
  if (c === null || typeof c != "object")
15
15
  return c;
@@ -51,7 +51,7 @@ const x = {
51
51
  width: 1
52
52
  }
53
53
  };
54
- class B {
54
+ class C {
55
55
  constructor(t, e) {
56
56
  this.viewer = t, this.options = {
57
57
  ...x,
@@ -73,6 +73,8 @@ class B {
73
73
  viewModel: this.sketchViewModel,
74
74
  layer: this.graphicsLayer,
75
75
  visible: this.options.defaultSketchVisible,
76
+ creationMode: this.options.creationMode || "single",
77
+ // multiple | single | update
76
78
  snappingOptions: {
77
79
  // autocasts to SnappingOptions()
78
80
  enabled: !0,
@@ -83,7 +85,7 @@ class B {
83
85
  }), this.sketch.visibleElements = {
84
86
  ...this.options.sketchVisibleElements
85
87
  }, this.viewer.ui.add(this.sketch, this.options.sketchPosition);
86
- const i = M.useAppDataStore;
88
+ const i = A.useAppDataStore;
87
89
  this.sketch.on("create", (s) => {
88
90
  s.state === "complete" ? i.isSketching = !1 : s.state === "start" && (i.isSketching = !0);
89
91
  });
@@ -142,7 +144,7 @@ class B {
142
144
  return Object.keys(t).map((r) => {
143
145
  const o = t[r][0], a = t[r][1];
144
146
  e && (o.reverse(), a.reverse());
145
- const n = A(), h = this.createPolylineGraphic(
147
+ const n = M(), h = this.createPolylineGraphic(
146
148
  o,
147
149
  m,
148
150
  {
@@ -157,7 +159,7 @@ class B {
157
159
  }), i;
158
160
  }
159
161
  createPolylineGraphic(t, e, i) {
160
- const s = new b({
162
+ const s = new k({
161
163
  paths: t
162
164
  }), r = g.geographicToWebMercator(s);
163
165
  return new l({
@@ -190,14 +192,13 @@ class B {
190
192
  return;
191
193
  }
192
194
  if (i.state === "complete" && ((a = i.graphic) != null && a.geometry)) {
193
- console.log(i.graphic);
194
195
  const n = i.graphic.geometry;
195
196
  i.graphic.setAttribute("type", "draw"), i.graphic.setAttribute("id", new Date().getTime());
196
197
  const h = e.getGraphicPoint(n);
197
198
  t && t("create", h, i);
198
199
  }
199
200
  }), this.sketchViewModel.on("update", function(i) {
200
- if (console.log("update", i), i.aborted) {
201
+ if (i.aborted) {
201
202
  const s = i.graphics[0];
202
203
  e.graphicsLayer.remove(s);
203
204
  return;
@@ -308,7 +309,7 @@ class B {
308
309
  let s = !1;
309
310
  for (let r = 0; r < i.length; r++) {
310
311
  const o = i[r], a = t[o];
311
- if (k(
312
+ if (b(
312
313
  d.polygon(e),
313
314
  d.polygon(a)
314
315
  )) {
@@ -513,13 +514,12 @@ class B {
513
514
  setMaxAllowedGraphics(t) {
514
515
  this.options.maxAllowedGraphics = t === 0 ? void 0 : t;
515
516
  }
516
- deepClone(t) {
517
- }
517
+ // deepClone(obj: any) {}
518
518
  destroy() {
519
519
  var t, e;
520
520
  this.viewer.map.remove(this.graphicsLayer), this.viewer.map.remove(this.TextGraphicsLayer), (t = this.sketch) == null || t.destroy(), (e = this.sketchViewModel) == null || e.destroy();
521
521
  }
522
522
  }
523
523
  export {
524
- B as default
524
+ C as default
525
525
  };
@@ -229,8 +229,8 @@ export interface IUnselectSumoParams {
229
229
  }
230
230
  export interface ISplitOpenDriveLaneParams {
231
231
  id: string;
232
- start: number;
233
- end: number;
232
+ start?: number;
233
+ end?: number;
234
234
  }
235
235
  export interface IJunctionTableData {
236
236
  id: string;
@@ -75,8 +75,13 @@ declare const _sfc_main: import("vue").DefineComponent<{
75
75
  findSumoInOpenDrive: (params: IFindSumoParams) => Promise<import("../types").IResult>;
76
76
  selectSumoInOpenDrive: (params: IFindSumoParams) => Promise<import("../types").IResult>;
77
77
  unselectSumoInOpenDrive: (params?: IUnselectSumoParams | undefined) => Promise<import("../types").IResult>;
78
+ geometrySearchInOpenDrive: (params: any) => Promise<import("../types").IResult>;
78
79
  getSumoInfo: (params: IFindSumoParams) => Promise<import("../types").IResult>;
79
80
  splitOpenDriveLane: (params: ISplitOpenDriveLaneParams) => Promise<import("../types").IResult>;
81
+ clearSplitOpenDriveLane: () => Promise<void | {
82
+ status: number;
83
+ message: string;
84
+ }>;
80
85
  showSignalControlArea: (params: any) => import("../types").IResult;
81
86
  clearSignalControlArea: () => void;
82
87
  locateSignalControlArea: (params: {
@@ -1 +1 @@
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;
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 Ce=require("./utils/holo-flow/index.js"),ke=require("./utils/map-initializer.js"),O=require("./utils/open-drive-renderer/index.js"),Te=require("./utils/overlay.js"),De=require("./utils/queue-length.js"),C=require("./utils/road-config-tool/index.js"),Le=require("./utils/signal-control-area-controller/index.js"),Ae=require("./utils/traffic-flow.js"),Ie={class:"gis-viewer"},be={style:{position:"absolute",bottom:"10px",left:"10px"}},qe=o.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(k,{expose:T,emit:D}){const p=o.ref(null);let i,l,c,n,a,r,g,t,s;const f=o.ref(!1);o.onMounted(async()=>{if(y.registerStore(),!p.value)return;document.addEventListener("keydown",m=>{m.ctrlKey&&m.key==="i"&&(f.value=!f.value)});const e=o.getCurrentInstance(),{$gisviewerAssetsRoot:u}=e.appContext.config.globalProperties,S=await(await fetch(h.config)).json();S.assetsRoot=h.assetsRoot||u;const Se=y.default.useAppDataStore;Se.mapConfig=S,l=new ke.default,i=await l.initialize({container:p.value,markerClickCallback:(m,v,w,Oe)=>{d("markerClick",m,v,w,Oe)},mapClickCallback:(m,v,w)=>{d("mapClick",m,v,w)}}),a=new Ce.default(i),await a.init(),d("mapLoaded")}),o.onUnmounted(()=>{s==null||s.clearSignalControlArea(),t==null||t.clearOpenDrive(),a==null||a.clearHoloTrace(),a==null||a.clearHoloSignal(),n==null||n.disconnectTrafficFlow()});const L=o.computed(()=>i),A=()=>{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 C.default(i)),c.showLaneNumber(e)),B=()=>{c==null||c.clearLaneNumber()},E=async e=>(c||(c=new C.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)},W=e=>{a.togglePause(e)},X=e=>{n==null||n.toggleTrafficObject(e),a.toggleTrafficObject(e)},Y=e=>{a.updatePanelContent(e)},R=async e=>(r||(r=new Te.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 De.default(i)),g.updateQueueLength(e)},re=()=>{g==null||g.removeQueueLength()},se=async(e,u)=>(t||(t=new O.default(i)),await t.showOpenDriveFromServer(e,u)),oe=async e=>(t||(t=new O.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.geometrySearch(e):{status:-1,message:"未加载OpenDrive地图"},me=async e=>t?await t.getSumoInfo(e):{status:-1,message:"未加载OpenDrive地图"},pe=async e=>t?await(t==null?void 0:t.splitLane(e)):{status:-1,message:"未加载OpenDrive地图"},fe=async()=>t?t==null?void 0:t.clearSplitLane():{status:-1,message:"未加载OpenDrive地图"},de=e=>(s||(s=new Le.default(i)),s.showSignalControlArea(e)),ve=()=>{s==null||s.clearSignalControlArea()},we=async e=>s?await s.locateSignalControlArea(e):{status:-1,message:"未加载信号控制区"},ye=async e=>s?await s.highlightSignalControlArea(e):{status:-1,message:"未加载信号控制区"},he=()=>s?s.resetHighlight():{status:-1,message:"未加载信号控制区"},h=k,d=D;return T({mapViewer:L,setLayerVisibility:x,setMapCenter:b,lookAt:_,setMapCamera:q,setMapZoomRange:M,requestCoordinateTransform:H,cancelCoordinateTransform:V,addOverlays:R,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:X,toggleVehicleInfo:Y,togglePause:W,updateQueueLength:ne,removeQueueLength:re,showOpenDriveFromServer:se,showOpenDriveFromFile:oe,clearOpenDrive:ce,geometrySearchInOpenDrive:ge,findSumoInOpenDrive:ie,selectSumoInOpenDrive:le,unselectSumoInOpenDrive:ue,getSumoInfo:me,splitOpenDriveLane:pe,clearSplitOpenDriveLane:fe,showSignalControlArea:de,clearSignalControlArea:ve,locateSignalControlArea:we,highlightSignalControlArea:ye,resetHighlightSignalControlArea:he}),(e,u)=>(o.openBlock(),o.createElementBlock("div",Ie,[o.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:p},[o.withDirectives(o.createElementVNode("div",be,[o.createElementVNode("button",{style:{"margin-right":"10px"},onClick:A}," 开始记录 "),o.createElementVNode("button",{onClick:I},"下载日志")],512),[[o.vShow,f.value]])],512)]))}});exports.default=qe;
@@ -64,8 +64,13 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
64
64
  findSumoInOpenDrive: (params: import("../types").IFindSumoParams) => Promise<import("../types").IResult>;
65
65
  selectSumoInOpenDrive: (params: import("../types").IFindSumoParams) => Promise<import("../types").IResult>;
66
66
  unselectSumoInOpenDrive: (params?: import("../types").IUnselectSumoParams | undefined) => Promise<import("../types").IResult>;
67
+ geometrySearchInOpenDrive: (params: any) => Promise<import("../types").IResult>;
67
68
  getSumoInfo: (params: import("../types").IFindSumoParams) => Promise<import("../types").IResult>;
68
69
  splitOpenDriveLane: (params: import("../types").ISplitOpenDriveLaneParams) => Promise<import("../types").IResult>;
70
+ clearSplitOpenDriveLane: () => Promise<void | {
71
+ status: number;
72
+ message: string;
73
+ }>;
69
74
  showSignalControlArea: (params: any) => import("../types").IResult;
70
75
  clearSignalControlArea: () => void;
71
76
  locateSignalControlArea: (params: {
@@ -10,6 +10,7 @@ export default class OpenDriveRenderer {
10
10
  private highlightLayer;
11
11
  private flashLayer;
12
12
  private drawLayer;
13
+ private splitLaneLayer;
13
14
  private allLaneGraphics;
14
15
  private allRefLineGraphics;
15
16
  private mouseMoveHandler;
@@ -105,5 +106,7 @@ export default class OpenDriveRenderer {
105
106
  * @returns
106
107
  */
107
108
  selectSumo(params: IFindSumoParams): IResult;
109
+ geometrySearch(coordinate: number[][]): Promise<IResult>;
108
110
  splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
111
+ clearSplitLane(): void;
109
112
  }
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),J=require("@arcgis/core/core/promiseUtils"),A=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),T=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),E=require("md5"),F=require("pako"),R=require("vue"),_=require("../../stores/index.js"),M=require("../common-utils.js");function j(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const $=j(J),S=j(q),P=j(T);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 C({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 C({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 I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}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:E(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var g,m;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 b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(h){return{status:-1,message:h.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;M.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const l=await(await fetch(c)).arrayBuffer(),n=F.inflate(l,{to:"string"}),r=JSON.parse(n);await this.showAllLanes(r,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0);const d=o.data.result.junctions;if(this.showJunction(d),e.options&&e.options.centerMap!==!1){const h=M.default.transformPointProjection([0,0]);await this.view.goTo(h)}this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const u=_.default.useAppDataStore;return R.watch(()=>u.isSketching,()=>{var h,p;u.isSketching?((h=this.mouseMoveHandler)==null||h.remove(),this.mouseMoveHandler=void 0,(p=this.mouseClickHandler)==null||p.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.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 a=await(await fetch(s)).arrayBuffer(),l=F.inflate(a,{to:"string"}),n=JSON.parse(l);return await this.showAllLanes(n,!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 c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const a=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:r,refLine:d}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const g=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:r,roadName:u}});this.allRefLineGraphics.push(g),n.laneSections.sort((m,h)=>Number(m.id)-Number(h.id));for(let m=0;m<n.laneSections.length;m++){const h=n.laneSections[m],p=Number(h.id);for(const f of h.lanePaths){const w=Number(f.id);if(w===0)continue;const v=f.type,x=[...f.outerPath],N=f.innerPath.concat(x.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(f.innerPath[0]);const k=new A.Polygon({rings:[N]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${r}+${p}+${w}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(r),roadName:n.name,sectionId:String(p),sectionIndex:m,laneId:w,type:v,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath}});this.allLaneGraphics.push(G),a.push(G)}}}}const l=setInterval(()=>{if(a.length>0||this.allRefLineGraphics.length>0){if(a.length>0){const n=a.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(l),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 y({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=$.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(a=>a.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 a=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(a===this.currentSectionCode||this.sectionLayer.graphics.findIndex(p=>p.getAttribute("id")===a)>=0)return;this.currentSectionCode=a;const n=this.allLaneGraphics.filter(p=>`${p.attributes.roadId}+${p.attributes.sectionId}`===a),r=S.union(n.map(p=>p.geometry)),d=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(d)||d,m=this.junctionNames.get(u)||u;this.highlightGraphic=new y({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,selected:!1,fromNodeName:g,toNodeName:m,laneCount:n.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 h=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:h})}else if(s.layer.id==="OpenDriveJunction"){const a=this.hitGraphic.getAttribute("id");if(a===this.currentJunctionId)return;this.currentJunctionId=a,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=$.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),a=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:r.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:a,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(c==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",r.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:r.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 b.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(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,a=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(a,{params:{id:c,projectName:this.projectName}});return l.status===200?l.data:{status:-1,message:`路段信息查询失败: ${c}`}}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 c=s.length===2?Number(s[1]):void 0,a=s[0].split("#");if(a.length>2)return{status:-1,message:"id格式错误"};const l=a[0],n=a.length===2?Number(a[1]):void 0;return await this.findLane({roadsectId:l,segmentId:n,laneId:c,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 y({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(l=>l.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.sectionId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),i>l.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=l[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.laneId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),o>l.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=l[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(l=>l.geometry),a=S.union(c);if(e.flash){const l=new y({geometry:a,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(l)}return await this.view.goTo(a,{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=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o="0";t.length===2&&(o=String(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionId")===o)),s.length>0){const c=S.union(s.map(l=>l.geometry)),a=new y({geometry:c,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(a),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const l of i.features){const n=l.getAttribute("roadId"),r=l.getAttribute("sectionId"),d=`${n}#${r}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const u=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(u,{params:{id:`${n}+${r}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(l=>{const n=l.geometry;return S.contains(t,n)}),a=[];for(const l of c){const n=l.getAttribute("id");this.selectSumo({type:"junction",id:n});const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(r,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&a.push(d.data.result)}return{status:0,message:"ok",result:{junctions:a,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let a=s[0];a.startsWith("-")&&(a=a.slice(1));const l=this.allLaneGraphics.filter(v=>v.getAttribute("roadId")===a&&v.getAttribute("sectionIndex")===c);if(l.length===0)return{status:-1,message:"未找到路段"};const n=l.length-o,r=l.find(v=>Math.abs(v.getAttribute("laneId"))===n);if(!r)return{status:-1,message:"未找到车道"};const d=e.start||0,u=e.end||100,g=P.lineString(r.getAttribute("leftLine")),m=O.lineSliceAlong(g,d,u,{units:"meters"}),h=P.lineString(r.getAttribute("rightLine")),p=O.lineSliceAlong(h,d,u,{units:"meters"}),f=m.geometry.coordinates.concat(p.geometry.coordinates.reverse());f.push(f[f.length-1]);const w=new y({geometry:new A.Polygon({rings:[f]}),attributes:{ObjectID:r.getAttribute("ObjectID"),id:r.getAttribute("id"),fromNode:r.getAttribute("fromNode"),toNode:r.getAttribute("toNode"),roadId:r.getAttribute("roadId"),roadName:r.getAttribute("roadName"),sectionId:r.getAttribute("sectionId"),sectionIndex:r.getAttribute("sectionIndex"),laneId:r.getAttribute("laneId"),type:r.getAttribute("type"),sumoId:r.getAttribute("sumoId"),leftLine:m.geometry.coordinates,rightLine:p.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(w),this.view.goTo(w),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}}exports.default=D;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class e{constructor(t){this.parentName="",this.crosses=[],this.subDistricts=[],this.areaColor=[Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255)],this.crossCount=0,this.subDistrictCount=0,this.id=t.id,this.name=t.name,this.parentId=t.parentId;for(const s of t.children)if(s.children){const o=new e(s);o.parentName=this.name,o.areaColor=this.areaColor,this.subDistricts.push(o),this.subDistrictCount++,this.crossCount+=o.crossCount}else{const o={id:s.id,name:s.name,parentId:s.parentId,latitude:Number(s.latitude),longitude:Number(s.longitude),signalId:s.signalId,isKey:s.isKey===1};this.crosses.push(o),this.crossCount++}}getAllCrossCoordinates(){const t=[];for(const s of this.crosses)t.push([s.longitude,s.latitude]);for(const s of this.subDistricts)t.push(...s.getAllCrossCoordinates());return t}}exports.default=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class i{constructor(s){this.parentName="",this.crosses=[],this.subDistricts=[],this.areaColor=[Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255)],this.crossCount=0,this.subDistrictCount=0,this.id=s.id,this.name=s.name,this.parentId=s.parentId;for(const t of s.children)if(t.children){const o=new i(t);o.parentName=this.name;const e=this.areaColor[0],n=this.areaColor[1],a=this.areaColor[2],r=Math.random()*200-100;o.areaColor=[e+r,n+r,a+r],this.subDistricts.push(o),this.subDistrictCount++,this.crossCount+=o.crossCount}else{const o={id:t.id,name:t.name,parentId:t.parentId,latitude:Number(t.latitude),longitude:Number(t.longitude),signalId:t.signalId,isKey:t.isKey===1};this.crosses.push(o),this.crossCount++}}getAllCrossCoordinates(){const s=[];for(const t of this.crosses)s.push([t.longitude,t.latitude]);for(const t of this.subDistricts)s.push(...t.getAllCrossCoordinates());return s}}exports.default=i;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/core/reactiveUtils.js"),y=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),f=require("@turf/buffer"),L=require("@turf/concave"),m=require("@turf/convex"),v=require("@turf/helpers"),C=require("./district-controller.js");function g(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const w=g(b),c=g(v);class S{constructor(e){this.crossScale=3e3,this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0},this.districtControllerLayer=new l({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new l({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new l({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new l({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}showSignalControlArea(e){this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const t of e){const i=new C.default(t);this.drawArea(i,!0)}return this.watchHandle=w.watch(()=>this.view.scale,(t,i)=>{t>this.crossScale&&i<=this.crossScale?(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker"))})):t<=this.crossScale&&i>this.crossScale&&(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture"))}))}),{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.watchHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);return t?(t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry),this.showPopup(t),{status:0,message:"ok"}):{status:1,message:"未找到"}}showPopup(e){const t=e.geometry.type==="point"?e.geometry:e.geometry.centroid;this.view.openPopup({features:[e],location:t})}async highlightSignalControlArea(e){this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;const t=this.districtControllerLayer.graphics.filter(r=>r.getAttribute("id")===e.id).toArray().map(r=>r.clone()),i=this.subDistrictControllerLayer.graphics.filter(r=>r.getAttribute("id")===e.id||r.getAttribute("parentId")===e.id).toArray().map(r=>r.clone()),s=this.crossLayer.graphics.filter(r=>r.getAttribute("id")===e.id||r.getAttribute("districtId")===e.id||r.getAttribute("subDistrictId")===e.id).toArray().map(r=>r.clone());return t.length>0&&this.highlightLayer.addMany(t),i.length>0&&(this.highlightLayer.addMany(i),this.showPopup(i[0])),s.length>0&&this.highlightLayer.addMany(s),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?(await this.view.goTo(t),this.showPopup(t[0])):i.length>0?(await this.view.goTo(i),this.showPopup(i[0])):(s.length>1?await this.view.goTo(s):await this.view.goTo({target:s[0].geometry,scale:1500}),this.showPopup(s[0])),{status:0,message:"ok"})}resetHighlight(){return this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0,this.crossLayer.visible=!0,{status:0,message:"ok"}}findAreaGraphic(e){let t=this.districtControllerLayer.graphics.find(i=>i.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(i=>i.attributes.id===e)),t||(t=this.crossLayer.graphics.find(i=>i.attributes.id===e)),t}drawArea(e,t){const i=e.getAllCrossCoordinates();if(i.length>=2){let r=null;if(i.length===2)r=c.lineString(i);else if(i.length>2){const h=c.featureCollection(i.map(d=>c.point(d)));t?r=m(h):(r=L(h,{maxEdge:400,units:"meters"}),r||(r=m(h)))}if(!r){console.log("生成区控面失败",e);return}const o=f(r.geometry,t?200:30,{units:"meters"});let n;t?n=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:n=[{fieldName:"parentName",label:"所属区控"},{fieldName:"crossCount",label:"路口数量"}];const p={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},u=new y({geometry:{type:"polygon",rings:o.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:p,popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:n}]}});t?this.districtControllerLayer.add(u):this.subDistrictControllerLayer.add(u)}for(const r of e.subDistricts)this.drawArea(r,!1);const s=e.crosses.map(r=>{const o={type:"cross",id:r.id,name:r.name,color:e.areaColor,signalId:r.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,isKey:r.isKey};return new y({geometry:{type:"point",x:r.longitude,y:r.latitude},symbol:this.getCrossGraphicSymbol(o,"marker"),attributes:o,popupTemplate:{title:r.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}})});this.crossLayer.addMany(s)}getCrossGraphicSymbol(e,t){const{isKey:i,color:s}=e;if(t==="marker")return{type:"simple-marker",style:i?"diamond":"circle",color:s,size:i?16:8,outline:{color:i?"red":"white",width:i?2:1}};if(t==="picture")return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?30:22,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:i?45:30,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/xhj_${i?4:1}.png`}]}}}}}exports.default=S;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/core/reactiveUtils.js"),y=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),f=require("@turf/buffer"),L=require("@turf/concave"),m=require("@turf/convex"),v=require("@turf/helpers"),C=require("./district-controller.js");function p(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const w=p(b),c=p(v);class A{constructor(e){this.crossScale=3e3,this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0},this.districtControllerLayer=new l({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new l({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new l({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new l({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}showSignalControlArea(e){this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const t of e){const r=new C.default(t);this.drawArea(r,!0)}return this.watchHandle=w.watch(()=>this.view.scale,(t,r)=>{t>this.crossScale&&r<=this.crossScale?(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker"))})):t<=this.crossScale&&r>this.crossScale&&(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture"))}))}),{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.watchHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);return t?(t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry),this.showPopup(t),{status:0,message:"ok"}):{status:1,message:"未找到"}}showPopup(e){const t=e.geometry.type==="point"?e.geometry:e.geometry.centroid;this.view.openPopup({features:[e],location:t})}async highlightSignalControlArea(e){this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;const t=this.districtControllerLayer.graphics.filter(i=>i.getAttribute("id")===e.id).toArray().map(i=>i.clone()),r=this.subDistrictControllerLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("parentId")===e.id).toArray().map(i=>i.clone()),s=this.crossLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("districtId")===e.id||i.getAttribute("subDistrictId")===e.id).toArray().map(i=>i.clone());return t.length>0&&this.highlightLayer.addMany(t),r.length>0&&(this.highlightLayer.addMany(r),this.showPopup(r[0])),s.length>0&&this.highlightLayer.addMany(s),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?(await this.view.goTo(t),this.showPopup(t[0])):r.length>0?(await this.view.goTo(r),this.showPopup(r[0])):(s.length>1?await this.view.goTo(s):await this.view.goTo({target:s[0].geometry,scale:1500}),this.showPopup(s[0])),{status:0,message:"ok"})}resetHighlight(){return this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0,this.crossLayer.visible=!0,{status:0,message:"ok"}}findAreaGraphic(e){let t=this.districtControllerLayer.graphics.find(r=>r.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(r=>r.attributes.id===e)),t||(t=this.crossLayer.graphics.find(r=>r.attributes.id===e)),t}drawArea(e,t){const r=e.getAllCrossCoordinates();if(r.length>=2){let i=null;if(r.length===2)i=c.lineString(r);else if(r.length>2){const h=c.featureCollection(r.map(d=>c.point(d)));t?i=m(h):(i=L(h,{maxEdge:400,units:"meters"}),i||(i=m(h)))}if(!i){console.log("生成区控面失败",e);return}const o=f(i.geometry,t?200:30,{units:"meters"});let n;t?n=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:n=[{fieldName:"parentName",label:"所属区控"},{fieldName:"crossCount",label:"路口数量"}];const g={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},u=new y({geometry:{type:"polygon",rings:o.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:g,popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:n}]}});t?this.districtControllerLayer.add(u):this.subDistrictControllerLayer.add(u)}for(const i of e.subDistricts)this.drawArea(i,!1);const s=e.crosses.map(i=>{const o={type:"cross",id:i.id,name:i.name,color:e.areaColor,signalId:i.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,isKey:i.isKey};return new y({geometry:{type:"point",x:i.longitude,y:i.latitude},symbol:this.getCrossGraphicSymbol(o,"marker"),attributes:o,popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}})});this.crossLayer.addMany(s)}getCrossGraphicSymbol(e,t){const{isKey:r,color:s}=e;if(t==="marker")return r?{type:"picture-marker",url:"/GisViewerAssets/Images/icon_star.png",width:"30px",height:"30px"}:{type:"simple-marker",style:"circle",color:s,size:8,outline:{color:"white",width:1}};if(t==="picture")return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:r?30:22,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:r?45:30,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/xhj_${r?4:1}.png`}]}}}}}exports.default=A;
@@ -5,6 +5,7 @@ import SceneView from '@arcgis/core/views/SceneView';
5
5
  import Sketch from '@arcgis/core/widgets/Sketch';
6
6
  import SketchViewModel from '@arcgis/core/widgets/Sketch/SketchViewModel';
7
7
  interface sketchViewOptions {
8
+ creationMode?: 'single' | 'continuous' | 'update' | undefined;
8
9
  /**
9
10
  * 最大允许绘制的图形数量
10
11
  */
@@ -203,7 +204,6 @@ export default class SketchView {
203
204
  * @param num 数量
204
205
  */
205
206
  setMaxAllowedGraphics(num: number): void;
206
- deepClone(obj: any): void;
207
207
  destroy(): void;
208
208
  }
209
209
  export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/geometry/geometryEngine.js"),P=require("@arcgis/core/geometry/support/webMercatorUtils.js"),l=require("@arcgis/core/Graphic"),u=require("@arcgis/core/layers/GraphicsLayer"),G=require("@arcgis/core/widgets/Sketch"),S=require("@arcgis/core/widgets/Sketch/SketchViewModel"),k=require("@arcgis/core/geometry/Polygon.js"),M=require("@arcgis/core/geometry/Polyline.js"),A=require("@turf/helpers"),x=require("@turf/intersect"),v=require("uuid"),E=require("../stores/index.js");function f(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const V=f(b),g=f(P),d=f(A);function w(a,e=[]){if(a===null||typeof a!="object")return a;if(Object.prototype.toString.call(a)==="[object Date]")return new Date(a);if(Object.prototype.toString.call(a)==="[object RegExp]")return new RegExp(a);if(Object.prototype.toString.call(a)==="[object Error]")return new Error(a);const t=e.filter(s=>s.original===a)[0];if(t)return t.copy;const i=Array.isArray(a)?[]:{};return e.push({original:a,copy:i}),Object.keys(a).forEach(s=>{i[s]=w(a[s],e)}),i}const O={maxAllowedGraphics:0,GraphicsLayer:{},sketchVisibleElements:{},sketchPosition:"top-right",defaultSketchVisible:!0,sketchViewModelItemSymbol:{}},m={type:"simple-line",color:"#556DEA",width:2},y={type:"simple-fill",color:[227,139,79,.4],outline:{color:[255,255,255],width:1}};class D{constructor(e,t){this.viewer=e,this.options={...O,...t},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()}init(){this.sketchViewModel=new S({layer:this.graphicsLayer,view:this.viewer,updateOnGraphicClick:!0,polylineSymbol:m,polygonSymbol:y,...this.options.sketchViewModelItemSymbol});const e=this.findLayerById("TrafficMarkings"),t=[];e&&t.push({layer:e,enabled:!0}),this.sketch=new G({view:this.viewer,viewModel:this.sketchViewModel,layer:this.graphicsLayer,visible:this.options.defaultSketchVisible,snappingOptions:{enabled:!0,featureSources:t}}),this.sketch.visibleElements={...this.options.sketchVisibleElements},this.viewer.ui.add(this.sketch,this.options.sketchPosition);const i=E.default.useAppDataStore;this.sketch.on("create",s=>{s.state==="complete"?i.isSketching=!1:s.state==="start"&&(i.isSketching=!0)})}initPoint(e,t="all",i=!1){if(!e)return;const{crossArea:s,sectionArea:r}=e;if(s&&(t=="crossArea"||t=="all")){const o=this.initCrossArea(s);this.graphicsLayer.add(o)}if(r&&(t=="sectionArea"||t=="all")){const o=this.initSectionArea(r,i);this.graphicsLayer.addMany(o)}}initEntranceFusionZone(e){const t=[];e.map(i=>{t.push(this.createPolygonGraphic(i,y,{}))}),this.graphicsLayer.addMany(t)}initCrossArea(e){return this.createPolygonGraphic(e,y,{})}initSectionArea(e,t=!1){const i=[],s={type:"simple-line",color:[0,0,255],width:2};return Object.keys(e).map(r=>{const o=e[r][0],c=e[r][1];t&&(o.reverse(),c.reverse());const n=v.v4(),h=this.createPolylineGraphic(o,m,{type:"draw",id:n}),p=this.createPolylineGraphic(c,s,{type:"shiftLine",id:n});i.push(h,p)}),i}createPolylineGraphic(e,t,i){const s=new M({paths:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}createPolygonGraphic(e,t,i){const s=new k({rings:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}on(e){const t=this;this.sketchViewModel.on("create",function(i){var r,o,c;const s=t.graphicsLayer.graphics;if((r=t.options)!=null&&r.maxAllowedGraphics&&s.length>((o=t.options)==null?void 0:o.maxAllowedGraphics)){t.graphicsLayer.remove(i.graphic),console.log("已达到最大图形数量,无法继续绘制!");return}if(i.state==="complete"&&((c=i.graphic)!=null&&c.geometry)){console.log(i.graphic);const n=i.graphic.geometry;i.graphic.setAttribute("type","draw"),i.graphic.setAttribute("id",new Date().getTime());const h=t.getGraphicPoint(n);e&&e("create",h,i)}}),this.sketchViewModel.on("update",function(i){if(console.log("update",i),i.aborted){const s=i.graphics[0];t.graphicsLayer.remove(s);return}if(i.state==="complete"&&i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("update",o,i)}}),this.sketchViewModel.on("delete",function(i){if(console.log("delete",i,t.graphicsLayer.graphics),i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("delete",o,i)}})}graphicPoint(){const e=[];return this.graphicsLayer.graphics.map(t=>{var r;const i=t.geometry,s=this.getGraphicPoint(i);e.push({point:s,type:(r=t.attributes)==null?void 0:r.type,attributes:t.attributes})}),e}getEntranceRoad(){const e={},t=this.graphicPoint().filter(n=>n.point.type==="polyline");if(console.log("🚀 ~ file: sketchView.ts:378 ~ SketchView ~ getEntranceRoad ~ graphics:",t),!t.length)return!1;const i=t.filter(n=>n.type=="draw"),s=t.filter(n=>n.type=="shiftLine");if(s.length==0)throw"未绘制平移!";if(i.length!=s.length)throw"绘制的线和平移的线数量不一致!";const r=i.sort((n,h)=>n.point.angle-h.point.angle),o=r.findIndex(n=>n.point.angle>135);return[...r.slice(o),...r.slice(0,o).reverse()].map((n,h)=>{const p=s.find(L=>L.attributes.id==n.attributes.id);if(!p)throw"绘制的线和平移的线不匹配!";console.log("🚀 ~ file: sketchView.ts:393 ~ SketchView ~ getEntranceRoad ~ m:",n,p),e[h+1]={0:[n.point.paths[0],n.point.paths[n.point.paths.length-1]],1:[p.point.paths[0],p.point.paths[p.point.paths.length-1]]}}),e}getEntranceFusionZone(e){const t=[],i={};this.graphicsLayer.graphics.map(r=>{var n;const o=r.geometry,c=this.getGraphicPoint(o,!1);t.push({point:c,type:(n=r.attributes)==null?void 0:n.type,attributes:r.attributes})});const s=t;return e.map((r,o)=>{i[r]=t[o]}),{graphics:i,rawData:s}}getIntersectionArea(e,t){const i=Object.keys(e);let s=!1;for(let r=0;r<i.length;r++){const o=i[r],c=e[o];if(x(d.polygon(t),d.polygon(c))){s=o;break}}return s}filterData(e){const t=w(e);return t.length>0&&t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&t.pop(),t}getGraphicPoint(e,t=!0){let i=e;this.viewer.spatialReference.isWebMercator&&(i=g.webMercatorToGeographic(e));let s;if(e.type==="point")s={type:e.type,x:i.x,y:i.y};else if(e.type==="polyline"){s={type:e.type,paths:[]},i.paths.forEach(n=>{let h=n;t&&(h=this.filterData(n)),h.forEach(p=>{s.paths.push(p)})});const r={x:s.paths[0][0],y:s.paths[0][1]},o={x:s.paths[s.paths.length-1][0],y:s.paths[s.paths.length-1][1]},c=this.getAngle(r,o);s.angle=c}else e.type==="polygon"&&(s={type:e.type,rings:[]},i.rings.forEach(r=>{let o=r;t&&(o=this.filterData(r)),o.forEach(c=>{s.rings.push(c)})}));return s}close(){this.sketch.visible=!1}show(){this.sketch.visible=!0}removeAll(){this.graphicsLayer.removeAll()}getAngle(e,t){const i=t.x-e.x,s=t.y-e.y;return Math.atan2(s,i)*180/Math.PI}getShiftLine(e,t,i="meters"){const s=e,r=-t;return V.offset(s,r,i)}setShiftLine(e,t="meters",i){i||(i={type:"simple-line",color:[0,0,255],width:2}),this.removeShiftLine(),this.graphicsLayer.graphics.map(s=>{const r=s.geometry,o=s.attributes;if((r==null?void 0:r.type)==="polyline"&&(o==null?void 0:o.type)==="draw"){const c=o.id,n=this.getShiftLine(r,e,t),h=new l({geometry:n,symbol:i,attributes:{type:"shiftLine",id:c}});this.graphicsLayer.add(h)}})}removeShiftLine(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="shiftLine"&&e.push(t)}),this.graphicsLayer.removeMany(e)}removeDraw(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="draw"&&e.push(t)}),this.graphicsLayer.removeMany(e)}addGraphic(e,t={type:"simple-line",color:[0,0,255],width:2},i){const s=new l({geometry:e,symbol:t,attributes:i});this.graphicsLayer.add(s)}getDirection(e,t){const i=t.x-e.x,s=t.y-e.y,o=Math.atan2(s,i)*180/Math.PI;return o>=-45&&o<=45?0:o>45&&o<=135?1:o>135||o<=-135?2:3}findLayerById(e){return this.viewer.map.findLayerById(e)}findShiftLineGraphicsById(e){return this.graphicsLayer.graphics.find(i=>i.attributes.id===e&&i.attributes.type==="shiftLine")}remove(e){this.graphicsLayer.remove(e)}setMaxAllowedGraphics(e){this.options.maxAllowedGraphics=e===0?void 0:e}deepClone(e){}destroy(){var e,t;this.viewer.map.remove(this.graphicsLayer),this.viewer.map.remove(this.TextGraphicsLayer),(e=this.sketch)==null||e.destroy(),(t=this.sketchViewModel)==null||t.destroy()}}exports.default=D;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/geometry/geometryEngine.js"),P=require("@arcgis/core/geometry/support/webMercatorUtils.js"),l=require("@arcgis/core/Graphic"),d=require("@arcgis/core/layers/GraphicsLayer"),G=require("@arcgis/core/widgets/Sketch"),S=require("@arcgis/core/widgets/Sketch/SketchViewModel"),k=require("@arcgis/core/geometry/Polygon.js"),M=require("@arcgis/core/geometry/Polyline.js"),A=require("@turf/helpers"),x=require("@turf/intersect"),v=require("uuid"),E=require("../stores/index.js");function f(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const V=f(b),g=f(P),u=f(A);function w(a,e=[]){if(a===null||typeof a!="object")return a;if(Object.prototype.toString.call(a)==="[object Date]")return new Date(a);if(Object.prototype.toString.call(a)==="[object RegExp]")return new RegExp(a);if(Object.prototype.toString.call(a)==="[object Error]")return new Error(a);const t=e.filter(s=>s.original===a)[0];if(t)return t.copy;const i=Array.isArray(a)?[]:{};return e.push({original:a,copy:i}),Object.keys(a).forEach(s=>{i[s]=w(a[s],e)}),i}const O={maxAllowedGraphics:0,GraphicsLayer:{},sketchVisibleElements:{},sketchPosition:"top-right",defaultSketchVisible:!0,sketchViewModelItemSymbol:{}},m={type:"simple-line",color:"#556DEA",width:2},y={type:"simple-fill",color:[227,139,79,.4],outline:{color:[255,255,255],width:1}};class D{constructor(e,t){this.viewer=e,this.options={...O,...t},this.graphicsLayer=new d({...this.options.GraphicsLayer}),this.TextGraphicsLayer=new d,this.viewer.map.layers.add(this.graphicsLayer),this.viewer.map.layers.add(this.TextGraphicsLayer),this.init()}init(){this.sketchViewModel=new S({layer:this.graphicsLayer,view:this.viewer,updateOnGraphicClick:!0,polylineSymbol:m,polygonSymbol:y,...this.options.sketchViewModelItemSymbol});const e=this.findLayerById("TrafficMarkings"),t=[];e&&t.push({layer:e,enabled:!0}),this.sketch=new G({view:this.viewer,viewModel:this.sketchViewModel,layer:this.graphicsLayer,visible:this.options.defaultSketchVisible,creationMode:this.options.creationMode||"single",snappingOptions:{enabled:!0,featureSources:t}}),this.sketch.visibleElements={...this.options.sketchVisibleElements},this.viewer.ui.add(this.sketch,this.options.sketchPosition);const i=E.default.useAppDataStore;this.sketch.on("create",s=>{s.state==="complete"?i.isSketching=!1:s.state==="start"&&(i.isSketching=!0)})}initPoint(e,t="all",i=!1){if(!e)return;const{crossArea:s,sectionArea:r}=e;if(s&&(t=="crossArea"||t=="all")){const o=this.initCrossArea(s);this.graphicsLayer.add(o)}if(r&&(t=="sectionArea"||t=="all")){const o=this.initSectionArea(r,i);this.graphicsLayer.addMany(o)}}initEntranceFusionZone(e){const t=[];e.map(i=>{t.push(this.createPolygonGraphic(i,y,{}))}),this.graphicsLayer.addMany(t)}initCrossArea(e){return this.createPolygonGraphic(e,y,{})}initSectionArea(e,t=!1){const i=[],s={type:"simple-line",color:[0,0,255],width:2};return Object.keys(e).map(r=>{const o=e[r][0],c=e[r][1];t&&(o.reverse(),c.reverse());const n=v.v4(),h=this.createPolylineGraphic(o,m,{type:"draw",id:n}),p=this.createPolylineGraphic(c,s,{type:"shiftLine",id:n});i.push(h,p)}),i}createPolylineGraphic(e,t,i){const s=new M({paths:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}createPolygonGraphic(e,t,i){const s=new k({rings:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}on(e){const t=this;this.sketchViewModel.on("create",function(i){var r,o,c;const s=t.graphicsLayer.graphics;if((r=t.options)!=null&&r.maxAllowedGraphics&&s.length>((o=t.options)==null?void 0:o.maxAllowedGraphics)){t.graphicsLayer.remove(i.graphic),console.log("已达到最大图形数量,无法继续绘制!");return}if(i.state==="complete"&&((c=i.graphic)!=null&&c.geometry)){const n=i.graphic.geometry;i.graphic.setAttribute("type","draw"),i.graphic.setAttribute("id",new Date().getTime());const h=t.getGraphicPoint(n);e&&e("create",h,i)}}),this.sketchViewModel.on("update",function(i){if(i.aborted){const s=i.graphics[0];t.graphicsLayer.remove(s);return}if(i.state==="complete"&&i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("update",o,i)}}),this.sketchViewModel.on("delete",function(i){if(console.log("delete",i,t.graphicsLayer.graphics),i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("delete",o,i)}})}graphicPoint(){const e=[];return this.graphicsLayer.graphics.map(t=>{var r;const i=t.geometry,s=this.getGraphicPoint(i);e.push({point:s,type:(r=t.attributes)==null?void 0:r.type,attributes:t.attributes})}),e}getEntranceRoad(){const e={},t=this.graphicPoint().filter(n=>n.point.type==="polyline");if(console.log("🚀 ~ file: sketchView.ts:378 ~ SketchView ~ getEntranceRoad ~ graphics:",t),!t.length)return!1;const i=t.filter(n=>n.type=="draw"),s=t.filter(n=>n.type=="shiftLine");if(s.length==0)throw"未绘制平移!";if(i.length!=s.length)throw"绘制的线和平移的线数量不一致!";const r=i.sort((n,h)=>n.point.angle-h.point.angle),o=r.findIndex(n=>n.point.angle>135);return[...r.slice(o),...r.slice(0,o).reverse()].map((n,h)=>{const p=s.find(L=>L.attributes.id==n.attributes.id);if(!p)throw"绘制的线和平移的线不匹配!";console.log("🚀 ~ file: sketchView.ts:393 ~ SketchView ~ getEntranceRoad ~ m:",n,p),e[h+1]={0:[n.point.paths[0],n.point.paths[n.point.paths.length-1]],1:[p.point.paths[0],p.point.paths[p.point.paths.length-1]]}}),e}getEntranceFusionZone(e){const t=[],i={};this.graphicsLayer.graphics.map(r=>{var n;const o=r.geometry,c=this.getGraphicPoint(o,!1);t.push({point:c,type:(n=r.attributes)==null?void 0:n.type,attributes:r.attributes})});const s=t;return e.map((r,o)=>{i[r]=t[o]}),{graphics:i,rawData:s}}getIntersectionArea(e,t){const i=Object.keys(e);let s=!1;for(let r=0;r<i.length;r++){const o=i[r],c=e[o];if(x(u.polygon(t),u.polygon(c))){s=o;break}}return s}filterData(e){const t=w(e);return t.length>0&&t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&t.pop(),t}getGraphicPoint(e,t=!0){let i=e;this.viewer.spatialReference.isWebMercator&&(i=g.webMercatorToGeographic(e));let s;if(e.type==="point")s={type:e.type,x:i.x,y:i.y};else if(e.type==="polyline"){s={type:e.type,paths:[]},i.paths.forEach(n=>{let h=n;t&&(h=this.filterData(n)),h.forEach(p=>{s.paths.push(p)})});const r={x:s.paths[0][0],y:s.paths[0][1]},o={x:s.paths[s.paths.length-1][0],y:s.paths[s.paths.length-1][1]},c=this.getAngle(r,o);s.angle=c}else e.type==="polygon"&&(s={type:e.type,rings:[]},i.rings.forEach(r=>{let o=r;t&&(o=this.filterData(r)),o.forEach(c=>{s.rings.push(c)})}));return s}close(){this.sketch.visible=!1}show(){this.sketch.visible=!0}removeAll(){this.graphicsLayer.removeAll()}getAngle(e,t){const i=t.x-e.x,s=t.y-e.y;return Math.atan2(s,i)*180/Math.PI}getShiftLine(e,t,i="meters"){const s=e,r=-t;return V.offset(s,r,i)}setShiftLine(e,t="meters",i){i||(i={type:"simple-line",color:[0,0,255],width:2}),this.removeShiftLine(),this.graphicsLayer.graphics.map(s=>{const r=s.geometry,o=s.attributes;if((r==null?void 0:r.type)==="polyline"&&(o==null?void 0:o.type)==="draw"){const c=o.id,n=this.getShiftLine(r,e,t),h=new l({geometry:n,symbol:i,attributes:{type:"shiftLine",id:c}});this.graphicsLayer.add(h)}})}removeShiftLine(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="shiftLine"&&e.push(t)}),this.graphicsLayer.removeMany(e)}removeDraw(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="draw"&&e.push(t)}),this.graphicsLayer.removeMany(e)}addGraphic(e,t={type:"simple-line",color:[0,0,255],width:2},i){const s=new l({geometry:e,symbol:t,attributes:i});this.graphicsLayer.add(s)}getDirection(e,t){const i=t.x-e.x,s=t.y-e.y,o=Math.atan2(s,i)*180/Math.PI;return o>=-45&&o<=45?0:o>45&&o<=135?1:o>135||o<=-135?2:3}findLayerById(e){return this.viewer.map.findLayerById(e)}findShiftLineGraphicsById(e){return this.graphicsLayer.graphics.find(i=>i.attributes.id===e&&i.attributes.type==="shiftLine")}remove(e){this.graphicsLayer.remove(e)}setMaxAllowedGraphics(e){this.options.maxAllowedGraphics=e===0?void 0:e}destroy(){var e,t;this.viewer.map.remove(this.graphicsLayer),this.viewer.map.remove(this.TextGraphicsLayer),(e=this.sketch)==null||e.destroy(),(t=this.sketchViewModel)==null||t.destroy()}}exports.default=D;
@@ -229,8 +229,8 @@ export interface IUnselectSumoParams {
229
229
  }
230
230
  export interface ISplitOpenDriveLaneParams {
231
231
  id: string;
232
- start: number;
233
- end: number;
232
+ start?: number;
233
+ end?: number;
234
234
  }
235
235
  export interface IJunctionTableData {
236
236
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.144",
3
+ "version": "1.0.146",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [
@@ -30,6 +30,7 @@
30
30
  "@turf/helpers": "^6.5.0",
31
31
  "@turf/intersect": "^6.5.0",
32
32
  "@turf/line-intersect": "^7.0.0",
33
+ "@turf/line-slice-along": "^7.1.0",
33
34
  "@turf/turf": "6.5.0",
34
35
  "@types/pako": "^2.0.0",
35
36
  "@vitest/coverage-c8": "^0.29.2",