gisviewer-vue3-arcgis 1.0.250 → 1.0.252
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 +4 -1
- package/es/src/gis-map/gis-map.vue.mjs +155 -153
- package/es/src/gis-map/index.d.ts +2 -0
- package/es/src/gis-map/utils/dbscan-cluster/index.d.ts +51 -0
- package/es/src/gis-map/utils/dbscan-cluster/index.mjs +256 -0
- package/es/src/gis-map/utils/green-wave-band-controller/index.d.ts +1 -0
- package/es/src/gis-map/utils/green-wave-band-controller/index.mjs +143 -127
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +87 -86
- package/es/src/gis-map/utils/overlay.d.ts +3 -8
- package/es/src/gis-map/utils/overlay.mjs +48 -52
- package/es/src/gis-map/utils/signal-control-area/district-renderer.d.ts +2 -2
- package/es/src/gis-map/utils/signal-control-area/district-renderer.mjs +6 -2
- package/es/src/gis-map/utils/signal-control-area/show-area.mjs +15 -15
- package/es/src/gis-map/utils/signal-control-area/sub-district-renderer.d.ts +1 -1
- package/es/src/gis-map/utils/signal-control-area/sub-district-renderer.mjs +6 -2
- package/es/src/types/index.d.ts +33 -3
- package/lib/src/gis-map/gis-map.vue.d.ts +4 -1
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/index.d.ts +2 -0
- package/lib/src/gis-map/utils/dbscan-cluster/index.d.ts +51 -0
- package/lib/src/gis-map/utils/dbscan-cluster/index.js +1 -0
- package/lib/src/gis-map/utils/green-wave-band-controller/index.d.ts +1 -0
- package/lib/src/gis-map/utils/green-wave-band-controller/index.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/lib/src/gis-map/utils/overlay.d.ts +3 -8
- package/lib/src/gis-map/utils/overlay.js +1 -1
- package/lib/src/gis-map/utils/signal-control-area/district-renderer.d.ts +2 -2
- package/lib/src/gis-map/utils/signal-control-area/district-renderer.js +1 -1
- package/lib/src/gis-map/utils/signal-control-area/show-area.js +1 -1
- package/lib/src/gis-map/utils/signal-control-area/sub-district-renderer.d.ts +1 -1
- package/lib/src/gis-map/utils/signal-control-area/sub-district-renderer.js +1 -1
- package/lib/src/types/index.d.ts +33 -3
- package/package.json +1 -1
|
@@ -101,9 +101,13 @@ class x {
|
|
|
101
101
|
*/
|
|
102
102
|
async highlightDistrict(t) {
|
|
103
103
|
const i = this.districtControllerDashLayer.definitionExpression;
|
|
104
|
-
this.districtControllerDashLayer.definitionExpression = `id = '${t}'`;
|
|
104
|
+
this.districtControllerDashLayer.definitionExpression = `id = '${t.id}'`;
|
|
105
105
|
const e = await this.districtControllerDashLayer.queryFeatures(), r = e.features.length;
|
|
106
|
-
return r > 0 ? (this.districtControllerSolidLayer.definitionExpression = `id = '${t}'`, await n.viewGoto(
|
|
106
|
+
return r > 0 ? (this.districtControllerSolidLayer.definitionExpression = `id = '${t.id}'`, await n.viewGoto(
|
|
107
|
+
this.view,
|
|
108
|
+
e.features,
|
|
109
|
+
t.needZoom !== !1
|
|
110
|
+
)) : this.districtControllerDashLayer.definitionExpression = i, r;
|
|
107
111
|
}
|
|
108
112
|
filter(t) {
|
|
109
113
|
const i = `id = '${t}'`;
|
|
@@ -21,15 +21,15 @@ class N {
|
|
|
21
21
|
*/
|
|
22
22
|
async showSignalControlArea(e) {
|
|
23
23
|
this.detachmentLayerLoaded || await this.loadDetachmentLayer(), await this.clearSignalControlArea(), this.districtRenderer.setVisible(!1), this.subDistrictRenderer.setVisible(!1), this.signalRenderer.setClusterVisible(!1), this.signalRenderer.setPointVisible(!1);
|
|
24
|
-
const t = [],
|
|
24
|
+
const t = [], s = [];
|
|
25
25
|
for (const n of e.areaList) {
|
|
26
|
-
const
|
|
26
|
+
const i = new w(
|
|
27
27
|
n,
|
|
28
28
|
e.style || ""
|
|
29
29
|
);
|
|
30
|
-
t.push(
|
|
30
|
+
t.push(i), s.push(...i.subDistricts);
|
|
31
31
|
}
|
|
32
|
-
return this.districtRenderer.style = e.style || "", await this.districtRenderer.showDistricts(t), await this.subDistrictRenderer.showSubDistricts(
|
|
32
|
+
return this.districtRenderer.style = e.style || "", await this.districtRenderer.showDistricts(t), await this.subDistrictRenderer.showSubDistricts(s), await this.signalRenderer.showSignals(t), { status: 0, message: "ok" };
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* 清空区控、子区、信号机
|
|
@@ -88,13 +88,13 @@ class N {
|
|
|
88
88
|
async highlightSignalControlArea(e) {
|
|
89
89
|
switch (this.view.closePopup(), e.type) {
|
|
90
90
|
case "district":
|
|
91
|
-
return await this.districtRenderer.highlightDistrict(e
|
|
91
|
+
return await this.districtRenderer.highlightDistrict(e) ? (this.subDistrictRenderer.filter(e), this.signalRenderer.filter(e), await this.subDistrictRenderer.showRoads(e), { status: 0, message: "ok" }) : { status: 1, message: "未找到区控" };
|
|
92
92
|
case "subDistrict": {
|
|
93
|
-
const { count: t, parentId:
|
|
94
|
-
return t > 0 ? (this.districtRenderer.filter(
|
|
93
|
+
const { count: t, parentId: s } = await this.subDistrictRenderer.highlightSubDistrict(e);
|
|
94
|
+
return t > 0 ? (this.districtRenderer.filter(s), this.signalRenderer.filter(e), { status: 0, message: "ok" }) : { status: 1, message: "未找到子区" };
|
|
95
95
|
}
|
|
96
96
|
case "signal": {
|
|
97
|
-
const { districtId: t, subDistrictId:
|
|
97
|
+
const { districtId: t, subDistrictId: s, count: n } = await this.signalRenderer.highlightSignal(e.id);
|
|
98
98
|
return n > 0 ? (this.districtRenderer.filter(t), this.subDistrictRenderer.filter(e), { status: 0, message: "ok" }) : { status: 1, message: "未找到信号机" };
|
|
99
99
|
}
|
|
100
100
|
default:
|
|
@@ -118,13 +118,13 @@ class N {
|
|
|
118
118
|
if (!e)
|
|
119
119
|
return;
|
|
120
120
|
const t = e.find(
|
|
121
|
-
(
|
|
121
|
+
(s) => s.options.id === "shanghai_district"
|
|
122
122
|
);
|
|
123
123
|
if (t)
|
|
124
124
|
try {
|
|
125
125
|
const n = await (await fetch(
|
|
126
126
|
"/GisViewerAssets/ShangHai/Layers/district.json"
|
|
127
|
-
)).json(),
|
|
127
|
+
)).json(), i = [], { renderer: r, labelingInfo: d } = t.options;
|
|
128
128
|
n.features.forEach((c) => {
|
|
129
129
|
const o = c.attributes.ZD_NAME;
|
|
130
130
|
if (o !== "高架支队") {
|
|
@@ -154,17 +154,17 @@ class N {
|
|
|
154
154
|
width: 2
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
|
-
if (
|
|
157
|
+
if (i.push(a), d && o !== "边防港航支队" && o !== "机场支队") {
|
|
158
158
|
const h = new g({
|
|
159
159
|
geometry: l.centroid,
|
|
160
160
|
symbol: { ...d.symbol, text: o }
|
|
161
161
|
});
|
|
162
|
-
|
|
162
|
+
i.push(h);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
}), this.detachmentLayer.addMany(
|
|
166
|
-
} catch (
|
|
167
|
-
console.error("加载支队图层失败:",
|
|
165
|
+
}), this.detachmentLayer.addMany(i), this.detachmentLayerLoaded = !0;
|
|
166
|
+
} catch (s) {
|
|
167
|
+
console.error("加载支队图层失败:", s);
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
}
|
|
@@ -25,7 +25,7 @@ export default class SubDistrictRenderer {
|
|
|
25
25
|
* @param id 子区ID
|
|
26
26
|
* @return 返回高亮子区的数量以及区控id
|
|
27
27
|
*/
|
|
28
|
-
highlightSubDistrict(
|
|
28
|
+
highlightSubDistrict(params: IFindSignalControlAreaParams): Promise<{
|
|
29
29
|
count: number;
|
|
30
30
|
parentId: string;
|
|
31
31
|
}>;
|
|
@@ -238,9 +238,13 @@ class C {
|
|
|
238
238
|
async highlightSubDistrict(e) {
|
|
239
239
|
let s = "";
|
|
240
240
|
const t = this.subDistrictPointLayer.definitionExpression;
|
|
241
|
-
this.subDistrictPointLayer.definitionExpression = `subDistrictId = '${e}'`;
|
|
241
|
+
this.subDistrictPointLayer.definitionExpression = `subDistrictId = '${e.id}'`;
|
|
242
242
|
const r = await this.subDistrictPointLayer.queryFeatures(), i = r.features.length;
|
|
243
|
-
return i > 0 ? (this.subDistrictLineLayer.definitionExpression = `subDistrictId = '${e}'`, s = r.features[0].attributes.districtId, await v.viewGoto(
|
|
243
|
+
return i > 0 ? (this.subDistrictLineLayer.definitionExpression = `subDistrictId = '${e.id}'`, s = r.features[0].attributes.districtId, await v.viewGoto(
|
|
244
|
+
this.view,
|
|
245
|
+
r.features,
|
|
246
|
+
e.needZoom !== !1
|
|
247
|
+
)) : this.subDistrictPointLayer.definitionExpression = t, { count: i, parentId: s };
|
|
244
248
|
}
|
|
245
249
|
/**
|
|
246
250
|
* 按照区控、子区id显示子区
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -104,6 +104,10 @@ export interface IPointSymbol {
|
|
|
104
104
|
verticalOrigin?: string;
|
|
105
105
|
color?: string;
|
|
106
106
|
size?: number;
|
|
107
|
+
outline?: {
|
|
108
|
+
color?: string | number[];
|
|
109
|
+
width?: number;
|
|
110
|
+
};
|
|
107
111
|
}
|
|
108
112
|
export interface ILineSymbol {
|
|
109
113
|
type: string;
|
|
@@ -139,7 +143,30 @@ export interface IOverlayParam {
|
|
|
139
143
|
defaultSymbol?: IPointSymbol | ILineSymbol | IPolygonSymbol;
|
|
140
144
|
defaultVisible?: boolean;
|
|
141
145
|
overlays: Array<IOverlay>;
|
|
142
|
-
|
|
146
|
+
}
|
|
147
|
+
export interface IClusterPointParams {
|
|
148
|
+
type?: string;
|
|
149
|
+
clusterSymbol?: IPointSymbol;
|
|
150
|
+
pointSymbol?: IPointSymbol;
|
|
151
|
+
points: IClusterLocation[];
|
|
152
|
+
}
|
|
153
|
+
export interface IClusterLocation {
|
|
154
|
+
id: string;
|
|
155
|
+
x: number;
|
|
156
|
+
y: number;
|
|
157
|
+
properties?: any;
|
|
158
|
+
visited?: boolean;
|
|
159
|
+
clusterId?: number;
|
|
160
|
+
symbol?: IPointSymbol;
|
|
161
|
+
}
|
|
162
|
+
export interface ICluster {
|
|
163
|
+
id: number;
|
|
164
|
+
items: IClusterLocation[];
|
|
165
|
+
count: number;
|
|
166
|
+
center: {
|
|
167
|
+
x: number;
|
|
168
|
+
y: number;
|
|
169
|
+
} | null;
|
|
143
170
|
}
|
|
144
171
|
export interface ISetMapCameraParams {
|
|
145
172
|
name: string;
|
|
@@ -285,7 +312,7 @@ export interface IDistrictRoad {
|
|
|
285
312
|
export interface IFindSignalControlAreaParams {
|
|
286
313
|
type: string;
|
|
287
314
|
id: string;
|
|
288
|
-
|
|
315
|
+
needZoom?: boolean;
|
|
289
316
|
}
|
|
290
317
|
export interface INode {
|
|
291
318
|
id: string;
|
|
@@ -307,7 +334,10 @@ export interface IEditSignalControlAreaParams {
|
|
|
307
334
|
export interface IShowGreenWaveBandParams {
|
|
308
335
|
bandId: string;
|
|
309
336
|
coordinates: number[][];
|
|
310
|
-
nodeList
|
|
337
|
+
nodeList?: INode[];
|
|
338
|
+
lineColor?: string | number[];
|
|
339
|
+
lineWidth?: number;
|
|
340
|
+
arrowColor?: string | number[];
|
|
311
341
|
}
|
|
312
342
|
export interface IRoadLine {
|
|
313
343
|
id: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import MapView from '@arcgis/core/views/MapView';
|
|
2
2
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
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';
|
|
3
|
+
import { IClusterPointParams, 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 DbscanCluster from './utils/dbscan-cluster';
|
|
4
5
|
import EdpassDeviceController from './utils/edpass-device-controller';
|
|
5
6
|
import GreenWaveBandController from './utils/green-wave-band-controller';
|
|
6
7
|
import HoloFlow from './utils/holo-flow';
|
|
@@ -37,6 +38,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
37
38
|
greenWaveBandController: GreenWaveBandController;
|
|
38
39
|
policeJurisdictionController: PoliceJurisdiction;
|
|
39
40
|
edpassDeviceController: EdpassDeviceController;
|
|
41
|
+
dbscanCluster: DbscanCluster;
|
|
40
42
|
showLogDiv: import("vue").Ref<boolean>;
|
|
41
43
|
appDataStore: import("pinia").Store<"appData", {
|
|
42
44
|
mapConfig: {};
|
|
@@ -113,6 +115,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
113
115
|
toggleTrafficObject: (params: IToggleTrafficInfoParams) => void;
|
|
114
116
|
toggleVehicleInfo: (contentType: string) => void;
|
|
115
117
|
addOverlays: (params: IOverlayParam) => Promise<import("../types").IResult>;
|
|
118
|
+
addClusterPoints: (params: IClusterPointParams) => Promise<void>;
|
|
116
119
|
addMask: (params: IMaskParam) => void;
|
|
117
120
|
removeMask: () => void;
|
|
118
121
|
removeOverlaysByType: (types: string[]) => import("../types").IResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),T=require("./stores/index.js");require("./style/index.css");const rt=require("./utils/dbscan-cluster/index.js"),st=require("./utils/detect-gpu.js"),ot=require("./utils/edpass-device-controller.js"),M=require("./utils/green-wave-band-controller/index.js"),it=require("./utils/holo-flow/index.js"),ct=require("./utils/holo-flow/signal-countdown-panel.vue.js"),lt=require("./utils/map-initializer.js"),x=require("./utils/open-drive-renderer/index.js"),z=require("./utils/overlay.js"),ut=require("./utils/police-jurisdiction.js"),dt=require("./utils/queue-length.js"),E=require("./utils/road-config-tool/index.js"),mt=require("./utils/signal-control-area/edit-area.js"),pt=require("./utils/signal-control-area/show-area.js"),gt=require("./utils/traffic-flow.js"),ft={class:"gis-viewer"},yt={style:{position:"absolute",bottom:"80px",left:"10px","z-index":"9999"}},vt=r.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick","update:zoom"],setup(P,{expose:N,emit:H}){const C=r.ref(null);let n,p,l,i,a,s,f,t,u,o,g,y,h,b;const O=r.ref(!1);T.registerStore();const q=T.default.useAppDataStore,V=r.reactive([]),_=e=>Math.log2(591657527591555e-6/e);let v=null,B=null;const k=e=>{if(!Number.isFinite(e))return;const d=Math.round(e);d!==B&&(B=d,S("update:zoom",d))};st.default(),r.onMounted(async()=>{if(!C.value)return;document.addEventListener("keydown",m=>{m.ctrlKey&&m.key==="i"&&(O.value=!O.value)});const e=r.getCurrentInstance(),{$gisviewerAssetsRoot:d}=e.appContext.config.globalProperties,c=await(await fetch(I.config)).json();c.assetsRoot=I.assetsRoot||d,q.mapConfig=c,p=new lt.default,q.mapInitializer=p,n=await p.initialize({container:C.value,mapConfig:c,markerClickCallback:(m,L,D,at)=>{S("markerClick",m,L,D,at)},mapClickCallback:(m,L,D)=>{S("mapClick",m,L,D)}});const w=n.zoom??(n.scale?_(n.scale):void 0);typeof w=="number"&&k(w);const nt=n.zoom!==void 0?n.watch("zoom",m=>{k(m)}):n.watch("scale",m=>{typeof m=="number"&&m>0&&k(_(m))});v=()=>nt.remove(),a=new it.default(n,V),await a.init(),S("mapLoaded")}),r.onUnmounted(()=>{o==null||o.clearSignalControlArea(),t==null||t.clearOpenDrive(),a.clearHoloTrace(),a.clearHoloSignal(),i==null||i.disconnectTrafficFlow(),v==null||v(),v=null});const G=r.computed(()=>n),Z=()=>{const e=T.default.useAppDataStore;e.saveTrackLog=!0},W=()=>{a.downloadTrackLog()},j=()=>{A("vehicleId")},J=()=>{A("plateNumber")},Q=async e=>await p.setMapCenter(e),U=async e=>await p.setMapCamera(e),K=e=>p.setMapZoom(e),F=async e=>await p.lookAt(e),X=e=>p.setLayerVisibility(e),Y=(e,d)=>p.requestCoordinateTransform(e,d),R=e=>{p.cancelCoordinateTransform(e)},$=e=>{p.setMapZoomRange(e)},ee=e=>(l||(l=new E.default(n)),l.showLaneNumber(e)),te=()=>{l==null||l.clearLaneNumber()},ne=async e=>(l||(l=new E.default(n)),await l.initializeSearch(e)),ae=async()=>l==null?void 0:l.calCrossIndicatorArea(),re=async()=>{},se=async(e,d)=>{i||(i=new gt.default(n)),i.connectTrafficFlow(e,d)},oe=()=>{i==null||i.disconnectTrafficFlow()},ie=async e=>{a.handleVehicleTraceData(e)},ce=()=>{a.clearHoloTrace()},le=e=>{a.setInterpolate(e)},ue=async e=>{await a.handleSignalData(e)},de=async e=>{await a.initializeLampGroup(e)},me=e=>{a.handleUniSignalData(e)},pe=()=>{a.clearHoloSignal()},ge=e=>{i==null||i.toggleTrafficInfo(e),a==null||a.toggleTrafficInfo(e)},fe=e=>{a==null||a.togglePause(e)},ye=e=>{i==null||i.toggleTrafficObject(e),a==null||a.toggleTrafficObject(e)},A=e=>{a==null||a.updatePanelContent(e)},ve=async e=>(s||(s=new z.default(n)),s.addOverlays(e)),Se=async e=>(b||(b=new rt.default(n)),b.addClusterPoints(e)),we=e=>(s||(s=new z.default(n)),s.addMask(e)),Ce=()=>{s==null||s.removeMask()},he=e=>s==null?void 0:s.removeOverlaysByType(e),be=e=>s==null?void 0:s.removeOverlaysById(e),Oe=()=>s==null?void 0:s.removeAllOverlays(),ke=()=>{s==null||s.showAllOverlays()},Ae=e=>{f||(f=new dt.default(n)),f.updateQueueLength(e)},Le=()=>{f==null||f.removeQueueLength()},De=async(e,d)=>(t||(t=new x.default(n)),await t.showOpenDriveFromServer(e,d)),Te=async e=>(t||(t=new x.default(n)),await t.clearOpenDrive(),await t.showOpenDriveFromFile(e)),qe=e=>t?t.setOpendriveVisibility(e):{status:-1,message:"未加载OpenDrive地图"},Ve=async()=>await(t==null?void 0:t.clearOpenDrive()),_e=async e=>t?await(t==null?void 0:t.findSumo(e)):{status:-1,message:"未加载OpenDrive地图"},Be=async e=>t?t.selectSumo(e):{status:-1,message:"未加载OpenDrive地图"},Ie=async e=>t?t.unselectSumo(e):{status:-1,message:"未加载OpenDrive地图"},Me=async e=>t?await t.geometrySearch(e):{status:-1,message:"未加载OpenDrive地图"},xe=async e=>t?await t.getSumoInfo(e):{status:-1,message:"未加载OpenDrive地图"},ze=async e=>t?await(t==null?void 0:t.splitLane(e)):{status:-1,message:"未加载OpenDrive地图"},Ee=async()=>t?t==null?void 0:t.clearSplitLane():{status:-1,message:"未加载OpenDrive地图"},Pe=async e=>(o||(o=new pt.default(n)),await o.showSignalControlArea(e)),Ne=async()=>await(o==null?void 0:o.clearSignalControlArea()),He=e=>o==null?void 0:o.setLayerVisibility(e),Ge=async e=>o?await(o==null?void 0:o.locateSignalControlArea(e)):{status:-1,message:"未加载信号控制区"},Ze=async e=>o?await o.highlightSignalControlArea(e):{status:-1,message:"未加载信号控制区"},We=()=>o?o.resetHighlight():{status:-1,message:"未加载信号控制区"},je=e=>(u||(u=new mt.default(n)),u.showSubSignalControlArea(e)),Je=e=>u?u.editSubSignalControlArea(e):{status:-1,message:"未加载信号控制区"},Qe=()=>u?u.stopEditSubSignalControlArea():{status:-1,message:"未加载信号控制区"},Ue=e=>u?u.selectSubSignalControlAreaCross(e):{status:-1,message:"未加载信号控制区"},Ke=e=>u?u.unselectSubSignalControlAreaCross(e):{status:-1,message:"未加载信号控制区"},Fe=e=>{if(!u)return{status:-1,message:"未加载信号控制区"}},Xe=e=>(g||(g=new M.default(n)),g.addGreenWaveBand(e)),Ye=()=>{if(!g)return{status:-1,message:"未加载绿波带"};g.stopAddGreenWaveBand()},Re=async e=>(g||(g=new M.default(n)),await g.showGreenWaveBand(e)),$e=async e=>(y||(y=new ut.default(n)),await y.showJurisdiction(e)),et=()=>{if(!y)return{status:-1,message:"未加载警务管辖区"};y.clearJurisdiction()},tt=async e=>(h||(h=new ot.default(n)),await h.setEdpassLayerVisibility(e)),I=P,S=H;return N({mapViewer:G,setLayerVisibility:X,setMapCenter:Q,lookAt:F,setMapCamera:U,setMapZoom:K,setMapZoomRange:$,requestCoordinateTransform:Y,cancelCoordinateTransform:R,addOverlays:ve,addClusterPoints:Se,addMask:we,removeMask:Ce,showAllOverlays:ke,removeOverlaysByType:he,removeOverlaysById:be,removeAllOverlays:Oe,showLaneNumber:ee,clearLaneNumber:te,initializeAreaTool:ne,calCrossIndicatorArea:ae,calRoadIndicatorArea:re,connectCarFlow:se,disconnectCarFlow:oe,handleHoloVehicleTraceData:ie,clearHoloTrace:ce,initializeLampGroup:de,handleUniSignalData:me,handleHoloSignalData:ue,clearHoloSignal:pe,setInterpolate:le,toggleTrafficInfo:ge,toggleTrafficObject:ye,toggleVehicleInfo:A,togglePause:fe,updateQueueLength:Ae,removeQueueLength:Le,showOpenDriveFromServer:De,showOpenDriveFromFile:Te,clearOpenDrive:Ve,setOpendriveVisibility:qe,geometrySearchInOpenDrive:Me,findSumoInOpenDrive:_e,selectSumoInOpenDrive:Be,unselectSumoInOpenDrive:Ie,getSumoInfo:xe,splitOpenDriveLane:ze,clearSplitOpenDriveLane:Ee,showSignalControlArea:Pe,clearSignalControlArea:Ne,setSignalControlAreaVisibility:He,locateSignalControlArea:Ge,highlightSignalControlArea:Ze,resetHighlightSignalControlArea:We,showSubSignalControlArea:je,editSubSignalControlArea:Je,stopEditSubSignalControlArea:Qe,selectSubSignalControlAreaCross:Ue,unselectSubSignalControlAreaCross:Ke,changeSubSignalControlAreaBorderVisibility:Fe,addGreenWaveBand:Xe,stopAddGreenWaveBand:Ye,showGreenWaveBand:Re,showPoliceArea:$e,clearPoliceArea:et,setEdpassLayerVisibility:tt}),(e,d)=>(r.openBlock(),r.createElementBlock("div",ft,[r.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:C},[r.withDirectives(r.createElementVNode("div",yt,[r.createElementVNode("button",{style:{"margin-right":"10px"},onClick:Z}," 开始记录 "),r.createElementVNode("button",{style:{"margin-right":"10px"},onClick:W}," 下载日志 "),r.createElementVNode("button",{style:{"margin-right":"10px"},onClick:j}," 显示车辆id "),r.createElementVNode("button",{onClick:J},"显示车辆号牌")],512),[[r.vShow,O.value]])],512),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(V,(c,w)=>(r.openBlock(),r.createBlock(ct.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=vt;
|
|
@@ -22,6 +22,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
22
22
|
greenWaveBandController: import("./utils/green-wave-band-controller").default;
|
|
23
23
|
policeJurisdictionController: import("./utils/police-jurisdiction").default;
|
|
24
24
|
edpassDeviceController: import("./utils/edpass-device-controller").default;
|
|
25
|
+
dbscanCluster: import("./utils/dbscan-cluster").default;
|
|
25
26
|
showLogDiv: import("vue").Ref<boolean>;
|
|
26
27
|
appDataStore: import("pinia").Store<"appData", {
|
|
27
28
|
mapConfig: {};
|
|
@@ -98,6 +99,7 @@ export declare const GisMap: import("@easyest/utils/dist/lib/withinstall").SFCWi
|
|
|
98
99
|
toggleTrafficObject: (params: import("../types").IToggleTrafficInfoParams) => void;
|
|
99
100
|
toggleVehicleInfo: (contentType: string) => void;
|
|
100
101
|
addOverlays: (params: import("../types").IOverlayParam) => Promise<import("../types").IResult>;
|
|
102
|
+
addClusterPoints: (params: import("../types").IClusterPointParams) => Promise<void>;
|
|
101
103
|
addMask: (params: import("../types").IMaskParam) => void;
|
|
102
104
|
removeMask: () => void;
|
|
103
105
|
removeOverlaysByType: (types: string[]) => import("../types").IResult;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IClusterPointParams } from 'packages/components/src/types';
|
|
2
|
+
export default class DbscanCluster {
|
|
3
|
+
private view;
|
|
4
|
+
private clusterLayer;
|
|
5
|
+
private maxClusterSymbolSize;
|
|
6
|
+
private minClusterSymbolSize;
|
|
7
|
+
constructor(view: __esri.MapView | __esri.SceneView);
|
|
8
|
+
private zoomWatchHandle;
|
|
9
|
+
private locations;
|
|
10
|
+
private clusterMarkUrl;
|
|
11
|
+
private currentZoom;
|
|
12
|
+
/**
|
|
13
|
+
* 将地理位置转换为屏幕坐标
|
|
14
|
+
*/
|
|
15
|
+
private locationToScreen;
|
|
16
|
+
/**
|
|
17
|
+
* 添加聚类点到视图
|
|
18
|
+
* @param params
|
|
19
|
+
*/
|
|
20
|
+
addClusterPoints(params: IClusterPointParams): void;
|
|
21
|
+
private showClusters;
|
|
22
|
+
/**
|
|
23
|
+
* 获取邻居点
|
|
24
|
+
* @param locations
|
|
25
|
+
* @param index
|
|
26
|
+
* @param eps
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
private getNeighbors;
|
|
30
|
+
/**
|
|
31
|
+
* 两点间的像素距离
|
|
32
|
+
* @param point1
|
|
33
|
+
* @param point2
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
private getDistance;
|
|
37
|
+
/**
|
|
38
|
+
* 从聚类结果中创建聚类对象
|
|
39
|
+
* @param locations
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
private createClusters;
|
|
43
|
+
/**
|
|
44
|
+
* 按照像素距离聚类
|
|
45
|
+
* @param locations
|
|
46
|
+
* @param eps
|
|
47
|
+
* @param minPoints
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
private doPixelCluster;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/core/reactiveUtils"),m=require("@arcgis/core/geometry"),h=require("@arcgis/core/Graphic"),S=require("@arcgis/core/layers/GraphicsLayer");function g(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 C=g(b);class x{constructor(e){this.maxClusterSymbolSize=50,this.minClusterSymbolSize=25,this.zoomWatchHandle=null,this.locations=[],this.clusterMarkUrl="",this.currentZoom=0,this.view=e,this.currentZoom=e.zoom,this.clusterLayer=new S,this.view.map.add(this.clusterLayer)}locationToScreen(){this.locations.forEach(e=>{const t=this.view.toScreen(new m.Point({x:e.x,y:e.y}));e.properties.screenX=t.x,e.properties.screenY=t.y})}addClusterPoints(e){var i;this.locations=e.points,this.clusterMarkUrl=((i=e.clusterSymbol)==null?void 0:i.url)||"/GisViewerAssets/Images/cross/gis_xhj_blue.png",e.points.forEach(s=>{s.symbol||(s.symbol=e.pointSymbol||{type:"simple-marker",style:"circle",color:"#3388ff",size:8,outline:{color:"#ffffff",width:1}})}),this.zoomWatchHandle||(this.zoomWatchHandle=C.watch(()=>this.view.zoom,()=>{Math.abs(this.currentZoom-this.view.zoom)>=1&&(this.currentZoom=this.view.zoom,this.locationToScreen(),this.clusterLayer.removeAll(),this.addClusterPoints(e))})),this.locationToScreen(),console.time("cluster");const t=this.doPixelCluster(e.points,120,3);console.timeEnd("cluster"),this.showClusters(t)}showClusters(e){let t=Number.MIN_VALUE,i=Number.MAX_VALUE;e.forEach(s=>{s.count>1&&(i=Math.min(i,s.count),t=Math.max(t,s.count))}),e.forEach(s=>{if(s.id!==-1){let r=i===t?(this.maxClusterSymbolSize+this.minClusterSymbolSize)/2:this.minClusterSymbolSize+(s.count-i)/(t-i)*(this.maxClusterSymbolSize-this.minClusterSymbolSize);r*=.75;const o=new h({geometry:new m.Point({x:s.center.x,y:s.center.y}),attributes:{count:s.count},symbol:{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:"$feature.count",returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:r,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[-15,40],[15,40],[15,20],[-15,20],[-15,40]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[2,72,200,255]},{type:"CIMSolidStroke",enable:!0,width:5,color:[2,72,200,128]}]}},{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:16,horizontalAlignment:"Center",offsetX:0,offsetY:30,symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:r,rotateClockwise:!0,textureFilter:"Picture",url:this.clusterMarkUrl}]}}}});this.clusterLayer.add(o)}else s.items.forEach(r=>{const o=new h({geometry:new m.Point({x:r.x,y:r.y}),attributes:r.properties,symbol:r.symbol});this.clusterLayer.add(o)})})}getNeighbors(e,t,i){const s=e[t];return e.filter(r=>r.id===s.id||r.visited?!1:this.getDistance(s,r)<=i)}getDistance(e,t){return Math.sqrt(Math.pow(e.properties.screenX-t.properties.screenX,2)+Math.pow(e.properties.screenY-t.properties.screenY,2))}createClusters(e){const t={},i=[];for(let r=0;r<e.length;r++){const o=e[r];o.clusterId===void 0||o.clusterId===-1?i.push(o):(t[o.clusterId]||(t[o.clusterId]=[]),t[o.clusterId].push(o))}const s=Object.keys(t).map((r,o)=>{const n=t[Number(r)],c=n.length,y=n.reduce((u,a)=>u+a.x,0),d=n.reduce((u,a)=>u+a.y,0),p=y/c,f=d/c;return{id:Number(r),items:n,count:c,center:{x:p,y:f}}});return i.length>0&&s.push({id:-1,items:i,count:i.length,center:null}),s}doPixelCluster(e,t,i){let s=0;e.forEach(r=>r.visited=!1);for(let r=0;r<e.length;r++){const o=e[r];if(o.visited)continue;o.visited=!0;const n=this.getNeighbors(e,r,t);n.length<i?o.clusterId=-1:(n.forEach(c=>{c.visited=!0,c.clusterId=s}),o.clusterId=s,s++)}return this.createClusters(e)}}exports.default=x;
|
|
@@ -24,6 +24,7 @@ export default class GreenWaveBandController {
|
|
|
24
24
|
addGreenWaveBand(params: IEditSignalControlAreaParams): void;
|
|
25
25
|
stopAddGreenWaveBand(): void;
|
|
26
26
|
showGreenWaveBand(params: IShowGreenWaveBandParams): Promise<void>;
|
|
27
|
+
removeGreenWaveBand(bandId: string): void;
|
|
27
28
|
/**
|
|
28
29
|
* 显示所有路口,进入待选状态
|
|
29
30
|
* @param nodeAttributes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/core/reactiveUtils.js"),m=require("@arcgis/core/geometry"),c=require("@arcgis/core/Graphic"),y=require("@arcgis/core/layers/GraphicsLayer"),u=require("axios");function g(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const p=g(b);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",t=>{this.handleViewClick(t)}))}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.removeGreenWaveBand(e.bandId),this.scaleWatcher||(this.scaleWatcher=p.watch(()=>this.view.scale,(i,o)=>{i>this.nodeScale&&o<=this.nodeScale?this.bandLayer.graphics.forEach(a=>{a.geometry.type==="point"&&(a.symbol=this.getShowNodeSymbol("marker"))}):i<=this.nodeScale&&o>this.nodeScale&&this.bandLayer.graphics.forEach(a=>{a.geometry.type==="point"&&(a.symbol=this.getShowNodeSymbol("picture"))})}));const t=new m.Polyline({paths:[e.coordinates]}),s=new c({geometry:t,symbol:this.getLineSymbol(!0,e),attributes:{bandId:e.bandId,type:"greenWaveBand",id:e.bandId}});this.roadsectLayer.add(s),await this.view.goTo(s),e.nodeList&&e.nodeList.forEach(i=>{const o=new c({geometry:{type:"point",x:i.longitude,y:i.latitude},symbol:this.getShowNodeSymbol("picture"),attributes:{...i,bandId:e.bandId,type:"greenWaveBandNode"}});this.bandLayer.add(o)})}removeGreenWaveBand(e){let t=this.bandLayer.graphics.filter(s=>s.getAttribute("bandId")===e);this.bandLayer.removeMany(t.toArray()),t=this.roadsectLayer.graphics.filter(s=>s.getAttribute("bandId")===e),this.roadsectLayer.removeMany(t.toArray())}showAllNodes(e){const t=[];e.forEach(s=>{t.push(new c({geometry:{type:"point",x:s.longitude,y:s.latitude},symbol:this.getEditableNodeSymbol(!1),attributes:{...s,selected:!1}}))}),this.allNodesLayer.addMany(t)}async handleViewClick(e){var a;const s=(a=(await this.view.hitTest(e,{include:[this.allNodesLayer]})).results)==null?void 0:a.filter(d=>d.type==="graphic");if(s.length===0)return;const i=s[0].graphic,o=i.getAttribute("id");if(this.selectedNodeIds.includes(o)){const d=this.selectedNodeIds.indexOf(o)+1;if(d===1)this.removeAllNodeCallback&&this.removeAllNodeCallback(),this.selectedNodeIds=[],this.allNodesLayer.graphics.forEach(r=>{r.setAttribute("selected",!1),r.symbol=this.getEditableNodeSymbol(!1),r.visible=!0}),this.roadsectLayer.removeAll();else{for(let r=d;r<this.selectedNodeIds.length;r++){this.removeNodeCallback&&this.removeNodeCallback({id:this.selectedNodeIds[r]});for(let l=0;l<this.roadsectLayer.graphics.length;l++){const h=this.roadsectLayer.graphics.getItemAt(l);(h.getAttribute("id")===this.selectedNodeIds[r]||!h.getAttribute("selected"))&&(this.roadsectLayer.remove(h),l--)}}this.selectedNodeIds=this.selectedNodeIds.slice(0,d),this.allNodesLayer.graphics.forEach(r=>{const l=this.selectedNodeIds.includes(r.getAttribute("id"));r.setAttribute("selected",l),r.symbol=this.getEditableNodeSymbol(l),r.visible=l}),await this.showDownstreamNodes(o)}}else{i.setAttribute("selected",!0),i.symbol=this.getEditableNodeSymbol(!0),this.selectedNodeIds.push(o),this.allNodesLayer.graphics.forEach(r=>{r.visible=r.getAttribute("selected")});let d=[];for(let r=0;r<this.roadsectLayer.graphics.length;r++){const l=this.roadsectLayer.graphics.getItemAt(r);l.getAttribute("id")===o?(l.symbol=this.getLineSymbol(!0),l.setAttribute("selected",!0),d=l.geometry.paths[0]):l.getAttribute("selected")||(this.roadsectLayer.remove(l),r--)}this.addNodeCallback&&this.addNodeCallback({...i.attributes,roadsect:d}),await this.showDownstreamNodes(o)}}async showDownstreamNodes(e){this.view.container.style.cursor="progress";const t=await u.get(`http://${this.openDriveServer}/api/computable/getDownstreamNodes`,{params:{nodeId:e}});if(t.status!==200||t.data.status!==0){this.view.container.style.cursor="default";return}t.data.result.forEach(i=>{this.allNodesLayer.graphics.forEach(o=>{if(o.getAttribute("nodeId")===i.id&&o.getAttribute("selected")===!1&&(o.visible=!0,i.coordinates)){const a=new c({geometry:{type:"polyline",paths:[i.coordinates]},symbol:this.getLineSymbol(!1),attributes:{...i,selected:!1}});this.roadsectLayer.add(a)}})}),this.view.container.style.cursor="default"}getLineSymbol(e,t){if(e){const s=(t==null?void 0:t.lineWidth)||4,i=(t==null?void 0:t.lineColor)||[55,125,34,255],o=(t==null?void 0:t.arrowColor)||[255,255,255,255];return Array.isArray(i)&&i.length===3&&i.push(255),Array.isArray(o)&&o.length===3&&o.push(255),{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:[[[s,-s],[3*s,0],[s,s]],[[-s,s],[-3*s,0],[-s,-s]]]},symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,width:1.5,color:o}]}}]},{type:"CIMSolidStroke",enable:!0,width:s,color:i}]}}}}else return{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 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;
|
|
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 n=(t=new R.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o).OpenDRIVE.userData)==null?void 0:t.border;return n?n=JSON.parse(n):n=[],{status:0,message:"ok",result:{md5:T(o),border:n}}}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(),r=O.inflate(a,{to:"string"}),l=JSON.parse(r);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 n=await(await fetch(s)).arrayBuffer(),a=O.inflate(n,{to:"string"}),r=JSON.parse(a);return console.log(r),await this.showAllLanes(r,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){console.log(e);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 n=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:l,refLine:d}=r;let p=r.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),r.laneSections.sort((m,g)=>Number(m.id)-Number(g.id));for(let m=0;m<r.laneSections.length;m++){const g=r.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:r.fromNode,toNode:r.toNode,roadId:String(l),roadName:r.name,sectionId:String(u),sectionIndex:m,laneId:v,type:I,sumoId:"",leftLine:h.innerPath,rightLine:h.outerPath}});this.allLaneGraphics.push(C),n.push(C)}}}}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=[];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 n=new f({geometry:s,attributes:{...o,selected:!1,type:"OpenDriveJunction"},symbol:this.getCrossGraphicSymbol(o,"marker")});t.push(n)}}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(n=>n.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 n=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(this.currentSectionCode===n||this.selectedSectionIds.includes(n)||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),l=A.union(r.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:n,selected:!1,fromNodeName:y,toNodeName:m,laneCount:r.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}});this.highlightLayer.removeAll(),this.highlightLayer.add(g)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n}});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(r=>r.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),n=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(r,{params:{id:n,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,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:n,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(n);const r=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(r,{params:{id:n,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(r=>r!==n),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")}`,n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(n,{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,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: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(r=>{const l=Number(r.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((r,l)=>r-l),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 l=Number(r.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((r,l)=>r-l),o>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=a[o],s=s.filter(r=>Number(r.attributes.laneId)===o)}const c=s.map(a=>a.geometry),n=A.union(c);if(e.flash){const a=new f({geometry:n,symbol:{type:"simple-fill",color:[0,255,255,.6],style:"solid",outline:{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=>{(!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(n=>{const a=n.getAttribute("roadId")+"+"+n.getAttribute("sectionId");this.selectedSectionIds.includes(a)||this.selectedSectionIds.push(a);let r=c.get(a);r?r.push(n.geometry):(r=[n.geometry],c.set(a,r))}),c.forEach(async(n,a)=>{const r=A.union(n),l=new f({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,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 r=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${r}#${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:`${r}+${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 r=a.geometry;return A.contains(t,r)}),n=[];for(const a of c){const r=a.getAttribute("id");this.selectSumo({type:"junction",id:r});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:r,projectName:this.projectName}});d.status===200&&d.data.status===0&&n.push(d.data.result)}return{status:0,message:"ok",result:{junctions:n,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 n=s[0];n.startsWith("-")&&(n=n.slice(1));const a=this.allLaneGraphics.filter(I=>I.getAttribute("roadId")===n&&I.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const r=a.length-o,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===r);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;
|
|
@@ -2,7 +2,7 @@ import Graphic from '@arcgis/core/Graphic';
|
|
|
2
2
|
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
|
|
3
3
|
import MapView from '@arcgis/core/views/MapView';
|
|
4
4
|
import SceneView from '@arcgis/core/views/SceneView';
|
|
5
|
-
import {
|
|
5
|
+
import { IClusterPointParams, IMaskParam, IOverlayParam, IResult } from '../../types';
|
|
6
6
|
interface IOverlayOptions {
|
|
7
7
|
id: string;
|
|
8
8
|
}
|
|
@@ -73,13 +73,8 @@ export default class Overlay {
|
|
|
73
73
|
* @memberof Overlay
|
|
74
74
|
*/
|
|
75
75
|
showLayer(): void;
|
|
76
|
-
/**
|
|
77
|
-
* 添加点覆盖物
|
|
78
|
-
* @param overlay
|
|
79
|
-
* @param symbol
|
|
80
|
-
* @param properties
|
|
81
|
-
*/
|
|
82
|
-
addPoint(overlay: IOverlay, symbol: IPointSymbol, properties: any, visible?: boolean): IResult;
|
|
83
76
|
private addOverlay;
|
|
77
|
+
private clusterLayer;
|
|
78
|
+
addClusterPoint(params: IClusterPointParams): void;
|
|
84
79
|
}
|
|
85
80
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/geometry"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/geometry"),v=require("@arcgis/core/geometry/geometryEngine"),u=require("@arcgis/core/Graphic"),h=require("@arcgis/core/layers/FeatureLayer"),g=require("@arcgis/core/layers/GraphicsLayer");function f(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>o[r]})}}return e.default=o,Object.freeze(e)}const n=f(v);class p{constructor(e,r){this.defaultPointSymbol={type:"simple-marker",style:"circle",color:"yellow",size:10},this.view=e,this.overlayLayer=new g({...r}),this.view.map.layers.add(this.overlayLayer)}addMask(e){this.removeMask();const r=e.maskColor||[100,100,100,.8],i=e.maskSize||100;let t=new c.Polygon({rings:[e.geometry.rings[0]]});const s=t.centroid,a=n.geodesicBuffer(s,i,"kilometers");let l=n.difference(a,t);if(e.geometry.rings.length>1)for(let y=1;y<e.geometry.rings.length;y++)t=new c.Polygon({rings:[e.geometry.rings[y]]}),l=n.difference(l,t);const d=new u({geometry:l,symbol:{type:"simple-fill",color:r,outline:{style:"long-dash",color:"white"}},attributes:{type:"mask"}});this.overlayLayer.add(d)}removeMask(){const e=this.overlayLayer.graphics.find(r=>r.getAttribute("type")==="mask");e&&this.overlayLayer.remove(e)}addOverlays(e){let r=0,i=0;e.defaultVisible==null&&(e.defaultVisible=!0);for(const t of e.overlays){t.properties?(t.properties.type||(t.properties.type=e.type),t.properties.id||(t.properties.id=t.id)):t.properties={type:e.type,id:t.id};const s=t.symbol||e.defaultSymbol||this.defaultPointSymbol,a=t.visible==null?e.defaultVisible:t.visible;this.addOverlay(t,s,t.properties,a).message==="add"?r++:i++}return{status:0,message:`新增${r}, 更新${i}`}}removeOverlaysByType(e){const r=this.overlayLayer.graphics.filter(i=>{const t=i.getAttribute("type");return e.includes(t)});return this.overlayLayer.graphics.removeMany(r),{status:0,message:`删除${r.length}`}}removeOverlaysById(e){const r=this.overlayLayer.graphics.filter(i=>{const t=i.getAttribute("id");return e.includes(t)});return this.overlayLayer.graphics.removeMany(r),{status:0,message:`删除${r.length}`}}isShowOverlaysByIds(e,r){this.overlayLayer.graphics.map(i=>{const t=i.getAttribute("id");e.includes(t)?i.visible=r:i.visible=!r})}showAllOverlays(){this.overlayLayer.graphics.forEach(e=>{e.visible=!0})}removeAllOverlays(){const e=this.overlayLayer.graphics.length;return this.overlayLayer.removeAll(),{status:0,message:`删除${e}`}}destroy(){this.view.map.remove(this.overlayLayer),this.overlayLayer.destroy()}removeGraphics(e){Array.isArray(e)||(e=[e]),this.overlayLayer.graphics.removeMany(e)}async findGraphic(e){var t;return(t=(await this.view.hitTest(e)).results)==null?void 0:t.filter(s=>s.type==="graphic"&&s.graphic.layer===this.overlayLayer)}hideLayer(){this.overlayLayer.visible=!1}showLayer(){this.overlayLayer.visible=!0}addOverlay(e,r,i,t){let s,a=!0;return e.id&&(s=this.overlayLayer.graphics.find(l=>l.getAttribute("id")===e.id)),s?s.visible=t:(s=new u({visible:t}),this.overlayLayer.add(s),a=!1),s.geometry=e.geometry,s.symbol=r,s.attributes=i,{status:0,message:a?"add":"update"}}addClusterPoint(e){this.clusterLayer||(this.clusterLayer=new h({id:"clusterPointLayer",source:[],outFields:["*"],geometryType:"point"}),this.view.map.add(this.clusterLayer))}}exports.default=p;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IResult } from '../../../types';
|
|
1
|
+
import { IFindSignalControlAreaParams, IResult } from '../../../types';
|
|
2
2
|
import DistrictController from './district-controller';
|
|
3
3
|
export default class DistrictRenderer {
|
|
4
4
|
private view;
|
|
@@ -33,7 +33,7 @@ export default class DistrictRenderer {
|
|
|
33
33
|
* @param id 区控ID
|
|
34
34
|
* @return 返回高亮区控的数量
|
|
35
35
|
*/
|
|
36
|
-
highlightDistrict(
|
|
36
|
+
highlightDistrict(params: IFindSignalControlAreaParams): Promise<number>;
|
|
37
37
|
filter(id: string): void;
|
|
38
38
|
resetFilter(): void;
|
|
39
39
|
}
|