gisviewer-vue3-arcgis 1.0.115 → 1.0.117

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 (53) hide show
  1. package/es/src/gis-map/gis-map.vue.d.ts +6 -3
  2. package/es/src/gis-map/gis-map.vue.mjs +100 -95
  3. package/es/src/gis-map/index.d.ts +5 -2
  4. package/es/src/gis-map/stores/appData.d.ts +3 -0
  5. package/es/src/gis-map/stores/appData.mjs +7 -4
  6. package/es/src/gis-map/utils/common-utils.d.ts +12 -0
  7. package/es/src/gis-map/utils/common-utils.mjs +81 -43
  8. package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +3 -3
  9. package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.mjs +0 -1
  10. package/es/src/gis-map/utils/open-drive-renderer/draw-bezier.d.ts +17 -0
  11. package/es/src/gis-map/utils/open-drive-renderer/draw-bezier.mjs +49 -0
  12. package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +32 -3
  13. package/es/src/gis-map/utils/open-drive-renderer/index.mjs +279 -45
  14. package/es/src/gis-map/utils/open-drive-renderer/junction.d.ts +50 -0
  15. package/es/src/gis-map/utils/open-drive-renderer/junction.mjs +151 -0
  16. package/es/src/gis-map/utils/open-drive-renderer/lane-section.d.ts +48 -0
  17. package/es/src/gis-map/utils/open-drive-renderer/lane-section.mjs +82 -0
  18. package/es/src/gis-map/utils/open-drive-renderer/lane-utils.d.ts +29 -0
  19. package/es/src/gis-map/utils/open-drive-renderer/lane-utils.mjs +265 -0
  20. package/es/src/gis-map/utils/open-drive-renderer/lane.d.ts +77 -0
  21. package/es/src/gis-map/utils/open-drive-renderer/lane.mjs +110 -0
  22. package/es/src/gis-map/utils/open-drive-renderer/road.d.ts +60 -0
  23. package/es/src/gis-map/utils/open-drive-renderer/road.mjs +113 -0
  24. package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +88 -0
  25. package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.mjs +367 -0
  26. package/es/src/types/index.d.ts +54 -0
  27. package/lib/src/gis-map/gis-map.vue.d.ts +6 -3
  28. package/lib/src/gis-map/gis-map.vue.js +1 -1
  29. package/lib/src/gis-map/index.d.ts +5 -2
  30. package/lib/src/gis-map/stores/appData.d.ts +3 -0
  31. package/lib/src/gis-map/stores/appData.js +1 -1
  32. package/lib/src/gis-map/utils/common-utils.d.ts +12 -0
  33. package/lib/src/gis-map/utils/common-utils.js +1 -1
  34. package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
  35. package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -1
  36. package/lib/src/gis-map/utils/open-drive-renderer/draw-bezier.d.ts +17 -0
  37. package/lib/src/gis-map/utils/open-drive-renderer/draw-bezier.js +1 -0
  38. package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +32 -3
  39. package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
  40. package/lib/src/gis-map/utils/open-drive-renderer/junction.d.ts +50 -0
  41. package/lib/src/gis-map/utils/open-drive-renderer/junction.js +1 -0
  42. package/lib/src/gis-map/utils/open-drive-renderer/lane-section.d.ts +48 -0
  43. package/lib/src/gis-map/utils/open-drive-renderer/lane-section.js +1 -0
  44. package/lib/src/gis-map/utils/open-drive-renderer/lane-utils.d.ts +29 -0
  45. package/lib/src/gis-map/utils/open-drive-renderer/lane-utils.js +1 -0
  46. package/lib/src/gis-map/utils/open-drive-renderer/lane.d.ts +77 -0
  47. package/lib/src/gis-map/utils/open-drive-renderer/lane.js +1 -0
  48. package/lib/src/gis-map/utils/open-drive-renderer/road.d.ts +60 -0
  49. package/lib/src/gis-map/utils/open-drive-renderer/road.js +1 -0
  50. package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +88 -0
  51. package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.js +1 -0
  52. package/lib/src/types/index.d.ts +54 -0
  53. package/package.json +4 -1
