gisviewer-vue3-arcgis 1.0.154 → 1.0.156

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.
Files changed (31) hide show
  1. package/es/src/gis-map/gis-map.vue.d.ts +4 -2
  2. package/es/src/gis-map/gis-map.vue.mjs +120 -116
  3. package/es/src/gis-map/index.d.ts +3 -1
  4. package/es/src/gis-map/utils/holo-flow/index.d.ts +1 -2
  5. package/es/src/gis-map/utils/holo-flow/index.mjs +19 -12
  6. package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +9 -0
  7. package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.mjs +43 -0
  8. package/es/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +3 -4
  9. package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +1 -0
  10. package/es/src/gis-map/utils/open-drive-renderer/index.mjs +52 -46
  11. package/es/src/gis-map/utils/overlay.d.ts +3 -1
  12. package/es/src/gis-map/utils/overlay.mjs +75 -43
  13. package/es/src/gis-map/utils/signal-control-area-controller/index.d.ts +8 -4
  14. package/es/src/gis-map/utils/signal-control-area-controller/index.mjs +216 -137
  15. package/es/src/types/index.d.ts +5 -0
  16. package/lib/src/gis-map/gis-map.vue.d.ts +4 -2
  17. package/lib/src/gis-map/gis-map.vue.js +1 -1
  18. package/lib/src/gis-map/index.d.ts +3 -1
  19. package/lib/src/gis-map/utils/holo-flow/index.d.ts +1 -2
  20. package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
  21. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +9 -0
  22. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.js +1 -0
  23. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +3 -4
  24. package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +1 -0
  25. package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
  26. package/lib/src/gis-map/utils/overlay.d.ts +3 -1
  27. package/lib/src/gis-map/utils/overlay.js +1 -1
  28. package/lib/src/gis-map/utils/signal-control-area-controller/index.d.ts +8 -4
  29. package/lib/src/gis-map/utils/signal-control-area-controller/index.js +1 -1
  30. package/lib/src/types/index.d.ts +5 -0
  31. package/package.json +1 -1
