gisviewer-vue3-arcgis 1.0.248 → 1.0.249
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.
- package/es/src/gis-map/gis-map.vue.d.ts +9 -3
- package/es/src/gis-map/gis-map.vue.mjs +178 -162
- package/es/src/gis-map/index.d.ts +8 -2
- package/es/src/gis-map/utils/edpass-device-controller.d.ts +2 -0
- package/es/src/gis-map/utils/edpass-device-controller.mjs +42 -33
- package/es/src/gis-map/utils/green-wave-band-controller/index.mjs +5 -1
- package/es/src/gis-map/utils/map-initializer.d.ts +1 -0
- package/es/src/gis-map/utils/map-initializer.mjs +98 -81
- package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +1 -1
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +9 -9
- package/es/src/types/index.d.ts +2 -0
- package/lib/src/gis-map/gis-map.vue.d.ts +9 -3
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/index.d.ts +8 -2
- package/lib/src/gis-map/utils/edpass-device-controller.d.ts +2 -0
- package/lib/src/gis-map/utils/edpass-device-controller.js +1 -1
- package/lib/src/gis-map/utils/green-wave-band-controller/index.js +1 -1
- package/lib/src/gis-map/utils/map-initializer.d.ts +1 -0
- package/lib/src/gis-map/utils/map-initializer.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/lib/src/types/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import MapView from '@arcgis/core/views/MapView';
|
|
2
2
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
3
3
|
import { IEditSignalControlAreaParams, IFindSignalControlAreaParams, IFindSumoParams, ILaneNumberParams, ILayerVisibleParams, ILookAtParams, IMaskParam, IOverlayParam, IQueueLengthParams, ISetMapCameraParams, ISetMapCenterParams, IShowEdpassDeviceParams, IShowGreenWaveBandParams, IShowJurisdictionParams, IShowOpenDriveFromFileParams, IShowSignalControlAreaParams, ISignalCountdownProps, ISplitOpenDriveLaneParams, IStartCrossBufferParam, IToggleTrafficInfoParams, IUnselectSumoParams } from '../types';
|
|
4
|
+
import EdpassDeviceController from './utils/edpass-device-controller';
|
|
4
5
|
import GreenWaveBandController from './utils/green-wave-band-controller';
|
|
5
6
|
import HoloFlow from './utils/holo-flow';
|
|
6
7
|
import MapInitializer from './utils/map-initializer';
|
|
@@ -12,7 +13,6 @@ import RoadConfigTool from './utils/road-config-tool';
|
|
|
12
13
|
import EditSignalArea from './utils/signal-control-area/edit-area';
|
|
13
14
|
import ShowSignalArea from './utils/signal-control-area/show-area';
|
|
14
15
|
import TrafficFlow from './utils/traffic-flow';
|
|
15
|
-
import EdpassDeviceController from './utils/edpass-device-controller';
|
|
16
16
|
declare const _sfc_main: import("vue").DefineComponent<{
|
|
17
17
|
config: {
|
|
18
18
|
type: StringConstructor;
|
|
@@ -69,6 +69,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
69
69
|
rColor?: string | undefined;
|
|
70
70
|
};
|
|
71
71
|
}[];
|
|
72
|
+
scaleToZoom: (scale: number) => number;
|
|
73
|
+
removeZoomWatch: (() => void) | null;
|
|
74
|
+
lastEmittedZoomInt: number | null;
|
|
75
|
+
emitZoomIfChanged: (z: number) => void;
|
|
72
76
|
mapViewer: import("vue").ComputedRef<MapView | SceneView>;
|
|
73
77
|
handleStartSaveTrackLog: () => void;
|
|
74
78
|
handleDownloadTrackLog: () => void;
|
|
@@ -76,6 +80,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
76
80
|
handleShowPlateNumber: () => void;
|
|
77
81
|
setMapCenter: (params: ISetMapCenterParams) => Promise<import("../types").IResult>;
|
|
78
82
|
setMapCamera: (params: ISetMapCameraParams) => Promise<import("../types").IResult>;
|
|
83
|
+
setMapZoom: (zoom: number) => import("../types").IResult;
|
|
79
84
|
lookAt: (params: ILookAtParams) => Promise<void>;
|
|
80
85
|
setLayerVisibility: (params: ILayerVisibleParams) => import("../types").IResult;
|
|
81
86
|
requestCoordinateTransform: (points: number[][], callback: (points: number[][]) => void) => {
|
|
@@ -174,7 +179,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
174
179
|
} | undefined;
|
|
175
180
|
setEdpassLayerVisibility: (params: IShowEdpassDeviceParams) => Promise<import("../types").IResult>;
|
|
176
181
|
props: any;
|
|
177
|
-
emit: (event: "mapLoaded" | "markerClick" | "mapClick", ...args: any[]) => void;
|
|
182
|
+
emit: (event: "mapLoaded" | "markerClick" | "mapClick" | "update:zoom", ...args: any[]) => void;
|
|
178
183
|
SignalCountdownPanel: import("vue").DefineComponent<{
|
|
179
184
|
displayMode: {
|
|
180
185
|
type: StringConstructor;
|
|
@@ -299,7 +304,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
299
304
|
required: true;
|
|
300
305
|
};
|
|
301
306
|
}>>, {}, {}>;
|
|
302
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mapLoaded" | "markerClick" | "mapClick")[], "mapLoaded" | "markerClick" | "mapClick", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
307
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mapLoaded" | "markerClick" | "mapClick" | "update:zoom")[], "mapLoaded" | "markerClick" | "mapClick" | "update:zoom", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
303
308
|
config: {
|
|
304
309
|
type: StringConstructor;
|
|
305
310
|
required: true;
|
|
@@ -312,5 +317,6 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
312
317
|
onMapLoaded?: ((...args: any[]) => any) | undefined;
|
|
313
318
|
onMarkerClick?: ((...args: any[]) => any) | undefined;
|
|
314
319
|
onMapClick?: ((...args: any[]) => any) | undefined;
|
|
320
|
+
"onUpdate:zoom"?: ((...args: any[]) => any) | undefined;
|
|
315
321
|
}, {}, {}>;
|
|
316
322
|
export default _sfc_main;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),D=require("./stores/index.js");require("./style/index.css");const at=require("./utils/detect-gpu.js"),nt=require("./utils/edpass-device-controller.js"),I=require("./utils/green-wave-band-controller/index.js"),rt=require("./utils/holo-flow/index.js"),st=require("./utils/holo-flow/signal-countdown-panel.vue.js"),ot=require("./utils/map-initializer.js"),M=require("./utils/open-drive-renderer/index.js"),x=require("./utils/overlay.js"),it=require("./utils/police-jurisdiction.js"),ct=require("./utils/queue-length.js"),z=require("./utils/road-config-tool/index.js"),lt=require("./utils/signal-control-area/edit-area.js"),ut=require("./utils/signal-control-area/show-area.js"),dt=require("./utils/traffic-flow.js"),mt={class:"gis-viewer"},pt={style:{position:"absolute",bottom:"80px",left:"10px","z-index":"9999"}},gt=n.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick","update:zoom"],setup(E,{expose:N,emit:P}){const h=n.ref(null);let r,p,l,i,a,s,f,t,u,o,g,y,C;const b=n.ref(!1);D.registerStore();const T=D.default.useAppDataStore,V=n.reactive([]),_=e=>Math.log2(591657527591555e-6/e);let v=null,q=null;const O=e=>{if(!Number.isFinite(e))return;const d=Math.round(e);d!==q&&(q=d,S("update:zoom",d))};at.default(),n.onMounted(async()=>{if(!h.value)return;document.addEventListener("keydown",m=>{m.ctrlKey&&m.key==="i"&&(b.value=!b.value)});const e=n.getCurrentInstance(),{$gisviewerAssetsRoot:d}=e.appContext.config.globalProperties,c=await(await fetch(B.config)).json();c.assetsRoot=B.assetsRoot||d,T.mapConfig=c,p=new ot.default,T.mapInitializer=p,r=await p.initialize({container:h.value,mapConfig:c,markerClickCallback:(m,A,L,tt)=>{S("markerClick",m,A,L,tt)},mapClickCallback:(m,A,L)=>{S("mapClick",m,A,L)}});const w=r.zoom??(r.scale?_(r.scale):void 0);typeof w=="number"&&O(w);const et=r.zoom!==void 0?r.watch("zoom",m=>{O(m)}):r.watch("scale",m=>{typeof m=="number"&&m>0&&O(_(m))});v=()=>et.remove(),a=new rt.default(r,V),await a.init(),S("mapLoaded")}),n.onUnmounted(()=>{o==null||o.clearSignalControlArea(),t==null||t.clearOpenDrive(),a.clearHoloTrace(),a.clearHoloSignal(),i==null||i.disconnectTrafficFlow(),v==null||v(),v=null});const H=n.computed(()=>r),G=()=>{const e=D.default.useAppDataStore;e.saveTrackLog=!0},Z=()=>{a.downloadTrackLog()},W=()=>{k("vehicleId")},j=()=>{k("plateNumber")},J=async e=>await p.setMapCenter(e),Q=async e=>await p.setMapCamera(e),U=e=>p.setMapZoom(e),K=async e=>await p.lookAt(e),F=e=>p.setLayerVisibility(e),X=(e,d)=>p.requestCoordinateTransform(e,d),Y=e=>{p.cancelCoordinateTransform(e)},R=e=>{p.setMapZoomRange(e)},$=e=>(l||(l=new z.default(r)),l.showLaneNumber(e)),ee=()=>{l==null||l.clearLaneNumber()},te=async e=>(l||(l=new z.default(r)),await l.initializeSearch(e)),ae=async()=>l==null?void 0:l.calCrossIndicatorArea(),ne=async()=>{},re=async(e,d)=>{i||(i=new dt.default(r)),i.connectTrafficFlow(e,d)},se=()=>{i==null||i.disconnectTrafficFlow()},oe=async e=>{a.handleVehicleTraceData(e)},ie=()=>{a.clearHoloTrace()},ce=e=>{a.setInterpolate(e)},le=async e=>{await a.handleSignalData(e)},ue=async e=>{await a.initializeLampGroup(e)},de=e=>{a.handleUniSignalData(e)},me=()=>{a.clearHoloSignal()},pe=e=>{i==null||i.toggleTrafficInfo(e),a==null||a.toggleTrafficInfo(e)},ge=e=>{a==null||a.togglePause(e)},fe=e=>{i==null||i.toggleTrafficObject(e),a==null||a.toggleTrafficObject(e)},k=e=>{a==null||a.updatePanelContent(e)},ye=async e=>(s||(s=new x.default(r)),s.addOverlays(e)),ve=e=>(s||(s=new x.default(r)),s.addMask(e)),Se=()=>{s==null||s.removeMask()},we=e=>s==null?void 0:s.removeOverlaysByType(e),he=e=>s==null?void 0:s.removeOverlaysById(e),Ce=()=>s==null?void 0:s.removeAllOverlays(),be=()=>{s==null||s.showAllOverlays()},Oe=e=>{f||(f=new ct.default(r)),f.updateQueueLength(e)},ke=()=>{f==null||f.removeQueueLength()},Ae=async(e,d)=>(t||(t=new M.default(r)),await t.showOpenDriveFromServer(e,d)),Le=async e=>(t||(t=new M.default(r)),await t.clearOpenDrive(),await t.showOpenDriveFromFile(e)),De=e=>t?t.setOpendriveVisibility(e):{status:-1,message:"未加载OpenDrive地图"},Te=async()=>await(t==null?void 0:t.clearOpenDrive()),Ve=async e=>t?await(t==null?void 0:t.findSumo(e)):{status:-1,message:"未加载OpenDrive地图"},_e=async e=>t?t.selectSumo(e):{status:-1,message:"未加载OpenDrive地图"},qe=async e=>t?t.unselectSumo(e):{status:-1,message:"未加载OpenDrive地图"},Be=async e=>t?await t.geometrySearch(e):{status:-1,message:"未加载OpenDrive地图"},Ie=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地图"},xe=async()=>t?t==null?void 0:t.clearSplitLane():{status:-1,message:"未加载OpenDrive地图"},ze=async e=>(o||(o=new ut.default(r)),await o.showSignalControlArea(e)),Ee=async()=>await(o==null?void 0:o.clearSignalControlArea()),Ne=e=>o==null?void 0:o.setLayerVisibility(e),Pe=async e=>o?await(o==null?void 0:o.locateSignalControlArea(e)):{status:-1,message:"未加载信号控制区"},He=async e=>o?await o.highlightSignalControlArea(e):{status:-1,message:"未加载信号控制区"},Ge=()=>o?o.resetHighlight():{status:-1,message:"未加载信号控制区"},Ze=e=>(u||(u=new lt.default(r)),u.showSubSignalControlArea(e)),We=e=>u?u.editSubSignalControlArea(e):{status:-1,message:"未加载信号控制区"},je=()=>u?u.stopEditSubSignalControlArea():{status:-1,message:"未加载信号控制区"},Je=e=>u?u.selectSubSignalControlAreaCross(e):{status:-1,message:"未加载信号控制区"},Qe=e=>u?u.unselectSubSignalControlAreaCross(e):{status:-1,message:"未加载信号控制区"},Ue=e=>{if(!u)return{status:-1,message:"未加载信号控制区"}},Ke=e=>(g||(g=new I.default(r)),g.addGreenWaveBand(e)),Fe=()=>{if(!g)return{status:-1,message:"未加载绿波带"};g.stopAddGreenWaveBand()},Xe=async e=>(g||(g=new I.default(r)),await g.showGreenWaveBand(e)),Ye=async e=>(y||(y=new it.default(r)),await y.showJurisdiction(e)),Re=()=>{if(!y)return{status:-1,message:"未加载警务管辖区"};y.clearJurisdiction()},$e=async e=>(C||(C=new nt.default(r)),await C.setEdpassLayerVisibility(e)),B=E,S=P;return N({mapViewer:H,setLayerVisibility:F,setMapCenter:J,lookAt:K,setMapCamera:Q,setMapZoom:U,setMapZoomRange:R,requestCoordinateTransform:X,cancelCoordinateTransform:Y,addOverlays:ye,addMask:ve,removeMask:Se,showAllOverlays:be,removeOverlaysByType:we,removeOverlaysById:he,removeAllOverlays:Ce,showLaneNumber:$,clearLaneNumber:ee,initializeAreaTool:te,calCrossIndicatorArea:ae,calRoadIndicatorArea:ne,connectCarFlow:re,disconnectCarFlow:se,handleHoloVehicleTraceData:oe,clearHoloTrace:ie,initializeLampGroup:ue,handleUniSignalData:de,handleHoloSignalData:le,clearHoloSignal:me,setInterpolate:ce,toggleTrafficInfo:pe,toggleTrafficObject:fe,toggleVehicleInfo:k,togglePause:ge,updateQueueLength:Oe,removeQueueLength:ke,showOpenDriveFromServer:Ae,showOpenDriveFromFile:Le,clearOpenDrive:Te,setOpendriveVisibility:De,geometrySearchInOpenDrive:Be,findSumoInOpenDrive:Ve,selectSumoInOpenDrive:_e,unselectSumoInOpenDrive:qe,getSumoInfo:Ie,splitOpenDriveLane:Me,clearSplitOpenDriveLane:xe,showSignalControlArea:ze,clearSignalControlArea:Ee,setSignalControlAreaVisibility:Ne,locateSignalControlArea:Pe,highlightSignalControlArea:He,resetHighlightSignalControlArea:Ge,showSubSignalControlArea:Ze,editSubSignalControlArea:We,stopEditSubSignalControlArea:je,selectSubSignalControlAreaCross:Je,unselectSubSignalControlAreaCross:Qe,changeSubSignalControlAreaBorderVisibility:Ue,addGreenWaveBand:Ke,stopAddGreenWaveBand:Fe,showGreenWaveBand:Xe,showPoliceArea:Ye,clearPoliceArea:Re,setEdpassLayerVisibility:$e}),(e,d)=>(n.openBlock(),n.createElementBlock("div",mt,[n.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:h},[n.withDirectives(n.createElementVNode("div",pt,[n.createElementVNode("button",{style:{"margin-right":"10px"},onClick:G}," 开始记录 "),n.createElementVNode("button",{style:{"margin-right":"10px"},onClick:Z}," 下载日志 "),n.createElementVNode("button",{style:{"margin-right":"10px"},onClick:W}," 显示车辆id "),n.createElementVNode("button",{onClick:j},"显示车辆号牌")],512),[[n.vShow,b.value]])],512),(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(V,(c,w)=>(n.openBlock(),n.createBlock(st.default,{key:w,"display-mode":c.displayMode,flash:c.flash,"road-id":c.crossId,"cross-id":c.roadId,"map-point":c.mapPoint,"stop-line":c.stopLine,position:c.position,rotation:c.rotation,scale:c.scale,"lamp-status":c.lampStatus},null,8,["display-mode","flash","road-id","cross-id","map-point","stop-line","position","rotation","scale","lamp-status"]))),128))]))}});exports.default=gt;
|
|
@@ -54,6 +54,10 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
54
54
|
rColor?: string | undefined;
|
|
55
55
|
};
|
|
56
56
|
}[];
|
|
57
|
+
scaleToZoom: (scale: number) => number;
|
|
58
|
+
removeZoomWatch: (() => void) | null;
|
|
59
|
+
lastEmittedZoomInt: number | null;
|
|
60
|
+
emitZoomIfChanged: (z: number) => void;
|
|
57
61
|
mapViewer: import("vue").ComputedRef<__esri.MapView | __esri.SceneView>;
|
|
58
62
|
handleStartSaveTrackLog: () => void;
|
|
59
63
|
handleDownloadTrackLog: () => void;
|
|
@@ -61,6 +65,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
61
65
|
handleShowPlateNumber: () => void;
|
|
62
66
|
setMapCenter: (params: import("../types").ISetMapCenterParams) => Promise<import("../types").IResult>;
|
|
63
67
|
setMapCamera: (params: import("../types").ISetMapCameraParams) => Promise<import("../types").IResult>;
|
|
68
|
+
setMapZoom: (zoom: number) => import("../types").IResult;
|
|
64
69
|
lookAt: (params: import("../types").ILookAtParams) => Promise<void>;
|
|
65
70
|
setLayerVisibility: (params: import("../types").ILayerVisibleParams) => import("../types").IResult;
|
|
66
71
|
requestCoordinateTransform: (points: number[][], callback: (points: number[][]) => void) => {
|
|
@@ -159,7 +164,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
159
164
|
} | undefined;
|
|
160
165
|
setEdpassLayerVisibility: (params: import("../types").IShowEdpassDeviceParams) => Promise<import("../types").IResult>;
|
|
161
166
|
props: any;
|
|
162
|
-
emit: (event: "mapLoaded" | "markerClick" | "mapClick", ...args: any[]) => void;
|
|
167
|
+
emit: (event: "mapLoaded" | "markerClick" | "mapClick" | "update:zoom", ...args: any[]) => void;
|
|
163
168
|
SignalCountdownPanel: import("vue").DefineComponent<{
|
|
164
169
|
displayMode: {
|
|
165
170
|
type: StringConstructor;
|
|
@@ -284,7 +289,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
284
289
|
required: true;
|
|
285
290
|
};
|
|
286
291
|
}>>, {}, {}>;
|
|
287
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mapLoaded" | "markerClick" | "mapClick")[], "mapLoaded" | "markerClick" | "mapClick", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
292
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mapLoaded" | "markerClick" | "mapClick" | "update:zoom")[], "mapLoaded" | "markerClick" | "mapClick" | "update:zoom", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
288
293
|
config: {
|
|
289
294
|
type: StringConstructor;
|
|
290
295
|
required: true;
|
|
@@ -297,5 +302,6 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
297
302
|
onMapLoaded?: ((...args: any[]) => any) | undefined;
|
|
298
303
|
onMarkerClick?: ((...args: any[]) => any) | undefined;
|
|
299
304
|
onMapClick?: ((...args: any[]) => any) | undefined;
|
|
305
|
+
"onUpdate:zoom"?: ((...args: any[]) => any) | undefined;
|
|
300
306
|
}, {}, {}>>;
|
|
301
307
|
export default GisMap;
|
|
@@ -7,6 +7,8 @@ export default class EdpassDeviceController {
|
|
|
7
7
|
private kkAbnormalLayer;
|
|
8
8
|
private mapInitializer;
|
|
9
9
|
private watchHandle;
|
|
10
|
+
private currentZdCode;
|
|
11
|
+
private currentDdCode;
|
|
10
12
|
constructor(view: __esri.MapView | __esri.SceneView);
|
|
11
13
|
setEdpassLayerVisibility(params: IShowEdpassDeviceParams): Promise<IResult>;
|
|
12
14
|
private getLayerConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@arcgis/core/core/reactiveUtils.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@arcgis/core/core/reactiveUtils.js"),v=require("@arcgis/core/Graphic"),n=require("@arcgis/core/layers/GraphicsLayer"),b=require("vue"),p=require("../stores/index.js");function f(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const g=f(u);class C{constructor(e){this.watchHandle=null,this.currentZdCode="",this.currentDdCode="",this.view=e;const t=p.default.useAppDataStore;this.mapInitializer=b.toRaw(t.mapInitializer),this.cameraNormalLayer=new n({id:"cameraNormalLayer",visible:!1}),this.cameraAbnormalLayer=new n({id:"cameraAbnormalLayer",visible:!1}),this.kkNormalLayer=new n({id:"kkNormalLayer",visible:!1}),this.kkAbnormalLayer=new n({id:"kkAbnormalLayer",visible:!1}),this.view.map.addMany([this.cameraNormalLayer,this.cameraAbnormalLayer,this.kkNormalLayer,this.kkAbnormalLayer])}async setEdpassLayerVisibility(e){var t;if(e.deviceType!=="camera"&&e.deviceType!=="kk")return{status:-1,message:"不支持的设备类型"};switch(e.mode){case"scatter":return this.mapInitializer.setLayerVisibility({id:`${e.deviceType}-${e.deviceState}`,visible:e.visible});case"cluster":{const{deviceLayer:i}=this.getLayerConfig(e);i.visible=e.visible,this.currentDdCode=e.ddCode||"",this.currentZdCode=e.zdCode||"",e.visible?(await this.showClusterInExtent(e,this.view.extent),this.watchHandle||(this.watchHandle=g.when(()=>this.view.stationary,async()=>{this.cameraNormalLayer.visible&&await this.showClusterInExtent({deviceType:"camera",deviceState:"normal",mode:"cluster",ddCode:this.currentDdCode,zdCode:this.currentZdCode,visible:!0},this.view.extent),this.cameraAbnormalLayer.visible&&await this.showClusterInExtent({deviceType:"camera",deviceState:"abnormal",mode:"cluster",ddCode:this.currentDdCode,zdCode:this.currentZdCode,visible:!0},this.view.extent),this.kkNormalLayer.visible&&await this.showClusterInExtent({deviceType:"kk",deviceState:"normal",mode:"cluster",ddCode:this.currentDdCode,zdCode:this.currentZdCode,visible:!0},this.view.extent),this.kkAbnormalLayer.visible&&await this.showClusterInExtent({deviceType:"kk",deviceState:"abnormal",mode:"cluster",ddCode:this.currentDdCode,zdCode:this.currentZdCode,visible:!0},this.view.extent)}))):(i.removeAll(),!this.cameraNormalLayer.visible&&!this.cameraAbnormalLayer.visible&&!this.kkNormalLayer.visible&&!this.kkAbnormalLayer.visible&&((t=this.watchHandle)==null||t.remove(),this.watchHandle=null));break}}return{status:0,message:"Success"}}getLayerConfig(e){let t,i,a;return e.deviceType==="camera"?e.deviceState==="normal"?(t="/GisViewerAssets/Images/gis/gis_sxj_map.png",i=[45,108,196],a=this.cameraNormalLayer):(t="/GisViewerAssets/Images/gis/gis_sxj_yc.png",i=[189,49,50],a=this.cameraAbnormalLayer):e.deviceState==="normal"?(t="/GisViewerAssets/Images/gis/gis_kk_map.png",i=[45,108,196],a=this.kkNormalLayer):(t="/GisViewerAssets/Images/gis/gis_kk_yc.png",i=[189,49,50],a=this.kkAbnormalLayer),{icon:t,color:i,deviceLayer:a}}async showClusterInExtent(e,t){const i=await fetch("/es/queryGeoAggregation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceType:e.deviceType,topLeftLat:t.ymax,topLeftLon:t.xmin,bottomRightLat:t.ymin,bottomRightLon:t.xmax,devStateSet:[e.deviceState==="normal"?"1":"2"],zdCode:e.zdCode||"",ddCode:e.ddCode||"",mapLevel:this.view.zoom+9})});if(i.status!==200){console.error(i.statusText);return}const a=await i.json();if(a.code!==200)return;const{icon:c,color:d,deviceLayer:y}=this.getLayerConfig(e);y.removeAll();const h=a.data.map(r=>{var m;const s=(r.count.toString().length*6+6)/2,l=new v({geometry:{type:"point",x:r.lon,y:r.lat},attributes:{id:((m=r.devInfo)==null?void 0:m.deviceId)||r.key,type:e.deviceType,count:r.count,typeName:e.deviceType==="camera"?"视频":"卡口",stateName:e.deviceState==="normal"?"正常":"异常",...r.devInfo}});return r.count>1?l.symbol={type:"cim",data:{type:"CIMSymbolReference",symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[-s,30],[s,30],[s,15],[-s,15],[-s,30]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:d.concat([255])},{type:"CIMSolidStroke",enable:!0,width:3,color:d.concat([128])}]}},{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",fontFamilyName:"msyh",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:22,symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},verticalAlignment:"Center"},textString:r.count.toString()}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:24,rotateClockwise:!0,textureFilter:"Picture",url:c}]}}}:(l.symbol={type:"picture-marker",url:c,width:18,height:18},l.popupTemplate={title:"视频信息",content:[{type:"fields",fieldInfos:[{fieldName:"deviceId",label:"设备编号"},{fieldName:"deviceName",label:"设备名称"},{fieldName:"typeName",label:"设备类型"},{fieldName:"stateName",label:"设备状态"}]}]}),l});y.addMany(h)}}exports.default=C;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils.js"),b=require("@arcgis/core/geometry"),n=require("@arcgis/core/Graphic"),y=require("@arcgis/core/layers/GraphicsLayer"),u=require("axios");function p(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const s in c)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(c,s);Object.defineProperty(e,s,a.get?a:{enumerable:!0,get:()=>c[s]})}}return e.default=c,Object.freeze(e)}const g=p(m);class f{constructor(e){this.selectedNodeIds=[],this.nodeScale=5e3,this.hasGpu=!1,this.hasGpu=localStorage.getItem("gpu")!=="Unknown",this.view=e,this.roadsectLayer=new y({id:"roadsectLayer"}),this.view.map.add(this.roadsectLayer),this.allNodesLayer=new y({id:"allNodesLayer"}),this.view.map.add(this.allNodesLayer),this.bandLayer=new y({id:"bandLayer"}),this.view.map.add(this.bandLayer)}addGreenWaveBand(e){this.addNodeCallback=e.addCrossCallback,this.removeNodeCallback=e.removeCrossCallback,e.removeAllCrossCallback&&(this.removeAllNodeCallback=e.removeAllCrossCallback),this.selectedNodeIds=[],this.openDriveServer=e.odrServer,this.showAllNodes(e.crossesInArea),this.viewClickWatcher||(this.viewClickWatcher=this.view.on("click",s=>{this.handleViewClick(s)}))}stopAddGreenWaveBand(){var e;(e=this.viewClickWatcher)==null||e.remove(),this.viewClickWatcher=void 0,this.allNodesLayer.removeAll(),this.selectedNodeIds=[],this.roadsectLayer.removeAll(),this.bandLayer.removeAll()}async showGreenWaveBand(e){this.scaleWatcher||(this.scaleWatcher=g.watch(()=>this.view.scale,(i,r)=>{i>this.nodeScale&&r<=this.nodeScale?this.bandLayer.graphics.forEach(l=>{l.geometry.type==="point"&&(l.symbol=this.getShowNodeSymbol("marker"))}):i<=this.nodeScale&&r>this.nodeScale&&this.bandLayer.graphics.forEach(l=>{l.geometry.type==="point"&&(l.symbol=this.getShowNodeSymbol("picture"))})}));const s=new b.Polyline({paths:[e.coordinates]}),a=new n({geometry:s,symbol:this.getLineSymbol(!0),attributes:{bandId:e.bandId}});this.roadsectLayer.add(a),await this.view.goTo(a),e.nodeList.forEach(i=>{const r=new n({geometry:{type:"point",x:i.longitude,y:i.latitude},symbol:this.getShowNodeSymbol("picture"),attributes:i});this.bandLayer.add(r)})}showAllNodes(e){const s=[];e.forEach(a=>{s.push(new n({geometry:{type:"point",x:a.longitude,y:a.latitude},symbol:this.getEditableNodeSymbol(!1),attributes:{...a,selected:!1}}))}),this.allNodesLayer.addMany(s)}async handleViewClick(e){var l;const a=(l=(await this.view.hitTest(e,{include:[this.allNodesLayer]})).results)==null?void 0:l.filter(d=>d.type==="graphic");if(a.length===0)return;const i=a[0].graphic,r=i.getAttribute("id");if(this.selectedNodeIds.includes(r)){const d=this.selectedNodeIds.indexOf(r)+1;if(d===1)this.removeAllNodeCallback&&this.removeAllNodeCallback(),this.selectedNodeIds=[],this.allNodesLayer.graphics.forEach(t=>{t.setAttribute("selected",!1),t.symbol=this.getEditableNodeSymbol(!1),t.visible=!0}),this.roadsectLayer.removeAll();else{for(let t=d;t<this.selectedNodeIds.length;t++){this.removeNodeCallback&&this.removeNodeCallback({id:this.selectedNodeIds[t]});for(let o=0;o<this.roadsectLayer.graphics.length;o++){const h=this.roadsectLayer.graphics.getItemAt(o);(h.getAttribute("id")===this.selectedNodeIds[t]||!h.getAttribute("selected"))&&(this.roadsectLayer.remove(h),o--)}}this.selectedNodeIds=this.selectedNodeIds.slice(0,d),this.allNodesLayer.graphics.forEach(t=>{const o=this.selectedNodeIds.includes(t.getAttribute("id"));t.setAttribute("selected",o),t.symbol=this.getEditableNodeSymbol(o),t.visible=o}),await this.showDownstreamNodes(r)}}else{i.setAttribute("selected",!0),i.symbol=this.getEditableNodeSymbol(!0),this.selectedNodeIds.push(r),this.allNodesLayer.graphics.forEach(t=>{t.visible=t.getAttribute("selected")});let d=[];for(let t=0;t<this.roadsectLayer.graphics.length;t++){const o=this.roadsectLayer.graphics.getItemAt(t);o.getAttribute("id")===r?(o.symbol=this.getLineSymbol(!0),o.setAttribute("selected",!0),d=o.geometry.paths[0]):o.getAttribute("selected")||(this.roadsectLayer.remove(o),t--)}this.addNodeCallback&&this.addNodeCallback({...i.attributes,roadsect:d}),await this.showDownstreamNodes(r)}}async showDownstreamNodes(e){this.view.container.style.cursor="progress";const s=await u.get(`http://${this.openDriveServer}/api/computable/getDownstreamNodes`,{params:{nodeId:e}});if(s.status!==200||s.data.status!==0){this.view.container.style.cursor="default";return}s.data.result.forEach(i=>{this.allNodesLayer.graphics.forEach(r=>{if(r.getAttribute("nodeId")===i.id&&r.getAttribute("selected")===!1&&(r.visible=!0,i.coordinates)){const l=new n({geometry:{type:"polyline",paths:[i.coordinates]},symbol:this.getLineSymbol(!1),attributes:{...i,selected:!1}});this.roadsectLayer.add(l)}})}),this.view.container.style.cursor="default"}getLineSymbol(e){return e?{type:"cim",data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,size:4,markerPlacement:{type:"CIMMarkerPlacementAlongLineSameSize",endings:"WithMarkers",placementTemplate:[40],angleToLine:!0},frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[4,-4],[12,0],[4,4]],[[-4,4],[-12,0],[-4,-4]]]},symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,width:1.5,color:[255,255,255,255]}]}}]},{type:"CIMSolidStroke",enable:!0,width:4,color:[55,125,34,255]}]}}}:{type:"simple-line",color:"gray",width:2}}getShowNodeSymbol(e){return e==="marker"?{type:"simple-marker",style:"circle",color:[61,139,249],size:8,outline:{color:"white",width:1}}:this.getEditableNodeSymbol(!0)}getEditableNodeSymbol(e){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:30,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:20,haloSize:2,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:25,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/cross/${e?"gis_xhj_blue":"gis_xhj_gray"}.png`}]}}}}}exports.default=f;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/core/reactiveUtils.js"),b=require("@arcgis/core/geometry"),n=require("@arcgis/core/Graphic"),y=require("@arcgis/core/layers/GraphicsLayer"),u=require("axios");function p(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const s in c)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(c,s);Object.defineProperty(e,s,a.get?a:{enumerable:!0,get:()=>c[s]})}}return e.default=c,Object.freeze(e)}const g=p(m);class f{constructor(e){this.selectedNodeIds=[],this.nodeScale=5e3,this.hasGpu=!1,this.hasGpu=localStorage.getItem("gpu")!=="Unknown",this.view=e,this.roadsectLayer=new y({id:"roadsectLayer"}),this.view.map.add(this.roadsectLayer),this.allNodesLayer=new y({id:"allNodesLayer"}),this.view.map.add(this.allNodesLayer),this.bandLayer=new y({id:"bandLayer"}),this.view.map.add(this.bandLayer)}addGreenWaveBand(e){this.addNodeCallback=e.addCrossCallback,this.removeNodeCallback=e.removeCrossCallback,e.removeAllCrossCallback&&(this.removeAllNodeCallback=e.removeAllCrossCallback),this.selectedNodeIds=[],this.openDriveServer=e.odrServer,this.showAllNodes(e.crossesInArea),this.viewClickWatcher||(this.viewClickWatcher=this.view.on("click",s=>{this.handleViewClick(s)}))}stopAddGreenWaveBand(){var e;(e=this.viewClickWatcher)==null||e.remove(),this.viewClickWatcher=void 0,this.allNodesLayer.removeAll(),this.selectedNodeIds=[],this.roadsectLayer.removeAll(),this.bandLayer.removeAll()}async showGreenWaveBand(e){this.scaleWatcher||(this.scaleWatcher=g.watch(()=>this.view.scale,(i,r)=>{i>this.nodeScale&&r<=this.nodeScale?this.bandLayer.graphics.forEach(l=>{l.geometry.type==="point"&&(l.symbol=this.getShowNodeSymbol("marker"))}):i<=this.nodeScale&&r>this.nodeScale&&this.bandLayer.graphics.forEach(l=>{l.geometry.type==="point"&&(l.symbol=this.getShowNodeSymbol("picture"))})}));const s=new b.Polyline({paths:[e.coordinates]}),a=new n({geometry:s,symbol:this.getLineSymbol(!0),attributes:{bandId:e.bandId,type:"greenWaveBand",id:e.bandId}});this.roadsectLayer.add(a),await this.view.goTo(a),e.nodeList.forEach(i=>{const r=new n({geometry:{type:"point",x:i.longitude,y:i.latitude},symbol:this.getShowNodeSymbol("picture"),attributes:i});this.bandLayer.add(r)})}showAllNodes(e){const s=[];e.forEach(a=>{s.push(new n({geometry:{type:"point",x:a.longitude,y:a.latitude},symbol:this.getEditableNodeSymbol(!1),attributes:{...a,selected:!1}}))}),this.allNodesLayer.addMany(s)}async handleViewClick(e){var l;const a=(l=(await this.view.hitTest(e,{include:[this.allNodesLayer]})).results)==null?void 0:l.filter(d=>d.type==="graphic");if(a.length===0)return;const i=a[0].graphic,r=i.getAttribute("id");if(this.selectedNodeIds.includes(r)){const d=this.selectedNodeIds.indexOf(r)+1;if(d===1)this.removeAllNodeCallback&&this.removeAllNodeCallback(),this.selectedNodeIds=[],this.allNodesLayer.graphics.forEach(t=>{t.setAttribute("selected",!1),t.symbol=this.getEditableNodeSymbol(!1),t.visible=!0}),this.roadsectLayer.removeAll();else{for(let t=d;t<this.selectedNodeIds.length;t++){this.removeNodeCallback&&this.removeNodeCallback({id:this.selectedNodeIds[t]});for(let o=0;o<this.roadsectLayer.graphics.length;o++){const h=this.roadsectLayer.graphics.getItemAt(o);(h.getAttribute("id")===this.selectedNodeIds[t]||!h.getAttribute("selected"))&&(this.roadsectLayer.remove(h),o--)}}this.selectedNodeIds=this.selectedNodeIds.slice(0,d),this.allNodesLayer.graphics.forEach(t=>{const o=this.selectedNodeIds.includes(t.getAttribute("id"));t.setAttribute("selected",o),t.symbol=this.getEditableNodeSymbol(o),t.visible=o}),await this.showDownstreamNodes(r)}}else{i.setAttribute("selected",!0),i.symbol=this.getEditableNodeSymbol(!0),this.selectedNodeIds.push(r),this.allNodesLayer.graphics.forEach(t=>{t.visible=t.getAttribute("selected")});let d=[];for(let t=0;t<this.roadsectLayer.graphics.length;t++){const o=this.roadsectLayer.graphics.getItemAt(t);o.getAttribute("id")===r?(o.symbol=this.getLineSymbol(!0),o.setAttribute("selected",!0),d=o.geometry.paths[0]):o.getAttribute("selected")||(this.roadsectLayer.remove(o),t--)}this.addNodeCallback&&this.addNodeCallback({...i.attributes,roadsect:d}),await this.showDownstreamNodes(r)}}async showDownstreamNodes(e){this.view.container.style.cursor="progress";const s=await u.get(`http://${this.openDriveServer}/api/computable/getDownstreamNodes`,{params:{nodeId:e}});if(s.status!==200||s.data.status!==0){this.view.container.style.cursor="default";return}s.data.result.forEach(i=>{this.allNodesLayer.graphics.forEach(r=>{if(r.getAttribute("nodeId")===i.id&&r.getAttribute("selected")===!1&&(r.visible=!0,i.coordinates)){const l=new n({geometry:{type:"polyline",paths:[i.coordinates]},symbol:this.getLineSymbol(!1),attributes:{...i,selected:!1}});this.roadsectLayer.add(l)}})}),this.view.container.style.cursor="default"}getLineSymbol(e){return e?{type:"cim",data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,size:4,markerPlacement:{type:"CIMMarkerPlacementAlongLineSameSize",endings:"WithMarkers",placementTemplate:[40],angleToLine:!0},frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[4,-4],[12,0],[4,4]],[[-4,4],[-12,0],[-4,-4]]]},symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,width:1.5,color:[255,255,255,255]}]}}]},{type:"CIMSolidStroke",enable:!0,width:4,color:[55,125,34,255]}]}}}:{type:"simple-line",color:"gray",width:2}}getShowNodeSymbol(e){return e==="marker"?{type:"simple-marker",style:"circle",color:[61,139,249],size:8,outline:{color:"white",width:1}}:this.getEditableNodeSymbol(!0)}getEditableNodeSymbol(e){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:30,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:20,haloSize:2,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:25,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/cross/${e?"gis_xhj_blue":"gis_xhj_gray"}.png`}]}}}}}exports.default=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("@arcgis/core/Basemap"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("@arcgis/core/Basemap"),v=require("@arcgis/core/config"),C=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GeoJSONLayer"),S=require("@arcgis/core/layers/GroupLayer"),x=require("@arcgis/core/layers/IntegratedMesh3DTilesLayer"),I=require("@arcgis/core/layers/MapImageLayer"),G=require("@arcgis/core/layers/TileLayer"),H=require("@arcgis/core/layers/WebTileLayer"),R=require("@arcgis/core/layers/WMSLayer"),_=require("@arcgis/core/Map"),B=require("@arcgis/core/views/MapView"),U=require("@arcgis/core/views/SceneView"),j=require("@turf/destination"),N=require("@turf/helpers"),E=require("./custom-layer/custom-wmts-layer.js");function y(u){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const i in u)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(u,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>u[i]})}}return e.default=u,Object.freeze(e)}const L=y(C),d=y(z),A=y(N);class J{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}processUrl(e){return e&&(e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("{{")?e.replace("{{geoServer}}",this.mapConfig.geoServer):this.mapConfig.assetsRoot+e)}async initialize(e){var f,M,k,P;this.mapConfig=e.mapConfig;const{container:i,markerClickCallback:s,mapClickCallback:a}=e;v.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,v.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,v.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const r=new _;((f=this.mapConfig)==null?void 0:f.mapOptions.mode.toLowerCase())==="2d"?(this.view=new B({map:r,container:i,...this.mapConfig.mapOptions}),this.view.on("drag",t=>{t.button===2&&t.stopPropagation()})):this.view=new U({map:r,container:i,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(M=this.mapConfig)==null?void 0:M.mapOptions}),this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1,featureNavigation:!0},this.view.popup.dockOptions={buttonEnabled:!1,breakpoint:!1},this.view.on("click",async t=>{var l,m;if(a){let o=t.mapPoint;o.spatialReference.isWebMercator&&(o=d.webMercatorToGeographic(o)),a([o.x,o.y],[t.screenPoint.x,t.screenPoint.y],t)}if(this.view.type==="3d"){const o=this.view.camera;if(this.view.spatialReference.isWebMercator){const h=d.webMercatorToGeographic(o.position),p={heading:o.heading,tilt:o.tilt,position:h.toJSON()};console.log(p),(l=navigator.clipboard)==null||l.writeText(JSON.stringify(p))}else console.log(o.toJSON());console.log(this.view.zoom,this.view.scale)}else{let o=this.view.center;this.view.spatialReference.isWebMercator&&(o=d.webMercatorToGeographic(o)),console.log({center:o.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const c=(m=(await this.view.hitTest(t)).results)==null?void 0:m.filter(o=>o.type==="graphic");c.length>0&&c.forEach(o=>{var p;const h=o.graphic;(p=h.attributes)!=null&&p.type&&s&&s(h.attributes.type,h.attributes.id,h.attributes,t)})});{let t=0,n=!1;this.view.on("pointer-move",async c=>{var m;const l=performance.now();if(!(n||l-t<100)){t=l,n=!0;try{const h=(m=(await this.view.hitTest(c)).results)==null?void 0:m.some(q=>q.type==="graphic"),p=this.view.container;p&&(p.style.cursor=h?"pointer":"default")}finally{n=!1}}})}if(this.view.on("pointer-leave",()=>{const t=this.view.container;t&&(t.style.cursor="default")}),(k=this.mapConfig)!=null&&k.baseLayers?this.mapConfig.baseLayers.forEach(t=>{const n=this.processUrl(t.url);let c=null;switch(t.type.toLowerCase()){case"webTile".toLowerCase():{c=new H({urlTemplate:n,...t.options});break}case"tile":{c=new G({url:n,...t.options});break}case"customwmts".toLowerCase():{c=new E.default({urlTemplate:n,...t.options});break}case"mapimage".toLowerCase():{c=new I({url:n,...t.options});break}case"arcgis":{const l=new T(t.options);r.basemap=l;break}case"feature":{c=new W({url:n,...t.options});break}case"3dtiles":{c=new x({url:n,...t.options});break}case"wms":{c=new R({url:n,...t.options});break}default:console.warn(`不支持的图层类型: ${t.type}`);break}if(c)if(t.group){let l=r.findLayerById(t.group);l&&l.type==="group"?l.add(c):(l=new S({id:t.group,title:t.groupTitle,visibilityMode:"inherited",layers:[c],visible:t.groupVisible!==!1}),r.add(l))}else r.add(c)}):r.basemap=new T({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(P=this.mapConfig)!=null&&P.hdLayers){const t=this.mapConfig.hdLayers.map(n=>new O({url:this.processUrl(n.url),...n.options,title:n.options.id}));r.addMany(t)}this.view.ui.remove("attribution"),await this.view.when();const b=this.mapConfig.camera;let w;if(this.view.type==="2d"){let t=this.view.center;this.view.spatialReference.isWebMercator&&(t=d.webMercatorToGeographic(t)),w={center:[t.x,t.y],zoom:this.view.zoom}}else{let t=this.view.camera.position;this.view.spatialReference.isWebMercator&&(t=d.webMercatorToGeographic(t)),w={position:t,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return b?b.home=w:this.mapConfig.camera={home:w},this.view}setLayerVisibility(e){const{id:i,visible:s}=e,a=this.view.map.findLayerById(i);return a?(a.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type.toLowerCase()){case"point":e.target=new g.Point(e.target);break;case"polyline":e.target=new g.Polyline(e.target);break;case"polygon":e.target=new g.Polygon(e.target);break;case"multipoint":e.target=new g.Multipoint(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}setMapZoom(e){return this.view?(this.view.zoom=e,{status:0,message:"成功"}):{status:-1,message:"未初始化"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,s=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:s,tilt:0},{duration:(e.duration||2)*1e3});else{const a=Math.tan(i*Math.PI/180)*e.height,r=j(A.point(e.center),a,s+180,{units:"meters"});await this.view.goTo({position:{x:r.geometry.coordinates[0],y:r.geometry.coordinates[1],z:e.height},heading:s,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:s=0}=e,{camera:a}=this.mapConfig;if(!a)return{status:-1,message:"未配置camera"};const r=a[i];return r?(await this.view.goTo(r,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let s=0;const r=1e3/30,b=L.watch(()=>this.view.center,()=>{const w=this.transformPoints(e),f=Date.now();f-s>r&&(i(w),s=f)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,b),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const s=new g.Point({x:i[0],y:i[1]}),a=this.view.toScreen(s);return[a.x,a.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:s}=e;!i&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=L.watch(()=>this.view.zoom,a=>{i&&a<=i&&(this.view.zoom=i),s&&a>=s&&(this.view.zoom=s)}))}}exports.default=J;
|
|
@@ -110,7 +110,7 @@ export default class OpenDriveRenderer {
|
|
|
110
110
|
* @param params
|
|
111
111
|
* @returns
|
|
112
112
|
*/
|
|
113
|
-
selectSumo(params: IFindSumoParams): IResult
|
|
113
|
+
selectSumo(params: IFindSumoParams): Promise<IResult>;
|
|
114
114
|
geometrySearch(coordinate: number[][]): Promise<IResult>;
|
|
115
115
|
splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
|
|
116
116
|
clearSplitLane(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),J=require("@arcgis/core/core/reactiveUtils.js"),S=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),E=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),_=require("md5"),O=require("pako"),T=require("vue"),z=require("../../stores/index.js"),H=require("../common-utils.js");function N(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 M=N(F),U=N(J),A=N(q),P=N(E);class D{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({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:"sectionIndex",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 x({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.splitLaneLayer=new w({id:"SplitLane"}),this.borderLayer=new w({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let r=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:_(o),border:r}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var y,m,g;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(u,h)=>{u>this.junctionScale&&h<=this.junctionScale?this.updateAllJunctionSymbol("marker"):u<=this.junctionScale&&h>this.junctionScale&&this.updateAllJunctionSymbol("picture")});let t=e.file.split("/").pop()||"";t=t.split(".").slice(0,-1).join("."),console.log(`OpenDriveRenderer: 显示OpenDrive文件 ${t}`),this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:t}})}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;H.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 a=await(await fetch(c)).arrayBuffer(),n=O.inflate(a,{to:"string"}),l=JSON.parse(n);if(await this.showAllLanes(l,((y=e.options)==null?void 0:y.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0),((g=e.options)==null?void 0:g.showJunctionPoint)!==!1){const u=o.data.result.junctions;this.showJunction(u)}e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const p=z.default.useAppDataStore;return T.watch(()=>p.isSketching,()=>{var u,h;p.isSketching?((u=this.mouseMoveHandler)==null||u.remove(),this.mouseMoveHandler=void 0,(h=this.mouseClickHandler)==null||h.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 r=await(await fetch(s)).arrayBuffer(),a=O.inflate(r,{to:"string"}),n=JSON.parse(a);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 r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:l,refLine:d}=n;let p=n.name;p.includes("(")&&(p=p.slice(0,p.indexOf("("))),p=p.replace(/(.)/g,"$1 ");const y=new f({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:p}});this.allRefLineGraphics.push(y),n.laneSections.sort((m,g)=>Number(m.id)-Number(g.id));for(let m=0;m<n.laneSections.length;m++){const g=n.laneSections[m],u=Number(g.id);for(const h of g.lanePaths){const v=Number(h.id);if(v===0)continue;const I=h.type,$=[...h.outerPath],j=h.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(h.innerPath[0]);const k=new S.Polygon({rings:[j]});if(k){const C=new f({geometry:k,attributes:{ObjectID:c++,id:`${l}+${u}+${v}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(l),roadName:n.name,sectionId:String(u),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:h.innerPath,rightLine:h.outerPath}});this.allLaneGraphics.push(C),r.push(C)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.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(a),s()},10)})}showJunction(e){const t=[];let i;this.xodrBorder.length>0&&(i=new S.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const s=new S.Point({x:o.coordinates[0],y:o.coordinates[1]});let c=!0;if(i&&(c=A.contains(i,s)),c){const r=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",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 r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===r||this.selectedSectionIds.includes(r)||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===r),l=A.union(n.map(u=>u.geometry)),d=this.hitGraphic.getAttribute("fromNode"),p=this.hitGraphic.getAttribute("toNode"),y=this.junctionNames.get(d)||d,m=this.junctionNames.get(p)||p,g=new f({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,fromNodeName:y,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(g)}else if(s.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.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(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),r=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(n,{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}),s.setAttribute("selected",!0),s.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(r);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const d=l.data.result.obj_id;s.setAttribute("edgeId",d),this.openDriveClickCallback({type:"OpenDriveSection",id:d,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(n=>n!==r),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});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")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(r,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}async clearOpenDrive(){var t,i,o;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(),this.borderLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=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,r=s[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],n=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,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 f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],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(n=>{const l=Number(n.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(a=>a.geometry),r=A.union(c);if(e.flash){const a=new f({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{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=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!e||e.type==="edge"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const o=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==o)}),this.sectionLayer.removeMany(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=Number(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("sectionIndex")===o)),s.length>0){const c=new Map;return s.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let n=c.get(a);n?n.push(r.geometry):(n=[r.geometry],c.set(a,n))}),c.forEach((r,a)=>{const n=A.union(r),l=new f({geometry:n,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new S.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${n}#${l}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const p=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,y=await b.get(p,{params:{id:`${n}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});y.status===200&&y.data.status===0&&s.push(y.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return A.contains(t,n)}),r=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,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 r=s[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===r&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===n);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,p=e.end||100,y=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(y,d,p,{units:"meters"}),g=P.lineString(l.getAttribute("rightLine")),u=G.lineSliceAlong(g,d,p,{units:"meters"}),h=m.geometry.coordinates.concat(u.geometry.coordinates.reverse());h.push(h[h.length-1]);const v=new f({geometry:new S.Polygon({rings:[h]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:m.geometry.coordinates,rightLine:u.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:{coordinates:h}}}clearSplitLane(){this.splitLaneLayer.removeAll()}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(i=>{i.getAttribute("selected")||(i.symbol=this.getCrossGraphicSymbol(i.attributes,e))}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/cross/${i?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',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?25:15,haloSize:2,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:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=D;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/Graphic"),F=require("@arcgis/core/core/promiseUtils"),J=require("@arcgis/core/core/reactiveUtils.js"),S=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),x=require("@arcgis/core/layers/FeatureLayer"),w=require("@arcgis/core/layers/GraphicsLayer"),E=require("@turf/helpers"),G=require("@turf/line-slice-along"),b=require("axios"),R=require("fast-xml-parser"),T=require("md5"),O=require("pako"),_=require("vue"),z=require("../../stores/index.js"),H=require("../common-utils.js");function N(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 M=N(F),U=N(J),A=N(q),P=N(E);class D{constructor(e){this.junctionNames=new Map,this.junctionScale=5e3,this.xodrBorder=[],this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new x({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:"sectionIndex",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 x({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.splitLaneLayer=new w({id:"SplitLane"}),this.borderLayer=new w({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.sectionLayer,this.roadNameLayer,this.junctionLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){var t;try{const o=await(await fetch(e)).text();let r=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return r?r=JSON.parse(r):r=[],{status:0,message:"ok",result:{md5:T(o),border:r}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var y,m,g;this.openDriveClickCallback=e.selectedCallback,this.scaleWatch=U.watch(()=>this.view.scale,(u,h)=>{u>this.junctionScale&&h<=this.junctionScale?this.updateAllJunctionSymbol("marker"):u<=this.junctionScale&&h>this.junctionScale&&this.updateAllJunctionSymbol("picture")});let t=e.file.split("/").pop()||"";t=t.split(".").slice(0,-1).join("."),console.log(`OpenDriveRenderer: 显示OpenDrive文件 ${t}`),this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:t}})}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;H.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 a=await(await fetch(c)).arrayBuffer(),n=O.inflate(a,{to:"string"}),l=JSON.parse(n);if(await this.showAllLanes(l,((y=e.options)==null?void 0:y.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0),((g=e.options)==null?void 0:g.showJunctionPoint)!==!1){const u=o.data.result.junctions;this.showJunction(u)}e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const p=z.default.useAppDataStore;return _.watch(()=>p.isSketching,()=>{var u,h;p.isSketching?((u=this.mouseMoveHandler)==null||u.remove(),this.mouseMoveHandler=void 0,(h=this.mouseClickHandler)==null||h.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 r=await(await fetch(s)).arrayBuffer(),a=O.inflate(r,{to:"string"}),n=JSON.parse(a);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 r=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:l,refLine:d}=n;let p=n.name;p.includes("(")&&(p=p.slice(0,p.indexOf("("))),p=p.replace(/(.)/g,"$1 ");const y=new f({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:p}});this.allRefLineGraphics.push(y),n.laneSections.sort((m,g)=>Number(m.id)-Number(g.id));for(let m=0;m<n.laneSections.length;m++){const g=n.laneSections[m],u=Number(g.id);for(const h of g.lanePaths){const v=Number(h.id);if(v===0)continue;const I=h.type,$=[...h.outerPath],j=h.innerPath.concat($.reverse());if(j.length<=3){console.warn(`lane ${v} has less than 3 points`);continue}j.push(h.innerPath[0]);const k=new S.Polygon({rings:[j]});if(k){const C=new f({geometry:k,attributes:{ObjectID:c++,id:`${l}+${u}+${v}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(l),roadName:n.name,sectionId:String(u),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:h.innerPath,rightLine:h.outerPath}});this.allLaneGraphics.push(C),r.push(C)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const n=r.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(a),s()},10)})}showJunction(e){const t=[];let i;this.xodrBorder.length>0&&(i=new S.Polygon({rings:[this.xodrBorder]}));for(const o of e)if(o&&(this.junctionNames.set(o.id,o.name),o.nodeType=o.type,o.crossId)){const s=new S.Point({x:o.coordinates[0],y:o.coordinates[1]});let c=!0;if(i&&(c=A.contains(i,s)),c){const r=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(r)}}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",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 r=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===r||this.selectedSectionIds.includes(r)||this.sectionLayer.graphics.findIndex(u=>u.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const n=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===r),l=A.union(n.map(u=>u.geometry)),d=this.hitGraphic.getAttribute("fromNode"),p=this.hitGraphic.getAttribute("toNode"),y=this.junctionNames.get(d)||d,m=this.junctionNames.get(p)||p,g=new f({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,fromNodeName:y,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(g)}else if(s.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.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(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),r=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(n,{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}),s.setAttribute("selected",!0),s.symbol={type:"picture-marker",url:"/GisViewerAssets/Images/point_red.png",width:"20px",height:"20px"},this.increasePictureMarkerSize(s,50))}else this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),s.setAttribute("selected",!1),s.symbol=this.getCrossGraphicSymbol(s.attributes,this.view.scale<this.junctionScale?"picture":"marker");else if(c==="OpenDriveSection")if(s.layer.id==="OpenDriveHighlight"){this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0),this.selectedSectionIds.push(r);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(n,{params:{id:r,projectName:this.projectName}});if(l.status===200&&l.data.status===0&&this.openDriveClickCallback){const d=l.data.result.obj_id;s.setAttribute("edgeId",d),this.openDriveClickCallback({type:"OpenDriveSection",id:d,details:l.data.result})}}else this.sectionLayer.remove(s),this.selectedSectionIds=this.selectedSectionIds.filter(n=>n!==r),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0})});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")}`,r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(r,{params:{id:c,projectName:this.projectName}});return a.status===200?a.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}setOpendriveVisibility(e){this.laneLayer.visible=e}async clearOpenDrive(){var t,i,o;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(),this.borderLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0,(o=this.scaleWatch)==null||o.remove(),this.scaleWatch=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,r=s[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const a=r[0],n=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,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 f({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,255,255,.8],outline:{color:[0,255,255],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(n=>{const l=Number(n.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const a=[];if(s.forEach(n=>{const l=Number(n.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((n,l)=>n-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(a=>a.geometry),r=A.union(c);if(e.flash){const a=new f({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{width:0}}});this.flashGraphic(a)}return await this.view.goTo(r,{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=>{(!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")&&(t.setAttribute("selected",!1),t.symbol=this.getCrossGraphicSymbol(t.attributes,this.view.scale<this.junctionScale?"picture":"marker"))}),!e||e.type==="edge"){let t;!e||!e.id||e.id===""?t=this.sectionLayer.graphics.toArray():t=this.sectionLayer.graphics.filter(i=>i.getAttribute("edgeId")===e.id).toArray(),t.length>0&&(t.forEach(i=>{const o=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==o)}),this.sectionLayer.removeMany(t))}return{status:0,message:"ok"}}async 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=Number(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("sectionIndex")===o)),s.length>0){const c=new Map;return s.forEach(r=>{const a=r.getAttribute("roadId")+"+"+r.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let n=c.get(a);n?n.push(r.geometry):(n=[r.geometry],c.set(a,n))}),c.forEach(async(r,a)=>{const n=A.union(r),l=new f({geometry:n,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,edgeId:e.id,selected:!0}});this.sectionLayer.add(l),await this.view.goTo(l)}),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new S.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${n}#${l}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const p=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,y=await b.get(p,{params:{id:`${n}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});y.status===200&&y.data.status===0&&s.push(y.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return A.contains(t,n)}),r=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&r.push(d.data.result)}return{status:0,message:"ok",result:{junctions:r,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 r=s[0];r.startsWith("-")&&(r=r.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===r&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===n);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,p=e.end||100,y=P.lineString(l.getAttribute("leftLine")),m=G.lineSliceAlong(y,d,p,{units:"meters"}),g=P.lineString(l.getAttribute("rightLine")),u=G.lineSliceAlong(g,d,p,{units:"meters"}),h=m.geometry.coordinates.concat(u.geometry.coordinates.reverse());h.push(h[h.length-1]);const v=new f({geometry:new S.Polygon({rings:[h]}),attributes:{ObjectID:l.getAttribute("ObjectID"),id:l.getAttribute("id"),fromNode:l.getAttribute("fromNode"),toNode:l.getAttribute("toNode"),roadId:l.getAttribute("roadId"),roadName:l.getAttribute("roadName"),sectionId:l.getAttribute("sectionId"),sectionIndex:l.getAttribute("sectionIndex"),laneId:l.getAttribute("laneId"),type:l.getAttribute("type"),sumoId:l.getAttribute("sumoId"),leftLine:m.geometry.coordinates,rightLine:u.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(v),this.view.goTo(v),{status:0,message:"ok",result:{coordinates:h}}}clearSplitLane(){this.splitLaneLayer.removeAll()}updateAllJunctionSymbol(e){const t=this.junctionLayer.graphics.clone();this.junctionLayer.removeAll(),t.forEach(i=>{i.getAttribute("selected")||(i.symbol=this.getCrossGraphicSymbol(i.attributes,e))}),this.junctionLayer.addMany(t.toArray())}getCrossGraphicSymbol(e,t){const i=e.crossId!==""&&e.crossId!==void 0&&e.crossId!==null;if(t==="marker")return{type:"picture-marker",url:`/GisViewerAssets/Images/cross/${i?"gis_xhj_blue":"gis_lkcz_xz"}.png`,width:"32px",height:"32px"};if(t==="picture")return i?{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.crossId',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?25:15,haloSize:2,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:32,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}:{type:"picture-marker",url:"/GisViewerAssets/Images/cross/gis_lkcz_xz.png",width:"32px",height:"32px"}}}exports.default=D;
|
package/lib/src/types/index.d.ts
CHANGED