@@ -0,0 +1,88 @@
1
+ import { ILaneInfo, IResult, ISampledRoad } from '../../../types';
2
+ import Junction from './junction';
3
+ import Lane from './lane';
4
+ import Road from './road';
5
+ export default class WasmLoader {
6
+ private static instance;
7
+ static getInstance(): WasmLoader;
8
+ roadList: Map<string, Road>;
9
+ junctionList: Map<string, Junction>;
10
+ private isWasmLoaded;
11
+ private ModuleOpenDrive;
12
+ private ModuleOpenDriveMap;
13
+ private appStore;
14
+ private FsFile;
15
+ /**
16
+ * 载入指定xodr文件并解析
17
+ * @param filePath
18
+ */
19
+ load(file: string): Promise<IResult>;
20
+ clear(): void;
21
+ /**
22
+ * 解析路网
23
+ */
24
+ private getRoadNetwork;
25
+ /**
26
+ * 获取所有道路的采样结果
27
+ */
28
+ get allSampledRoads(): ISampledRoad[];
29
+ /**
30
+ * 获取路网结构
31
+ */
32
+ get roadNetwork(): {
33
+ roadName: string;
34
+ roadId: string;
35
+ roadLength: number;
36
+ sections: {
37
+ sectionId: number;
38
+ laneIds: number[];
39
+ }[];
40
+ }[];
41
+ /**
42
+ * 从车道信息获取车道对象
43
+ * @param laneInfo
44
+ */
45
+ getLane(laneInfo: ILaneInfo): Lane | undefined;
46
+ /**
47
+ * 获取两个车道之间的车道功能
48
+ * 左转、直行、右转、调头
49
+ * @param incoming
50
+ * @param outgoing
51
+ */
52
+ getFunctionFromIncomingToOutgoing(incoming: ILaneInfo, outgoing: ILaneInfo): IResult;
53
+ /**
54
+ * 获取所有路口的轮廓
55
+ * @returns
56
+ */
57
+ getJunctionOutline(junctionId: string): IResult;
58
+ /**
59
+ * 获取车道的前驱车道和后继车道
60
+ * @param laneInfo
61
+ * @returns
62
+ */
63
+ getLaneLink(laneInfo: ILaneInfo): IResult;
64
+ getRoadLink(roadId: string): IResult;
65
+ getConnectionLink(junctionId: string): IResult;
66
+ getLaneAngle(laneInfo: ILaneInfo): IResult;
67
+ getTurnArrow(params: {
68
+ incoming: ILaneInfo;
69
+ outgoing: ILaneInfo;
70
+ }): IResult;
71
+ /**
72
+ * 道路路段车道的轮廓
73
+ * @param roadId
74
+ * @param sectionId
75
+ * @param laneId
76
+ * @returns
77
+ */
78
+ getPolygon(roadId: string, sectionId?: number, laneId?: number): IResult;
79
+ /**
80
+ * 车道长度
81
+ * @param laneInfo
82
+ * @returns
83
+ */
84
+ getLaneLength(laneInfo: ILaneInfo): IResult;
85
+ getRoadStopLine(junctionId: string): IResult;
86
+ getLaneStopLine(laneInfo: ILaneInfo): IResult;
87
+ getLaneCenterLine(laneInfo: ILaneInfo): IResult;
88
+ }
@@ -0,0 +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;
@@ -170,3 +170,57 @@ export declare enum EVehiclePlateState {
170
170
  Id = 2,
171
171
  Mix = 3
172
172
  }
173
+ export interface ILaneInfo {
174
+ roadId: string;
175
+ sectionId: number;
176
+ laneId: number;
177
+ }
178
+ /** 采样后的车道 */
179
+ export interface ISampledLane {
180
+ id: number;
181
+ type: string;
182
+ innerPath: number[][];
183
+ outerPath: number[][];
184
+ }
185
+ /** 采样后的路段 */
186
+ export interface ISampledLaneSection {
187
+ id: number;
188
+ lanePaths: ISampledLane[];
189
+ }
190
+ /** 采样后的道路 */
191
+ export interface ISampledRoad {
192
+ id: string;
193
+ name: string;
194
+ junction: string;
195
+ refLine: number[][];
196
+ laneSections: ISampledLaneSection[];
197
+ }
198
+ export interface IRoadLink {
199
+ elementId: string;
200
+ elementType: string;
201
+ contactPoint?: string;
202
+ }
203
+ export interface IRoadStopLinesResult {
204
+ junctionId: string;
205
+ stopLines: {
206
+ roadId: string;
207
+ line: number[][];
208
+ }[];
209
+ }
210
+ export interface IShowOpenDriveFromFileParams {
211
+ file: string;
212
+ options?: {
213
+ showJunctionPolygon: boolean;
214
+ showJunctionLane: boolean;
215
+ showRoadName: boolean;
216
+ };
217
+ }
218
+ export interface IFindSumoParams {
219
+ id: string;
220
+ flash?: boolean;
221
+ }
222
+ export interface ISplitOpenDriveLaneParams {
223
+ id: string;
224
+ start: number;
225
+ end: number;
226
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.115",
3
+ "version": "1.0.117",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [
@@ -27,12 +27,15 @@
27
27
  "@turf/destination": "^6.5.0",
28
28
  "@turf/helpers": "^6.5.0",
29
29
  "@turf/intersect": "^6.5.0",
30
+ "@turf/line-intersect": "^7.0.0",
30
31
  "@turf/turf": "6.5.0",
31
32
  "@types/pako": "^2.0.0",
32
33
  "@vitest/coverage-c8": "^0.29.2",
33
34
  "axios": "^1.4.0",
35
+ "fast-xml-parser": "^4.4.0",
34
36
  "pako": "^2.1.0",
35
37
  "pinia": "^2.0.33",
38
+ "proj4": "^2.11.0",
36
39
  "three": "^0.156.1",
37
40
  "uuid": "^9.0.0",
38
41
  "gl-matrix": "^3.4.3",