@@ -1,7 +1,6 @@
1
- import View from '@arcgis/core/views/View';
2
1
  export default class SignalHoloFlow {
3
- private view;
4
- private mapConfig;
2
+ protected view: __esri.MapView | __esri.SceneView;
3
+ protected mapConfig: any;
5
4
  /** 显示停止线的图层 */
6
5
  private phaseLineLayer;
7
6
  /** 每个路口的当前相位 */
@@ -11,7 +10,7 @@ export default class SignalHoloFlow {
11
10
  private countdownWatchHandel;
12
11
  private plateBackground;
13
12
  private lastDataTime;
14
- constructor(view: View);
13
+ constructor(view: __esri.MapView | __esri.SceneView);
15
14
  /**
16
15
  * 初始化相位线图层
17
16
  * */
@@ -11,6 +11,7 @@ export default class OpenDriveRenderer {
11
11
  private flashLayer;
12
12
  private drawLayer;
13
13
  private splitLaneLayer;
14
+ private borderLayer;
14
15
  private allLaneGraphics;
15
16
  private allRefLineGraphics;
16
17
  private mouseMoveHandler;
@@ -1 +1 @@
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
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),P=require("@arcgis/core/core/promiseUtils"),N=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),v=require("@arcgis/core/layers/GraphicsLayer"),J=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),E=require("fast-xml-parser"),R=require("md5"),x=require("pako"),T=require("vue"),H=require("../../stores/index.js"),_=require("../common-utils.js");function D(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=D(P),S=D(q),$=D(J);class j{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 v({id:"OpenDriveJunction"}),this.sectionLayer=new v({id:"OpenDriveSection"}),this.highlightLayer=new v({id:"OpenDriveHighlight"}),this.flashLayer=new v({id:"OpenDriveFlash"}),this.drawLayer=new v({id:"Draw"}),this.splitLaneLayer=new v({id:"SplitLane"}),this.borderLayer=new v({id:"OpenDriveBorder"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer,this.borderLayer])}static getInstance(e){return this.instance||(this.instance=new j(e)),this.instance}async makeMd5FromFile(e){var t;try{const r=await(await fetch(e)).text(),n=(t=new E.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(r).OpenDRIVE.userData)==null?void 0:t.border;return{status:0,message:"ok",result:{md5:R(r),border:n}}}catch(i){return{status:-1,message:i.message}}}async showOpenDriveFromFile(e){var g,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.md5,console.timeEnd("md5用时"),console.log(t.result.border),this.openDriveServer=e.server;const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let r;try{r=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(m){return{status:-1,message:m.message}}if(r.status!==200)return{status:-1,message:r.statusText};console.time("渲染用时");const s=r.data.result.geoSetting;_.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=r.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const a=await(await fetch(c)).arrayBuffer(),o=x.inflate(a,{to:"string"}),l=JSON.parse(o);await this.showAllLanes(l,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);const d=r.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 m,f;h.isSketching?((m=this.mouseMoveHandler)==null||m.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`,r=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(r.status!==200)throw new Error(`OpenDriveRenderer: ${r.statusText}`);let s=r.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=x.inflate(n,{to:"string"}),o=JSON.parse(a);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const r=await this.laneLayer.queryFeatures();return r.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:r.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];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 g=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:l,roadName:h}});this.allRefLineGraphics.push(g),o.laneSections.sort((p,m)=>Number(p.id)-Number(m.id));for(let p=0;p<o.laneSections.length;p++){const m=o.laneSections[p],f=Number(m.id);for(const u of m.lanePaths){const w=Number(u.id);if(w===0)continue;const I=u.type,F=[...u.outerPath],A=u.innerPath.concat(F.reverse());if(A.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}A.push(u.innerPath[0]);const k=new N.Polygon({rings:[A]});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:I,sumoId:"",leftLine:u.innerPath,rightLine:u.outerPath}});this.allLaneGraphics.push(G),n.push(G)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const o=n.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 r=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/xhj_1.png":"/GisViewerAssets/Images/xhj_2.png",width:"18px",height:"28px",yoffset:"9px"},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(r)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const r=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(n=>n.type==="graphic");if(r.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId=""),this.view.closePopup();return}const s=r[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 o=this.allLaneGraphics.filter(u=>`${u.attributes.roadId}+${u.attributes.sectionId}`===n),l=S.union(o.map(u=>u.geometry)),d=this.hitGraphic.getAttribute("fromNode"),h=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(d)||d,p=this.junctionNames.get(h)||h,m=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:n,selected:!1,fromNodeName:g,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(m);const f=this.view.toMap(t);this.view.openPopup({features:[m],location:f})}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.getAttribute("id");if(n===this.currentJunctionId)return;this.currentJunctionId=n,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 r=(a=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:a.filter(o=>o.type==="graphic");if(r.length===0)return;const s=r[0].graphic,c=s.getAttribute("type"),n=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: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.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:n,details:void 0}),s.setAttribute("selected",!1);const 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(n);const o=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(o,{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(o=>o!==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 r=e.symbol,s=r.width;s<t?e.symbol={type:"picture-marker",url:r.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s>t?e.symbol={type:"picture-marker",url:r.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 r=0;t.length===2&&(r=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===r);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:"未知类型"}}}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,r=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,r);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],o=n.length===2?Number(n[1]):void 0;return await this.findLane({roadsectId:a,segmentId:o,laneId:c,flash:r})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(r=>r.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const r=new y({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[0,0,255,.6],outline:{color:"blue",width:1}}});this.flashGraphic(r)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:r}=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(r!==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),r>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};r=a[r],s=s.filter(o=>Number(o.attributes.laneId)===r)}const c=s.map(a=>a.geometry),n=S.union(c);if(e.flash){const a=new y({geometry:n,symbol:{type:"simple-fill",color:[0,0,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 r=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(r))},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 r=i.getAttribute("id");this.selectedSectionIds=this.selectedSectionIds.filter(s=>s!==r)}),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 r=0;t.length===2&&(r=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")===r)),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 o=c.get(a);o?o.push(n.geometry):(o=[n.geometry],c.set(a,o))}),c.forEach((n,a)=>{const o=S.union(n),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 N.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),r=[],s=[];for(const a of i.features){const o=a.getAttribute("roadId"),l=a.getAttribute("sectionIndex"),d=`${o}#${l}`;if(r.indexOf(d)===-1){r.push(d),this.selectSumo({type:"edge",id:d});const h=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(h,{params:{id:`${o}+${a.getAttribute("sectionId")}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(a=>{const o=a.geometry;return S.contains(t,o)}),n=[];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&&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 r=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 o=a.length-r,l=a.find(I=>Math.abs(I.getAttribute("laneId"))===o);if(!l)return{status:-1,message:"未找到车道"};const d=e.start||0,h=e.end||100,g=$.lineString(l.getAttribute("leftLine")),p=O.lineSliceAlong(g,d,h,{units:"meters"}),m=$.lineString(l.getAttribute("rightLine")),f=O.lineSliceAlong(m,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 N.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=j;
@@ -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 { IOverlay, IOverlayParam, IPointSymbol, IResult } from '../../types';
5
+ import { IMaskParam, IOverlay, IOverlayParam, IPointSymbol, IResult } from '../../types';
6
6
  interface IOverlayOptions {
7
7
  id: string;
8
8
  }
@@ -11,6 +11,8 @@ export default class Overlay {
11
11
  overlayLayer: GraphicsLayer;
12
12
  constructor(view: MapView | SceneView, options?: IOverlayOptions);
13
13
  private defaultPointSymbol;
14
+ addMask(params: IMaskParam): void;
15
+ removeMask(): void;
14
16
  /**
15
17
  * 添加覆盖物
16
18
  * @param params
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("@arcgis/core/Graphic"),o=require("@arcgis/core/layers/GraphicsLayer");class d{constructor(r,s){this.defaultPointSymbol={type:"simple-marker",style:"circle",color:"yellow",size:10},this.view=r,this.overlayLayer=new o({...s}),this.view.map.layers.add(this.overlayLayer)}addOverlays(r){let s=0,i=0;for(const e of r.overlays){e.properties?(e.properties.type||(e.properties.type=r.type),e.properties.id||(e.properties.id=e.id)):e.properties={type:r.type,id:e.id};const t=e.symbol||r.defaultSymbol||this.defaultPointSymbol;this.addOverlay(e,t,e.properties,e.visible).message==="add"?s++:i++}return{status:0,message:`新增${s}, 更新${i}`}}removeOverlaysByType(r){const s=this.overlayLayer.graphics.filter(i=>{const e=i.getAttribute("type");return r.includes(e)});return this.overlayLayer.graphics.removeMany(s),{status:0,message:`删除${s.length}`}}removeOverlaysById(r){const s=this.overlayLayer.graphics.filter(i=>{const e=i.getAttribute("id");return r.includes(e)});return this.overlayLayer.graphics.removeMany(s),{status:0,message:`删除${s.length}`}}isShowOverlaysByIds(r,s){this.overlayLayer.graphics.map(i=>{const e=i.getAttribute("id");r.includes(e)?i.visible=s:i.visible=!s})}showAllOverlays(){this.overlayLayer.graphics.forEach(r=>{r.visible=!0})}removeAllOverlays(){const r=this.overlayLayer.graphics.length;return this.overlayLayer.removeAll(),{status:0,message:`删除${r}`}}destroy(){this.view.map.remove(this.overlayLayer),this.overlayLayer.destroy()}removeGraphics(r){Array.isArray(r)||(r=[r]),this.overlayLayer.graphics.removeMany(r)}async findGraphic(r){var e;return(e=(await this.view.hitTest(r)).results)==null?void 0:e.filter(t=>t.type==="graphic"&&t.graphic.layer===this.overlayLayer)}hideLayer(){this.overlayLayer.visible=!1}showLayer(){this.overlayLayer.visible=!0}addPoint(r,s,i,e){let t,a=!0;return r.id&&(t=this.overlayLayer.graphics.find(y=>y.getAttribute("id")===r.id)),t?t.visible=e??t.visible:(e=e??!0,t=new l({visible:e}),this.overlayLayer.add(t),a=!1),t.geometry=r.geometry,t.symbol=s,t.attributes=i,{status:0,message:a?"add":"update"}}addOverlay(r,s,i,e){let t,a=!0;return r.id&&(t=this.overlayLayer.graphics.find(y=>y.getAttribute("id")===r.id)),t?t.visible=e??t.visible:(e=e??!0,t=new l({visible:e}),this.overlayLayer.add(t),a=!1),t.geometry=r.geometry,t.symbol=s,t.attributes=i,{status:0,message:a?"add":"update"}}}exports.default=d;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/geometry"),u=require("@arcgis/core/geometry/geometryEngine"),l=require("@arcgis/core/Graphic"),h=require("@arcgis/core/layers/GraphicsLayer");function p(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=p(u);class v{constructor(e,r){this.defaultPointSymbol={type:"simple-marker",style:"circle",color:"yellow",size:10},this.view=e,this.overlayLayer=new h({...r}),this.view.map.layers.add(this.overlayLayer)}addMask(e){this.removeMask();const r=e.maskColor||[100,100,100,.8],i=e.maskSize||100,t=new d.Polygon({rings:e.geometry.rings}),s=t.centroid,a=n.geodesicBuffer(s,i,"kilometers"),y=n.difference(a,t),c=new l({geometry:y,symbol:{type:"simple-fill",color:r,outline:{style:"none"}},attributes:{type:"mask"}});this.overlayLayer.add(c)}removeMask(){const e=this.overlayLayer.graphics.find(r=>r.getAttribute("type")==="mask");e&&this.overlayLayer.remove(e)}addOverlays(e){let r=0,i=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;this.addOverlay(t,s,t.properties,t.visible).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}addPoint(e,r,i,t){let s,a=!0;return e.id&&(s=this.overlayLayer.graphics.find(y=>y.getAttribute("id")===e.id)),s?s.visible=t??s.visible:(t=t??!0,s=new l({visible:t}),this.overlayLayer.add(s),a=!1),s.geometry=e.geometry,s.symbol=r,s.attributes=i,{status:0,message:a?"add":"update"}}addOverlay(e,r,i,t){let s,a=!0;return e.id&&(s=this.overlayLayer.graphics.find(y=>y.getAttribute("id")===e.id)),s?s.visible=t??s.visible:(t=t??!0,s=new l({visible:t}),this.overlayLayer.add(s),a=!1),s.geometry=e.geometry,s.symbol=r,s.attributes=i,{status:0,message:a?"add":"update"}}}exports.default=v;
@@ -5,10 +5,12 @@ export default class SignalControlAreaController {
5
5
  private subDistrictControllerLayer;
6
6
  private crossLayer;
7
7
  private highlightLayer;
8
+ private districtControllers;
8
9
  private watchHandle?;
10
+ private openDriveServerUrl;
9
11
  private readonly crossScale;
10
12
  constructor(view: __esri.MapView | __esri.SceneView);
11
- showSignalControlArea(params: any): IResult;
13
+ showSignalControlArea(params: any): Promise<IResult>;
12
14
  clearSignalControlArea(): IResult;
13
15
  locateSignalControlArea(params: {
14
16
  id: string;
@@ -25,12 +27,14 @@ export default class SignalControlAreaController {
25
27
  */
26
28
  private findAreaGraphic;
27
29
  /**
28
- * 绘制区控与子区
30
+ * 显示区控
29
31
  * @param districtController
30
- * @param isDistrict 是否是区控
31
32
  * @returns
32
33
  */
33
- private drawArea;
34
+ private showDistrict;
35
+ private showSubDistrictCross;
36
+ private loadedSubDistricts;
37
+ private showSubDistrictRoad;
34
38
  /**
35
39
  * 生成路口点符号。在不同比例尺下,使用不同的符号
36
40
  * @param attributes
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/core/reactiveUtils.js"),u=require("@arcgis/core/Graphic"),n=require("@arcgis/core/layers/GraphicsLayer"),b=require("@turf/buffer"),L=require("@turf/concave"),g=require("@turf/convex"),C=require("@turf/helpers"),v=require("../common-utils.js"),w=require("./district-controller.js");function m(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const S=m(f),c=m(C);class A{constructor(e){this.crossScale=5e3,this.view=e,this.districtControllerLayer=new n({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new n({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new n({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new n({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}showSignalControlArea(e){this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const t of e){const r=new w.default(t);this.drawArea(r,!0)}return this.watchHandle=S.watch(()=>this.view.scale,(t,r)=>{t>this.crossScale&&r<=this.crossScale?(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"marker"))})):t<=this.crossScale&&r>this.crossScale&&(this.crossLayer.graphics.forEach(s=>{s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture")}),this.highlightLayer.graphics.forEach(s=>{s.getAttribute("type")==="cross"&&(s.symbol=this.getCrossGraphicSymbol(s.attributes,"picture"))}))}),{status:0,message:"ok"}}clearSignalControlArea(){var e;return this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),(e=this.watchHandle)==null||e.remove(),this.view.closePopup(),{status:0,message:"ok"}}async locateSignalControlArea(e){const t=this.findAreaGraphic(e.id);return t?(t.attributes.type==="cross"?await this.view.goTo({target:t.geometry,scale:1500}):await this.view.goTo(t.geometry),{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){if(!e.id||e.id==="")return{status:1,message:"请输入id"};this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;const t=this.districtControllerLayer.graphics.filter(i=>i.getAttribute("id")===e.id).toArray().map(i=>i.clone()),r=this.subDistrictControllerLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("parentId")===e.id).toArray().map(i=>i.clone()),s=this.crossLayer.graphics.filter(i=>i.getAttribute("id")===e.id||i.getAttribute("districtId")===e.id||i.getAttribute("subDistrictId")===e.id).toArray().map(i=>i.clone());if(t.length>0&&this.highlightLayer.addMany(t),r.length>0&&this.highlightLayer.addMany(r),s.length>0&&this.highlightLayer.addMany(s),this.highlightLayer.graphics.length===0)return{status:1,message:"未找到"};if(t.length>0)await this.view.goTo(t);else if(r.length>0){const i=r[0].geometry.centroid;await this.view.goTo({target:i,scale:this.crossScale-500})}else s.length>1?await this.view.goTo(s):await this.view.goTo({target:s[0].geometry,scale:1500});return{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(r=>r.attributes.id===e);return t||(t=this.subDistrictControllerLayer.graphics.find(r=>r.attributes.id===e)),t||(t=this.crossLayer.graphics.find(r=>r.attributes.id===e)),t}drawArea(e,t){const r=e.getAllCrossCoordinates();if(r.length>=2){let i=null;if(r.length===2)i=c.lineString(r);else if(r.length>2){const h=c.featureCollection(r.map(d=>c.point(d)));t?i=g(h):(i=L(h),i||(i=g(h)))}i||(i=c.lineString(r));const l=b(i.geometry,t?200:30,{units:"meters"});let o;t?o=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}]:o=[{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:l.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:o}]}});t?this.districtControllerLayer.add(y):this.subDistrictControllerLayer.add(y)}for(const i of e.subDistricts)this.drawArea(i,!1);const s=[];e.crosses.forEach(i=>{if(v.default.isCoordinateValid(i)){const l={type:"cross",id:i.id,name:i.name,color:e.areaColor,signalId:i.signalId,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name,isKey:i.isKey},o=new u({geometry:{type:"point",x:i.longitude,y:i.latitude},symbol:this.getCrossGraphicSymbol(l,"marker"),attributes:l,popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}});s.push(o)}else console.log("路口坐标无效",i)}),this.crossLayer.addMany(s)}getCrossGraphicSymbol(e,t){const{isKey:r,color:s}=e;if(t==="marker")return r?{type:"picture-marker",url:"/GisViewerAssets/Images/icon_star.png",width:"30px",height:"30px"}:{type:"simple-marker",style:"circle",color:s,size:8,outline:{color:"white",width:1}};if(t==="picture")return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:r?30:22,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:r?45:30,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/xhj_${r?4:1}.png`,offsetY:r?22:15}]}}}}}exports.default=A;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@arcgis/core/core/reactiveUtils.js"),b=require("@arcgis/core/geometry"),C=require("@arcgis/core/geometry/geometryEngine.js"),l=require("@arcgis/core/Graphic"),n=require("@arcgis/core/layers/GraphicsLayer"),v=require("@turf/buffer"),S=require("@turf/concave"),L=require("@turf/helpers"),w=require("axios"),I=require("../../stores/index.js"),y=require("../common-utils.js"),A=require("./district-controller.js");function d(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const i in a)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:()=>a[i]})}}return e.default=a,Object.freeze(e)}const D=d(f),m=d(C),c=d(L);class N{constructor(e){this.districtControllers=[],this.crossScale=5e3,this.loadedSubDistricts=[],this.view=e;const r=I.default.useAppDataStore.mapConfig;this.openDriveServerUrl=r.openDriveServer.url,this.districtControllerLayer=new n({id:"districtControllerLayer",maxScale:144447,minScale:1155582}),this.subDistrictControllerLayer=new n({id:"subDistrictControllerLayer",maxScale:0,minScale:144447}),this.crossLayer=new n({id:"crossLayer",maxScale:0,minScale:36112}),this.highlightLayer=new n({id:"highlightLayer"}),this.view.map.addMany([this.districtControllerLayer,this.subDistrictControllerLayer,this.crossLayer,this.highlightLayer])}async showSignalControlArea(e){console.time("showSignalControlArea"),this.districtControllerLayer.removeAll(),this.subDistrictControllerLayer.removeAll(),this.crossLayer.removeAll(),this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!0,this.subDistrictControllerLayer.visible=!0;for(const i of e){const r=new A.default(i);this.showDistrict(r),this.districtControllers.push(r)}this.watchHandle=D.watch(()=>this.view.scale,(i,r)=>{i>this.crossScale&&r<=this.crossScale?(this.crossLayer.graphics.forEach(t=>{t.symbol=this.getCrossGraphicSymbol(t.attributes,"marker")}),this.highlightLayer.graphics.forEach(t=>{t.getAttribute("type")==="cross"&&(t.symbol=this.getCrossGraphicSymbol(t.attributes,"marker"))})):i<=this.crossScale&&r>this.crossScale&&(this.crossLayer.graphics.forEach(t=>{t.symbol=this.getCrossGraphicSymbol(t.attributes,"picture")}),this.highlightLayer.graphics.forEach(t=>{t.getAttribute("type")==="cross"&&(t.symbol=this.getCrossGraphicSymbol(t.attributes,"picture"))}))});for(const i of this.districtControllers)for(const r of i.subDistricts)await this.showSubDistrictRoad(r);return console.timeEnd("showSignalControlArea"),{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 i=this.findAreaGraphic(e.id);return i?(i[0].attributes.type==="cross"?await this.view.goTo({target:i,scale:1500}):await this.view.goTo(i),{status:0,message:"ok"}):{status:1,message:"未找到"}}showPopup(e){const i=e.geometry.type==="point"?e.geometry:e.geometry.centroid;this.view.openPopup({features:[e],location:i})}async highlightSignalControlArea(e){if(!e.id||e.id==="")return{status:1,message:"请输入id"};this.highlightLayer.removeAll(),this.districtControllerLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.crossLayer.visible=!1;for(const s of this.districtControllers)for(const o of s.subDistricts)(o.id===e.id||o.parentId===e.id)&&await this.showSubDistrictRoad(o);const i=this.districtControllerLayer.graphics.filter(s=>s.getAttribute("id")===e.id).toArray().map(s=>s.clone()),r=this.subDistrictControllerLayer.graphics.filter(s=>s.getAttribute("districtId")===e.id||s.getAttribute("subDistrictId")===e.id).toArray().map(s=>s.clone()),t=this.crossLayer.graphics.filter(s=>s.getAttribute("id")===e.id||s.getAttribute("districtId")===e.id||s.getAttribute("subDistrictId")===e.id).toArray().map(s=>s.clone());return i.length>0&&this.highlightLayer.addMany(i),r.length>0&&this.highlightLayer.addMany(r),t.length>0&&this.highlightLayer.addMany(t),this.highlightLayer.graphics.length===0?{status:1,message:"未找到"}:(i.length>0?await this.view.goTo(i):r.length>0?await this.view.goTo({target:r,scale:this.crossScale-500}):t.length>1?await this.view.goTo(t):await this.view.goTo({target:t[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 i=this.districtControllerLayer.graphics.filter(r=>r.attributes.id===e);if(i||(i=this.subDistrictControllerLayer.graphics.filter(r=>r.attributes.getAttribute("subDistrictId")===e)),i||(i=this.crossLayer.graphics.filter(r=>r.attributes.id===e)),i.length!==0)return i.toArray()}showDistrict(e){const i=e.getAllCrossCoordinates();if(i.length>=2){let t=null;if(i.length===2)t=c.lineString(i);else if(i.length>2){const g=c.featureCollection(i.map(p=>c.point(p)));t=S(g)}t||(t=c.lineString(i));const s=v(t.geometry,200,{units:"meters"}),o=[{fieldName:"id",label:"区控编号"},{fieldName:"crossCount",label:"路口数量"},{fieldName:"subDistrictCount",label:"子区数量"}],h={type:"signalControlArea",id:e.id,name:e.name,parentId:e.parentId,parentName:e.parentName,crossCount:e.crossCount,subDistrictCount:e.subDistrictCount},u=new l({geometry:{type:"polygon",rings:s.geometry.coordinates},symbol:{type:"simple-fill",color:[...e.areaColor,.1],outline:{color:e.areaColor,width:2}},attributes:h,popupTemplate:{title:`区控 ${e.name}`,content:[{type:"fields",fieldInfos:o}]}});this.districtControllerLayer.add(u)}for(let t=0;t<e.subDistricts.length;t++){const s=e.subDistricts[t];this.showSubDistrictCross(s)}const r=[];e.crosses=e.crosses.filter(t=>y.default.isCoordinateValid(t)),e.crosses.forEach(t=>{if(y.default.isCoordinateValid(t)){const s={type:"cross",id:t.id,name:t.name,color:e.areaColor,signalId:t.signalId,districtId:e.id,districtName:e.name,isKey:t.isKey},o=new l({geometry:{type:"point",x:t.longitude,y:t.latitude},symbol:this.getCrossGraphicSymbol(s,"marker"),attributes:s,popupTemplate:{title:t.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}});r.push(o)}else console.log("路口坐标无效",t)}),this.crossLayer.addMany(r)}showSubDistrictCross(e){const i=[];e.crosses=e.crosses.filter(r=>y.default.isCoordinateValid(r)),e.crosses.forEach(r=>{const t={type:"cross",id:r.id,name:r.name,color:e.areaColor,signalId:r.signalId,districtId:e.parentId,districtName:e.parentName,subDistrictId:e.id,subDistrictName:e.name,isKey:r.isKey},s=new l({geometry:{type:"point",x:r.longitude,y:r.latitude},symbol:this.getCrossGraphicSymbol(t,"marker"),attributes:t,popupTemplate:{title:r.name,content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"id",label:"路口编号"},{fieldName:"signalId",label:"信号机编号"}]}]}});i.push(s)}),this.crossLayer.addMany(i)}async showSubDistrictRoad(e){if(e.crosses.length>1&&!this.loadedSubDistricts.includes(e.id)&&this.openDriveServerUrl&&this.openDriveServerUrl!==""){this.loadedSubDistricts.push(e.id);const i=await w.get(`http://${this.openDriveServerUrl}/api/computable/getRoadsectWithinJunctions`,{params:{junctionIds:e.crosses.map(r=>r.id).join(",")}});if(i.status===200){const r=i.data.result;if(r.length>0){const t=r.map(u=>new b.Polyline({paths:[u]})),s=m.geodesicBuffer(t,5,"meters"),o=m.union(s),h=new l({geometry:o,symbol:{type:"simple-fill",color:[...e.areaColor,.8],outline:{color:e.areaColor,width:1}},attributes:{districtId:e.parentId,districtName:e.parentName,subDistrictId:e.id,subDistrictName:e.name}});this.subDistrictControllerLayer.add(h)}}}}getCrossGraphicSymbol(e,i){const{isKey:r,color:t}=e;if(i==="marker")return r?{type:"picture-marker",url:"/GisViewerAssets/Images/icon_star.png",width:"30px",height:"30px"}:{type:"simple-marker",style:"circle",color:t,size:8,outline:{color:"white",width:1}};if(i==="picture")return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:r?60:40,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:r?45:30,rotateClockwise:!0,textureFilter:"Picture",url:`/GisViewerAssets/Images/xhj_${r?4:1}.png`,offsetY:r?22:15}]}}}}}exports.default=N;
@@ -129,6 +129,11 @@ export interface IOverlay {
129
129
  symbol?: IPointSymbol | ILineSymbol | IPolygonSymbol;
130
130
  properties?: any;
131
131
  }
132
+ export interface IMaskParam {
133
+ geometry: IPolygon;
134
+ maskColor?: number[];
135
+ maskSize?: number;
136
+ }
132
137
  export interface IOverlayParam {
133
138
  type?: string;
134
139
  defaultSymbol?: IPointSymbol | ILineSymbol | IPolygonSymbol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.154",
3
+ "version": "1.0.156",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [