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.
- 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 +5 -0
- package/es/src/gis-map/utils/common-utils.mjs +47 -23
- package/es/src/gis-map/utils/map-initializer.mjs +100 -99
- package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +23 -3
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +290 -136
- package/es/src/gis-map/utils/open-drive-renderer/junction.d.ts +2 -1
- package/es/src/gis-map/utils/open-drive-renderer/road.d.ts +2 -0
- package/es/src/gis-map/utils/open-drive-renderer/road.mjs +16 -8
- package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +21 -1
- package/es/src/gis-map/utils/open-drive-renderer/wasm-loader.mjs +219 -161
- package/es/src/types/index.d.ts +11 -0
- 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 +5 -0
- package/lib/src/gis-map/utils/common-utils.js +1 -1
- package/lib/src/gis-map/utils/map-initializer.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +23 -3
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +2 -1
- package/lib/src/gis-map/utils/open-drive-renderer/junction.d.ts +2 -1
- package/lib/src/gis-map/utils/open-drive-renderer/road.d.ts +2 -0
- package/lib/src/gis-map/utils/open-drive-renderer/road.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.d.ts +21 -1
- package/lib/src/gis-map/utils/open-drive-renderer/wasm-loader.js +1 -1
- package/lib/src/types/index.d.ts +11 -0
- package/package.json +1 -1
|
@@ -1,38 +1,28 @@
|
|
|
1
1
|
import { XMLParser as m } from "fast-xml-parser";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
class
|
|
2
|
+
import L from "../../stores/index.mjs";
|
|
3
|
+
import g from "../common-utils.mjs";
|
|
4
|
+
import p from "./junction.mjs";
|
|
5
|
+
import S from "./road.mjs";
|
|
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.junctionTableData = /* @__PURE__ */ new Map(), this.isWasmLoaded = !1, this.appDataStore = L.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(o) {
|
|
18
18
|
if (!this.isWasmLoaded) {
|
|
19
|
-
const
|
|
20
|
-
this.ModuleOpenDrive = await
|
|
19
|
+
const r = window.libOpenDrive;
|
|
20
|
+
this.ModuleOpenDrive = await r(), this.isWasmLoaded = !0;
|
|
21
21
|
}
|
|
22
22
|
console.time("加载用时");
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}).parse(s), i = n.OpenDRIVE.header.geoReference, a = n.OpenDRIVE.header.offset;
|
|
27
|
-
if (a) {
|
|
28
|
-
const l = Number(a["@_x"]) || 0, u = Number(a["@_y"]) || 0;
|
|
29
|
-
this.appStore.$patch({
|
|
30
|
-
xOffset: l,
|
|
31
|
-
yOffset: u,
|
|
32
|
-
geoReference: i
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
const c = new TextEncoder().encode(s);
|
|
23
|
+
const t = await (await fetch(o)).text();
|
|
24
|
+
this.readXodrString(t);
|
|
25
|
+
const n = new TextEncoder().encode(t);
|
|
36
26
|
try {
|
|
37
27
|
this.ModuleOpenDrive.FS_unlink(`./${this.FsFile}`);
|
|
38
28
|
} catch {
|
|
@@ -40,11 +30,11 @@ class g {
|
|
|
40
30
|
this.ModuleOpenDrive.FS_createDataFile(
|
|
41
31
|
".",
|
|
42
32
|
this.FsFile,
|
|
43
|
-
|
|
33
|
+
n,
|
|
44
34
|
!0,
|
|
45
35
|
!0
|
|
46
36
|
);
|
|
47
|
-
const
|
|
37
|
+
const i = {
|
|
48
38
|
with_lateralProfile: !0,
|
|
49
39
|
with_laneHeight: !0,
|
|
50
40
|
with_road_objects: !1,
|
|
@@ -53,7 +43,7 @@ class g {
|
|
|
53
43
|
};
|
|
54
44
|
return this.ModuleOpenDriveMap = new this.ModuleOpenDrive.OpenDriveMap(
|
|
55
45
|
`./${this.FsFile}`,
|
|
56
|
-
|
|
46
|
+
i
|
|
57
47
|
), console.timeEnd("加载用时"), this.getRoadNetwork();
|
|
58
48
|
}
|
|
59
49
|
clear() {
|
|
@@ -63,83 +53,111 @@ class g {
|
|
|
63
53
|
} catch {
|
|
64
54
|
}
|
|
65
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* 读取xodr中wasm接口不提供的数据
|
|
58
|
+
* @param fileText
|
|
59
|
+
*/
|
|
60
|
+
readXodrString(o) {
|
|
61
|
+
const t = new m({
|
|
62
|
+
ignoreAttributes: !1,
|
|
63
|
+
allowBooleanAttributes: !0
|
|
64
|
+
}).parse(o), s = t.OpenDRIVE.header.geoReference, n = t.OpenDRIVE.header.offset;
|
|
65
|
+
if (n) {
|
|
66
|
+
const r = Number(n["@_x"]) || 0, a = Number(n["@_y"]) || 0;
|
|
67
|
+
g.setGeoData(s, r, a);
|
|
68
|
+
}
|
|
69
|
+
const i = t.OpenDRIVE.junction;
|
|
70
|
+
for (const r of i) {
|
|
71
|
+
const a = JSON.parse(
|
|
72
|
+
r.userData.tableData
|
|
73
|
+
);
|
|
74
|
+
this.junctionTableData.set(a.id, a);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
66
77
|
/**
|
|
67
78
|
* 解析路网
|
|
68
79
|
*/
|
|
69
80
|
getRoadNetwork() {
|
|
70
|
-
|
|
81
|
+
this.roadList.clear(), this.junctionList.clear();
|
|
82
|
+
let o;
|
|
71
83
|
try {
|
|
72
|
-
|
|
84
|
+
console.time("采样用时"), o = this.ModuleOpenDrive.get_odr_road_network(
|
|
73
85
|
this.ModuleOpenDriveMap,
|
|
74
86
|
0.5
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
);
|
|
88
|
+
} catch (s) {
|
|
89
|
+
return { status: -1, message: `解析路网失败, ${s}` };
|
|
90
|
+
} finally {
|
|
91
|
+
console.timeEnd("采样用时");
|
|
92
|
+
}
|
|
93
|
+
console.time("投影转换用时");
|
|
94
|
+
try {
|
|
95
|
+
g.getStdVecEntries(o.roads, !0).forEach((n) => {
|
|
96
|
+
const i = new S(n);
|
|
97
|
+
this.roadList.set(i.id, i);
|
|
98
|
+
});
|
|
99
|
+
} catch (s) {
|
|
100
|
+
return { status: -1, message: `解析道路失败, ${s}` };
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
g.getStdVecEntries(
|
|
104
|
+
o.junctions,
|
|
83
105
|
!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
|
-
});
|
|
106
|
+
).forEach((n) => {
|
|
107
|
+
const i = new p(n);
|
|
108
|
+
i.tableData = this.junctionTableData.get(i.id), this.junctionList.set(n.id, i);
|
|
110
109
|
});
|
|
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: "解析路网失败" };
|
|
110
|
+
} catch (s) {
|
|
111
|
+
return { status: -1, message: `解析路口失败, ${s}` };
|
|
126
112
|
}
|
|
113
|
+
console.timeEnd("投影转换用时");
|
|
114
|
+
const e = [];
|
|
115
|
+
this.roadList.forEach((s) => {
|
|
116
|
+
const n = s.allLaneSections.map((i) => {
|
|
117
|
+
const r = i.allLanes.map((a) => ({
|
|
118
|
+
id: a.id,
|
|
119
|
+
type: a.type,
|
|
120
|
+
innerPath: a.innerBorder,
|
|
121
|
+
outerPath: a.outerBorder,
|
|
122
|
+
centerLine: a.centerLine
|
|
123
|
+
}));
|
|
124
|
+
return {
|
|
125
|
+
id: i.s0,
|
|
126
|
+
lanePaths: r
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
e.push({
|
|
130
|
+
id: s.id,
|
|
131
|
+
name: s.name,
|
|
132
|
+
laneSections: n,
|
|
133
|
+
junction: s.junction,
|
|
134
|
+
refLine: s.refLine
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
const t = [];
|
|
138
|
+
return this.junctionList.forEach((s) => {
|
|
139
|
+
s.tableData && t.push(s.tableData);
|
|
140
|
+
}), {
|
|
141
|
+
status: 0,
|
|
142
|
+
message: "ok",
|
|
143
|
+
result: { roads: e, junctions: t }
|
|
144
|
+
};
|
|
127
145
|
}
|
|
128
146
|
/**
|
|
129
147
|
* 获取所有道路的采样结果
|
|
130
148
|
*/
|
|
131
149
|
get allSampledRoads() {
|
|
132
|
-
return [...this.roadList.values()].map((
|
|
150
|
+
return [...this.roadList.values()].map((o) => o.sampledRoad);
|
|
133
151
|
}
|
|
134
152
|
/**
|
|
135
153
|
* 获取路网结构
|
|
136
154
|
*/
|
|
137
155
|
get roadNetwork() {
|
|
138
156
|
return [...this.roadList.values()].map((e) => {
|
|
139
|
-
const
|
|
140
|
-
const n =
|
|
157
|
+
const t = e.allLaneSections.map((s) => {
|
|
158
|
+
const n = s.allLaneIds.filter((i) => i !== 0);
|
|
141
159
|
return {
|
|
142
|
-
sectionId:
|
|
160
|
+
sectionId: s.s0,
|
|
143
161
|
laneIds: n
|
|
144
162
|
};
|
|
145
163
|
});
|
|
@@ -147,7 +165,7 @@ class g {
|
|
|
147
165
|
roadName: e.name,
|
|
148
166
|
roadId: e.id,
|
|
149
167
|
roadLength: e.length,
|
|
150
|
-
sections:
|
|
168
|
+
sections: t
|
|
151
169
|
};
|
|
152
170
|
});
|
|
153
171
|
}
|
|
@@ -155,9 +173,9 @@ class g {
|
|
|
155
173
|
* 从车道信息获取车道对象
|
|
156
174
|
* @param laneInfo
|
|
157
175
|
*/
|
|
158
|
-
getLane(
|
|
159
|
-
const e = this.roadList.get(
|
|
160
|
-
return
|
|
176
|
+
getLane(o) {
|
|
177
|
+
const e = this.roadList.get(o.roadId), t = e == null ? void 0 : e.getLaneSection(o.sectionId);
|
|
178
|
+
return t == null ? void 0 : t.getLane(o.laneId);
|
|
161
179
|
}
|
|
162
180
|
/**
|
|
163
181
|
* 获取两个车道之间的车道功能
|
|
@@ -165,11 +183,11 @@ class g {
|
|
|
165
183
|
* @param incoming
|
|
166
184
|
* @param outgoing
|
|
167
185
|
*/
|
|
168
|
-
getFunctionFromIncomingToOutgoing(
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
186
|
+
getFunctionFromIncomingToOutgoing(o, e) {
|
|
187
|
+
const t = this.getLane(o), s = this.getLane(e);
|
|
188
|
+
if (!t || !s || !t.drivingAngle || !s.drivingAngle)
|
|
171
189
|
return { status: -1, message: "车道信息错误" };
|
|
172
|
-
let n =
|
|
190
|
+
let n = s.drivingAngle - t.drivingAngle;
|
|
173
191
|
n > 180 ? n -= 360 : n < -180 && (n += 360);
|
|
174
192
|
let i = "";
|
|
175
193
|
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" };
|
|
@@ -178,23 +196,23 @@ class g {
|
|
|
178
196
|
* 获取所有路口的轮廓
|
|
179
197
|
* @returns
|
|
180
198
|
*/
|
|
181
|
-
getJunctionOutline(
|
|
199
|
+
getJunctionOutline(o) {
|
|
182
200
|
const e = [];
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
const
|
|
201
|
+
if (o !== "") {
|
|
202
|
+
const t = this.junctionList.get(o);
|
|
203
|
+
if (t) {
|
|
204
|
+
const s = t.getJunctionOutline();
|
|
187
205
|
e.push({
|
|
188
|
-
junctionId:
|
|
189
|
-
name:
|
|
190
|
-
outline:
|
|
206
|
+
junctionId: o,
|
|
207
|
+
name: t.name,
|
|
208
|
+
outline: s
|
|
191
209
|
});
|
|
192
210
|
}
|
|
193
211
|
} else
|
|
194
|
-
for (const
|
|
195
|
-
const
|
|
196
|
-
i.length <= 4 ? console.log(i,
|
|
197
|
-
junctionId:
|
|
212
|
+
for (const t of this.junctionList) {
|
|
213
|
+
const s = t[0], n = t[1], i = n.getJunctionOutline();
|
|
214
|
+
i.length <= 4 ? console.log(i, s) : e.push({
|
|
215
|
+
junctionId: s,
|
|
198
216
|
name: n.name,
|
|
199
217
|
outline: i
|
|
200
218
|
});
|
|
@@ -206,74 +224,74 @@ class g {
|
|
|
206
224
|
* @param laneInfo
|
|
207
225
|
* @returns
|
|
208
226
|
*/
|
|
209
|
-
getLaneLink(
|
|
210
|
-
const e = this.getLane(
|
|
227
|
+
getLaneLink(o) {
|
|
228
|
+
const e = this.getLane(o);
|
|
211
229
|
return e ? { status: 0, result: e.getLink(), message: "ok" } : { status: -1, message: "车道信息错误" };
|
|
212
230
|
}
|
|
213
|
-
getRoadLink(
|
|
231
|
+
getRoadLink(o) {
|
|
214
232
|
const e = [];
|
|
215
|
-
if (
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
roadId:
|
|
219
|
-
successor:
|
|
220
|
-
predecessor:
|
|
233
|
+
if (o !== "") {
|
|
234
|
+
const t = this.roadList.get(o);
|
|
235
|
+
t && e.push({
|
|
236
|
+
roadId: o,
|
|
237
|
+
successor: t.successor,
|
|
238
|
+
predecessor: t.predecessor
|
|
221
239
|
});
|
|
222
240
|
} else
|
|
223
|
-
[...this.roadList.values()].forEach((
|
|
241
|
+
[...this.roadList.values()].forEach((s) => {
|
|
224
242
|
e.push({
|
|
225
|
-
roadId:
|
|
226
|
-
successor:
|
|
227
|
-
predecessor:
|
|
243
|
+
roadId: o,
|
|
244
|
+
successor: s.successor,
|
|
245
|
+
predecessor: s.predecessor
|
|
228
246
|
});
|
|
229
247
|
});
|
|
230
248
|
return { status: 0, result: e, message: "ok" };
|
|
231
249
|
}
|
|
232
|
-
getConnectionLink(
|
|
250
|
+
getConnectionLink(o) {
|
|
233
251
|
const e = [];
|
|
234
|
-
for (const
|
|
235
|
-
const
|
|
236
|
-
if ((
|
|
237
|
-
id:
|
|
252
|
+
for (const t of this.junctionList) {
|
|
253
|
+
const s = t[0], n = t[1];
|
|
254
|
+
if ((o === "" || s === o) && (e.push({
|
|
255
|
+
id: s,
|
|
238
256
|
name: n.name,
|
|
239
257
|
links: n.laneLinks
|
|
240
|
-
}),
|
|
258
|
+
}), o !== ""))
|
|
241
259
|
break;
|
|
242
260
|
}
|
|
243
261
|
return { status: 0, result: e, message: "ok" };
|
|
244
262
|
}
|
|
245
|
-
getLaneAngle(
|
|
246
|
-
const e = this.getLane(
|
|
263
|
+
getLaneAngle(o) {
|
|
264
|
+
const e = this.getLane(o);
|
|
247
265
|
if (e) {
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
250
|
-
return { status: 0, result:
|
|
266
|
+
const t = e.drivingAngle;
|
|
267
|
+
if (t)
|
|
268
|
+
return { status: 0, result: t, message: "ok" };
|
|
251
269
|
}
|
|
252
270
|
return { status: -1, message: "车道信息错误" };
|
|
253
271
|
}
|
|
254
|
-
getTurnArrow(
|
|
255
|
-
const e = this.getLane(
|
|
272
|
+
getTurnArrow(o) {
|
|
273
|
+
const e = this.getLane(o.incoming);
|
|
256
274
|
if (!e)
|
|
257
275
|
return { status: -1, message: "进口道信息错误" };
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
276
|
+
const t = e.drivingAngle;
|
|
277
|
+
if (!t)
|
|
260
278
|
return { status: -1, message: "进口道信息错误" };
|
|
261
|
-
const
|
|
262
|
-
if (!
|
|
279
|
+
const s = this.getLane(o.outgoing);
|
|
280
|
+
if (!s)
|
|
263
281
|
return { status: -1, message: "出口道信息错误" };
|
|
264
|
-
const n =
|
|
282
|
+
const n = s.drivingAngle;
|
|
265
283
|
if (!n)
|
|
266
284
|
return { status: -1, message: "出口道信息错误" };
|
|
267
|
-
let i = n -
|
|
285
|
+
let i = n - t;
|
|
268
286
|
i > 180 ? i -= 360 : i < -180 && (i += 360);
|
|
269
|
-
let
|
|
270
|
-
return -45 < i && i < 45 ?
|
|
287
|
+
let r = "";
|
|
288
|
+
return -45 < i && i < 45 ? r = "s" : 45 <= i && i <= 135 ? r = "r" : -135 <= i && i <= -45 ? r = "l" : r = "t", {
|
|
271
289
|
status: 0,
|
|
272
290
|
message: "ok",
|
|
273
291
|
result: {
|
|
274
|
-
incomingAngle:
|
|
292
|
+
incomingAngle: t,
|
|
275
293
|
outgoingAngle: n,
|
|
276
|
-
direction:
|
|
294
|
+
direction: r
|
|
277
295
|
}
|
|
278
296
|
};
|
|
279
297
|
}
|
|
@@ -302,66 +320,106 @@ class g {
|
|
|
302
320
|
* @param laneId
|
|
303
321
|
* @returns
|
|
304
322
|
*/
|
|
305
|
-
getPolygon(
|
|
306
|
-
const
|
|
307
|
-
if (!
|
|
323
|
+
getPolygon(o, e, t) {
|
|
324
|
+
const s = this.roadList.get(o);
|
|
325
|
+
if (!s)
|
|
308
326
|
return { status: -1, message: "道路id错误" };
|
|
309
|
-
if (e !== void 0 &&
|
|
310
|
-
const n = this.getLane({ roadId:
|
|
327
|
+
if (e !== void 0 && t !== void 0 && !isNaN(e) && !isNaN(t)) {
|
|
328
|
+
const n = this.getLane({ roadId: o, sectionId: e, laneId: t });
|
|
311
329
|
return n ? { status: 0, message: "ok", result: n.ring } : { status: -1, message: "车道信息错误" };
|
|
312
330
|
} else if (e !== void 0 && !isNaN(e)) {
|
|
313
|
-
const n =
|
|
331
|
+
const n = s.getLaneSection(e);
|
|
314
332
|
return n ? { status: 0, message: "ok", result: n.polygon } : { status: -1, message: "路段信息错误" };
|
|
315
333
|
} else
|
|
316
|
-
return { status: 0, message: "ok", result:
|
|
334
|
+
return { status: 0, message: "ok", result: s.polygon };
|
|
317
335
|
}
|
|
318
336
|
/**
|
|
319
337
|
* 车道长度
|
|
320
338
|
* @param laneInfo
|
|
321
339
|
* @returns
|
|
322
340
|
*/
|
|
323
|
-
getLaneLength(
|
|
324
|
-
const e = this.getLane(
|
|
341
|
+
getLaneLength(o) {
|
|
342
|
+
const e = this.getLane(o);
|
|
325
343
|
if (e) {
|
|
326
|
-
let
|
|
327
|
-
return e.road.isLastLaneSection(e.laneSection.s0) ?
|
|
344
|
+
let t = 0;
|
|
345
|
+
return e.road.isLastLaneSection(e.laneSection.s0) ? t = e.road.length - e.laneSection.s0 : t = e.road.getNextLaneSection(
|
|
328
346
|
e.laneSection.s0
|
|
329
347
|
).s0 - e.laneSection.s0, {
|
|
330
348
|
status: 0,
|
|
331
349
|
message: "ok",
|
|
332
|
-
result: Number(
|
|
350
|
+
result: Number(t.toFixed(2))
|
|
333
351
|
};
|
|
334
352
|
} else
|
|
335
353
|
return { status: -1, message: "车道信息错误" };
|
|
336
354
|
}
|
|
337
|
-
getRoadStopLine(
|
|
355
|
+
getRoadStopLine(o) {
|
|
338
356
|
const e = [];
|
|
339
|
-
for (const
|
|
340
|
-
const
|
|
341
|
-
if (
|
|
357
|
+
for (const t of this.junctionList) {
|
|
358
|
+
const s = t[0], n = t[1];
|
|
359
|
+
if (s === o) {
|
|
342
360
|
const i = n.getRoadStopLine();
|
|
343
|
-
e.push({ junctionId:
|
|
361
|
+
e.push({ junctionId: s, stopLines: i });
|
|
344
362
|
break;
|
|
345
|
-
} else if (
|
|
363
|
+
} else if (o === "") {
|
|
346
364
|
const i = n.getRoadStopLine();
|
|
347
|
-
e.push({ junctionId:
|
|
365
|
+
e.push({ junctionId: s, stopLines: i });
|
|
348
366
|
}
|
|
349
367
|
}
|
|
350
368
|
return { status: 0, message: "ok", result: e };
|
|
351
369
|
}
|
|
352
|
-
getLaneStopLine(
|
|
353
|
-
const e = this.getLane(
|
|
370
|
+
getLaneStopLine(o) {
|
|
371
|
+
const e = this.getLane(o);
|
|
354
372
|
return e ? { status: 0, message: "ok", result: e.getStopLine() } : { status: -1, message: "车道信息错误" };
|
|
355
373
|
}
|
|
356
|
-
getLaneCenterLine(
|
|
357
|
-
const e = this.getLane(
|
|
374
|
+
getLaneCenterLine(o) {
|
|
375
|
+
const e = this.getLane(o);
|
|
358
376
|
return e ? {
|
|
359
377
|
status: 0,
|
|
360
378
|
message: "ok",
|
|
361
379
|
result: e.getLaneEndPoints("middle")
|
|
362
380
|
} : { status: -1, message: "车道信息错误" };
|
|
363
381
|
}
|
|
382
|
+
getSumoEdgeInfo(o) {
|
|
383
|
+
const e = o.split("+"), t = e[0], s = Number(e[1]), n = this.roadList.get(t);
|
|
384
|
+
if (!n)
|
|
385
|
+
return;
|
|
386
|
+
let i = "";
|
|
387
|
+
if (n.laneSectionNumber === 1)
|
|
388
|
+
i = `-${t}`;
|
|
389
|
+
else {
|
|
390
|
+
const c = n.getLaneSectionIndex(s);
|
|
391
|
+
if (c === -1)
|
|
392
|
+
return;
|
|
393
|
+
i = `-${t}#${c}`;
|
|
394
|
+
}
|
|
395
|
+
const r = n.predecessor.elementId, a = n.successor.elementId, l = n.getLaneSection(s);
|
|
396
|
+
if (!l)
|
|
397
|
+
return;
|
|
398
|
+
const d = [], f = l.laneNumber - 1;
|
|
399
|
+
for (const c of l.allLanes) {
|
|
400
|
+
if (c.id === 0)
|
|
401
|
+
continue;
|
|
402
|
+
const h = f - Math.abs(c.id);
|
|
403
|
+
d.push({
|
|
404
|
+
obj_id: `${i}_${h}`
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
obj_id: i,
|
|
409
|
+
obj_type: 1,
|
|
410
|
+
obj_desc: "edge",
|
|
411
|
+
obj_info: {
|
|
412
|
+
obj_id: i,
|
|
413
|
+
length: n.getLaneSectionLength(s),
|
|
414
|
+
from: r,
|
|
415
|
+
to: a,
|
|
416
|
+
numLanes: f,
|
|
417
|
+
type: "driving",
|
|
418
|
+
laneList: d
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
}
|
|
364
422
|
}
|
|
365
423
|
export {
|
|
366
|
-
|
|
424
|
+
u as default
|
|
367
425
|
};
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -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,12 +66,17 @@ 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
|
+
static geoReference: string;
|
|
70
|
+
static xOffset: number;
|
|
71
|
+
static yOffset: number;
|
|
72
|
+
static setGeoData(geoReference: string, xOffset: number, yOffset: number): void;
|
|
69
73
|
/**
|
|
70
74
|
* OpenDrive坐标转换为WGS84坐标
|
|
71
75
|
* @param line
|
|
72
76
|
* @returns
|
|
73
77
|
*/
|
|
74
78
|
static transformLineProjection(line: number[][]): number[][];
|
|
79
|
+
static transformPointProjection(point: number[]): number[];
|
|
75
80
|
static pointsEqual(point1: number[], point2: number[]): boolean;
|
|
76
81
|
static getExtensionLine(pt1: number[], pt2: number[], distance: number): turf.Position;
|
|
77
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@arcgis/core/geometry"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@arcgis/core/geometry"),L=require("@arcgis/core/geometry/geometryEngineAsync"),w=require("@arcgis/core/geometry/support/webMercatorUtils"),y=require("@turf/bearing"),g=require("@turf/destination"),b=require("@turf/helpers"),S=require("pako"),P=require("proj4");function l(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=l(L),h=l(w),c=l(b);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 y(n,r)}static extendLineInTowDir(e,t){const n=e.paths[0],r=c.point(n[0]),s=c.point(n[1]),o=y(s,r),f=g(r,t,o,{units:"meters"}),O=o>0?o-180:o+180,d=g(s,t,O,{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=h.geographicToWebMercator(e),r=await p.offset(n,t,"meters");return h.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 S.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=>P(i.geoReference).inverse([t[0]-i.xOffset,t[1]-i.yOffset]))}catch{return console.error("OpenDrive坐标转换为WGS84坐标失败",i.geoReference),e}}static transformPointProjection(e){try{return P(i.geoReference).inverse([e[0]-i.xOffset,e[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=y(r,s);return g(s,n,o,{units:"meters"}).geometry.coordinates}}exports.default=i;
|