gisviewer-vue3-arcgis 1.0.118 → 1.0.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/src/gis-map/gis-map.vue.mjs +2 -2
- package/es/src/gis-map/stores/appData.d.ts +0 -3
- package/es/src/gis-map/stores/appData.mjs +4 -7
- package/es/src/gis-map/utils/common-utils.d.ts +4 -0
- package/es/src/gis-map/utils/common-utils.mjs +34 -23
- package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +1 -1
- package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.mjs +177 -169
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/stores/appData.d.ts +0 -3
- package/lib/src/gis-map/stores/appData.js +1 -1
- package/lib/src/gis-map/utils/common-utils.d.ts +4 -0
- package/lib/src/gis-map/utils/common-utils.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.js +1 -1
- package/package.json +1 -1
|
@@ -19,8 +19,8 @@ const Se = { class: "gis-viewer" }, be = { style: { position: "absolute", bottom
|
|
|
19
19
|
const u = h(null);
|
|
20
20
|
let s, i, o, n, r, a, l, t;
|
|
21
21
|
const f = h(!1);
|
|
22
|
-
|
|
23
|
-
if (!u.value)
|
|
22
|
+
fe(async () => {
|
|
23
|
+
if (Ce(), !u.value)
|
|
24
24
|
return;
|
|
25
25
|
document.addEventListener("keydown", (m) => {
|
|
26
26
|
m.ctrlKey && m.key === "i" && (f.value = !f.value);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { defineStore as
|
|
2
|
-
const
|
|
1
|
+
import { defineStore as a } from "pinia";
|
|
2
|
+
const t = a("appData", {
|
|
3
3
|
state: () => ({
|
|
4
4
|
mapConfig: {},
|
|
5
|
-
saveTrackLog: !1
|
|
6
|
-
geoReference: "",
|
|
7
|
-
xOffset: 0,
|
|
8
|
-
yOffset: 0
|
|
5
|
+
saveTrackLog: !1
|
|
9
6
|
})
|
|
10
7
|
});
|
|
11
8
|
export {
|
|
12
|
-
|
|
9
|
+
t as useAppDataStore
|
|
13
10
|
};
|
|
@@ -66,6 +66,10 @@ export default class CommonUtils {
|
|
|
66
66
|
static getStdVecEntries(std_vec: any, delete_vec?: boolean): any[];
|
|
67
67
|
static getStdMapEntries(std_map: any): any[];
|
|
68
68
|
static getStdMapKeys(std_map: any, delete_map?: boolean): any[];
|
|
69
|
+
private static geoReference;
|
|
70
|
+
private static xOffset;
|
|
71
|
+
private static yOffset;
|
|
72
|
+
static setGeoData(geoReference: string, xOffset: number, yOffset: number): void;
|
|
69
73
|
/**
|
|
70
74
|
* OpenDrive坐标转换为WGS84坐标
|
|
71
75
|
* @param line
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Point as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
1
|
+
import { Point as P, Polyline as f } from "@arcgis/core/geometry";
|
|
2
|
+
import * as g from "@arcgis/core/geometry/geometryEngineAsync";
|
|
3
|
+
import * as y from "@arcgis/core/geometry/support/webMercatorUtils";
|
|
4
4
|
import u from "@turf/bearing";
|
|
5
|
-
import
|
|
5
|
+
import p from "@turf/destination";
|
|
6
6
|
import * as a from "@turf/helpers";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { useAppDataStore as w } from "../stores/appData.mjs";
|
|
7
|
+
import L from "pako";
|
|
8
|
+
import O from "proj4";
|
|
10
9
|
class i {
|
|
11
10
|
/**
|
|
12
11
|
* 得到某个点在一定方向、距离之外的另一个点
|
|
@@ -16,10 +15,10 @@ class i {
|
|
|
16
15
|
* @returns
|
|
17
16
|
*/
|
|
18
17
|
static destinationWithPoint(t, e, n) {
|
|
19
|
-
const r = a.point([t.x, t.y]), s =
|
|
18
|
+
const r = a.point([t.x, t.y]), s = p(r, n, e, {
|
|
20
19
|
units: "meters"
|
|
21
20
|
});
|
|
22
|
-
return new
|
|
21
|
+
return new P({
|
|
23
22
|
x: s.geometry.coordinates[0],
|
|
24
23
|
y: s.geometry.coordinates[1]
|
|
25
24
|
});
|
|
@@ -39,14 +38,14 @@ class i {
|
|
|
39
38
|
* @param distance
|
|
40
39
|
*/
|
|
41
40
|
static extendLineInTowDir(t, e) {
|
|
42
|
-
const n = t.paths[0], r = a.point(n[0]), s = a.point(n[1]), o = u(s, r), c =
|
|
41
|
+
const n = t.paths[0], r = a.point(n[0]), s = a.point(n[1]), o = u(s, r), c = p(r, e, o, {
|
|
43
42
|
units: "meters"
|
|
44
|
-
}),
|
|
43
|
+
}), h = o > 0 ? o - 180 : o + 180, l = p(s, e, h, {
|
|
45
44
|
units: "meters"
|
|
46
45
|
});
|
|
47
46
|
return new f({
|
|
48
47
|
paths: [
|
|
49
|
-
[c.geometry.coordinates,
|
|
48
|
+
[c.geometry.coordinates, l.geometry.coordinates]
|
|
50
49
|
]
|
|
51
50
|
});
|
|
52
51
|
}
|
|
@@ -57,7 +56,7 @@ class i {
|
|
|
57
56
|
* @returns
|
|
58
57
|
*/
|
|
59
58
|
static async getIntersectPointOfTwoLines(t, e) {
|
|
60
|
-
const n = await
|
|
59
|
+
const n = await g.intersectLinesToPoints(
|
|
61
60
|
t,
|
|
62
61
|
e
|
|
63
62
|
);
|
|
@@ -102,7 +101,7 @@ class i {
|
|
|
102
101
|
if (t.length < 2)
|
|
103
102
|
return 0;
|
|
104
103
|
const e = new f({ paths: [t] });
|
|
105
|
-
return await
|
|
104
|
+
return await g.geodesicLength(e, "meters");
|
|
106
105
|
}
|
|
107
106
|
/**
|
|
108
107
|
* 线按一定距离平移之后,与面相交的两个端点
|
|
@@ -113,7 +112,7 @@ class i {
|
|
|
113
112
|
*/
|
|
114
113
|
static async getIntersectPointOfLineAndPolygon(t, e, n = 0) {
|
|
115
114
|
n !== 0 && (t = await i.getOffsetLine(t, n));
|
|
116
|
-
const r = await
|
|
115
|
+
const r = await g.intersect(t, e);
|
|
117
116
|
if (r instanceof f) {
|
|
118
117
|
const s = r.paths[0], o = s[0], c = s[s.length - 1];
|
|
119
118
|
return [o, c];
|
|
@@ -127,12 +126,12 @@ class i {
|
|
|
127
126
|
* @returns 平移后的polyline
|
|
128
127
|
*/
|
|
129
128
|
static async getOffsetLine(t, e) {
|
|
130
|
-
const n =
|
|
129
|
+
const n = y.geographicToWebMercator(t), r = await g.offset(
|
|
131
130
|
n,
|
|
132
131
|
e,
|
|
133
132
|
"meters"
|
|
134
133
|
);
|
|
135
|
-
return
|
|
134
|
+
return y.webMercatorToGeographic(
|
|
136
135
|
r,
|
|
137
136
|
!1
|
|
138
137
|
);
|
|
@@ -150,7 +149,7 @@ class i {
|
|
|
150
149
|
e.push(o.charCodeAt(0));
|
|
151
150
|
}
|
|
152
151
|
const r = new Uint8Array(e);
|
|
153
|
-
return
|
|
152
|
+
return L.inflate(r, { to: "string" });
|
|
154
153
|
} catch {
|
|
155
154
|
console.log(`非压缩内容: ${t}`);
|
|
156
155
|
}
|
|
@@ -173,23 +172,35 @@ class i {
|
|
|
173
172
|
n.push(r.get(s));
|
|
174
173
|
return r.delete(), e && t.delete(), n;
|
|
175
174
|
}
|
|
175
|
+
static setGeoData(t, e, n) {
|
|
176
|
+
i.geoReference = t, i.xOffset = e, i.yOffset = n;
|
|
177
|
+
}
|
|
176
178
|
/**
|
|
177
179
|
* OpenDrive坐标转换为WGS84坐标
|
|
178
180
|
* @param line
|
|
179
181
|
* @returns
|
|
180
182
|
*/
|
|
181
183
|
static transformLineProjection(t) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
try {
|
|
185
|
+
return t.map(
|
|
186
|
+
(e) => O(i.geoReference).inverse([
|
|
187
|
+
e[0] - i.xOffset,
|
|
188
|
+
e[1] - i.yOffset
|
|
189
|
+
])
|
|
190
|
+
);
|
|
191
|
+
} catch {
|
|
192
|
+
return console.error(
|
|
193
|
+
"OpenDrive坐标转换为WGS84坐标失败",
|
|
194
|
+
i.geoReference
|
|
195
|
+
), t;
|
|
196
|
+
}
|
|
186
197
|
}
|
|
187
198
|
static pointsEqual(t, e) {
|
|
188
199
|
return Math.abs(t[0] - e[0]) < Number.EPSILON && Math.abs(t[1] - e[1]) < Number.EPSILON;
|
|
189
200
|
}
|
|
190
201
|
static getExtensionLine(t, e, n) {
|
|
191
202
|
const r = a.point(t), s = a.point(e), o = u(r, s);
|
|
192
|
-
return
|
|
203
|
+
return p(s, n, o, { units: "meters" }).geometry.coordinates;
|
|
193
204
|
}
|
|
194
205
|
}
|
|
195
206
|
export {
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import { XMLParser as m } from "fast-xml-parser";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import f from "../../stores/index.mjs";
|
|
3
|
+
import l from "../common-utils.mjs";
|
|
4
4
|
import L from "./junction.mjs";
|
|
5
5
|
import p from "./road.mjs";
|
|
6
|
-
class
|
|
6
|
+
class u {
|
|
7
7
|
constructor() {
|
|
8
|
-
this.roadList = /* @__PURE__ */ new Map(), this.junctionList = /* @__PURE__ */ new Map(), this.isWasmLoaded = !1, this.
|
|
8
|
+
this.roadList = /* @__PURE__ */ new Map(), this.junctionList = /* @__PURE__ */ new Map(), this.isWasmLoaded = !1, this.appDataStore = f.useAppDataStore, this.FsFile = "data.xodr";
|
|
9
9
|
}
|
|
10
10
|
static getInstance() {
|
|
11
|
-
return
|
|
11
|
+
return u.instance || (u.instance = new u()), u.instance;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* 载入指定xodr文件并解析
|
|
15
15
|
* @param filePath
|
|
16
16
|
*/
|
|
17
|
-
async load(
|
|
17
|
+
async load(n) {
|
|
18
18
|
if (!this.isWasmLoaded) {
|
|
19
|
-
const
|
|
20
|
-
this.ModuleOpenDrive = await
|
|
19
|
+
const c = window.libOpenDrive;
|
|
20
|
+
this.ModuleOpenDrive = await c(), this.isWasmLoaded = !0;
|
|
21
21
|
}
|
|
22
22
|
console.time("加载用时");
|
|
23
|
-
const
|
|
23
|
+
const t = await (await fetch(n)).text(), i = new m({
|
|
24
24
|
ignoreAttributes: !1,
|
|
25
25
|
allowBooleanAttributes: !0
|
|
26
|
-
}).parse(
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
xOffset: l,
|
|
31
|
-
yOffset: u,
|
|
32
|
-
geoReference: i
|
|
33
|
-
});
|
|
26
|
+
}).parse(t), o = i.OpenDRIVE.header.geoReference, r = i.OpenDRIVE.header.offset;
|
|
27
|
+
if (r) {
|
|
28
|
+
const c = Number(r["@_x"]) || 0, h = Number(r["@_y"]) || 0;
|
|
29
|
+
l.setGeoData(o, c, h);
|
|
34
30
|
}
|
|
35
|
-
const
|
|
31
|
+
const g = new TextEncoder().encode(t);
|
|
36
32
|
try {
|
|
37
33
|
this.ModuleOpenDrive.FS_unlink(`./${this.FsFile}`);
|
|
38
34
|
} catch {
|
|
@@ -40,7 +36,7 @@ class g {
|
|
|
40
36
|
this.ModuleOpenDrive.FS_createDataFile(
|
|
41
37
|
".",
|
|
42
38
|
this.FsFile,
|
|
43
|
-
|
|
39
|
+
g,
|
|
44
40
|
!0,
|
|
45
41
|
!0
|
|
46
42
|
);
|
|
@@ -67,87 +63,99 @@ class g {
|
|
|
67
63
|
* 解析路网
|
|
68
64
|
*/
|
|
69
65
|
getRoadNetwork() {
|
|
70
|
-
|
|
66
|
+
this.roadList.clear(), this.junctionList.clear();
|
|
67
|
+
let n;
|
|
71
68
|
try {
|
|
72
|
-
|
|
69
|
+
console.time("采样用时"), n = this.ModuleOpenDrive.get_odr_road_network(
|
|
73
70
|
this.ModuleOpenDriveMap,
|
|
74
71
|
0.5
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
);
|
|
73
|
+
} catch (s) {
|
|
74
|
+
return { status: -1, message: `解析路网失败, ${s}` };
|
|
75
|
+
} finally {
|
|
76
|
+
console.timeEnd("采样用时");
|
|
77
|
+
}
|
|
78
|
+
console.time("投影转换用时");
|
|
79
|
+
try {
|
|
80
|
+
l.getStdVecEntries(n.roads, !0).forEach((i) => {
|
|
81
|
+
const o = new p(i);
|
|
82
|
+
this.roadList.set(o.id, o);
|
|
83
|
+
});
|
|
84
|
+
} catch (s) {
|
|
85
|
+
return { status: -1, message: `解析道路失败, ${s}` };
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
l.getStdVecEntries(
|
|
89
|
+
n.junctions,
|
|
83
90
|
!0
|
|
84
|
-
).forEach((
|
|
85
|
-
const
|
|
86
|
-
this.junctionList.set(
|
|
87
|
-
}), console.timeEnd("投影转换用时");
|
|
88
|
-
const i = [];
|
|
89
|
-
this.roadList.forEach((r) => {
|
|
90
|
-
const c = r.allLaneSections.map((d) => {
|
|
91
|
-
const l = d.allLanes.map((u) => ({
|
|
92
|
-
id: u.id,
|
|
93
|
-
type: u.type,
|
|
94
|
-
innerPath: u.innerBorder,
|
|
95
|
-
outerPath: u.outerBorder,
|
|
96
|
-
centerLine: u.centerLine
|
|
97
|
-
}));
|
|
98
|
-
return {
|
|
99
|
-
id: d.s0,
|
|
100
|
-
lanePaths: l
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
i.push({
|
|
104
|
-
id: r.id,
|
|
105
|
-
name: r.name,
|
|
106
|
-
laneSections: c,
|
|
107
|
-
junction: r.junction,
|
|
108
|
-
refLine: r.refLine
|
|
109
|
-
});
|
|
91
|
+
).forEach((i) => {
|
|
92
|
+
const o = new L(i);
|
|
93
|
+
this.junctionList.set(i.id, o);
|
|
110
94
|
});
|
|
111
|
-
|
|
112
|
-
return
|
|
113
|
-
const c = r.getJunctionOutline();
|
|
114
|
-
a.push({
|
|
115
|
-
id: r.id,
|
|
116
|
-
name: r.name,
|
|
117
|
-
outline: c
|
|
118
|
-
});
|
|
119
|
-
}), {
|
|
120
|
-
status: 0,
|
|
121
|
-
message: "ok",
|
|
122
|
-
result: { roads: i, junctions: a }
|
|
123
|
-
};
|
|
124
|
-
} catch {
|
|
125
|
-
return { status: -1, message: "解析路网失败" };
|
|
95
|
+
} catch (s) {
|
|
96
|
+
return { status: -1, message: `解析路口失败, ${s}` };
|
|
126
97
|
}
|
|
98
|
+
console.timeEnd("投影转换用时");
|
|
99
|
+
const e = [];
|
|
100
|
+
this.roadList.forEach((s) => {
|
|
101
|
+
const i = s.allLaneSections.map((o) => {
|
|
102
|
+
const r = o.allLanes.map((a) => ({
|
|
103
|
+
id: a.id,
|
|
104
|
+
type: a.type,
|
|
105
|
+
innerPath: a.innerBorder,
|
|
106
|
+
outerPath: a.outerBorder,
|
|
107
|
+
centerLine: a.centerLine
|
|
108
|
+
}));
|
|
109
|
+
return {
|
|
110
|
+
id: o.s0,
|
|
111
|
+
lanePaths: r
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
e.push({
|
|
115
|
+
id: s.id,
|
|
116
|
+
name: s.name,
|
|
117
|
+
laneSections: i,
|
|
118
|
+
junction: s.junction,
|
|
119
|
+
refLine: s.refLine
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
const t = [];
|
|
123
|
+
return this.junctionList.forEach((s) => {
|
|
124
|
+
const i = s.getJunctionOutline();
|
|
125
|
+
t.push({
|
|
126
|
+
id: s.id,
|
|
127
|
+
name: s.name,
|
|
128
|
+
outline: i
|
|
129
|
+
});
|
|
130
|
+
}), {
|
|
131
|
+
status: 0,
|
|
132
|
+
message: "ok",
|
|
133
|
+
result: { roads: e, junctions: t }
|
|
134
|
+
};
|
|
127
135
|
}
|
|
128
136
|
/**
|
|
129
137
|
* 获取所有道路的采样结果
|
|
130
138
|
*/
|
|
131
139
|
get allSampledRoads() {
|
|
132
|
-
return [...this.roadList.values()].map((
|
|
140
|
+
return [...this.roadList.values()].map((n) => n.sampledRoad);
|
|
133
141
|
}
|
|
134
142
|
/**
|
|
135
143
|
* 获取路网结构
|
|
136
144
|
*/
|
|
137
145
|
get roadNetwork() {
|
|
138
146
|
return [...this.roadList.values()].map((e) => {
|
|
139
|
-
const
|
|
140
|
-
const
|
|
147
|
+
const t = e.allLaneSections.map((s) => {
|
|
148
|
+
const i = s.allLaneIds.filter((o) => o !== 0);
|
|
141
149
|
return {
|
|
142
|
-
sectionId:
|
|
143
|
-
laneIds:
|
|
150
|
+
sectionId: s.s0,
|
|
151
|
+
laneIds: i
|
|
144
152
|
};
|
|
145
153
|
});
|
|
146
154
|
return {
|
|
147
155
|
roadName: e.name,
|
|
148
156
|
roadId: e.id,
|
|
149
157
|
roadLength: e.length,
|
|
150
|
-
sections:
|
|
158
|
+
sections: t
|
|
151
159
|
};
|
|
152
160
|
});
|
|
153
161
|
}
|
|
@@ -155,9 +163,9 @@ class g {
|
|
|
155
163
|
* 从车道信息获取车道对象
|
|
156
164
|
* @param laneInfo
|
|
157
165
|
*/
|
|
158
|
-
getLane(
|
|
159
|
-
const e = this.roadList.get(
|
|
160
|
-
return
|
|
166
|
+
getLane(n) {
|
|
167
|
+
const e = this.roadList.get(n.roadId), t = e == null ? void 0 : e.getLaneSection(n.sectionId);
|
|
168
|
+
return t == null ? void 0 : t.getLane(n.laneId);
|
|
161
169
|
}
|
|
162
170
|
/**
|
|
163
171
|
* 获取两个车道之间的车道功能
|
|
@@ -165,38 +173,38 @@ class g {
|
|
|
165
173
|
* @param incoming
|
|
166
174
|
* @param outgoing
|
|
167
175
|
*/
|
|
168
|
-
getFunctionFromIncomingToOutgoing(
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
176
|
+
getFunctionFromIncomingToOutgoing(n, e) {
|
|
177
|
+
const t = this.getLane(n), s = this.getLane(e);
|
|
178
|
+
if (!t || !s || !t.drivingAngle || !s.drivingAngle)
|
|
171
179
|
return { status: -1, message: "车道信息错误" };
|
|
172
|
-
let
|
|
173
|
-
|
|
174
|
-
let
|
|
175
|
-
return -45 <
|
|
180
|
+
let i = s.drivingAngle - t.drivingAngle;
|
|
181
|
+
i > 180 ? i -= 360 : i < -180 && (i += 360);
|
|
182
|
+
let o = "";
|
|
183
|
+
return -45 < i && i < 45 ? o = "s" : 45 <= i && i <= 135 ? o = "r" : -135 <= i && i <= -45 ? o = "l" : o = "t", { status: 0, result: o, message: "ok" };
|
|
176
184
|
}
|
|
177
185
|
/**
|
|
178
186
|
* 获取所有路口的轮廓
|
|
179
187
|
* @returns
|
|
180
188
|
*/
|
|
181
|
-
getJunctionOutline(
|
|
189
|
+
getJunctionOutline(n) {
|
|
182
190
|
const e = [];
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
const
|
|
191
|
+
if (n !== "") {
|
|
192
|
+
const t = this.junctionList.get(n);
|
|
193
|
+
if (t) {
|
|
194
|
+
const s = t.getJunctionOutline();
|
|
187
195
|
e.push({
|
|
188
|
-
junctionId:
|
|
189
|
-
name:
|
|
190
|
-
outline:
|
|
196
|
+
junctionId: n,
|
|
197
|
+
name: t.name,
|
|
198
|
+
outline: s
|
|
191
199
|
});
|
|
192
200
|
}
|
|
193
201
|
} else
|
|
194
|
-
for (const
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
junctionId:
|
|
198
|
-
name:
|
|
199
|
-
outline:
|
|
202
|
+
for (const t of this.junctionList) {
|
|
203
|
+
const s = t[0], i = t[1], o = i.getJunctionOutline();
|
|
204
|
+
o.length <= 4 ? console.log(o, s) : e.push({
|
|
205
|
+
junctionId: s,
|
|
206
|
+
name: i.name,
|
|
207
|
+
outline: o
|
|
200
208
|
});
|
|
201
209
|
}
|
|
202
210
|
return { status: 0, result: e, message: "ok" };
|
|
@@ -206,74 +214,74 @@ class g {
|
|
|
206
214
|
* @param laneInfo
|
|
207
215
|
* @returns
|
|
208
216
|
*/
|
|
209
|
-
getLaneLink(
|
|
210
|
-
const e = this.getLane(
|
|
217
|
+
getLaneLink(n) {
|
|
218
|
+
const e = this.getLane(n);
|
|
211
219
|
return e ? { status: 0, result: e.getLink(), message: "ok" } : { status: -1, message: "车道信息错误" };
|
|
212
220
|
}
|
|
213
|
-
getRoadLink(
|
|
221
|
+
getRoadLink(n) {
|
|
214
222
|
const e = [];
|
|
215
|
-
if (
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
roadId:
|
|
219
|
-
successor:
|
|
220
|
-
predecessor:
|
|
223
|
+
if (n !== "") {
|
|
224
|
+
const t = this.roadList.get(n);
|
|
225
|
+
t && e.push({
|
|
226
|
+
roadId: n,
|
|
227
|
+
successor: t.successor,
|
|
228
|
+
predecessor: t.predecessor
|
|
221
229
|
});
|
|
222
230
|
} else
|
|
223
|
-
[...this.roadList.values()].forEach((
|
|
231
|
+
[...this.roadList.values()].forEach((s) => {
|
|
224
232
|
e.push({
|
|
225
|
-
roadId:
|
|
226
|
-
successor:
|
|
227
|
-
predecessor:
|
|
233
|
+
roadId: n,
|
|
234
|
+
successor: s.successor,
|
|
235
|
+
predecessor: s.predecessor
|
|
228
236
|
});
|
|
229
237
|
});
|
|
230
238
|
return { status: 0, result: e, message: "ok" };
|
|
231
239
|
}
|
|
232
|
-
getConnectionLink(
|
|
240
|
+
getConnectionLink(n) {
|
|
233
241
|
const e = [];
|
|
234
|
-
for (const
|
|
235
|
-
const
|
|
236
|
-
if ((
|
|
237
|
-
id:
|
|
238
|
-
name:
|
|
239
|
-
links:
|
|
240
|
-
}),
|
|
242
|
+
for (const t of this.junctionList) {
|
|
243
|
+
const s = t[0], i = t[1];
|
|
244
|
+
if ((n === "" || s === n) && (e.push({
|
|
245
|
+
id: s,
|
|
246
|
+
name: i.name,
|
|
247
|
+
links: i.laneLinks
|
|
248
|
+
}), n !== ""))
|
|
241
249
|
break;
|
|
242
250
|
}
|
|
243
251
|
return { status: 0, result: e, message: "ok" };
|
|
244
252
|
}
|
|
245
|
-
getLaneAngle(
|
|
246
|
-
const e = this.getLane(
|
|
253
|
+
getLaneAngle(n) {
|
|
254
|
+
const e = this.getLane(n);
|
|
247
255
|
if (e) {
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
250
|
-
return { status: 0, result:
|
|
256
|
+
const t = e.drivingAngle;
|
|
257
|
+
if (t)
|
|
258
|
+
return { status: 0, result: t, message: "ok" };
|
|
251
259
|
}
|
|
252
260
|
return { status: -1, message: "车道信息错误" };
|
|
253
261
|
}
|
|
254
|
-
getTurnArrow(
|
|
255
|
-
const e = this.getLane(
|
|
262
|
+
getTurnArrow(n) {
|
|
263
|
+
const e = this.getLane(n.incoming);
|
|
256
264
|
if (!e)
|
|
257
265
|
return { status: -1, message: "进口道信息错误" };
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
266
|
+
const t = e.drivingAngle;
|
|
267
|
+
if (!t)
|
|
260
268
|
return { status: -1, message: "进口道信息错误" };
|
|
261
|
-
const
|
|
262
|
-
if (!
|
|
269
|
+
const s = this.getLane(n.outgoing);
|
|
270
|
+
if (!s)
|
|
263
271
|
return { status: -1, message: "出口道信息错误" };
|
|
264
|
-
const
|
|
265
|
-
if (!
|
|
272
|
+
const i = s.drivingAngle;
|
|
273
|
+
if (!i)
|
|
266
274
|
return { status: -1, message: "出口道信息错误" };
|
|
267
|
-
let
|
|
268
|
-
|
|
269
|
-
let
|
|
270
|
-
return -45 <
|
|
275
|
+
let o = i - t;
|
|
276
|
+
o > 180 ? o -= 360 : o < -180 && (o += 360);
|
|
277
|
+
let r = "";
|
|
278
|
+
return -45 < o && o < 45 ? r = "s" : 45 <= o && o <= 135 ? r = "r" : -135 <= o && o <= -45 ? r = "l" : r = "t", {
|
|
271
279
|
status: 0,
|
|
272
280
|
message: "ok",
|
|
273
281
|
result: {
|
|
274
|
-
incomingAngle:
|
|
275
|
-
outgoingAngle:
|
|
276
|
-
direction:
|
|
282
|
+
incomingAngle: t,
|
|
283
|
+
outgoingAngle: i,
|
|
284
|
+
direction: r
|
|
277
285
|
}
|
|
278
286
|
};
|
|
279
287
|
}
|
|
@@ -302,59 +310,59 @@ class g {
|
|
|
302
310
|
* @param laneId
|
|
303
311
|
* @returns
|
|
304
312
|
*/
|
|
305
|
-
getPolygon(
|
|
306
|
-
const
|
|
307
|
-
if (!
|
|
313
|
+
getPolygon(n, e, t) {
|
|
314
|
+
const s = this.roadList.get(n);
|
|
315
|
+
if (!s)
|
|
308
316
|
return { status: -1, message: "道路id错误" };
|
|
309
|
-
if (e !== void 0 &&
|
|
310
|
-
const
|
|
311
|
-
return
|
|
317
|
+
if (e !== void 0 && t !== void 0 && !isNaN(e) && !isNaN(t)) {
|
|
318
|
+
const i = this.getLane({ roadId: n, sectionId: e, laneId: t });
|
|
319
|
+
return i ? { status: 0, message: "ok", result: i.ring } : { status: -1, message: "车道信息错误" };
|
|
312
320
|
} else if (e !== void 0 && !isNaN(e)) {
|
|
313
|
-
const
|
|
314
|
-
return
|
|
321
|
+
const i = s.getLaneSection(e);
|
|
322
|
+
return i ? { status: 0, message: "ok", result: i.polygon } : { status: -1, message: "路段信息错误" };
|
|
315
323
|
} else
|
|
316
|
-
return { status: 0, message: "ok", result:
|
|
324
|
+
return { status: 0, message: "ok", result: s.polygon };
|
|
317
325
|
}
|
|
318
326
|
/**
|
|
319
327
|
* 车道长度
|
|
320
328
|
* @param laneInfo
|
|
321
329
|
* @returns
|
|
322
330
|
*/
|
|
323
|
-
getLaneLength(
|
|
324
|
-
const e = this.getLane(
|
|
331
|
+
getLaneLength(n) {
|
|
332
|
+
const e = this.getLane(n);
|
|
325
333
|
if (e) {
|
|
326
|
-
let
|
|
327
|
-
return e.road.isLastLaneSection(e.laneSection.s0) ?
|
|
334
|
+
let t = 0;
|
|
335
|
+
return e.road.isLastLaneSection(e.laneSection.s0) ? t = e.road.length - e.laneSection.s0 : t = e.road.getNextLaneSection(
|
|
328
336
|
e.laneSection.s0
|
|
329
337
|
).s0 - e.laneSection.s0, {
|
|
330
338
|
status: 0,
|
|
331
339
|
message: "ok",
|
|
332
|
-
result: Number(
|
|
340
|
+
result: Number(t.toFixed(2))
|
|
333
341
|
};
|
|
334
342
|
} else
|
|
335
343
|
return { status: -1, message: "车道信息错误" };
|
|
336
344
|
}
|
|
337
|
-
getRoadStopLine(
|
|
345
|
+
getRoadStopLine(n) {
|
|
338
346
|
const e = [];
|
|
339
|
-
for (const
|
|
340
|
-
const
|
|
341
|
-
if (
|
|
342
|
-
const
|
|
343
|
-
e.push({ junctionId:
|
|
347
|
+
for (const t of this.junctionList) {
|
|
348
|
+
const s = t[0], i = t[1];
|
|
349
|
+
if (s === n) {
|
|
350
|
+
const o = i.getRoadStopLine();
|
|
351
|
+
e.push({ junctionId: s, stopLines: o });
|
|
344
352
|
break;
|
|
345
|
-
} else if (
|
|
346
|
-
const
|
|
347
|
-
e.push({ junctionId:
|
|
353
|
+
} else if (n === "") {
|
|
354
|
+
const o = i.getRoadStopLine();
|
|
355
|
+
e.push({ junctionId: s, stopLines: o });
|
|
348
356
|
}
|
|
349
357
|
}
|
|
350
358
|
return { status: 0, message: "ok", result: e };
|
|
351
359
|
}
|
|
352
|
-
getLaneStopLine(
|
|
353
|
-
const e = this.getLane(
|
|
360
|
+
getLaneStopLine(n) {
|
|
361
|
+
const e = this.getLane(n);
|
|
354
362
|
return e ? { status: 0, message: "ok", result: e.getStopLine() } : { status: -1, message: "车道信息错误" };
|
|
355
363
|
}
|
|
356
|
-
getLaneCenterLine(
|
|
357
|
-
const e = this.getLane(
|
|
364
|
+
getLaneCenterLine(n) {
|
|
365
|
+
const e = this.getLane(n);
|
|
358
366
|
return e ? {
|
|
359
367
|
status: 0,
|
|
360
368
|
message: "ok",
|
|
@@ -363,5 +371,5 @@ class g {
|
|
|
363
371
|
}
|
|
364
372
|
}
|
|
365
373
|
export {
|
|
366
|
-
|
|
374
|
+
u as default
|
|
367
375
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),v=require("./stores/index.js");require("./style/index.css");const de=require("./utils/holo-flow/index.js"),me=require("./utils/map-initializer.js"),C=require("./utils/open-drive-renderer/index.js"),pe=require("./utils/overlay.js"),fe=require("./utils/queue-length.js"),O=require("./utils/road-config-tool/index.js"),ge=require("./utils/traffic-flow.js"),we={class:"gis-viewer"},ve={style:{position:"absolute",bottom:"10px",left:"10px"}},ye=n.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(k,{expose:T,emit:L}){const m=n.ref(null);let c,i,o,r,s,a,u,t;const p=n.ref(!1);
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),v=require("./stores/index.js");require("./style/index.css");const de=require("./utils/holo-flow/index.js"),me=require("./utils/map-initializer.js"),C=require("./utils/open-drive-renderer/index.js"),pe=require("./utils/overlay.js"),fe=require("./utils/queue-length.js"),O=require("./utils/road-config-tool/index.js"),ge=require("./utils/traffic-flow.js"),we={class:"gis-viewer"},ve={style:{position:"absolute",bottom:"10px",left:"10px"}},ye=n.defineComponent({__name:"gis-map",props:{config:{},assetsRoot:{}},emits:["mapLoaded","markerClick","mapClick"],setup(k,{expose:T,emit:L}){const m=n.ref(null);let c,i,o,r,s,a,u,t;const p=n.ref(!1);n.onMounted(async()=>{if(v.registerStore(),!m.value)return;document.addEventListener("keydown",d=>{d.ctrlKey&&d.key==="i"&&(p.value=!p.value)});const e=n.getCurrentInstance(),{$gisviewerAssetsRoot:l}=e.appContext.config.globalProperties,h=await(await fetch(y.config)).json();h.assetsRoot=y.assetsRoot||l;const le=v.default.useAppDataStore;le.mapConfig=h,i=new me.default,c=await i.initialize({container:m.value,markerClickCallback:(d,g,w,ue)=>{f("markerClick",d,g,w,ue)},mapClickCallback:(d,g,w)=>{f("mapClick",d,g,w)}}),s=new de.default(c),await s.init(),f("mapLoaded")});const b=n.computed(()=>c),S=()=>{const e=v.default.useAppDataStore;e.saveTrackLog=!0},D=()=>{s.downloadTrackLog()},I=async e=>await i.setMapCenter(e),A=async e=>await i.setMapCamera(e),_=async e=>await i.lookAt(e),q=e=>i.setLayerVisibility(e),x=(e,l)=>i.requestCoordinateTransform(e,l),V=e=>{i.cancelCoordinateTransform(e)},M=e=>{i.setMapZoomRange(e)},N=e=>(o||(o=new O.default(c)),o.showLaneNumber(e)),F=()=>{o==null||o.clearLaneNumber()},B=async e=>(o||(o=new O.default(c)),await o.initializeSearch(e)),E=async()=>o==null?void 0:o.calCrossIndicatorArea(),H=async()=>{},j=async(e,l)=>{r||(r=new ge.default(c)),r.connectTrafficFlow(e,l)},z=()=>{r==null||r.disconnectTrafficFlow()},P=e=>{s.handleVehicleTraceData(e)},Q=()=>{s.clearHoloTrace()},R=e=>{s.setInterpolate(e)},Z=async e=>{await s.handleSignalData(e)},K=()=>{s.clearHoloSignal()},G=e=>{r==null||r.toggleTrafficInfo(e),s.toggleTrafficInfo(e)},J=e=>{s.togglePause(e)},U=e=>{r==null||r.toggleTrafficObject(e),s.toggleTrafficObject(e)},W=e=>{s.updatePanelContent(e)},X=async e=>(a||(a=new pe.default(c)),a.addOverlays(e)),Y=e=>a==null?void 0:a.removeOverlaysByType(e),$=e=>a==null?void 0:a.removeOverlaysById(e),ee=()=>a==null?void 0:a.removeAllOverlays(),te=()=>{a==null||a.showAllOverlays()},ae=e=>{u||(u=new fe.default(c)),u.updateQueueLength(e)},ne=()=>{u==null||u.removeQueueLength()},oe=async(e,l)=>(t||(t=new C.default(c)),await t.showOpenDriveFromServer(e,l)),re=async e=>(t||(t=new C.default(c)),await t.clearOpenDrive(),await t.showOpenDriveFromFile(e)),se=async()=>await(t==null?void 0:t.clearOpenDrive()),ce=async e=>t?await(t==null?void 0:t.findSumo(e)):{status:-1,message:"未加载OpenDrive地图"},ie=async e=>t?await(t==null?void 0:t.splitLane(e)):{status:-1,message:"未加载OpenDrive地图"},y=k,f=L;return T({mapViewer:b,setLayerVisibility:q,setMapCenter:I,lookAt:_,setMapCamera:A,setMapZoomRange:M,requestCoordinateTransform:x,cancelCoordinateTransform:V,addOverlays:X,showAllOverlays:te,removeOverlaysByType:Y,removeOverlaysById:$,removeAllOverlays:ee,showLaneNumber:N,clearLaneNumber:F,initializeAreaTool:B,calCrossIndicatorArea:E,calRoadIndicatorArea:H,connectCarFlow:j,disconnectCarFlow:z,handleHoloVehicleTraceData:P,clearHoloTrace:Q,handleHoloSignalData:Z,clearHoloSignal:K,setInterpolate:R,toggleTrafficInfo:G,toggleTrafficObject:U,toggleVehicleInfo:W,togglePause:J,updateQueueLength:ae,removeQueueLength:ne,showOpenDriveFromServer:oe,showOpenDriveFromFile:re,clearOpenDrive:se,findSumoInOpenDrive:ce,splitOpenDriveLane:ie}),(e,l)=>(n.openBlock(),n.createElementBlock("div",we,[n.createElementVNode("div",{class:"gis-viewer-main",ref_key:"mapContainer",ref:m},[n.withDirectives(n.createElementVNode("div",ve,[n.createElementVNode("button",{style:{"margin-right":"10px"},onClick:S}," 开始记录 "),n.createElementVNode("button",{onClick:D},"下载日志")],512),[[n.vShow,p.value]])],512)]))}});exports.default=ye;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("pinia"),t=e.defineStore("appData",{state:()=>({mapConfig:{},saveTrackLog:!1
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("pinia"),t=e.defineStore("appData",{state:()=>({mapConfig:{},saveTrackLog:!1})});exports.useAppDataStore=t;
|
|
@@ -66,6 +66,10 @@ export default class CommonUtils {
|
|
|
66
66
|
static getStdVecEntries(std_vec: any, delete_vec?: boolean): any[];
|
|
67
67
|
static getStdMapEntries(std_map: any): any[];
|
|
68
68
|
static getStdMapKeys(std_map: any, delete_map?: boolean): any[];
|
|
69
|
+
private static geoReference;
|
|
70
|
+
private static xOffset;
|
|
71
|
+
private static yOffset;
|
|
72
|
+
static setGeoData(geoReference: string, xOffset: number, yOffset: number): void;
|
|
69
73
|
/**
|
|
70
74
|
* OpenDrive坐标转换为WGS84坐标
|
|
71
75
|
* @param line
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@arcgis/core/geometry"),O=require("@arcgis/core/geometry/geometryEngineAsync"),L=require("@arcgis/core/geometry/support/webMercatorUtils"),l=require("@turf/bearing"),g=require("@turf/destination"),w=require("@turf/helpers"),b=require("pako"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@arcgis/core/geometry"),O=require("@arcgis/core/geometry/geometryEngineAsync"),L=require("@arcgis/core/geometry/support/webMercatorUtils"),l=require("@turf/bearing"),g=require("@turf/destination"),w=require("@turf/helpers"),b=require("pako"),A=require("proj4");function y(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const p=y(O),P=y(L),c=y(w);class i{static destinationWithPoint(e,t,n){const r=c.point([e.x,e.y]),s=g(r,n,t,{units:"meters"});return new u.Point({x:s.geometry.coordinates[0],y:s.geometry.coordinates[1]})}static angleOfLine(e){const t=e.paths[0],n=c.point(t[0]),r=c.point(t[t.length-1]);return l(n,r)}static extendLineInTowDir(e,t){const n=e.paths[0],r=c.point(n[0]),s=c.point(n[1]),o=l(s,r),f=g(r,t,o,{units:"meters"}),h=o>0?o-180:o+180,d=g(s,t,h,{units:"meters"});return new u.Polyline({paths:[[f.geometry.coordinates,d.geometry.coordinates]]})}static async getIntersectPointOfTwoLines(e,t){const n=await p.intersectLinesToPoints(e,t);if(n.length)return n[0]}static async getIntersectPointsOfStopLineAndLane(e,t,n){let r=await i.getIntersectPointOfLineAndPolygon(e,t);if(await i.pointDistance(r)<3&&n){for(const s of n)if(r=await i.getIntersectPointOfLineAndPolygon(e,t,s),await i.pointDistance(r)>2.5){const o=new u.Polyline({paths:[r]});return(await i.getOffsetLine(o,-s)).paths[0]}}else return r;return[]}static async pointDistance(e){if(e.length<2)return 0;const t=new u.Polyline({paths:[e]});return await p.geodesicLength(t,"meters")}static async getIntersectPointOfLineAndPolygon(e,t,n=0){n!==0&&(e=await i.getOffsetLine(e,n));const r=await p.intersect(e,t);if(r instanceof u.Polyline){const s=r.paths[0],o=s[0],f=s[s.length-1];return[o,f]}return[]}static async getOffsetLine(e,t){const n=P.geographicToWebMercator(e),r=await p.offset(n,t,"meters");return P.webMercatorToGeographic(r,!1)}static unzip(e){try{const t=[],n=e.split("");for(let s=0;s<n.length;s++){const o=n[s];t.push(o.charCodeAt(0))}const r=new Uint8Array(t);return b.inflate(r,{to:"string"})}catch{console.log(`非压缩内容: ${e}`)}}static getStdVecEntries(e,t=!1){const n=new Array(e.size());for(let r=0;r<e.size();r++)n[r]=e.get(r);return t&&e.delete(),n}static getStdMapEntries(e){const t=[];for(const n of i.getStdMapKeys(e))t.push([n,e.get(n)]);return t}static getStdMapKeys(e,t=!1){const n=[],r=e.keys();for(let s=0;s<r.size();s++)n.push(r.get(s));return r.delete(),t&&e.delete(),n}static setGeoData(e,t,n){i.geoReference=e,i.xOffset=t,i.yOffset=n}static transformLineProjection(e){try{return e.map(t=>A(i.geoReference).inverse([t[0]-i.xOffset,t[1]-i.yOffset]))}catch{return console.error("OpenDrive坐标转换为WGS84坐标失败",i.geoReference),e}}static pointsEqual(e,t){return Math.abs(e[0]-t[0])<Number.EPSILON&&Math.abs(e[1]-t[1])<Number.EPSILON}static getExtensionLine(e,t,n){const r=c.point(e),s=c.point(t),o=l(r,s);return g(s,n,o,{units:"meters"}).geometry.coordinates}}exports.default=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("fast-xml-parser"),m=require("../../stores/index.js"),l=require("../common-utils.js"),L=require("./junction.js"),p=require("./road.js");class u{constructor(){this.roadList=new Map,this.junctionList=new Map,this.isWasmLoaded=!1,this.appDataStore=m.default.useAppDataStore,this.FsFile="data.xodr"}static getInstance(){return u.instance||(u.instance=new u),u.instance}async load(n){if(!this.isWasmLoaded){const c=window.libOpenDrive;this.ModuleOpenDrive=await c(),this.isWasmLoaded=!0}console.time("加载用时");const t=await(await fetch(n)).text(),i=new f.XMLParser({ignoreAttributes:!1,allowBooleanAttributes:!0}).parse(t),o=i.OpenDRIVE.header.geoReference,r=i.OpenDRIVE.header.offset;if(r){const c=Number(r["@_x"])||0,h=Number(r["@_y"])||0;l.default.setGeoData(o,c,h)}const g=new TextEncoder().encode(t);try{this.ModuleOpenDrive.FS_unlink(`./${this.FsFile}`)}catch{}this.ModuleOpenDrive.FS_createDataFile(".",this.FsFile,g,!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(){this.roadList.clear(),this.junctionList.clear();let n;try{console.time("采样用时"),n=this.ModuleOpenDrive.get_odr_road_network(this.ModuleOpenDriveMap,.5)}catch(s){return{status:-1,message:`解析路网失败, ${s}`}}finally{console.timeEnd("采样用时")}console.time("投影转换用时");try{l.default.getStdVecEntries(n.roads,!0).forEach(i=>{const o=new p.default(i);this.roadList.set(o.id,o)})}catch(s){return{status:-1,message:`解析道路失败, ${s}`}}try{l.default.getStdVecEntries(n.junctions,!0).forEach(i=>{const o=new L.default(i);this.junctionList.set(i.id,o)})}catch(s){return{status:-1,message:`解析路口失败, ${s}`}}console.timeEnd("投影转换用时");const e=[];this.roadList.forEach(s=>{const i=s.allLaneSections.map(o=>{const r=o.allLanes.map(a=>({id:a.id,type:a.type,innerPath:a.innerBorder,outerPath:a.outerBorder,centerLine:a.centerLine}));return{id:o.s0,lanePaths:r}});e.push({id:s.id,name:s.name,laneSections:i,junction:s.junction,refLine:s.refLine})});const t=[];return this.junctionList.forEach(s=>{const i=s.getJunctionOutline();t.push({id:s.id,name:s.name,outline:i})}),{status:0,message:"ok",result:{roads:e,junctions:t}}}get allSampledRoads(){return[...this.roadList.values()].map(n=>n.sampledRoad)}get roadNetwork(){return[...this.roadList.values()].map(e=>{const t=e.allLaneSections.map(s=>{const i=s.allLaneIds.filter(o=>o!==0);return{sectionId:s.s0,laneIds:i}});return{roadName:e.name,roadId:e.id,roadLength:e.length,sections:t}})}getLane(n){const e=this.roadList.get(n.roadId),t=e==null?void 0:e.getLaneSection(n.sectionId);return t==null?void 0:t.getLane(n.laneId)}getFunctionFromIncomingToOutgoing(n,e){const t=this.getLane(n),s=this.getLane(e);if(!t||!s||!t.drivingAngle||!s.drivingAngle)return{status:-1,message:"车道信息错误"};let i=s.drivingAngle-t.drivingAngle;i>180?i-=360:i<-180&&(i+=360);let o="";return-45<i&&i<45?o="s":45<=i&&i<=135?o="r":-135<=i&&i<=-45?o="l":o="t",{status:0,result:o,message:"ok"}}getJunctionOutline(n){const e=[];if(n!==""){const t=this.junctionList.get(n);if(t){const s=t.getJunctionOutline();e.push({junctionId:n,name:t.name,outline:s})}}else for(const t of this.junctionList){const s=t[0],i=t[1],o=i.getJunctionOutline();o.length<=4?console.log(o,s):e.push({junctionId:s,name:i.name,outline:o})}return{status:0,result:e,message:"ok"}}getLaneLink(n){const e=this.getLane(n);return e?{status:0,result:e.getLink(),message:"ok"}:{status:-1,message:"车道信息错误"}}getRoadLink(n){const e=[];if(n!==""){const t=this.roadList.get(n);t&&e.push({roadId:n,successor:t.successor,predecessor:t.predecessor})}else[...this.roadList.values()].forEach(s=>{e.push({roadId:n,successor:s.successor,predecessor:s.predecessor})});return{status:0,result:e,message:"ok"}}getConnectionLink(n){const e=[];for(const t of this.junctionList){const s=t[0],i=t[1];if((n===""||s===n)&&(e.push({id:s,name:i.name,links:i.laneLinks}),n!==""))break}return{status:0,result:e,message:"ok"}}getLaneAngle(n){const e=this.getLane(n);if(e){const t=e.drivingAngle;if(t)return{status:0,result:t,message:"ok"}}return{status:-1,message:"车道信息错误"}}getTurnArrow(n){const e=this.getLane(n.incoming);if(!e)return{status:-1,message:"进口道信息错误"};const t=e.drivingAngle;if(!t)return{status:-1,message:"进口道信息错误"};const s=this.getLane(n.outgoing);if(!s)return{status:-1,message:"出口道信息错误"};const i=s.drivingAngle;if(!i)return{status:-1,message:"出口道信息错误"};let o=i-t;o>180?o-=360:o<-180&&(o+=360);let r="";return-45<o&&o<45?r="s":45<=o&&o<=135?r="r":-135<=o&&o<=-45?r="l":r="t",{status:0,message:"ok",result:{incomingAngle:t,outgoingAngle:i,direction:r}}}getPolygon(n,e,t){const s=this.roadList.get(n);if(!s)return{status:-1,message:"道路id错误"};if(e!==void 0&&t!==void 0&&!isNaN(e)&&!isNaN(t)){const i=this.getLane({roadId:n,sectionId:e,laneId:t});return i?{status:0,message:"ok",result:i.ring}:{status:-1,message:"车道信息错误"}}else if(e!==void 0&&!isNaN(e)){const i=s.getLaneSection(e);return i?{status:0,message:"ok",result:i.polygon}:{status:-1,message:"路段信息错误"}}else return{status:0,message:"ok",result:s.polygon}}getLaneLength(n){const e=this.getLane(n);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(n){const e=[];for(const t of this.junctionList){const s=t[0],i=t[1];if(s===n){const o=i.getRoadStopLine();e.push({junctionId:s,stopLines:o});break}else if(n===""){const o=i.getRoadStopLine();e.push({junctionId:s,stopLines:o})}}return{status:0,message:"ok",result:e}}getLaneStopLine(n){const e=this.getLane(n);return e?{status:0,message:"ok",result:e.getStopLine()}:{status:-1,message:"车道信息错误"}}getLaneCenterLine(n){const e=this.getLane(n);return e?{status:0,message:"ok",result:e.getLaneEndPoints("middle")}:{status:-1,message:"车道信息错误"}}}exports.default=u;
|