gisviewer-vue3-arcgis 1.0.150 → 1.0.151
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/utils/map-initializer.mjs +43 -35
- 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 +231 -222
- package/es/src/gis-map/utils/signal-control-area-controller/index.mjs +12 -15
- 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/gis-map/utils/signal-control-area-controller/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as p from "@arcgis/core/core/reactiveUtils.js";
|
|
2
2
|
import y from "@arcgis/core/Graphic";
|
|
3
3
|
import o from "@arcgis/core/layers/GraphicsLayer";
|
|
4
4
|
import f from "@turf/buffer";
|
|
5
|
-
import
|
|
5
|
+
import d from "@turf/concave";
|
|
6
6
|
import m from "@turf/convex";
|
|
7
7
|
import * as h from "@turf/helpers";
|
|
8
|
-
import
|
|
8
|
+
import b from "./district-controller.mjs";
|
|
9
9
|
class x {
|
|
10
10
|
constructor(e) {
|
|
11
|
-
this.crossScale =
|
|
12
|
-
closeButton: !0,
|
|
13
|
-
collapseButton: !1,
|
|
14
|
-
actionBar: !0
|
|
15
|
-
}, this.districtControllerLayer = new o({
|
|
11
|
+
this.crossScale = 5e3, this.view = e, this.districtControllerLayer = new o({
|
|
16
12
|
id: "districtControllerLayer",
|
|
17
13
|
maxScale: 144447,
|
|
18
14
|
minScale: 1155582
|
|
@@ -36,10 +32,10 @@ class x {
|
|
|
36
32
|
showSignalControlArea(e) {
|
|
37
33
|
this.districtControllerLayer.removeAll(), this.subDistrictControllerLayer.removeAll(), this.crossLayer.removeAll(), this.highlightLayer.removeAll(), this.districtControllerLayer.visible = !0, this.subDistrictControllerLayer.visible = !0;
|
|
38
34
|
for (const t of e) {
|
|
39
|
-
const r = new
|
|
35
|
+
const r = new b(t);
|
|
40
36
|
this.drawArea(r, !0);
|
|
41
37
|
}
|
|
42
|
-
return this.watchHandle =
|
|
38
|
+
return this.watchHandle = p.watch(
|
|
43
39
|
() => this.view.scale,
|
|
44
40
|
(t, r) => {
|
|
45
41
|
t > this.crossScale && r <= this.crossScale ? (this.crossLayer.graphics.forEach((s) => {
|
|
@@ -126,9 +122,9 @@ class x {
|
|
|
126
122
|
i = h.lineString(r);
|
|
127
123
|
else if (r.length > 2) {
|
|
128
124
|
const n = h.featureCollection(
|
|
129
|
-
r.map((
|
|
125
|
+
r.map((u) => h.point(u))
|
|
130
126
|
);
|
|
131
|
-
t ? i = m(n) : (i =
|
|
127
|
+
t ? i = m(n) : (i = d(n, { maxEdge: 400, units: "meters" }), i || (i = m(n)));
|
|
132
128
|
}
|
|
133
129
|
if (!i) {
|
|
134
130
|
console.log("生成区控面失败", e);
|
|
@@ -166,7 +162,7 @@ class x {
|
|
|
166
162
|
label: "路口数量"
|
|
167
163
|
}
|
|
168
164
|
];
|
|
169
|
-
const
|
|
165
|
+
const g = {
|
|
170
166
|
type: "signalControlArea",
|
|
171
167
|
id: e.id,
|
|
172
168
|
name: e.name,
|
|
@@ -188,7 +184,7 @@ class x {
|
|
|
188
184
|
style: t ? "solid" : "long-dash"
|
|
189
185
|
}
|
|
190
186
|
},
|
|
191
|
-
attributes:
|
|
187
|
+
attributes: g,
|
|
192
188
|
popupTemplate: {
|
|
193
189
|
title: `${t ? "区控" : "子区"} ${e.name}`,
|
|
194
190
|
content: [
|
|
@@ -359,7 +355,8 @@ class x {
|
|
|
359
355
|
size: r ? 45 : 30,
|
|
360
356
|
rotateClockwise: !0,
|
|
361
357
|
textureFilter: "Picture",
|
|
362
|
-
url: `/GisViewerAssets/Images/xhj_${r ? 4 : 1}.png
|
|
358
|
+
url: `/GisViewerAssets/Images/xhj_${r ? 4 : 1}.png`,
|
|
359
|
+
offsetY: r ? 22 : 15
|
|
363
360
|
}
|
|
364
361
|
]
|
|
365
362
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),b=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),O=require("@arcgis/core/layers/GeoJSONLayer"),W=require("@arcgis/core/layers/TileLayer"),S=require("@arcgis/core/layers/WebTileLayer"),L=require("@arcgis/core/Map"),x=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),N=require("../stores/index.js"),_=require("./custom-layer/custom-wmts-layer.js");function v(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:()=>r[i]})}}return e.default=r,Object.freeze(e)}const k=v(q),d=v(z),C=v(I);function T(r,e){return r&&(r.startsWith("http://")||r.startsWith("https://")?r:e+r)}class G{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){const i=N.default.useAppDataStore,t=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=t;const{container:o,markerClickCallback:n,mapClickCallback:f}=e;b.assetsPath=`${t.assetsRoot}/ArcgisAssets`,b.fontsUrl=`${t.assetsRoot}/fonts`,b.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const c=new L;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new x({map:c,container:o,...t.mapOptions}):this.view=new R({map:c,container:o,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...t==null?void 0:t.mapOptions}),this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1,featureNavigation:!1},this.view.popup.dockOptions={buttonEnabled:!1,breakpoint:!1},this.view.on("click",async s=>{var y,M;if(f){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=d.webMercatorToGeographic(a)),f([a.x,a.y],[s.screenPoint.x,s.screenPoint.y],s)}if(this.view.type==="3d"){const a=this.view.camera;if(this.view.spatialReference.isWebMercator){const u=d.webMercatorToGeographic(a.position),p={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(p),(y=navigator.clipboard)==null||y.writeText(JSON.stringify(p))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=d.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const l=(M=(await this.view.hitTest(s)).results)==null?void 0:M.filter(a=>a.type==="graphic");l.length>0&&l.forEach(a=>{var p;const u=a.graphic;(p=u.attributes)!=null&&p.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),t!=null&&t.baseLayers?t.baseLayers.forEach(s=>{const h=T(s.url,t.assetsRoot);switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const l=new S({urlTemplate:h,...s.options});c.add(l);break}case"tile":{const l=new W({url:h,...s.options});c.add(l);break}case"customWMTS".toLowerCase():{const l=new _.default({urlTemplate:h,...s.options});c.add(l);break}case"arcgis":{const l=new P(s.options);c.basemap=l;break}}}):c.basemap=new P({style:{id:"arcgis/light-gray",language:"zh-CN"}}),t!=null&&t.hdLayers){const s=t.hdLayers.map(h=>new O({url:T(h.url,t.assetsRoot),...h.options,title:h.options.id}));c.addMany(s)}this.view.ui.remove("attribution"),this.view.ui.add("compass","top-left"),await this.view.when();const w=this.mapConfig.camera;let m;if(this.view.type==="2d"){let s=this.view.center;this.view.spatialReference.isWebMercator&&(s=d.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=d.webMercatorToGeographic(s)),m={position:s,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return w?w.home=m:this.mapConfig.camera={home:m},this.view}setLayerVisibility(e){const{id:i,visible:t}=e,o=this.view.map.findLayerById(i);return o?(o.visible=t,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type){case"point":e.target=new g.Point(e.target);break;case"polyline":e.target=new g.Polyline(e.target);break;case"polygon":e.target=new g.Polygon(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,t=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:t,tilt:0},{duration:(e.duration||2)*1e3});else{const o=Math.tan(i*Math.PI/180)*e.height,n=H(C.point(e.center),o,t+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:t,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:t=0}=e,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const n=o[i];return n?(await this.view.goTo(n,{duration:t*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let t=0;const n=1e3/30,f=k.watch(()=>this.view.center,()=>{const c=this.transformPoints(e),w=Date.now();w-t>n&&(i(c),t=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const t=new g.Point({x:i[0],y:i[1]}),o=this.view.toScreen(t);return[o.x,o.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:t}=e;!i&&!t||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=k.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),t&&o>=t&&(this.view.zoom=t)}))}}exports.default=G;
|
|
@@ -48,9 +48,9 @@ export default class OpenDriveRenderer {
|
|
|
48
48
|
*/
|
|
49
49
|
private showJunction;
|
|
50
50
|
private currentSectionCode;
|
|
51
|
+
private selectedSectionIds;
|
|
51
52
|
private currentJunctionId;
|
|
52
53
|
private hitGraphic;
|
|
53
|
-
private highlightGraphic;
|
|
54
54
|
/**
|
|
55
55
|
* 监听鼠标移动事件,高亮显示鼠标所在路段和路口
|
|
56
56
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),x=require("@arcgis/core/core/promiseUtils"),A=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),T=require("md5"),F=require("pako"),E=require("vue"),R=require("../../stores/index.js"),_=require("../common-utils.js");function j(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=j(x),S=j(J),$=j(q);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new C({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new C({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:T(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var m,p;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(g){return{status:-1,message:g.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;_.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=F.inflate(a,{to:"string"}),r=JSON.parse(n);await this.showAllLanes(r,((m=e.options)==null?void 0:m.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);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 d=R.default.useAppDataStore;return E.watch(()=>d.isSketching,()=>{var g,h;d.isSketching?((g=this.mouseMoveHandler)==null||g.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 l=await(await fetch(s)).arrayBuffer(),a=F.inflate(l,{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 l=[];console.log(e.length);for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:r,refLine:u}=n;let d=n.name;d.includes("(")&&(d=d.slice(0,d.indexOf("("))),d=d.replace(/(.)/g,"$1 ");const m=new y({geometry:{type:"polyline",paths:[u]},attributes:{ObjectID:c++,roadId:r,roadName:d}});this.allRefLineGraphics.push(m),n.laneSections.sort((p,g)=>Number(p.id)-Number(g.id));for(let p=0;p<n.laneSections.length;p++){const g=n.laneSections[p],h=Number(g.id);for(const f of g.lanePaths){const w=Number(f.id);if(w===0)continue;const v=f.type,P=[...f.outerPath],N=f.innerPath.concat(P.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(f.innerPath[0]);const k=new A.Polygon({rings:[N]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${r}+${h}+${w}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(r),roadName:n.name,sectionId:String(h),sectionIndex:p,laneId:w,type:v,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath}});this.allLaneGraphics.push(G),l.push(G)}}}}const a=setInterval(()=>{if(l.length>0||this.allRefLineGraphics.length>0){if(l.length>0){const n=l.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const o=new y({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=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(l=>l.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const l=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(l===this.currentSectionCode||this.sectionLayer.graphics.findIndex(h=>h.getAttribute("id")===l)>=0)return;this.currentSectionCode=l;const n=this.allLaneGraphics.filter(h=>`${h.attributes.roadId}+${h.attributes.sectionId}`===l),r=S.union(n.map(h=>h.geometry)),u=this.hitGraphic.getAttribute("fromNode"),d=this.hitGraphic.getAttribute("toNode"),m=this.junctionNames.get(u)||u,p=this.junctionNames.get(d)||d;this.highlightGraphic=new y({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:l,selected:!1,fromNodeName:m,toNodeName:p,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic);const g=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:g})}else if(s.layer.id==="OpenDriveJunction"){const l=this.hitGraphic.getAttribute("id");if(l===this.currentJunctionId)return;this.currentJunctionId=l,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=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"),l=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await b.get(n,{params:{id:l,projectName:this.projectName}});r.status===200&&r.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:l,details:r.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:l,details:void 0}),s.setAttribute("selected",!1);const n=s.getAttribute("crossId");s.symbol.url=n?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(c==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:s.getAttribute("edgeId"),details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,r=await b.get(n,{params:{id:l,projectName:this.projectName}});if(r.status===200&&r.data.status===0&&this.openDriveClickCallback){const u=r.data.result.obj_id;s.setAttribute("edgeId",u),this.openDriveClickCallback({type:"OpenDriveSection",id:u,details:r.data.result})}}});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,l=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,a=await b.get(l,{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:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,l=s[0].split("#");if(l.length>2)return{status:-1,message:"id格式错误"};const a=l[0],n=l.length===2?Number(l[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 y({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const a=[];if(s.forEach(n=>{const r=Number(n.attributes.sectionId);a.indexOf(r)===-1&&a.push(r)}),a.sort((n,r)=>n-r),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 r=Number(n.attributes.laneId);a.indexOf(r)===-1&&a.push(r)}),a.sort((n,r)=>n-r),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),l=S.union(c);if(e.flash){const a=new y({geometry:l,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(a)}return await this.view.goTo(l,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&this.sectionLayer.remove(t)}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o="0";t.length===2&&(o=String(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionId")===o)),s.length>0){const c=S.union(s.map(a=>a.geometry)),l=new y({geometry:c,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(l),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const a of i.features){const n=a.getAttribute("roadId"),r=a.getAttribute("sectionId"),u=`${n}#${r}`;if(o.indexOf(u)===-1){o.push(u),this.selectSumo({type:"edge",id:u});const d=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,m=await b.get(d,{params:{id:`${n}+${r}`,projectName:this.projectName}});m.status===200&&m.data.status===0&&s.push(m.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const n=a.geometry;return S.contains(t,n)}),l=[];for(const a of c){const n=a.getAttribute("id");this.selectSumo({type:"junction",id:n});const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,u=await b.get(r,{params:{id:n,projectName:this.projectName}});u.status===200&&u.data.status===0&&l.push(u.data.result)}return{status:0,message:"ok",result:{junctions:l,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 l=s[0];l.startsWith("-")&&(l=l.slice(1));const a=this.allLaneGraphics.filter(v=>v.getAttribute("roadId")===l&&v.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const n=a.length-o,r=a.find(v=>Math.abs(v.getAttribute("laneId"))===n);if(!r)return{status:-1,message:"未找到车道"};const u=e.start||0,d=e.end||100,m=$.lineString(r.getAttribute("leftLine")),p=O.lineSliceAlong(m,u,d,{units:"meters"}),g=$.lineString(r.getAttribute("rightLine")),h=O.lineSliceAlong(g,u,d,{units:"meters"}),f=p.geometry.coordinates.concat(h.geometry.coordinates.reverse());f.push(f[f.length-1]);const w=new y({geometry:new A.Polygon({rings:[f]}),attributes:{ObjectID:r.getAttribute("ObjectID"),id:r.getAttribute("id"),fromNode:r.getAttribute("fromNode"),toNode:r.getAttribute("toNode"),roadId:r.getAttribute("roadId"),roadName:r.getAttribute("roadName"),sectionId:r.getAttribute("sectionId"),sectionIndex:r.getAttribute("sectionIndex"),laneId:r.getAttribute("laneId"),type:r.getAttribute("type"),sumoId:r.getAttribute("sumoId"),leftLine:p.geometry.coordinates,rightLine:h.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(w),this.view.goTo(w),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}}exports.default=D;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),P=require("@arcgis/core/core/promiseUtils"),A=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),E=require("md5"),M=require("pako"),T=require("vue"),H=require("../../stores/index.js"),R=require("../common-utils.js");function j(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const F=j(P),S=j(J),$=j(q);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.selectedSectionIds=[],this.currentJunctionId="",this.view=e,this.laneLayer=new C({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"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 C({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new I({id:"OpenDriveJunction"}),this.sectionLayer=new I({id:"OpenDriveSection"}),this.highlightLayer=new I({id:"OpenDriveHighlight"}),this.flashLayer=new I({id:"OpenDriveFlash"}),this.drawLayer=new I({id:"Draw"}),this.splitLaneLayer=new I({id:"SplitLane"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:E(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var m,p;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let n;try{n=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(g){return{status:-1,message:g.message}}if(n.status!==200)return{status:-1,message:n.statusText};console.time("渲染用时");const s=n.data.result.geoSetting;R.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=n.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),o=M.inflate(a,{to:"string"}),l=JSON.parse(o);await this.showAllLanes(l,((m=e.options)==null?void 0:m.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);const d=n.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const h=H.default.useAppDataStore;return T.watch(()=>h.isSketching,()=>{var g,f;h.isSketching?((g=this.mouseMoveHandler)==null||g.remove(),this.mouseMoveHandler=void 0,(f=this.mouseClickHandler)==null||f.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`,n=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(n.status!==200)throw new Error(`OpenDriveRenderer: ${n.statusText}`);let s=n.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const r=await(await fetch(s)).arrayBuffer(),a=M.inflate(r,{to:"string"}),o=JSON.parse(a);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const n=await this.laneLayer.queryFeatures();return n.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:n.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const o of e){if(!t&&o.junction!=="-1")continue;const{id:l,refLine:d}=o;let h=o.name;h.includes("(")&&(h=h.slice(0,h.indexOf("("))),h=h.replace(/(.)/g,"$1 ");const m=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(m),o.laneSections.sort((p,g)=>Number(p.id)-Number(g.id));for(let p=0;p<o.laneSections.length;p++){const g=o.laneSections[p],f=Number(g.id);for(const u of g.lanePaths){const w=Number(u.id);if(w===0)continue;const v=u.type,x=[...u.outerPath],N=u.innerPath.concat(x.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(u.innerPath[0]);const k=new A.Polygon({rings:[N]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${l}+${f}+${w}`,fromNode:o.fromNode,toNode:o.toNode,roadId:String(l),roadName:o.name,sectionId:String(f),sectionIndex:p,laneId:w,type:v,sumoId:"",leftLine:u.innerPath,rightLine:u.outerPath}});this.allLaneGraphics.push(G),r.push(G)}}}}const a=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const o=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:o})}if(this.allRefLineGraphics.length>0){const o=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:o})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const n=new y({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(n)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=F.debounce(async t=>{var c;const n=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(n.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=n[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 o=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===r),l=S.union(o.map(u=>u.geometry)),d=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),m=this.junctionNames.get(d)||d,p=this.junctionNames.get(h)||h,g=new y({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:m,toNodeName:p,laneCount:o.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);const f=this.view.toMap(t);this.view.openPopup({features:[g],location:f})}else if(s.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=F.debounce(async t=>{var a;const n=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(o=>o.type==="graphic");if(n.length===0)return;const s=n[0].graphic,c=s.getAttribute("type"),r=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const o=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await b.get(o,{params:{id:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:l.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),s.setAttribute("selected",!1);const o=s.getAttribute("crossId");s.symbol.url=o?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}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 o=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(o,{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(o=>o!==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 n=e.symbol,s=n.width;s<t?e.symbol={type:"picture-marker",url:n.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const n=e.symbol,s=n.width;s>t?e.symbol={type:"picture-marker",url:n.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 n=0;t.length===2&&(n=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===n);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:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.sectionLayer.removeAll(),this.flashLayer.removeAll(),(t=this.mouseMoveHandler)==null||t.remove(),this.mouseMoveHandler=void 0,(i=this.mouseClickHandler)==null||i.remove(),this.mouseClickHandler=void 0}async findSumo(e){const{type:t,id:i}=e,n=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,n);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],o=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:a,segmentId:o,laneId:c,flash:n})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(n=>n.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const n=new y({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(n)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:n}=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(o=>{const l=Number(o.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),i>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=a[i],s=s.filter(o=>Number(o.attributes.sectionId)===i)}if(n!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),n>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};n=a[n],s=s.filter(o=>Number(o.attributes.laneId)===n)}const c=s.map(a=>a.geometry),r=S.union(c);if(e.flash){const a=new y({geometry:r,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",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 n=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(n))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge"){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 n=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==n)}),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 n=0;t.length===2&&(n=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")===n)),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 o=c.get(a);o?o.push(r.geometry):(o=[r.geometry],c.set(a,o))}),c.forEach((r,a)=>{const o=S.union(r),l=new y({geometry:o,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 A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),n=[],s=[];for(const a of i.features){const o=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${o}#${l}`;if(n.indexOf(d)===-1){n.push(d),this.selectSumo({type:"edge",id:d});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,m=await b.get(h,{params:{id:`${o}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});m.status===200&&m.data.status===0&&s.push(m.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const o=a.geometry;return S.contains(t,o)}),r=[];for(const a of c){const o=a.getAttribute("id");this.selectSumo({type:"junction",id:o});const l=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(l,{params:{id:o,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 n=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(v=>v.getAttribute("roadId")===r&&v.getAttribute("sectionIndex")===c);if(a.length===0)return{status:-1,message:"未找到路段"};const o=a.length-n,l=a.find(v=>Math.abs(v.getAttribute("laneId"))===o);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,h=e.end||100,m=$.lineString(l.getAttribute("leftLine")),p=O.lineSliceAlong(m,d,h,{units:"meters"}),g=$.lineString(l.getAttribute("rightLine")),f=O.lineSliceAlong(g,d,h,{units:"meters"}),u=p.geometry.coordinates.concat(f.geometry.coordinates.reverse());u.push(u[u.length-1]);const w=new y({geometry:new A.Polygon({rings:[u]}),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:p.geometry.coordinates,rightLine:f.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(w),this.view.goTo(w),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}}exports.default=D;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/core/reactiveUtils.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/core/reactiveUtils.js"),u=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/GraphicsLayer"),f=require("@turf/buffer"),L=require("@turf/concave"),m=require("@turf/convex"),v=require("@turf/helpers"),C=require("./district-controller.js");function g(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const w=g(b),c=g(v);class A{constructor(e){this.crossScale=5e3,this.view=e,this.districtControllerLayer=new l({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new l({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new l({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new l({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}showSignalControlArea(e){this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const t of e){const i=new C.default(t);this.drawArea(i,!0)}return this.watchHandle=w.watch(()=>this.view.scale,(t,i)=>{t>this.crossScale&&i<=this.crossScale?(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker"))})):t<=this.crossScale&&i>this.crossScale&&(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture"))}))}),{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.watchHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);return t?(t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry),{status:0,message:"ok"}):{status:1,message:"未找到"}}showPopup(e){const t=e.geometry.type==="point"?e.geometry:e.geometry.centroid;this.view.openPopup({features:[e],location:t})}async highlightSignalControlArea(e){this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;const t=this.districtControllerLayer.graphics.filter(r=>r.getAttribute("id")===e.id).toArray().map(r=>r.clone()),i=this.subDistrictControllerLayer.graphics.filter(r=>r.getAttribute("id")===e.id||r.getAttribute("parentId")===e.id).toArray().map(r=>r.clone()),s=this.crossLayer.graphics.filter(r=>r.getAttribute("id")===e.id||r.getAttribute("districtId")===e.id||r.getAttribute("subDistrictId")===e.id).toArray().map(r=>r.clone());return t.length>0&&this.highlightLayer.addMany(t),i.length>0&&this.highlightLayer.addMany(i),s.length>0&&this.highlightLayer.addMany(s),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(t.length>0?await this.view.goTo(t):i.length>0?await this.view.goTo(i):s.length>1?await this.view.goTo(s):await this.view.goTo({target:s[0].geometry,scale:1500}),{status:0,message:"ok"})}resetHighlight(){return this.highlightLayer.removeAll(),this.view.closePopup(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0,this.crossLayer.visible=!0,{status:0,message:"ok"}}findAreaGraphic(e){let t=this.districtControllerLayer.graphics.find(i=>i.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(i=>i.attributes.id===e)),t||(t=this.crossLayer.graphics.find(i=>i.attributes.id===e)),t}drawArea(e,t){const i=e.getAllCrossCoordinates();if(i.length>=2){let r=null;if(i.length===2)r=c.lineString(i);else if(i.length>2){const h=c.featureCollection(i.map(d=>c.point(d)));t?r=m(h):(r=L(h,{maxEdge:400,units:"meters"}),r||(r=m(h)))}if(!r){console.log("生成区控面失败",e);return}const o=f(r.geometry,t?200:30,{units:"meters"});let n;t?n=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:n=[{fieldName:"parentName",label:"所属区控"},{fieldName:"crossCount",label:"路口数量"}];const p={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},y=new u({geometry:{type:"polygon",rings:o.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,t?.6:.8],outline:{color:e.areaColor,width:2,style:t?"solid":"long-dash"}},attributes:p,popupTemplate:{title:`${t?"区控":"子区"} ${e.name}`,content:[{type:"fields",fieldInfos:n}]}});t?this.districtControllerLayer.add(y):this.subDistrictControllerLayer.add(y)}for(const r of e.subDistricts)this.drawArea(r,!1);const s=e.crosses.map(r=>{const o={type:"cross",id:r.id,name:r.name,color:e.areaColor,signalId:r.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,isKey:r.isKey};return new u({geometry:{type:"point",x:r.longitude,y:r.latitude},symbol:this.getCrossGraphicSymbol(o,"marker"),attributes:o,popupTemplate:{title:r.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}})});this.crossLayer.addMany(s)}getCrossGraphicSymbol(e,t){const{isKey:i,color:s}=e;if(t==="marker")return i?{type:"picture-marker",url:"/GisViewerAssets/Images/icon_star.png",width:"30px",height:"30px"}:{type:"simple-marker",style:"circle",color:s,size:8,outline:{color:"white",width:1}};if(t==="picture")return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:i?30:22,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:i?45:30,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/xhj_${i?4:1}.png`,offsetY:i?22:15}]}}}}}exports.default=A;
|