gisviewer-vue3-arcgis 1.0.118 → 1.0.120

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 (29) hide show
  1. package/es/src/gis-map/gis-map.vue.mjs +2 -2
  2. package/es/src/gis-map/stores/appData.d.ts +0 -3
  3. package/es/src/gis-map/stores/appData.mjs +4 -7
  4. package/es/src/gis-map/utils/common-utils.d.ts +5 -0
  5. package/es/src/gis-map/utils/common-utils.mjs +47 -23
  6. package/es/src/gis-map/utils/map-initializer.mjs +100 -99
  7. package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +23 -3
  8. package/es/src/gis-map/utils/open-drive-renderer/index.mjs +290 -136
  9. package/es/src/gis-map/utils/open-drive-renderer/junction.d.ts +2 -1
  10. package/es/src/gis-map/utils/open-drive-renderer/road.d.ts +2 -0
  11. package/es/src/gis-map/utils/open-drive-renderer/road.mjs +16 -8
  12. package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +21 -1
  13. package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.mjs +219 -161
  14. package/es/src/types/index.d.ts +11 -0
  15. package/lib/src/gis-map/gis-map.vue.js +1 -1
  16. package/lib/src/gis-map/stores/appData.d.ts +0 -3
  17. package/lib/src/gis-map/stores/appData.js +1 -1
  18. package/lib/src/gis-map/utils/common-utils.d.ts +5 -0
  19. package/lib/src/gis-map/utils/common-utils.js +1 -1
  20. package/lib/src/gis-map/utils/map-initializer.js +1 -1
  21. package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +23 -3
  22. package/lib/src/gis-map/utils/open-drive-renderer/index.js +2 -1
  23. package/lib/src/gis-map/utils/open-drive-renderer/junction.d.ts +2 -1
  24. package/lib/src/gis-map/utils/open-drive-renderer/road.d.ts +2 -0
  25. package/lib/src/gis-map/utils/open-drive-renderer/road.js +1 -1
  26. package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +21 -1
  27. package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.js +1 -1
  28. package/lib/src/types/index.d.ts +11 -0
  29. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("@arcgis/core/Basemap"),z=require("@arcgis/core/Map"),b=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),O=require("@arcgis/core/geometry/support/webMercatorUtils"),S=require("@arcgis/core/layers/GeoJSONLayer"),W=require("@arcgis/core/layers/TileLayer"),x=require("@arcgis/core/layers/WebTileLayer"),L=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.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 T=v(q),p=v(O),G=v(I);function y(r,e){return r.startsWith("http://")||r.startsWith("https://")?r:e+r}class N{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){const i=_.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 l=new z;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new L({map:l,container:o,...t.mapOptions}):this.view=new R({map:l,container:o,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...t==null?void 0:t.mapOptions}),this.view.on("click",async s=>{var M,P;if(f){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=p.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=p.webMercatorToGeographic(a.position),d={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(d),(M=navigator.clipboard)==null||M.writeText(JSON.stringify(d))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom})}const h=(P=(await this.view.hitTest(s)).results)==null?void 0:P.filter(a=>a.type==="graphic");h.length>0&&h.forEach(a=>{var d;const u=a.graphic;(d=u.attributes)!=null&&d.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),t!=null&&t.baseLayers?t.baseLayers.forEach(s=>{switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const c=y(s.url,t.assetsRoot),h=new x({urlTemplate:c,...s.options});l.add(h);break}case"tile":{const c=y(s.url,t.assetsRoot),h=new W({url:c,...s.options});l.add(h);break}case"arcgis":{const c=new k(s.options);l.basemap=c;break}}}):l.basemap=new k({style:{id:"arcgis/dark-gray",language:"zh-CN"}}),t!=null&&t.hdLayers){const s=t.hdLayers.map(c=>new S({url:y(c.url,t.assetsRoot),...c.options,title:c.options.id}));l.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=p.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.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(G.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=T.watch(()=>this.view.center,()=>{const l=this.transformPoints(e),w=Date.now();w-t>n&&(i(l),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=T.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),t&&o>=t&&(this.view.zoom=t)}))}}exports.default=N;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),y=require("@arcgis/core/config"),z=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/support/webMercatorUtils"),O=require("@arcgis/core/layers/GeoJSONLayer"),S=require("@arcgis/core/layers/TileLayer"),W=require("@arcgis/core/layers/WebTileLayer"),x=require("@arcgis/core/Map"),L=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.js");function b(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=b(z),p=b(q),C=b(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=_.default.useAppDataStore,t=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=t;const{container:o,markerClickCallback:n,mapClickCallback:f}=e;y.assetsPath=`${t.assetsRoot}/ArcgisAssets`,y.fontsUrl=`${t.assetsRoot}/fonts`,y.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const c=new x;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new L({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.on("click",async s=>{var v,M;if(f){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=p.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=p.webMercatorToGeographic(a.position),d={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(d),(v=navigator.clipboard)==null||v.writeText(JSON.stringify(d))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom})}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 d;const u=a.graphic;(d=u.attributes)!=null&&d.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 W({urlTemplate:h,...s.options});c.add(l);break}case"tile":{const l=new S({url: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/dark-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=p.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.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;
@@ -1,8 +1,7 @@
1
- import View from '@arcgis/core/views/View';
2
1
  import { IFindSumoParams, IResult, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams } from '../../../types';
3
2
  export default class OpenDriveRenderer {
4
3
  private static instance;
5
- static getInstance(view: View): OpenDriveRenderer;
4
+ static getInstance(view: __esri.MapView | __esri.SceneView): OpenDriveRenderer;
6
5
  private readonly view;
7
6
  private laneLayer;
8
7
  private roadNameLayer;
@@ -10,8 +9,12 @@ export default class OpenDriveRenderer {
10
9
  private highlightLayer;
11
10
  private allLaneGraphics;
12
11
  private allRefLineGraphics;
12
+ private mouseMoveHandler;
13
+ private mouseClickHandler;
13
14
  private wasmLoader;
14
- constructor(view: View);
15
+ constructor(view: __esri.MapView | __esri.SceneView);
16
+ private projectName;
17
+ private openDriveServer;
15
18
  showOpenDriveFromFile(params: IShowOpenDriveFromFileParams): Promise<IResult>;
16
19
  /**
17
20
  * 从服务器载入OpenDrive文件解析结果并显示
@@ -21,6 +24,23 @@ export default class OpenDriveRenderer {
21
24
  showOpenDriveFromServer(server: string, projectName: string): Promise<IResult>;
22
25
  private showAllLanes;
23
26
  private showJunction;
27
+ private currentSectionCode;
28
+ private currentJunctionId;
29
+ private hitGraphic;
30
+ private highlightGraphic;
31
+ /**
32
+ * 监听鼠标移动事件,高亮显示鼠标所在路段和路口
33
+ */
34
+ private monitorMouseMove;
35
+ /**
36
+ * 监听鼠标点击事件,获取高亮要素的拓扑信息
37
+ */
38
+ private monitorMouseClick;
39
+ private increasePictureMarkerSize;
40
+ private decreasePictureMarkerSize;
41
+ /**
42
+ * 清除OpenDrive内容
43
+ */
24
44
  clearOpenDrive(): Promise<void>;
25
45
  /**
26
46
  * 用sumo的id定位车道、基本段、路段
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/Graphic"),v=require("@arcgis/core/geometry"),F=require("@arcgis/core/geometry/geometryEngineAsync.js"),I=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GraphicsLayer"),G=require("axios"),N=require("pako"),R=require("./wasm-loader.js");function q(u){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const t in u)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(u,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>u[t]})}}return e.default=u,Object.freeze(e)}const P=q(F);class w{constructor(e){this.wasmLoader=R.default.getInstance(),this.view=e,this.laneLayer=new I({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new I({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 O({id:"OpenDriveJunction"}),this.highlightLayer=new O({id:"OpenDriveHighlight"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.highlightLayer,this.roadNameLayer])}static getInstance(e){return this.instance||(this.instance=new w(e)),this.instance}async showOpenDriveFromFile(e){var n,h,s;const t=await this.wasmLoader.load(e.file);if(t.status!==0)return t;console.time("渲染用时");const{roads:a,junctions:o}=t.result;return await this.showAllLanes(a,((n=e.options)==null?void 0:n.showJunctionLane)||!1,((h=e.options)==null?void 0:h.showRoadName)||!0),(s=e.options)!=null&&s.showJunctionPolygon&&this.showJunction(o),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const a=`http://${e}/api/openDrive/analyzeXodr`,o=await G.get(a,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let n=o.data.result.json;n.startsWith(window.location.protocol)||(n=`${window.location.protocol}//${e}${n}`);const s=await(await fetch(n)).arrayBuffer(),r=N.inflate(s,{to:"string"}),d=JSON.parse(r);return await this.showAllLanes(d,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,a){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=a,new Promise(n=>{let h=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:d,refLine:l}=r;let i=r.name;i.includes("(")&&(i=i.slice(0,i.indexOf("("))),i=i.replace(/(.)/g,"$1 ");const c=new m({geometry:{type:"polyline",paths:[l]},attributes:{ObjectID:h++,roadId:d,roadName:i}});this.allRefLineGraphics.push(c);for(const p of r.laneSections){const b=Number(p.id);for(const y of p.lanePaths){const f=Number(y.id);if(f===0)continue;const D=y.type,g=y.innerPath.concat(y.outerPath.reverse());if(g.length<=3){console.warn(`lane ${f} has less than 3 points`);continue}g.push(y.innerPath[0]);const L=new v.Polygon({rings:[g]});if(L){const j=new m({geometry:L,attributes:{ObjectID:h++,id:`${d}+${b}+${f}`,roadId:d,roadName:r.name,sectionId:b,laneId:f,type:D,sumoId:""}});this.allLaneGraphics.push(j)}}}}this.view.type==="2d"?this.view.goTo(this.allRefLineGraphics):this.view.goTo(this.allRefLineGraphics);const s=setInterval(()=>{if(this.allLaneGraphics.length>0||this.allRefLineGraphics.length>0){if(this.allLaneGraphics.length>0){const r=this.allLaneGraphics.splice(0,100);this.laneLayer.applyEdits({addFeatures:r})}if(this.allRefLineGraphics.length>0){const r=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:r})}}else clearInterval(s),n()},10)})}async showJunction(e){for(const t of e){const a=new v.Polygon({rings:[t.outline]}),o=new m({geometry:a,attributes:{id:t.id,name:t.name},symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}});this.junctionLayer.add(o)}}async clearOpenDrive(){const e=await this.laneLayer.queryFeatures();e.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:e.features}),this.wasmLoader.clear()}async findSumo(e){const{id:t}=e,a=e.flash===void 0?!0:e.flash,o=t.split("+");if(o.length>2)return{status:-1,message:"id格式错误"};const n=o.length===2?Number(o[1]):void 0,h=o[0].split("#");if(h.length>2)return{status:-1,message:"id格式错误"};let s=h[0];s.startsWith("-")&&(s=s.slice(1));const r=h.length===2?Number(h[1]):void 0;return await this.findLane({roadsectId:s,segmentId:r,laneId:n,flash:a})}async findLane(e){let{segmentId:t,laneId:a}=e;const{roadsectId:o}=e,n=this.laneLayer.createQuery();n.returnGeometry=!0,n.outFields=["*"],n.where=`roadId = '${o}'`;const h=await this.laneLayer.queryFeatures(n);if(h.features.length===0)return{status:-1,message:"未找到。请检查路段编号"};let s=h.features;if(t!==void 0){const l=[];if(s.forEach(i=>{const c=Number(i.attributes.sectionId);l.indexOf(c)===-1&&l.push(c)}),l.sort((i,c)=>i-c),t>l.length-1)return{status:-1,message:"未找到。请检查基本段编号"};t=l[t],s=s.filter(i=>Number(i.attributes.sectionId)===t)}if(a!==void 0){const l=[];if(s.forEach(i=>{const c=Number(i.attributes.laneId);l.indexOf(c)===-1&&l.push(c)}),l.sort((i,c)=>i-c),a>l.length-1)return{status:-1,message:"未找到。请检查车道编号"};a=l[a],s=s.filter(i=>Number(i.attributes.laneId)===a)}const r=s.map(l=>l.geometry),d=await P.union(r);if(e.flash){this.highlightLayer.removeAll();const l=new m({geometry:d,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:2}}});this.highlightLayer.add(l);let i=0,c=!0;const p=setInterval(()=>{c?(this.highlightLayer.opacity-=.02,this.highlightLayer.opacity<=.1&&(c=!1,i++)):(this.highlightLayer.opacity+=.02,this.highlightLayer.opacity>=1&&(c=!0)),i>5&&(this.highlightLayer.removeAll(),this.highlightLayer.opacity=1,clearInterval(p))},20)}return this.view.type==="2d"?await this.view.goTo(d,{duration:1e3}):await this.view.goTo(d,{duration:1e3}),{status:0,message:"ok"}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=w;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@arcgis/core/Graphic"),C=require("@arcgis/core/core/promiseUtils"),$=require("@arcgis/core/geometry"),A=require("@arcgis/core/geometry/geometryEngineAsync"),D=require("@arcgis/core/layers/FeatureLayer"),j=require("@arcgis/core/layers/GraphicsLayer"),w=require("axios"),S=require("pako"),O=require("../common-utils.js"),M=require("./wasm-loader.js");function k(p){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const t in p)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(p,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>p[t]})}}return e.default=p,Object.freeze(e)}const P=k(C),N=k(A);class b{constructor(e){this.wasmLoader=M.default.getInstance(),this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.laneLayer=new D({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new D({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 j({id:"OpenDriveJunction"}),this.highlightLayer=new j({id:"OpenDriveHighlight"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.roadNameLayer,this.highlightLayer])}static getInstance(e){return this.instance||(this.instance=new b(e)),this.instance}async showOpenDriveFromFile(e){var d,c;this.projectName=Date.now().toString(),this.openDriveServer=e.server;const t=`http://${this.openDriveServer}/api/openDrive/uploadXodr`,i=await w.post(t,null,{params:{url:e.file,projectName:this.projectName}});if(i.status!==200)throw new Error(`OpenDriveRenderer: ${i.statusText}`);console.time("渲染用时");const r=i.data.result.geoSetting;O.default.setGeoData(r.geoReference,r.offsetX,r.offsetY);let s=i.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e.server}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=S.inflate(n,{to:"string"}),o=JSON.parse(a);await this.showAllLanes(o,((d=e.options)==null?void 0:d.showJunctionLane)||!1,((c=e.options)==null?void 0:c.showRoadName)||!0);const l=i.data.result.junctions;if(this.showJunction(l),e.options&&e.options.centerMap!==!1){const g=O.default.transformPointProjection([0,0]);await this.view.goTo(g)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,r=await w.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=S.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 h=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 c=o.name;c.includes("(")&&(c=c.slice(0,c.indexOf("("))),c=c.replace(/(.)/g,"$1 ");const g=new u({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:h++,roadId:l,roadName:c}});this.allRefLineGraphics.push(g);for(const v of o.laneSections){const I=Number(v.id);for(const y of v.lanePaths){const m=Number(y.id);if(m===0)continue;const F=y.type,f=y.innerPath.concat(y.outerPath.reverse());if(f.length<=3){console.warn(`lane ${m} has less than 3 points`);continue}f.push(y.innerPath[0]);const L=new $.Polygon({rings:[f]});if(L){const G=new u({geometry:L,attributes:{ObjectID:h++,id:`${l}+${I}+${m}`,roadId:l,roadName:o.name,sectionId:I,laneId:m,type:F,sumoId:""}});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){const r=new u({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/normal-cross.png",width:30,height:30}});t.push(r)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=P.debounce(async t=>{var h;const r=(h=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:h.filter(n=>n.type==="graphic");if(r.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.highlightGraphic=void 0,this.highlightLayer.removeAll());return}const s=r[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;if(n===this.currentSectionCode)return;this.currentSectionCode=n;const a=this.allLaneGraphics.filter(l=>`${l.attributes.roadId}+${l.attributes.sectionId}`===n),o=await N.union(a.map(l=>l.geometry));this.highlightGraphic=new u({geometry:o,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:2}},attributes:{type:"OpenDriveSection",id:n,detail:""}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.attributes.id;if(n===this.currentJunctionId)return;this.currentJunctionId=n,this.highlightGraphic=new u({geometry:this.hitGraphic.geometry,symbol:{type:"simple-marker",style:"circle",size:40,color:[0,0,0,0],outline:{color:[0,0,0,0]}},attributes:{type:"OpenDriveJunction",id:n}});const a=new u({geometry:this.hitGraphic.geometry,symbol:{type:"text",color:"black",backgroundColor:"gray",text:`${this.hitGraphic.attributes.name}
2
+ ${this.hitGraphic.attributes.id}`,font:{size:10},yoffset:40}});this.highlightLayer.removeAll(),this.highlightLayer.addMany([this.highlightGraphic,a])}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){this.mouseClickHandler=this.view.on("immediate-click",async()=>{var e,t;if(this.hitGraphic&&!this.currentSectionCode){if(this.currentJunctionId)if(this.hitGraphic.getAttribute("selected")===!1){const i=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await w.get(i,{params:{id:this.currentJunctionId,projectName:this.projectName}});r.status===200&&r.data.status===0&&((e=this.highlightGraphic)==null||e.setAttribute("detail",r.data.result),this.hitGraphic.setAttribute("selected",!0),this.hitGraphic.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(this.hitGraphic,50))}else(t=this.highlightGraphic)==null||t.setAttribute("detail",void 0),this.hitGraphic.setAttribute("selected",!1),this.hitGraphic.symbol.url="/GisViewerAssets/Images/point_green.png",this.decreasePictureMarkerSize(this.hitGraphic,30)}})}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 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.wasmLoader.clear(),(t=this.mouseMoveHandler)==null||t.remove(),(i=this.mouseClickHandler)==null||i.remove()}async findSumo(e){const{id:t}=e,i=e.flash===void 0?!0:e.flash,r=t.split("+");if(r.length>2)return{status:-1,message:"id格式错误"};const s=r.length===2?Number(r[1]):void 0,h=r[0].split("#");if(h.length>2)return{status:-1,message:"id格式错误"};let n=h[0];n.startsWith("-")&&(n=n.slice(1));const a=h.length===2?Number(h[1]):void 0;return await this.findLane({roadsectId:n,segmentId:a,laneId:s,flash:i})}async findLane(e){let{segmentId:t,laneId:i}=e;const{roadsectId:r}=e;let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===r);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(t!==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),t>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};t=a[t],s=s.filter(o=>Number(o.attributes.sectionId)===t)}if(i!==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),i>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};i=a[i],s=s.filter(o=>Number(o.attributes.laneId)===i)}const h=s.map(a=>a.geometry),n=await N.union(h);if(e.flash){this.highlightLayer.removeAll();const a=new u({geometry:n,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:2}}});this.highlightLayer.add(a);let o=0,l=!0;const d=setInterval(()=>{l?(this.highlightLayer.opacity-=.02,this.highlightLayer.opacity<=.1&&(l=!1,o++)):(this.highlightLayer.opacity+=.02,this.highlightLayer.opacity>=1&&(l=!0)),o>5&&(this.highlightLayer.removeAll(),this.highlightLayer.opacity=1,clearInterval(d))},20)}return await this.view.goTo(n,{duration:1e3}),{status:0,message:"ok"}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=b;
@@ -1,4 +1,4 @@
1
- import { ILaneInfo } from '../../../types';
1
+ import { IJunctionTableData, ILaneInfo } from '../../../types';
2
2
  interface ILink {
3
3
  incoming: ILaneInfo;
4
4
  connecting: ILaneInfo;
@@ -9,6 +9,7 @@ export default class Junction {
9
9
  name: string;
10
10
  /** 路口内的行车通道,包含进口道->转接道->出口道三个车道 */
11
11
  laneLinks: Array<ILink>;
12
+ tableData: IJunctionTableData | undefined;
12
13
  /** 进口车道按roadId归类, */
13
14
  private incomingLanes;
14
15
  private outline;
@@ -35,6 +35,8 @@ export default class Road {
35
35
  * @returns
36
36
  */
37
37
  getLastLaneSection(): LaneSection;
38
+ getLaneSectionIndex(s: number): number;
39
+ getLaneSectionLength(s: number): number;
38
40
  /**
39
41
  * 是否是最后一个路段的里程值
40
42
  * @param s
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("../common-utils.js"),h=require("./lane-section.js");class l{constructor(e){this.id=e.id,this.name=e.name,this.length=e.length,this.junction=e.junction,this.sToLaneSection=new Map;const t=a.default.getStdVecEntries(e.ref_line,!0);this.refLine=a.default.transformLineProjection(t);for(const i of[!0,!1]){const o=i?e.predecessor:e.successor,r={elementId:o.id,elementType:o.type,contactPoint:o.contact_point};i?this.predecessor=r:this.successor=r}a.default.getStdVecEntries(e.odr_lanesections,!0).forEach(i=>{const o=new h.default(i,this);this.sToLaneSection.set(o.s0,o)}),this.borders=this.getBorderLine();const n=[];n.push(...this.borders.right),n.push(...this.borders.top),n.push(...[...this.borders.left].reverse()),n.push(...[...this.borders.bottom].reverse()),n.push(n[0]),this.polygon=n}getLaneSection(e){return this.sToLaneSection.get(e)}getFirstLaneSection(){const e=[...this.sToLaneSection.keys()];return e.sort((t,s)=>t-s),this.sToLaneSection.get(e[0])}getLastLaneSection(){const e=[...this.sToLaneSection.keys()];return e.sort((t,s)=>t-s),this.sToLaneSection.get(e[e.length-1])}isLastLaneSection(e){const t=[...this.sToLaneSection.keys()];return t.sort((s,n)=>s-n),e===t[t.length-1]}getNextLaneSection(e){const t=[...this.sToLaneSection.keys()],s=t.indexOf(e);if(s>=0&&s<t.length-1)return this.sToLaneSection.get(t[s+1])}getPrevLaneSection(e){const t=[...this.sToLaneSection.keys()],s=t.indexOf(e);if(s>0)return this.sToLaneSection.get(t[s-1])}get allLaneSections(){return[...this.sToLaneSection.values()]}get laneSectionNumber(){return this.sToLaneSection.size}get sampledRoad(){return{id:this.id,name:this.name,junction:this.junction,refLine:this.refLine,laneSections:this.allLaneSections.map(e=>e.sampledLaneSection)}}getBorderLine(){const e=[],t=[];let s=[],n=[];const i=[...this.sToLaneSection.keys()];return i.forEach((o,r)=>{const c=this.getLaneSection(o);r===0?n=c.borders.bottom:r===i.length-1&&(s=c.borders.top),e.push(...c.borders.left),t.push(...c.borders.right)}),{left:e,right:t,top:s,bottom:n}}}exports.default=l;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("../common-utils.js"),h=require("./lane-section.js");class l{constructor(e){this.id=e.id,this.name=e.name,this.length=e.length,this.junction=e.junction,this.sToLaneSection=new Map;const t=a.default.getStdVecEntries(e.ref_line,!0);this.refLine=a.default.transformLineProjection(t);for(const i of[!0,!1]){const o=i?e.predecessor:e.successor,r={elementId:o.id,elementType:o.type,contactPoint:o.contact_point};i?this.predecessor=r:this.successor=r}a.default.getStdVecEntries(e.odr_lanesections,!0).forEach(i=>{const o=new h.default(i,this);this.sToLaneSection.set(o.s0,o)}),this.borders=this.getBorderLine();const n=[];n.push(...this.borders.right),n.push(...this.borders.top),n.push(...[...this.borders.left].reverse()),n.push(...[...this.borders.bottom].reverse()),n.push(n[0]),this.polygon=n}getLaneSection(e){return this.sToLaneSection.get(e)}getFirstLaneSection(){const e=[...this.sToLaneSection.keys()];return e.sort((t,s)=>t-s),this.sToLaneSection.get(e[0])}getLastLaneSection(){const e=[...this.sToLaneSection.keys()];return e.sort((t,s)=>t-s),this.sToLaneSection.get(e[e.length-1])}getLaneSectionIndex(e){return[...this.sToLaneSection.keys()].indexOf(e)}getLaneSectionLength(e){const t=[...this.sToLaneSection.keys()],s=t.indexOf(e);let n=0;return s===0?t.length===1?n=this.length:n=t[1]:s===t.length-1?n=this.length-t[t.length-1]:n=t[s+1]-e,n}isLastLaneSection(e){const t=[...this.sToLaneSection.keys()];return t.sort((s,n)=>s-n),e===t[t.length-1]}getNextLaneSection(e){const t=[...this.sToLaneSection.keys()],s=t.indexOf(e);if(s>=0&&s<t.length-1)return this.sToLaneSection.get(t[s+1])}getPrevLaneSection(e){const t=[...this.sToLaneSection.keys()],s=t.indexOf(e);if(s>0)return this.sToLaneSection.get(t[s-1])}get allLaneSections(){return[...this.sToLaneSection.values()]}get laneSectionNumber(){return this.sToLaneSection.size}get sampledRoad(){return{id:this.id,name:this.name,junction:this.junction,refLine:this.refLine,laneSections:this.allLaneSections.map(e=>e.sampledLaneSection)}}getBorderLine(){const e=[],t=[];let s=[],n=[];const i=[...this.sToLaneSection.keys()];return i.forEach((o,r)=>{const c=this.getLaneSection(o);r===0?n=c.borders.bottom:r===i.length-1&&(s=c.borders.top),e.push(...c.borders.left),t.push(...c.borders.right)}),{left:e,right:t,top:s,bottom:n}}}exports.default=l;
@@ -7,10 +7,11 @@ export default class WasmLoader {
7
7
  static getInstance(): WasmLoader;
8
8
  roadList: Map<string, Road>;
9
9
  junctionList: Map<string, Junction>;
10
+ private junctionTableData;
10
11
  private isWasmLoaded;
11
12
  private ModuleOpenDrive;
12
13
  private ModuleOpenDriveMap;
13
- private appStore;
14
+ private appDataStore;
14
15
  private FsFile;
15
16
  /**
16
17
  * 载入指定xodr文件并解析
@@ -18,6 +19,11 @@ export default class WasmLoader {
18
19
  */
19
20
  load(file: string): Promise<IResult>;
20
21
  clear(): void;
22
+ /**
23
+ * 读取xodr中wasm接口不提供的数据
24
+ * @param fileText
25
+ */
26
+ private readXodrString;
21
27
  /**
22
28
  * 解析路网
23
29
  */
@@ -85,4 +91,18 @@ export default class WasmLoader {
85
91
  getRoadStopLine(junctionId: string): IResult;
86
92
  getLaneStopLine(laneInfo: ILaneInfo): IResult;
87
93
  getLaneCenterLine(laneInfo: ILaneInfo): IResult;
94
+ getSumoEdgeInfo(sectionCode: string): {
95
+ obj_id: string;
96
+ obj_type: number;
97
+ obj_desc: string;
98
+ obj_info: {
99
+ obj_id: string;
100
+ length: number;
101
+ from: string;
102
+ to: string;
103
+ numLanes: number;
104
+ type: string;
105
+ laneList: any[];
106
+ };
107
+ } | undefined;
88
108
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const L=require("fast-xml-parser"),h=require("../../stores/appData.js"),f=require("../common-utils.js"),m=require("./junction.js"),p=require("./road.js");class g{constructor(){this.roadList=new Map,this.junctionList=new Map,this.isWasmLoaded=!1,this.appStore=h.useAppDataStore(),this.FsFile="data.xodr"}static getInstance(){return g.instance||(g.instance=new g),g.instance}async load(t){if(!this.isWasmLoaded){const l=window.libOpenDrive;this.ModuleOpenDrive=await l(),this.isWasmLoaded=!0}console.time("加载用时");const s=await(await fetch(t)).text(),n=new L.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(s),o=n.OpenDRIVE.header.geoReference,a=n.OpenDRIVE.header.offset;if(a){const l=Number(a["@_x"])||0,c=Number(a["@_y"])||0;this.appStore.$patch({xOffset:l,yOffset:c,geoReference:o})}const u=new TextEncoder().encode(s);try{this.ModuleOpenDrive.FS_unlink(`./${this.FsFile}`)}catch{}this.ModuleOpenDrive.FS_createDataFile(".",this.FsFile,u,!0,!0);const d={with_lateralProfile:!0,with_laneHeight:!0,with_road_objects:!1,center_map:!1,abs_z_for_for_local_road_obj_outline:!0};return this.ModuleOpenDriveMap=new this.ModuleOpenDrive.OpenDriveMap(`./${this.FsFile}`,d),console.timeEnd("加载用时"),this.getRoadNetwork()}clear(){this.roadList.clear(),this.junctionList.clear();try{this.ModuleOpenDrive.FS_unlink(`./${this.FsFile}`)}catch{}}getRoadNetwork(){console.time("采样用时"),this.roadList.clear(),this.junctionList.clear();try{const t=this.ModuleOpenDrive.get_odr_road_network(this.ModuleOpenDriveMap,.5),e=t.geo_reference;h.useAppDataStore().$patch({geoReference:e}),console.timeEnd("采样用时"),console.time("投影转换用时"),f.default.getStdVecEntries(t.roads,!0).forEach(r=>{const u=new p.default(r);this.roadList.set(u.id,u)}),f.default.getStdVecEntries(t.junctions,!0).forEach(r=>{const u=new m.default(r);this.junctionList.set(r.id,u)}),console.timeEnd("投影转换用时");const o=[];this.roadList.forEach(r=>{const u=r.allLaneSections.map(d=>{const l=d.allLanes.map(c=>({id:c.id,type:c.type,innerPath:c.innerBorder,outerPath:c.outerBorder,centerLine:c.centerLine}));return{id:d.s0,lanePaths:l}});o.push({id:r.id,name:r.name,laneSections:u,junction:r.junction,refLine:r.refLine})});const a=[];return this.junctionList.forEach(r=>{const u=r.getJunctionOutline();a.push({id:r.id,name:r.name,outline:u})}),{status:0,message:"ok",result:{roads:o,junctions:a}}}catch{return{status:-1,message:"解析路网失败"}}}get allSampledRoads(){return[...this.roadList.values()].map(t=>t.sampledRoad)}get roadNetwork(){return[...this.roadList.values()].map(e=>{const s=e.allLaneSections.map(i=>{const n=i.allLaneIds.filter(o=>o!==0);return{sectionId:i.s0,laneIds:n}});return{roadName:e.name,roadId:e.id,roadLength:e.length,sections:s}})}getLane(t){const e=this.roadList.get(t.roadId),s=e==null?void 0:e.getLaneSection(t.sectionId);return s==null?void 0:s.getLane(t.laneId)}getFunctionFromIncomingToOutgoing(t,e){const s=this.getLane(t),i=this.getLane(e);if(!s||!i||!s.drivingAngle||!i.drivingAngle)return{status:-1,message:"车道信息错误"};let n=i.drivingAngle-s.drivingAngle;n>180?n-=360:n<-180&&(n+=360);let o="";return-45<n&&n<45?o="s":45<=n&&n<=135?o="r":-135<=n&&n<=-45?o="l":o="t",{status:0,result:o,message:"ok"}}getJunctionOutline(t){const e=[];if(t!==""){const s=this.junctionList.get(t);if(s){const i=s.getJunctionOutline();e.push({junctionId:t,name:s.name,outline:i})}}else for(const s of this.junctionList){const i=s[0],n=s[1],o=n.getJunctionOutline();o.length<=4?console.log(o,i):e.push({junctionId:i,name:n.name,outline:o})}return{status:0,result:e,message:"ok"}}getLaneLink(t){const e=this.getLane(t);return e?{status:0,result:e.getLink(),message:"ok"}:{status:-1,message:"车道信息错误"}}getRoadLink(t){const e=[];if(t!==""){const s=this.roadList.get(t);s&&e.push({roadId:t,successor:s.successor,predecessor:s.predecessor})}else[...this.roadList.values()].forEach(i=>{e.push({roadId:t,successor:i.successor,predecessor:i.predecessor})});return{status:0,result:e,message:"ok"}}getConnectionLink(t){const e=[];for(const s of this.junctionList){const i=s[0],n=s[1];if((t===""||i===t)&&(e.push({id:i,name:n.name,links:n.laneLinks}),t!==""))break}return{status:0,result:e,message:"ok"}}getLaneAngle(t){const e=this.getLane(t);if(e){const s=e.drivingAngle;if(s)return{status:0,result:s,message:"ok"}}return{status:-1,message:"车道信息错误"}}getTurnArrow(t){const e=this.getLane(t.incoming);if(!e)return{status:-1,message:"进口道信息错误"};const s=e.drivingAngle;if(!s)return{status:-1,message:"进口道信息错误"};const i=this.getLane(t.outgoing);if(!i)return{status:-1,message:"出口道信息错误"};const n=i.drivingAngle;if(!n)return{status:-1,message:"出口道信息错误"};let o=n-s;o>180?o-=360:o<-180&&(o+=360);let a="";return-45<o&&o<45?a="s":45<=o&&o<=135?a="r":-135<=o&&o<=-45?a="l":a="t",{status:0,message:"ok",result:{incomingAngle:s,outgoingAngle:n,direction:a}}}getPolygon(t,e,s){const i=this.roadList.get(t);if(!i)return{status:-1,message:"道路id错误"};if(e!==void 0&&s!==void 0&&!isNaN(e)&&!isNaN(s)){const n=this.getLane({roadId:t,sectionId:e,laneId:s});return n?{status:0,message:"ok",result:n.ring}:{status:-1,message:"车道信息错误"}}else if(e!==void 0&&!isNaN(e)){const n=i.getLaneSection(e);return n?{status:0,message:"ok",result:n.polygon}:{status:-1,message:"路段信息错误"}}else return{status:0,message:"ok",result:i.polygon}}getLaneLength(t){const e=this.getLane(t);if(e){let s=0;return e.road.isLastLaneSection(e.laneSection.s0)?s=e.road.length-e.laneSection.s0:s=e.road.getNextLaneSection(e.laneSection.s0).s0-e.laneSection.s0,{status:0,message:"ok",result:Number(s.toFixed(2))}}else return{status:-1,message:"车道信息错误"}}getRoadStopLine(t){const e=[];for(const s of this.junctionList){const i=s[0],n=s[1];if(i===t){const o=n.getRoadStopLine();e.push({junctionId:i,stopLines:o});break}else if(t===""){const o=n.getRoadStopLine();e.push({junctionId:i,stopLines:o})}}return{status:0,message:"ok",result:e}}getLaneStopLine(t){const e=this.getLane(t);return e?{status:0,message:"ok",result:e.getStopLine()}:{status:-1,message:"车道信息错误"}}getLaneCenterLine(t){const e=this.getLane(t);return e?{status:0,message:"ok",result:e.getLaneEndPoints("middle")}:{status:-1,message:"车道信息错误"}}}exports.default=g;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("fast-xml-parser"),L=require("../../stores/index.js"),g=require("../common-utils.js"),p=require("./junction.js"),S=require("./road.js");class c{constructor(){this.roadList=new Map,this.junctionList=new Map,this.junctionTableData=new Map,this.isWasmLoaded=!1,this.appDataStore=L.default.useAppDataStore,this.FsFile="data.xodr"}static getInstance(){return c.instance||(c.instance=new c),c.instance}async load(o){if(!this.isWasmLoaded){const r=window.libOpenDrive;this.ModuleOpenDrive=await r(),this.isWasmLoaded=!0}console.time("加载用时");const t=await(await fetch(o)).text();this.readXodrString(t);const n=new TextEncoder().encode(t);try{this.ModuleOpenDrive.FS_unlink(`./${this.FsFile}`)}catch{}this.ModuleOpenDrive.FS_createDataFile(".",this.FsFile,n,!0,!0);const i={with_lateralProfile:!0,with_laneHeight:!0,with_road_objects:!1,center_map:!1,abs_z_for_for_local_road_obj_outline:!0};return this.ModuleOpenDriveMap=new this.ModuleOpenDrive.OpenDriveMap(`./${this.FsFile}`,i),console.timeEnd("加载用时"),this.getRoadNetwork()}clear(){this.roadList.clear(),this.junctionList.clear();try{this.ModuleOpenDrive.FS_unlink(`./${this.FsFile}`)}catch{}}readXodrString(o){const t=new m.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(o),s=t.OpenDRIVE.header.geoReference,n=t.OpenDRIVE.header.offset;if(n){const r=Number(n["@_x"])||0,a=Number(n["@_y"])||0;g.default.setGeoData(s,r,a)}const i=t.OpenDRIVE.junction;for(const r of i){const a=JSON.parse(r.userData.tableData);this.junctionTableData.set(a.id,a)}}getRoadNetwork(){this.roadList.clear(),this.junctionList.clear();let o;try{console.time("采样用时"),o=this.ModuleOpenDrive.get_odr_road_network(this.ModuleOpenDriveMap,.5)}catch(s){return{status:-1,message:`解析路网失败, ${s}`}}finally{console.timeEnd("采样用时")}console.time("投影转换用时");try{g.default.getStdVecEntries(o.roads,!0).forEach(n=>{const i=new S.default(n);this.roadList.set(i.id,i)})}catch(s){return{status:-1,message:`解析道路失败, ${s}`}}try{g.default.getStdVecEntries(o.junctions,!0).forEach(n=>{const i=new p.default(n);i.tableData=this.junctionTableData.get(i.id),this.junctionList.set(n.id,i)})}catch(s){return{status:-1,message:`解析路口失败, ${s}`}}console.timeEnd("投影转换用时");const e=[];this.roadList.forEach(s=>{const n=s.allLaneSections.map(i=>{const r=i.allLanes.map(a=>({id:a.id,type:a.type,innerPath:a.innerBorder,outerPath:a.outerBorder,centerLine:a.centerLine}));return{id:i.s0,lanePaths:r}});e.push({id:s.id,name:s.name,laneSections:n,junction:s.junction,refLine:s.refLine})});const t=[];return this.junctionList.forEach(s=>{s.tableData&&t.push(s.tableData)}),{status:0,message:"ok",result:{roads:e,junctions:t}}}get allSampledRoads(){return[...this.roadList.values()].map(o=>o.sampledRoad)}get roadNetwork(){return[...this.roadList.values()].map(e=>{const t=e.allLaneSections.map(s=>{const n=s.allLaneIds.filter(i=>i!==0);return{sectionId:s.s0,laneIds:n}});return{roadName:e.name,roadId:e.id,roadLength:e.length,sections:t}})}getLane(o){const e=this.roadList.get(o.roadId),t=e==null?void 0:e.getLaneSection(o.sectionId);return t==null?void 0:t.getLane(o.laneId)}getFunctionFromIncomingToOutgoing(o,e){const t=this.getLane(o),s=this.getLane(e);if(!t||!s||!t.drivingAngle||!s.drivingAngle)return{status:-1,message:"车道信息错误"};let n=s.drivingAngle-t.drivingAngle;n>180?n-=360:n<-180&&(n+=360);let i="";return-45<n&&n<45?i="s":45<=n&&n<=135?i="r":-135<=n&&n<=-45?i="l":i="t",{status:0,result:i,message:"ok"}}getJunctionOutline(o){const e=[];if(o!==""){const t=this.junctionList.get(o);if(t){const s=t.getJunctionOutline();e.push({junctionId:o,name:t.name,outline:s})}}else for(const t of this.junctionList){const s=t[0],n=t[1],i=n.getJunctionOutline();i.length<=4?console.log(i,s):e.push({junctionId:s,name:n.name,outline:i})}return{status:0,result:e,message:"ok"}}getLaneLink(o){const e=this.getLane(o);return e?{status:0,result:e.getLink(),message:"ok"}:{status:-1,message:"车道信息错误"}}getRoadLink(o){const e=[];if(o!==""){const t=this.roadList.get(o);t&&e.push({roadId:o,successor:t.successor,predecessor:t.predecessor})}else[...this.roadList.values()].forEach(s=>{e.push({roadId:o,successor:s.successor,predecessor:s.predecessor})});return{status:0,result:e,message:"ok"}}getConnectionLink(o){const e=[];for(const t of this.junctionList){const s=t[0],n=t[1];if((o===""||s===o)&&(e.push({id:s,name:n.name,links:n.laneLinks}),o!==""))break}return{status:0,result:e,message:"ok"}}getLaneAngle(o){const e=this.getLane(o);if(e){const t=e.drivingAngle;if(t)return{status:0,result:t,message:"ok"}}return{status:-1,message:"车道信息错误"}}getTurnArrow(o){const e=this.getLane(o.incoming);if(!e)return{status:-1,message:"进口道信息错误"};const t=e.drivingAngle;if(!t)return{status:-1,message:"进口道信息错误"};const s=this.getLane(o.outgoing);if(!s)return{status:-1,message:"出口道信息错误"};const n=s.drivingAngle;if(!n)return{status:-1,message:"出口道信息错误"};let i=n-t;i>180?i-=360:i<-180&&(i+=360);let r="";return-45<i&&i<45?r="s":45<=i&&i<=135?r="r":-135<=i&&i<=-45?r="l":r="t",{status:0,message:"ok",result:{incomingAngle:t,outgoingAngle:n,direction:r}}}getPolygon(o,e,t){const s=this.roadList.get(o);if(!s)return{status:-1,message:"道路id错误"};if(e!==void 0&&t!==void 0&&!isNaN(e)&&!isNaN(t)){const n=this.getLane({roadId:o,sectionId:e,laneId:t});return n?{status:0,message:"ok",result:n.ring}:{status:-1,message:"车道信息错误"}}else if(e!==void 0&&!isNaN(e)){const n=s.getLaneSection(e);return n?{status:0,message:"ok",result:n.polygon}:{status:-1,message:"路段信息错误"}}else return{status:0,message:"ok",result:s.polygon}}getLaneLength(o){const e=this.getLane(o);if(e){let t=0;return e.road.isLastLaneSection(e.laneSection.s0)?t=e.road.length-e.laneSection.s0:t=e.road.getNextLaneSection(e.laneSection.s0).s0-e.laneSection.s0,{status:0,message:"ok",result:Number(t.toFixed(2))}}else return{status:-1,message:"车道信息错误"}}getRoadStopLine(o){const e=[];for(const t of this.junctionList){const s=t[0],n=t[1];if(s===o){const i=n.getRoadStopLine();e.push({junctionId:s,stopLines:i});break}else if(o===""){const i=n.getRoadStopLine();e.push({junctionId:s,stopLines:i})}}return{status:0,message:"ok",result:e}}getLaneStopLine(o){const e=this.getLane(o);return e?{status:0,message:"ok",result:e.getStopLine()}:{status:-1,message:"车道信息错误"}}getLaneCenterLine(o){const e=this.getLane(o);return e?{status:0,message:"ok",result:e.getLaneEndPoints("middle")}:{status:-1,message:"车道信息错误"}}getSumoEdgeInfo(o){const e=o.split("+"),t=e[0],s=Number(e[1]),n=this.roadList.get(t);if(!n)return;let i="";if(n.laneSectionNumber===1)i=`-${t}`;else{const u=n.getLaneSectionIndex(s);if(u===-1)return;i=`-${t}#${u}`}const r=n.predecessor.elementId,a=n.successor.elementId,l=n.getLaneSection(s);if(!l)return;const d=[],f=l.laneNumber-1;for(const u of l.allLanes){if(u.id===0)continue;const h=f-Math.abs(u.id);d.push({obj_id:`${i}_${h}`})}return{obj_id:i,obj_type:1,obj_desc:"edge",obj_info:{obj_id:i,length:n.getLaneSectionLength(s),from:r,to:a,numLanes:f,type:"driving",laneList:d}}}}exports.default=c;
@@ -208,11 +208,13 @@ export interface IRoadStopLinesResult {
208
208
  }[];
209
209
  }
210
210
  export interface IShowOpenDriveFromFileParams {
211
+ server: string;
211
212
  file: string;
212
213
  options?: {
213
214
  showJunctionPolygon: boolean;
214
215
  showJunctionLane: boolean;
215
216
  showRoadName: boolean;
217
+ centerMap: boolean;
216
218
  };
217
219
  }
218
220
  export interface IFindSumoParams {
@@ -224,3 +226,12 @@ export interface ISplitOpenDriveLaneParams {
224
226
  start: number;
225
227
  end: number;
226
228
  }
229
+ export interface IJunctionTableData {
230
+ id: string;
231
+ name: string;
232
+ type: string;
233
+ coordinates: number[];
234
+ district: string;
235
+ crossId?: string;
236
+ factoryCode?: string;
237
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.118",
3
+ "version": "1.0.120",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [