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.
@@ -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
- Ce(), fe(async () => {
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,7 +1,4 @@
1
1
  export declare const useAppDataStore: import("pinia").StoreDefinition<"appData", {
2
2
  mapConfig: {};
3
3
  saveTrackLog: boolean;
4
- geoReference: string;
5
- xOffset: number;
6
- yOffset: number;
7
4
  }, {}, {}>;
@@ -1,13 +1,10 @@
1
- import { defineStore as e } from "pinia";
2
- const a = e("appData", {
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
- a as useAppDataStore
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 m, Polyline as f } from "@arcgis/core/geometry";
2
- import * as p from "@arcgis/core/geometry/geometryEngineAsync";
3
- import * as l from "@arcgis/core/geometry/support/webMercatorUtils";
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 g from "@turf/destination";
5
+ import p from "@turf/destination";
6
6
  import * as a from "@turf/helpers";
7
- import P from "pako";
8
- import L from "proj4";
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 = g(r, n, e, {
18
+ const r = a.point([t.x, t.y]), s = p(r, n, e, {
20
19
  units: "meters"
21
20
  });
22
- return new m({
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 = g(r, e, o, {
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
- }), y = o > 0 ? o - 180 : o + 180, h = g(s, e, y, {
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, h.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 p.intersectLinesToPoints(
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 p.geodesicLength(e, "meters");
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 p.intersect(t, e);
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 = l.geographicToWebMercator(t), r = await p.offset(
129
+ const n = y.geographicToWebMercator(t), r = await g.offset(
131
130
  n,
132
131
  e,
133
132
  "meters"
134
133
  );
135
- return l.webMercatorToGeographic(
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 P.inflate(r, { to: "string" });
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
- const e = w(), n = e.geoReference, r = e.xOffset, s = e.yOffset;
183
- return t.map(
184
- (o) => L(n).inverse([o[0] - r, o[1] - s])
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 g(s, n, o, { units: "meters" }).geometry.coordinates;
203
+ return p(s, n, o, { units: "meters" }).geometry.coordinates;
193
204
  }
194
205
  }
195
206
  export {
@@ -10,7 +10,7 @@ export default class WasmLoader {
10
10
  private isWasmLoaded;
11
11
  private ModuleOpenDrive;
12
12
  private ModuleOpenDriveMap;
13
- private appStore;
13
+ private appDataStore;
14
14
  private FsFile;
15
15
  /**
16
16
  * 载入指定xodr文件并解析
@@ -1,38 +1,34 @@
1
1
  import { XMLParser as m } from "fast-xml-parser";
2
- import { useAppDataStore as h } from "../../stores/appData.mjs";
3
- import f from "../common-utils.mjs";
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 g {
6
+ class u {
7
7
  constructor() {
8
- this.roadList = /* @__PURE__ */ new Map(), this.junctionList = /* @__PURE__ */ new Map(), this.isWasmLoaded = !1, this.appStore = h(), this.FsFile = "data.xodr";
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 g.instance || (g.instance = new g()), g.instance;
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(t) {
17
+ async load(n) {
18
18
  if (!this.isWasmLoaded) {
19
- const l = window.libOpenDrive;
20
- this.ModuleOpenDrive = await l(), this.isWasmLoaded = !0;
19
+ const c = window.libOpenDrive;
20
+ this.ModuleOpenDrive = await c(), this.isWasmLoaded = !0;
21
21
  }
22
22
  console.time("加载用时");
23
- const s = await (await fetch(t)).text(), n = new m({
23
+ const t = await (await fetch(n)).text(), i = new m({
24
24
  ignoreAttributes: !1,
25
25
  allowBooleanAttributes: !0
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
- });
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 c = new TextEncoder().encode(s);
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
- c,
39
+ g,
44
40
  !0,
45
41
  !0
46
42
  );
@@ -67,87 +63,99 @@ class g {
67
63
  * 解析路网
68
64
  */
69
65
  getRoadNetwork() {
70
- console.time("采样用时"), this.roadList.clear(), this.junctionList.clear();
66
+ this.roadList.clear(), this.junctionList.clear();
67
+ let n;
71
68
  try {
72
- const t = this.ModuleOpenDrive.get_odr_road_network(
69
+ console.time("采样用时"), n = this.ModuleOpenDrive.get_odr_road_network(
73
70
  this.ModuleOpenDriveMap,
74
71
  0.5
75
- ), e = t.geo_reference;
76
- h().$patch({
77
- geoReference: e
78
- }), console.timeEnd("采样用时"), console.time("投影转换用时"), f.getStdVecEntries(t.roads, !0).forEach((r) => {
79
- const c = new p(r);
80
- this.roadList.set(c.id, c);
81
- }), f.getStdVecEntries(
82
- t.junctions,
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((r) => {
85
- const c = new L(r);
86
- this.junctionList.set(r.id, c);
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
- const a = [];
112
- return this.junctionList.forEach((r) => {
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((t) => t.sampledRoad);
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 s = e.allLaneSections.map((o) => {
140
- const n = o.allLaneIds.filter((i) => i !== 0);
147
+ const t = e.allLaneSections.map((s) => {
148
+ const i = s.allLaneIds.filter((o) => o !== 0);
141
149
  return {
142
- sectionId: o.s0,
143
- laneIds: n
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: s
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(t) {
159
- const e = this.roadList.get(t.roadId), s = e == null ? void 0 : e.getLaneSection(t.sectionId);
160
- return s == null ? void 0 : s.getLane(t.laneId);
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(t, e) {
169
- const s = this.getLane(t), o = this.getLane(e);
170
- if (!s || !o || !s.drivingAngle || !o.drivingAngle)
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 n = o.drivingAngle - s.drivingAngle;
173
- n > 180 ? n -= 360 : n < -180 && (n += 360);
174
- let i = "";
175
- 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" };
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(t) {
189
+ getJunctionOutline(n) {
182
190
  const e = [];
183
- if (t !== "") {
184
- const s = this.junctionList.get(t);
185
- if (s) {
186
- const o = s.getJunctionOutline();
191
+ if (n !== "") {
192
+ const t = this.junctionList.get(n);
193
+ if (t) {
194
+ const s = t.getJunctionOutline();
187
195
  e.push({
188
- junctionId: t,
189
- name: s.name,
190
- outline: o
196
+ junctionId: n,
197
+ name: t.name,
198
+ outline: s
191
199
  });
192
200
  }
193
201
  } else
194
- for (const s of this.junctionList) {
195
- const o = s[0], n = s[1], i = n.getJunctionOutline();
196
- i.length <= 4 ? console.log(i, o) : e.push({
197
- junctionId: o,
198
- name: n.name,
199
- outline: i
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(t) {
210
- const e = this.getLane(t);
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(t) {
221
+ getRoadLink(n) {
214
222
  const e = [];
215
- if (t !== "") {
216
- const s = this.roadList.get(t);
217
- s && e.push({
218
- roadId: t,
219
- successor: s.successor,
220
- predecessor: s.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((o) => {
231
+ [...this.roadList.values()].forEach((s) => {
224
232
  e.push({
225
- roadId: t,
226
- successor: o.successor,
227
- predecessor: o.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(t) {
240
+ getConnectionLink(n) {
233
241
  const e = [];
234
- for (const s of this.junctionList) {
235
- const o = s[0], n = s[1];
236
- if ((t === "" || o === t) && (e.push({
237
- id: o,
238
- name: n.name,
239
- links: n.laneLinks
240
- }), t !== ""))
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(t) {
246
- const e = this.getLane(t);
253
+ getLaneAngle(n) {
254
+ const e = this.getLane(n);
247
255
  if (e) {
248
- const s = e.drivingAngle;
249
- if (s)
250
- return { status: 0, result: s, message: "ok" };
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(t) {
255
- const e = this.getLane(t.incoming);
262
+ getTurnArrow(n) {
263
+ const e = this.getLane(n.incoming);
256
264
  if (!e)
257
265
  return { status: -1, message: "进口道信息错误" };
258
- const s = e.drivingAngle;
259
- if (!s)
266
+ const t = e.drivingAngle;
267
+ if (!t)
260
268
  return { status: -1, message: "进口道信息错误" };
261
- const o = this.getLane(t.outgoing);
262
- if (!o)
269
+ const s = this.getLane(n.outgoing);
270
+ if (!s)
263
271
  return { status: -1, message: "出口道信息错误" };
264
- const n = o.drivingAngle;
265
- if (!n)
272
+ const i = s.drivingAngle;
273
+ if (!i)
266
274
  return { status: -1, message: "出口道信息错误" };
267
- let i = n - s;
268
- i > 180 ? i -= 360 : i < -180 && (i += 360);
269
- let a = "";
270
- return -45 < i && i < 45 ? a = "s" : 45 <= i && i <= 135 ? a = "r" : -135 <= i && i <= -45 ? a = "l" : a = "t", {
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: s,
275
- outgoingAngle: n,
276
- direction: a
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(t, e, s) {
306
- const o = this.roadList.get(t);
307
- if (!o)
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 && s !== void 0 && !isNaN(e) && !isNaN(s)) {
310
- const n = this.getLane({ roadId: t, sectionId: e, laneId: s });
311
- return n ? { status: 0, message: "ok", result: n.ring } : { status: -1, message: "车道信息错误" };
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 n = o.getLaneSection(e);
314
- return n ? { status: 0, message: "ok", result: n.polygon } : { status: -1, message: "路段信息错误" };
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: o.polygon };
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(t) {
324
- const e = this.getLane(t);
331
+ getLaneLength(n) {
332
+ const e = this.getLane(n);
325
333
  if (e) {
326
- let s = 0;
327
- return e.road.isLastLaneSection(e.laneSection.s0) ? s = e.road.length - e.laneSection.s0 : s = e.road.getNextLaneSection(
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(s.toFixed(2))
340
+ result: Number(t.toFixed(2))
333
341
  };
334
342
  } else
335
343
  return { status: -1, message: "车道信息错误" };
336
344
  }
337
- getRoadStopLine(t) {
345
+ getRoadStopLine(n) {
338
346
  const e = [];
339
- for (const s of this.junctionList) {
340
- const o = s[0], n = s[1];
341
- if (o === t) {
342
- const i = n.getRoadStopLine();
343
- e.push({ junctionId: o, stopLines: i });
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 (t === "") {
346
- const i = n.getRoadStopLine();
347
- e.push({ junctionId: o, stopLines: i });
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(t) {
353
- const e = this.getLane(t);
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(t) {
357
- const e = this.getLane(t);
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
- g as default
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);v.registerStore(),n.onMounted(async()=>{if(!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
+ "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,7 +1,4 @@
1
1
  export declare const useAppDataStore: import("pinia").StoreDefinition<"appData", {
2
2
  mapConfig: {};
3
3
  saveTrackLog: boolean;
4
- geoReference: string;
5
- xOffset: number;
6
- yOffset: number;
7
4
  }, {}, {}>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("pinia"),t=e.defineStore("appData",{state:()=>({mapConfig:{},saveTrackLog:!1,geoReference:"",xOffset:0,yOffset:0})});exports.useAppDataStore=t;
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"),m=require("proj4"),A=require("../stores/appData.js");function y(c){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const e in c)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(c,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>c[e]})}}return t.default=c,Object.freeze(t)}const p=y(O),P=y(L),a=y(w);class i{static destinationWithPoint(t,e,n){const r=a.point([t.x,t.y]),s=g(r,n,e,{units:"meters"});return new u.Point({x:s.geometry.coordinates[0],y:s.geometry.coordinates[1]})}static angleOfLine(t){const e=t.paths[0],n=a.point(e[0]),r=a.point(e[e.length-1]);return l(n,r)}static extendLineInTowDir(t,e){const n=t.paths[0],r=a.point(n[0]),s=a.point(n[1]),o=l(s,r),f=g(r,e,o,{units:"meters"}),h=o>0?o-180:o+180,d=g(s,e,h,{units:"meters"});return new u.Polyline({paths:[[f.geometry.coordinates,d.geometry.coordinates]]})}static async getIntersectPointOfTwoLines(t,e){const n=await p.intersectLinesToPoints(t,e);if(n.length)return n[0]}static async getIntersectPointsOfStopLineAndLane(t,e,n){let r=await i.getIntersectPointOfLineAndPolygon(t,e);if(await i.pointDistance(r)<3&&n){for(const s of n)if(r=await i.getIntersectPointOfLineAndPolygon(t,e,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(t){if(t.length<2)return 0;const e=new u.Polyline({paths:[t]});return await p.geodesicLength(e,"meters")}static async getIntersectPointOfLineAndPolygon(t,e,n=0){n!==0&&(t=await i.getOffsetLine(t,n));const r=await p.intersect(t,e);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(t,e){const n=P.geographicToWebMercator(t),r=await p.offset(n,e,"meters");return P.webMercatorToGeographic(r,!1)}static unzip(t){try{const e=[],n=t.split("");for(let s=0;s<n.length;s++){const o=n[s];e.push(o.charCodeAt(0))}const r=new Uint8Array(e);return b.inflate(r,{to:"string"})}catch{console.log(`非压缩内容: ${t}`)}}static getStdVecEntries(t,e=!1){const n=new Array(t.size());for(let r=0;r<t.size();r++)n[r]=t.get(r);return e&&t.delete(),n}static getStdMapEntries(t){const e=[];for(const n of i.getStdMapKeys(t))e.push([n,t.get(n)]);return e}static getStdMapKeys(t,e=!1){const n=[],r=t.keys();for(let s=0;s<r.size();s++)n.push(r.get(s));return r.delete(),e&&t.delete(),n}static transformLineProjection(t){const e=A.useAppDataStore(),n=e.geoReference,r=e.xOffset,s=e.yOffset;return t.map(o=>m(n).inverse([o[0]-r,o[1]-s]))}static pointsEqual(t,e){return Math.abs(t[0]-e[0])<Number.EPSILON&&Math.abs(t[1]-e[1])<Number.EPSILON}static getExtensionLine(t,e,n){const r=a.point(t),s=a.point(e),o=l(r,s);return g(s,n,o,{units:"meters"}).geometry.coordinates}}exports.default=i;
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;
@@ -10,7 +10,7 @@ export default class WasmLoader {
10
10
  private isWasmLoaded;
11
11
  private ModuleOpenDrive;
12
12
  private ModuleOpenDriveMap;
13
- private appStore;
13
+ private appDataStore;
14
14
  private FsFile;
15
15
  /**
16
16
  * 载入指定xodr文件并解析
@@ -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 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;
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.119",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [