gisviewer-vue3-arcgis 1.0.127 → 1.0.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- class i {
1
+ class r {
2
2
  constructor(t) {
3
3
  this.crosses = [], this.subDistricts = [], this.areaColor = [
4
4
  Math.floor(Math.random() * 255),
@@ -7,15 +7,15 @@ class i {
7
7
  ], this.crossCount = 0, this.subDistrictCount = 0, this.id = t.id, this.name = t.name, this.parentId = t.parentId;
8
8
  for (const s of t.children)
9
9
  if (s.children) {
10
- const o = new i(s);
10
+ const o = new r(s);
11
11
  o.areaColor = this.areaColor, this.subDistricts.push(o), this.subDistrictCount++, this.crossCount += o.crossCount;
12
12
  } else {
13
13
  const o = {
14
14
  id: s.id,
15
15
  name: s.name,
16
16
  parentId: s.parentId,
17
- latitude: s.latitude,
18
- longitude: s.longitude
17
+ latitude: Number(s.latitude),
18
+ longitude: Number(s.longitude)
19
19
  };
20
20
  this.crosses.push(o), this.crossCount++;
21
21
  }
@@ -30,5 +30,5 @@ class i {
30
30
  }
31
31
  }
32
32
  export {
33
- i as default
33
+ r as default
34
34
  };
@@ -11,5 +11,11 @@ export default class SignalControlAreaController {
11
11
  locateSignalControlArea(params: {
12
12
  id: string;
13
13
  }): IResult;
14
+ /**
15
+ * 绘制区控与子区
16
+ * @param districtController
17
+ * @param isDistrict 是否是区控
18
+ * @returns
19
+ */
14
20
  private drawArea;
15
21
  }
@@ -1,9 +1,10 @@
1
1
  import n from "@arcgis/core/Graphic";
2
2
  import s from "@arcgis/core/layers/GraphicsLayer";
3
- import p from "@turf/convex";
3
+ import p from "@turf/buffer";
4
+ import f from "@turf/convex";
4
5
  import * as c from "@turf/helpers";
5
- import u from "./district-controller.mjs";
6
- class C {
6
+ import y from "./district-controller.mjs";
7
+ class v {
7
8
  constructor(e) {
8
9
  this.view = e, this.view.popup.visibleElements = {
9
10
  closeButton: !0,
@@ -29,7 +30,7 @@ class C {
29
30
  }
30
31
  showSignalControlArea(e) {
31
32
  for (const t of e) {
32
- const r = new u(t);
33
+ const r = new y(t);
33
34
  this.drawArea(r, !0);
34
35
  }
35
36
  return { status: 0, message: "ok" };
@@ -56,16 +57,30 @@ class C {
56
57
  }
57
58
  return { status: 1, message: "未找到" };
58
59
  }
60
+ /**
61
+ * 绘制区控与子区
62
+ * @param districtController
63
+ * @param isDistrict 是否是区控
64
+ * @returns
65
+ */
59
66
  drawArea(e, t) {
60
67
  const r = e.getAllCrossCoordinates();
61
68
  if (r.length > 2) {
62
- const a = c.featureCollection(
63
- r.map((m) => c.point(m))
64
- ), o = p(a);
65
- if (!o)
69
+ const o = c.featureCollection(
70
+ r.map((u) => c.point(u))
71
+ ), i = f(o);
72
+ if (!i)
66
73
  return;
67
- let i;
68
- t ? i = [
74
+ const d = p(
75
+ i.geometry,
76
+ // 区控面积更大,需要更大的缓冲半径
77
+ t ? 200 : 20,
78
+ {
79
+ units: "meters"
80
+ }
81
+ );
82
+ let a;
83
+ t ? a = [
69
84
  {
70
85
  fieldName: "id",
71
86
  label: "区控编号"
@@ -78,7 +93,7 @@ class C {
78
93
  fieldName: "subDistrictCount",
79
94
  label: "子区数量"
80
95
  }
81
- ] : i = [
96
+ ] : a = [
82
97
  {
83
98
  fieldName: "parentId",
84
99
  label: "区控编号"
@@ -95,7 +110,7 @@ class C {
95
110
  const l = new n({
96
111
  geometry: {
97
112
  type: "polygon",
98
- rings: o.geometry.coordinates
113
+ rings: d.geometry.coordinates
99
114
  },
100
115
  symbol: {
101
116
  type: "simple-fill",
@@ -118,20 +133,20 @@ class C {
118
133
  content: [
119
134
  {
120
135
  type: "fields",
121
- fieldInfos: i
136
+ fieldInfos: a
122
137
  }
123
138
  ]
124
139
  }
125
140
  });
126
141
  t ? this.districtControllerLayer.add(l) : this.subDistrictControllerLayer.add(l);
127
142
  }
128
- for (const a of e.subDistricts)
129
- this.drawArea(a, !1);
130
- const d = e.crosses.map((a) => new n({
143
+ for (const o of e.subDistricts)
144
+ this.drawArea(o, !1);
145
+ const m = e.crosses.map((o) => new n({
131
146
  geometry: {
132
147
  type: "point",
133
- x: a.longitude,
134
- y: a.latitude
148
+ x: o.longitude,
149
+ y: o.latitude
135
150
  },
136
151
  symbol: {
137
152
  type: "simple-marker",
@@ -140,21 +155,17 @@ class C {
140
155
  },
141
156
  attributes: {
142
157
  type: "cross",
143
- id: a.id,
144
- name: a.name,
158
+ id: o.id,
159
+ name: o.name,
145
160
  districtId: t ? e.id : e.parentId,
146
161
  subDistrictId: t ? "" : e.id
147
162
  },
148
163
  popupTemplate: {
149
- title: a.name,
164
+ title: o.name,
150
165
  content: [
151
166
  {
152
167
  type: "fields",
153
168
  fieldInfos: [
154
- {
155
- fieldName: "id",
156
- label: "路口编号"
157
- },
158
169
  {
159
170
  fieldName: "districtId",
160
171
  label: "区控编号"
@@ -162,15 +173,19 @@ class C {
162
173
  {
163
174
  fieldName: "subDistrictId",
164
175
  label: "子区编号"
176
+ },
177
+ {
178
+ fieldName: "id",
179
+ label: "路口编号"
165
180
  }
166
181
  ]
167
182
  }
168
183
  ]
169
184
  }
170
185
  }));
171
- this.crossLayer.addMany(d);
186
+ this.crossLayer.addMany(m);
172
187
  }
173
188
  }
174
189
  export {
175
- C as default
190
+ v as default
176
191
  };
@@ -223,6 +223,10 @@ export interface IFindSumoParams {
223
223
  id: string;
224
224
  flash?: boolean;
225
225
  }
226
+ export interface IUnselectSumoParams {
227
+ type: string;
228
+ id?: string;
229
+ }
226
230
  export interface ISplitOpenDriveLaneParams {
227
231
  id: string;
228
232
  start: number;
@@ -1,6 +1,6 @@
1
1
  import MapView from '@arcgis/core/views/MapView';
2
2
  import SceneView from '@arcgis/core/views/SceneView';
3
- import { IFindSumoParams, ILaneNumberParams, ILayerVisibleParams, ILookAtParams, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams, IStartCrossBufferParam, IToggleTrafficInfoParams } from '../types';
3
+ import { IFindSumoParams, ILaneNumberParams, ILayerVisibleParams, ILookAtParams, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams, IStartCrossBufferParam, IToggleTrafficInfoParams, IUnselectSumoParams } from '../types';
4
4
  import HoloFlow from './utils/holo-flow';
5
5
  import MapInitializer from './utils/map-initializer';
6
6
  import OpenDriveRenderer from './utils/open-drive-renderer';
@@ -73,6 +73,9 @@ declare const _sfc_main: import("vue").DefineComponent<{
73
73
  showOpenDriveFromFile: (params: IShowOpenDriveFromFileParams) => Promise<import("../types").IResult>;
74
74
  clearOpenDrive: () => Promise<void>;
75
75
  findSumoInOpenDrive: (params: IFindSumoParams) => Promise<import("../types").IResult>;
76
+ selectSumoInOpenDrive: (params: IFindSumoParams) => Promise<import("../types").IResult>;
77
+ unselectSumoInOpenDrive: (params?: IUnselectSumoParams | undefined) => Promise<import("../types").IResult>;
78
+ getSumoInfo: (params: IFindSumoParams) => Promise<import("../types").IResult>;
76
79
  splitOpenDriveLane: (params: ISplitOpenDriveLaneParams) => Promise<import("../types").IResult>;
77
80
  showSignalControlArea: (params: any) => import("../types").IResult;
78
81
  clearSignalControlArea: () => void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),y=require("./stores/index.js");require("./style/index.css");const ge=require("./utils/holo-flow/index.js"),we=require("./utils/map-initializer.js"),O=require("./utils/open-drive-renderer/index.js"),ve=require("./utils/overlay.js"),ye=require("./utils/queue-length.js"),k=require("./utils/road-config-tool/index.js"),he=require("./utils/signal-control-area-controller/index.js"),Ce=require("./utils/traffic-flow.js"),Oe={class:"gis-viewer"},ke={style:{position:"absolute",bottom:"10px",left:"10px"}},Se=n.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(S,{expose:T,emit:L}){const p=n.ref(null);let c,i,o,r,s,a,d,t,l;const f=n.ref(!1);n.onMounted(async()=>{if(y.registerStore(),!p.value)return;document.addEventListener("keydown",m=>{m.ctrlKey&&m.key==="i"&&(f.value=!f.value)});const e=n.getCurrentInstance(),{$gisviewerAssetsRoot:u}=e.appContext.config.globalProperties,C=await(await fetch(h.config)).json();C.assetsRoot=h.assetsRoot||u;const pe=y.default.useAppDataStore;pe.mapConfig=C,i=new we.default,c=await i.initialize({container:p.value,markerClickCallback:(m,w,v,fe)=>{g("markerClick",m,w,v,fe)},mapClickCallback:(m,w,v)=>{g("mapClick",m,w,v)}}),s=new ge.default(c),await s.init(),g("mapLoaded")});const b=n.computed(()=>c),A=()=>{const e=y.default.useAppDataStore;e.saveTrackLog=!0},D=()=>{s.downloadTrackLog()},I=async e=>await i.setMapCenter(e),q=async e=>await i.setMapCamera(e),_=async e=>await i.lookAt(e),x=e=>i.setLayerVisibility(e),V=(e,u)=>i.requestCoordinateTransform(e,u),M=e=>{i.cancelCoordinateTransform(e)},N=e=>{i.setMapZoomRange(e)},F=e=>(o||(o=new k.default(c)),o.showLaneNumber(e)),B=()=>{o==null||o.clearLaneNumber()},E=async e=>(o||(o=new k.default(c)),await o.initializeSearch(e)),H=async()=>o==null?void 0:o.calCrossIndicatorArea(),j=async()=>{},z=async(e,u)=>{r||(r=new Ce.default(c)),r.connectTrafficFlow(e,u)},P=()=>{r==null||r.disconnectTrafficFlow()},Q=e=>{s.handleVehicleTraceData(e)},R=()=>{s.clearHoloTrace()},Z=e=>{s.setInterpolate(e)},K=async e=>{await s.handleSignalData(e)},G=()=>{s.clearHoloSignal()},J=e=>{r==null||r.toggleTrafficInfo(e),s.toggleTrafficInfo(e)},U=e=>{s.togglePause(e)},W=e=>{r==null||r.toggleTrafficObject(e),s.toggleTrafficObject(e)},X=e=>{s.updatePanelContent(e)},Y=async e=>(a||(a=new ve.default(c)),a.addOverlays(e)),$=e=>a==null?void 0:a.removeOverlaysByType(e),ee=e=>a==null?void 0:a.removeOverlaysById(e),te=()=>a==null?void 0:a.removeAllOverlays(),ae=()=>{a==null||a.showAllOverlays()},ne=e=>{d||(d=new ye.default(c)),d.updateQueueLength(e)},oe=()=>{d==null||d.removeQueueLength()},re=async(e,u)=>(t||(t=new O.default(c)),await t.showOpenDriveFromServer(e,u)),se=async e=>(t||(t=new O.default(c)),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?await(t==null?void 0:t.splitLane(e)):{status:-1,message:"未加载OpenDrive地图"},ue=e=>(l||(l=new he.default(c)),l.showSignalControlArea(e)),de=()=>{l==null||l.clearSignalControlArea()},me=e=>l?l.locateSignalControlArea(e):{status:-1,message:"未加载信号控制区"},h=S,g=L;return T({mapViewer:b,setLayerVisibility:x,setMapCenter:I,lookAt:_,setMapCamera:q,setMapZoomRange:N,requestCoordinateTransform:V,cancelCoordinateTransform:M,addOverlays:Y,showAllOverlays:ae,removeOverlaysByType:$,removeOverlaysById:ee,removeAllOverlays:te,showLaneNumber:F,clearLaneNumber:B,initializeAreaTool:E,calCrossIndicatorArea:H,calRoadIndicatorArea:j,connectCarFlow:z,disconnectCarFlow:P,handleHoloVehicleTraceData:Q,clearHoloTrace:R,handleHoloSignalData:K,clearHoloSignal:G,setInterpolate:Z,toggleTrafficInfo:J,toggleTrafficObject:W,toggleVehicleInfo:X,togglePause:U,updateQueueLength:ne,removeQueueLength:oe,showOpenDriveFromServer:re,showOpenDriveFromFile:se,clearOpenDrive:ce,findSumoInOpenDrive:ie,splitOpenDriveLane:le,showSignalControlArea:ue,clearSignalControlArea:de,locateSignalControlArea:me}),(e,u)=>(n.openBlock(),n.createElementBlock("div",Oe,[n.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:p},[n.withDirectives(n.createElementVNode("div",ke,[n.createElementVNode("button",{style:{"margin-right":"10px"},onClick:A}," 开始记录 "),n.createElementVNode("button",{onClick:D},"下载日志")],512),[[n.vShow,f.value]])],512)]))}});exports.default=Se;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),y=require("./stores/index.js");require("./style/index.css");const ye=require("./utils/holo-flow/index.js"),he=require("./utils/map-initializer.js"),O=require("./utils/open-drive-renderer/index.js"),Ce=require("./utils/overlay.js"),Oe=require("./utils/queue-length.js"),S=require("./utils/road-config-tool/index.js"),Se=require("./utils/signal-control-area-controller/index.js"),ke=require("./utils/traffic-flow.js"),De={class:"gis-viewer"},Te={style:{position:"absolute",bottom:"10px",left:"10px"}},Le=a.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(k,{expose:D,emit:T}){const d=a.ref(null);let c,i,r,o,s,n,m,t,l;const f=a.ref(!1);a.onMounted(async()=>{if(y.registerStore(),!d.value)return;document.addEventListener("keydown",p=>{p.ctrlKey&&p.key==="i"&&(f.value=!f.value)});const e=a.getCurrentInstance(),{$gisviewerAssetsRoot:u}=e.appContext.config.globalProperties,C=await(await fetch(h.config)).json();C.assetsRoot=h.assetsRoot||u;const we=y.default.useAppDataStore;we.mapConfig=C,i=new he.default,c=await i.initialize({container:d.value,markerClickCallback:(p,w,v,ve)=>{g("markerClick",p,w,v,ve)},mapClickCallback:(p,w,v)=>{g("mapClick",p,w,v)}}),s=new ye.default(c),await s.init(),g("mapLoaded")});const L=a.computed(()=>c),I=()=>{const e=y.default.useAppDataStore;e.saveTrackLog=!0},b=()=>{s.downloadTrackLog()},A=async e=>await i.setMapCenter(e),q=async e=>await i.setMapCamera(e),_=async e=>await i.lookAt(e),x=e=>i.setLayerVisibility(e),V=(e,u)=>i.requestCoordinateTransform(e,u),M=e=>{i.cancelCoordinateTransform(e)},N=e=>{i.setMapZoomRange(e)},F=e=>(r||(r=new S.default(c)),r.showLaneNumber(e)),B=()=>{r==null||r.clearLaneNumber()},E=async e=>(r||(r=new S.default(c)),await r.initializeSearch(e)),H=async()=>r==null?void 0:r.calCrossIndicatorArea(),j=async()=>{},z=async(e,u)=>{o||(o=new ke.default(c)),o.connectTrafficFlow(e,u)},P=()=>{o==null||o.disconnectTrafficFlow()},Q=e=>{s.handleVehicleTraceData(e)},R=()=>{s.clearHoloTrace()},Z=e=>{s.setInterpolate(e)},K=async e=>{await s.handleSignalData(e)},G=()=>{s.clearHoloSignal()},J=e=>{o==null||o.toggleTrafficInfo(e),s.toggleTrafficInfo(e)},U=e=>{s.togglePause(e)},W=e=>{o==null||o.toggleTrafficObject(e),s.toggleTrafficObject(e)},X=e=>{s.updatePanelContent(e)},Y=async e=>(n||(n=new Ce.default(c)),n.addOverlays(e)),$=e=>n==null?void 0:n.removeOverlaysByType(e),ee=e=>n==null?void 0:n.removeOverlaysById(e),te=()=>n==null?void 0:n.removeAllOverlays(),ne=()=>{n==null||n.showAllOverlays()},ae=e=>{m||(m=new Oe.default(c)),m.updateQueueLength(e)},re=()=>{m==null||m.removeQueueLength()},oe=async(e,u)=>(t||(t=new O.default(c)),await t.showOpenDriveFromServer(e,u)),se=async e=>(t||(t=new O.default(c)),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地图"},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地图"},de=e=>(l||(l=new Se.default(c)),l.showSignalControlArea(e)),fe=()=>{l==null||l.clearSignalControlArea()},ge=e=>l?l.locateSignalControlArea(e):{status:-1,message:"未加载信号控制区"},h=k,g=T;return D({mapViewer:L,setLayerVisibility:x,setMapCenter:A,lookAt:_,setMapCamera:q,setMapZoomRange:N,requestCoordinateTransform:V,cancelCoordinateTransform:M,addOverlays:Y,showAllOverlays:ne,removeOverlaysByType:$,removeOverlaysById:ee,removeAllOverlays:te,showLaneNumber:F,clearLaneNumber:B,initializeAreaTool:E,calCrossIndicatorArea:H,calRoadIndicatorArea:j,connectCarFlow:z,disconnectCarFlow:P,handleHoloVehicleTraceData:Q,clearHoloTrace:R,handleHoloSignalData:K,clearHoloSignal:G,setInterpolate:Z,toggleTrafficInfo:J,toggleTrafficObject:W,toggleVehicleInfo:X,togglePause:U,updateQueueLength:ae,removeQueueLength:re,showOpenDriveFromServer:oe,showOpenDriveFromFile:se,clearOpenDrive:ce,findSumoInOpenDrive:ie,selectSumoInOpenDrive:le,unselectSumoInOpenDrive:ue,getSumoInfo:me,splitOpenDriveLane:pe,showSignalControlArea:de,clearSignalControlArea:fe,locateSignalControlArea:ge}),(e,u)=>(a.openBlock(),a.createElementBlock("div",De,[a.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:d},[a.withDirectives(a.createElementVNode("div",Te,[a.createElementVNode("button",{style:{"margin-right":"10px"},onClick:I}," 开始记录 "),a.createElementVNode("button",{onClick:b},"下载日志")],512),[[a.vShow,f.value]])],512)]))}});exports.default=Le;
@@ -62,6 +62,9 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
62
62
  showOpenDriveFromFile: (params: import("../types").IShowOpenDriveFromFileParams) => Promise<import("../types").IResult>;
63
63
  clearOpenDrive: () => Promise<void>;
64
64
  findSumoInOpenDrive: (params: import("../types").IFindSumoParams) => Promise<import("../types").IResult>;
65
+ selectSumoInOpenDrive: (params: import("../types").IFindSumoParams) => Promise<import("../types").IResult>;
66
+ unselectSumoInOpenDrive: (params?: import("../types").IUnselectSumoParams | undefined) => Promise<import("../types").IResult>;
67
+ getSumoInfo: (params: import("../types").IFindSumoParams) => Promise<import("../types").IResult>;
65
68
  splitOpenDriveLane: (params: import("../types").ISplitOpenDriveLaneParams) => Promise<import("../types").IResult>;
66
69
  showSignalControlArea: (params: any) => import("../types").IResult;
67
70
  clearSignalControlArea: () => void;
@@ -1,4 +1,4 @@
1
- import { IFindSumoParams, IResult, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams } from '../../../types';
1
+ import { IFindSumoParams, IResult, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams, IUnselectSumoParams } from '../../../types';
2
2
  export default class OpenDriveRenderer {
3
3
  private static instance;
4
4
  static getInstance(view: __esri.MapView | __esri.SceneView): OpenDriveRenderer;
@@ -19,6 +19,11 @@ export default class OpenDriveRenderer {
19
19
  private openDriveServer;
20
20
  private openDriveClickCallback;
21
21
  private makeMd5FromFile;
22
+ /**
23
+ * 从本地文件/网络文件显示OpenDrive内容
24
+ * @param params
25
+ * @returns
26
+ */
22
27
  showOpenDriveFromFile(params: IShowOpenDriveFromFileParams): Promise<IResult>;
23
28
  /**
24
29
  * 从服务器载入OpenDrive文件解析结果并显示
@@ -26,7 +31,19 @@ export default class OpenDriveRenderer {
26
31
  * @param projectName
27
32
  */
28
33
  showOpenDriveFromServer(server: string, projectName: string): Promise<IResult>;
34
+ /**
35
+ * 显示所有车道
36
+ * @param roads 道路列表
37
+ * @param showJunctionLane 是否显示路口内车道
38
+ * @param showRoadName 是否显示道路名称
39
+ * @returns
40
+ */
29
41
  private showAllLanes;
42
+ /**
43
+ * 显示路口
44
+ * @param params
45
+ * @returns
46
+ */
30
47
  private showJunction;
31
48
  private currentSectionCode;
32
49
  private currentJunctionId;
@@ -40,8 +57,19 @@ export default class OpenDriveRenderer {
40
57
  * 监听鼠标点击事件,获取高亮要素的拓扑信息
41
58
  */
42
59
  private monitorMouseClick;
60
+ /**
61
+ * 图标增大动画
62
+ * @param graphic
63
+ * @param targetSize
64
+ */
43
65
  private increasePictureMarkerSize;
66
+ /**
67
+ * 图标缩小动画
68
+ * @param graphic
69
+ * @param targetSize
70
+ */
44
71
  private decreasePictureMarkerSize;
72
+ getSumoInfo(params: IFindSumoParams): Promise<IResult>;
45
73
  /**
46
74
  * 清除OpenDrive内容
47
75
  */
@@ -59,6 +87,22 @@ export default class OpenDriveRenderer {
59
87
  * @returns
60
88
  */
61
89
  private findLane;
90
+ /**
91
+ * graphic渐隐渐显闪烁
92
+ * @param flashGraphic
93
+ */
62
94
  private flashGraphic;
95
+ /**
96
+ * 通过接口取消选中
97
+ * @param params
98
+ * @returns
99
+ */
100
+ unselectSumo(params?: IUnselectSumoParams): IResult;
101
+ /**
102
+ * 通过接口选中
103
+ * @param params
104
+ * @returns
105
+ */
106
+ selectSumo(params: IFindSumoParams): IResult;
63
107
  splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
64
108
  }
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/Graphic"),A=require("@arcgis/core/core/promiseUtils"),$=require("@arcgis/core/geometry"),M=require("@arcgis/core/geometry/geometryEngineAsync"),j=require("@arcgis/core/layers/FeatureLayer"),g=require("@arcgis/core/layers/GraphicsLayer"),w=require("axios"),J=require("md5"),G=require("pako"),C=require("../common-utils.js"),P=require("./wasm-loader.js");function N(p){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const s in p)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(p,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>p[s]})}}return e.default=p,Object.freeze(e)}const O=N(A),S=N(M);class v{constructor(e){this.wasmLoader=P.default.getInstance(),this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={closeButton:!1,collapseButton:!1,actionBar:!1},this.laneLayer=new j({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"}],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 j({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 g({id:"OpenDriveJunction"}),this.sectionLayer=new g({id:"OpenDriveSection"}),this.highlightLayer=new g({id:"OpenDriveHighlight"}),this.flashLayer=new g({id:"OpenDriveFlash"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer])}static getInstance(e){return this.instance||(this.instance=new v(e)),this.instance}async makeMd5FromFile(e){const i=await(await fetch(e)).text();return J(i)}async showOpenDriveFromFile(e){var h,u;this.openDriveClickCallback=e.selectedCallback,this.projectName=await this.makeMd5FromFile(e.file),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const s=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let i;try{i=await w.post(s,{},{params:{url:e.file,projectName:this.projectName}})}catch(y){return{status:-1,message:y.message}}if(i.status!==200)return{status:-1,message:i.statusText};console.time("渲染用时");const a=i.data.result.geoSetting;C.default.setGeoData(a.geoReference,a.offsetX,a.offsetY);let t=i.data.result.json;t.startsWith(window.location.protocol)||(t=`${window.location.protocol}//${e.server}${t}`);const r=await(await fetch(t)).arrayBuffer(),n=G.inflate(r,{to:"string"}),o=JSON.parse(n);await this.showAllLanes(o,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((u=e.options)==null?void 0:u.showRoadName)||!0);const l=i.data.result.junctions;if(this.showJunction(l),e.options&&e.options.centerMap!==!1){const y=C.default.transformPointProjection([0,0]);await this.view.goTo(y)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,s){const i=`http://${e}/api/openDrive/analyzeXodr`,a=await w.get(i,{headers:{projectName:s},params:{analyze:!1,compressed:!0}});if(a.status!==200)throw new Error(`OpenDriveRenderer: ${a.statusText}`);let t=a.data.result.json;t.startsWith(window.location.protocol)||(t=`${window.location.protocol}//${e}${t}`);const r=await(await fetch(t)).arrayBuffer(),n=G.inflate(r,{to:"string"}),o=JSON.parse(n);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,s,i){const a=await this.laneLayer.queryFeatures();return a.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:a.features}),this.roadNameLayer.visible=i,new Promise(t=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const o of e){if(!s&&o.junction!=="-1")continue;const{id:l,refLine:h}=o;let u=o.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const y=new d({geometry:{type:"polyline",paths:[h]},attributes:{ObjectID:c++,roadId:l,roadName:u}});this.allRefLineGraphics.push(y);for(const I of o.laneSections){const L=Number(I.id);for(const f of I.lanePaths){const m=Number(f.id);if(m===0)continue;const F=f.type,b=f.innerPath.concat(f.outerPath.reverse());if(b.length<=3){console.warn(`lane ${m} has less than 3 points`);continue}b.push(f.innerPath[0]);const D=new $.Polygon({rings:[b]});if(D){const k=new d({geometry:D,attributes:{ObjectID:c++,id:`${l}+${L}+${m}`,roadId:l,roadName:o.name,sectionId:L,laneId:m,type:F,sumoId:""}});this.allLaneGraphics.push(k),r.push(k)}}}}const n=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const o=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:o})}if(this.allRefLineGraphics.length>0){const o=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:o})}}else clearInterval(n),t()},10)})}showJunction(e){const s=[];for(const i of e){i.nodeType=i.type;const a=new d({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}});s.push(a)}this.junctionLayer.addMany(s)}monitorMouseMove(){const e=O.debounce(async s=>{var c;const a=(c=(await this.view.hitTest(s,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(a.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const t=a[0];if(this.hitGraphic=t.graphic,t.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;if(r===this.currentSectionCode||this.sectionLayer.graphics.findIndex(h=>h.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const o=this.allLaneGraphics.filter(h=>`${h.attributes.roadId}+${h.attributes.sectionId}`===r),l=await S.union(o.map(h=>h.geometry));this.highlightGraphic=new d({geometry:l,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}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic)}else if(t.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r;const n=this.hitGraphic.getAttribute("name"),o=this.hitGraphic.getAttribute("crossId");this.view.popup.open({title:n,content:`<table>
2
- <tr><td>路口编号</td><td>${r}</td></tr>
3
- <tr><td>信号机编号</td><td>${o||"无信控"}</td></tr>
4
- </table>`,location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async s=>{e(s).catch(()=>{})})}monitorMouseClick(){const e=O.debounce(async s=>{var n;const a=(n=(await this.view.hitTest(s,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:n.filter(o=>o.type==="graphic");if(a.length===0)return;const t=a[0].graphic,c=t.getAttribute("type"),r=t.getAttribute("id");if(c==="OpenDriveJunction")if(t.getAttribute("selected")===!1){const o=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await w.get(o,{params:{id:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:l.data.result}),t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),t.setAttribute("selected",!1);const o=t.getAttribute("crossId");t.symbol.url=o?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}else if(c==="OpenDriveSection")if(t.getAttribute("selected"))this.sectionLayer.remove(t),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:r,details:void 0});else{this.highlightLayer.remove(t),this.sectionLayer.add(t),t.setAttribute("selected",!0);const o=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await w.get(o,{params:{id:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:r,details:l.data.result})}});this.mouseClickHandler=this.view.on("immediate-click",async s=>{e(s).catch(()=>{})})}increasePictureMarkerSize(e,s){const i=setInterval(()=>{const a=e.symbol,t=a.width;t<s?e.symbol={type:"picture-marker",url:a.url,width:t+1,height:t+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,s){const i=setInterval(()=>{const a=e.symbol,t=a.width;t>s?e.symbol={type:"picture-marker",url:a.url,width:t-1,height:t-1}:clearInterval(i)},20)}async clearOpenDrive(){var s,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.wasmLoader.clear(),(s=this.mouseMoveHandler)==null||s.remove(),(i=this.mouseClickHandler)==null||i.remove()}async findSumo(e){const{type:s,id:i}=e,a=e.flash===void 0?!0:e.flash;if(s==="junction")return await this.findJunction(i,a);if(s==="edge"){const t=i.split("+");if(t.length>2)return{status:-1,message:"id格式错误"};const c=t.length===2?Number(t[1]):void 0,r=t[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const n=r[0],o=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:n,segmentId:o,laneId:c,flash:a})}else return{status:-1,message:"未知类型"}}async findJunction(e,s){const i=this.junctionLayer.graphics.find(a=>a.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(s){const a=new d({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(a)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:s,segmentId:i,laneId:a}=e;s.startsWith("-")&&(s=s.slice(1));let t=this.allLaneGraphics.filter(n=>n.attributes.roadId===s);if(t.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const n=[];if(t.forEach(o=>{const l=Number(o.attributes.sectionId);n.indexOf(l)===-1&&n.push(l)}),n.sort((o,l)=>o-l),i>n.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=n[i],t=t.filter(o=>Number(o.attributes.sectionId)===i)}if(a!==void 0){const n=[];if(t.forEach(o=>{const l=Number(o.attributes.laneId);n.indexOf(l)===-1&&n.push(l)}),n.sort((o,l)=>o-l),a>n.length-1)return{status:-1,message:"未找到。请检查车道编号"};a=n[a],t=t.filter(o=>Number(o.attributes.laneId)===a)}const c=t.map(n=>n.geometry),r=await S.union(c);if(e.flash){const n=new d({geometry:r,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(n)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let s=0,i=!0;const a=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,s++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),s>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(a))},10)}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=v;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("@arcgis/core/Graphic"),$=require("@arcgis/core/core/promiseUtils"),M=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),G=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),y=require("axios"),P=require("md5"),A=require("pako"),C=require("../common-utils.js"),x=require("./wasm-loader.js");function O(f){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const t in f)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(f,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>f[t]})}}return e.default=f,Object.freeze(e)}const N=O($),L=O(J);class D{constructor(e){this.wasmLoader=x.default.getInstance(),this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={closeButton:!1,collapseButton:!1,actionBar:!1},this.laneLayer=new G({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"}],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 G({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer])}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:P(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var h,g;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 y.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(d){return{status:-1,message:d.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;C.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let l=o.data.result.json;l.startsWith(window.location.protocol)||(l=`${window.location.protocol}//${e.server}${l}`);const a=await(await fetch(l)).arrayBuffer(),r=A.inflate(a,{to:"string"}),c=JSON.parse(r);await this.showAllLanes(c,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((g=e.options)==null?void 0:g.showRoadName)||!0);const u=o.data.result.junctions;if(this.showJunction(u),e.options&&e.options.centerMap!==!1){const d=C.default.transformPointProjection([0,0]);await this.view.goTo(d)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await y.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=A.inflate(n,{to:"string"}),r=JSON.parse(a);return await this.showAllLanes(r,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let l=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:c,refLine:u}=r;let h=r.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const g=new p({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:l++,roadId:c,roadName:h}});this.allRefLineGraphics.push(g),r.laneSections.sort((d,b)=>Number(d.id)-Number(b.id));for(let d=0;d<r.laneSections.length;d++){const b=r.laneSections[d],k=Number(b.id);for(const m of b.lanePaths){const w=Number(m.id);if(w===0)continue;const F=m.type,I=m.innerPath.concat(m.outerPath.reverse());if(I.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}I.push(m.innerPath[0]);const j=new M.Polygon({rings:[I]});if(j){const S=new p({geometry:j,attributes:{ObjectID:l++,id:`${c}+${k}+${w}`,roadId:c,roadName:r.name,sectionId:k,sectionIndex:d,laneId:w,type:F,sumoId:""}});this.allLaneGraphics.push(S),n.push(S)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const r=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:r})}if(this.allRefLineGraphics.length>0){const r=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:r})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){i.nodeType=i.type;const o=new p({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=N.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;if(n===this.currentSectionCode||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===n)>=0)return;this.currentSectionCode=n;const r=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),c=L.union(r.map(u=>u.geometry));this.highlightGraphic=new p({geometry:c,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:n,selected:!1}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n;const a=this.hitGraphic.getAttribute("name"),r=this.hitGraphic.getAttribute("crossId");this.view.popup.open({title:a,content:`<table>
2
+ <tr><td>路口编号</td><td>${n}</td></tr>
3
+ <tr><td>信号机编号</td><td>${r||"无信控"}</td></tr>
4
+ </table>`,location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=N.debounce(async t=>{var a;const o=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(r=>r.type==="graphic");if(o.length===0)return;const s=o[0].graphic,l=s.getAttribute("type"),n=s.getAttribute("id");if(l==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,c=await y.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:c.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1);const r=s.getAttribute("crossId");s.symbol.url=r?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(l==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,c=await y.get(r,{params:{id:n,projectName:this.projectName}});c.status===200&&c.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",c.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:n,details:c.data.result}))}});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await y.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s){const l=`${i}+${s.getAttribute("sectionId")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await y.get(n,{params:{id:l,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${l}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("+");if(s.length>2)return{status:-1,message:"id格式错误"};const l=s.length===2?Number(s[1]):void 0,n=s[0].split("#");if(n.length>2)return{status:-1,message:"id格式错误"};const a=n[0],r=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:r,laneId:l,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new p({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(r=>{const c=Number(r.attributes.sectionId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(r=>Number(r.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(r=>{const c=Number(r.attributes.laneId);a.indexOf(c)===-1&&a.push(c)}),a.sort((r,c)=>r-c),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(r=>Number(r.attributes.laneId)===o)}const l=s.map(a=>a.geometry),n=L.union(l);if(e.flash){const a=new p({geometry:n,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(a)}return await this.view.goTo(n,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.graphics.forEach(t=>{t.visible=!1,t.setAttribute("selected",!1)});else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&(t.visible=!1,t.setAttribute("selected",!1))}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.filter(l=>l.getAttribute("roadId")===i&&l.getAttribute("sectionIndex")===o);if(s.length>0){const l=L.union(s.map(a=>a.geometry)),n=new p({geometry:l,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(n),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=D;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class i{constructor(s){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.areaColor=this.areaColor,this.subDistricts.push(o),this.subDistrictCount++,this.crossCount+=o.crossCount}else{const o={id:t.id,name:t.name,parentId:t.parentId,latitude:t.latitude,longitude:t.longitude};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
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class r{constructor(s){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 r(t);o.areaColor=this.areaColor,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)};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=r;
@@ -11,5 +11,11 @@ export default class SignalControlAreaController {
11
11
  locateSignalControlArea(params: {
12
12
  id: string;
13
13
  }): IResult;
14
+ /**
15
+ * 绘制区控与子区
16
+ * @param districtController
17
+ * @param isDistrict 是否是区控
18
+ * @returns
19
+ */
14
20
  private drawArea;
15
21
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/Graphic"),o=require("@arcgis/core/layers/GraphicsLayer"),m=require("@turf/convex"),f=require("@turf/helpers"),y=require("./district-controller.js");function b(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const u=b(f);class h{constructor(e){this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1},this.districtControllerLayer=new o({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new o({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new o({id:"crossLayer",maxScale:0,minScale:18056}),this.view.map.addMany([this.crossLayer,this.districtControllerLayer,this.subDistrictControllerLayer])}showSignalControlArea(e){for(const t of e){const r=new y.default(t);this.drawArea(r,!0)}return{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),(e=this.eventHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}locateSignalControlArea(e){let t=this.districtControllerLayer.graphics.find(r=>r.attributes.id===e.id);if(t||(t=this.subDistrictControllerLayer.graphics.find(r=>r.attributes.id===e.id)),t||(t=this.crossLayer.graphics.find(r=>r.attributes.id===e.id)),t){this.view.goTo(t.geometry);const r=t.geometry.type==="point"?t.geometry:t.geometry.centroid;return this.view.popup.open({features:[t],location:r}),{status:0,message:"ok"}}return{status:1,message:"未找到"}}drawArea(e,t){const r=e.getAllCrossCoordinates();if(r.length>2){const a=u.featureCollection(r.map(p=>u.point(p))),l=m(a);if(!l)return;let i;t?i=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:i=[{fieldName:"parentId",label:"区控编号"},{fieldName:"id",label:"子区编号"},{fieldName:"crossCount",label:"路口数量"}];const n=new c({geometry:{type:"polygon",rings:l.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,.5],outline:{color:e.areaColor,width:1}},attributes:{type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},popupTemplate:{title:e.name,content:[{type:"fields",fieldInfos:i}]}});t?this.districtControllerLayer.add(n):this.subDistrictControllerLayer.add(n)}for(const a of e.subDistricts)this.drawArea(a,!1);const d=e.crosses.map(a=>new c({geometry:{type:"point",x:a.longitude,y:a.latitude},symbol:{type:"simple-marker",color:e.areaColor,size:8},attributes:{type:"cross",id:a.id,name:a.name,districtId:t?e.id:e.parentId,subDistrictId:t?"":e.id},popupTemplate:{title:a.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"districtId",label:"区控编号"},{fieldName:"subDistrictId",label:"子区编号"}]}]}}));this.crossLayer.addMany(d)}}exports.default=h;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/Graphic"),i=require("@arcgis/core/layers/GraphicsLayer"),m=require("@turf/buffer"),y=require("@turf/convex"),b=require("@turf/helpers"),g=require("./district-controller.js");function h(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const u=h(b);class C{constructor(e){this.view=e,this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1},this.districtControllerLayer=new i({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new i({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new i({id:"crossLayer",maxScale:0,minScale:18056}),this.view.map.addMany([this.crossLayer,this.districtControllerLayer,this.subDistrictControllerLayer])}showSignalControlArea(e){for(const t of e){const r=new g.default(t);this.drawArea(r,!0)}return{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),(e=this.eventHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}locateSignalControlArea(e){let t=this.districtControllerLayer.graphics.find(r=>r.attributes.id===e.id);if(t||(t=this.subDistrictControllerLayer.graphics.find(r=>r.attributes.id===e.id)),t||(t=this.crossLayer.graphics.find(r=>r.attributes.id===e.id)),t){this.view.goTo(t.geometry);const r=t.geometry.type==="point"?t.geometry:t.geometry.centroid;return this.view.popup.open({features:[t],location:r}),{status:0,message:"ok"}}return{status:1,message:"未找到"}}drawArea(e,t){const r=e.getAllCrossCoordinates();if(r.length>2){const o=u.featureCollection(r.map(f=>u.point(f))),l=y(o);if(!l)return;const p=m(l.geometry,t?200:20,{units:"meters"});let a;t?a=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:a=[{fieldName:"parentId",label:"区控编号"},{fieldName:"id",label:"子区编号"},{fieldName:"crossCount",label:"路口数量"}];const n=new c({geometry:{type:"polygon",rings:p.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,.5],outline:{color:e.areaColor,width:1}},attributes:{type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},popupTemplate:{title:e.name,content:[{type:"fields",fieldInfos:a}]}});t?this.districtControllerLayer.add(n):this.subDistrictControllerLayer.add(n)}for(const o of e.subDistricts)this.drawArea(o,!1);const d=e.crosses.map(o=>new c({geometry:{type:"point",x:o.longitude,y:o.latitude},symbol:{type:"simple-marker",color:e.areaColor,size:8},attributes:{type:"cross",id:o.id,name:o.name,districtId:t?e.id:e.parentId,subDistrictId:t?"":e.id},popupTemplate:{title:o.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtId",label:"区控编号"},{fieldName:"subDistrictId",label:"子区编号"},{fieldName:"id",label:"路口编号"}]}]}}));this.crossLayer.addMany(d)}}exports.default=C;
@@ -223,6 +223,10 @@ export interface IFindSumoParams {
223
223
  id: string;
224
224
  flash?: boolean;
225
225
  }
226
+ export interface IUnselectSumoParams {
227
+ type: string;
228
+ id?: string;
229
+ }
226
230
  export interface ISplitOpenDriveLaneParams {
227
231
  id: string;
228
232
  start: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.127",
3
+ "version": "1.0.129",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [