gisviewer-vue3-arcgis 1.0.119 → 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.
@@ -1,11 +1,11 @@
1
1
  import { XMLParser as m } from "fast-xml-parser";
2
- import f from "../../stores/index.mjs";
3
- import l from "../common-utils.mjs";
4
- import L from "./junction.mjs";
5
- import p from "./road.mjs";
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
6
  class u {
7
7
  constructor() {
8
- this.roadList = /* @__PURE__ */ new Map(), this.junctionList = /* @__PURE__ */ new Map(), this.isWasmLoaded = !1, this.appDataStore = f.useAppDataStore, this.FsFile = "data.xodr";
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
11
  return u.instance || (u.instance = new u()), u.instance;
@@ -14,21 +14,15 @@ class u {
14
14
  * 载入指定xodr文件并解析
15
15
  * @param filePath
16
16
  */
17
- async load(n) {
17
+ async load(o) {
18
18
  if (!this.isWasmLoaded) {
19
- const c = window.libOpenDrive;
20
- this.ModuleOpenDrive = await c(), this.isWasmLoaded = !0;
19
+ const r = window.libOpenDrive;
20
+ this.ModuleOpenDrive = await r(), this.isWasmLoaded = !0;
21
21
  }
22
22
  console.time("加载用时");
23
- const t = await (await fetch(n)).text(), i = new m({
24
- ignoreAttributes: !1,
25
- allowBooleanAttributes: !0
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);
30
- }
31
- const g = new TextEncoder().encode(t);
23
+ const t = await (await fetch(o)).text();
24
+ this.readXodrString(t);
25
+ const n = new TextEncoder().encode(t);
32
26
  try {
33
27
  this.ModuleOpenDrive.FS_unlink(`./${this.FsFile}`);
34
28
  } catch {
@@ -36,11 +30,11 @@ class u {
36
30
  this.ModuleOpenDrive.FS_createDataFile(
37
31
  ".",
38
32
  this.FsFile,
39
- g,
33
+ n,
40
34
  !0,
41
35
  !0
42
36
  );
43
- const d = {
37
+ const i = {
44
38
  with_lateralProfile: !0,
45
39
  with_laneHeight: !0,
46
40
  with_road_objects: !1,
@@ -49,7 +43,7 @@ class u {
49
43
  };
50
44
  return this.ModuleOpenDriveMap = new this.ModuleOpenDrive.OpenDriveMap(
51
45
  `./${this.FsFile}`,
52
- d
46
+ i
53
47
  ), console.timeEnd("加载用时"), this.getRoadNetwork();
54
48
  }
55
49
  clear() {
@@ -59,14 +53,35 @@ class u {
59
53
  } catch {
60
54
  }
61
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
+ }
62
77
  /**
63
78
  * 解析路网
64
79
  */
65
80
  getRoadNetwork() {
66
81
  this.roadList.clear(), this.junctionList.clear();
67
- let n;
82
+ let o;
68
83
  try {
69
- console.time("采样用时"), n = this.ModuleOpenDrive.get_odr_road_network(
84
+ console.time("采样用时"), o = this.ModuleOpenDrive.get_odr_road_network(
70
85
  this.ModuleOpenDriveMap,
71
86
  0.5
72
87
  );
@@ -77,20 +92,20 @@ class u {
77
92
  }
78
93
  console.time("投影转换用时");
79
94
  try {
80
- l.getStdVecEntries(n.roads, !0).forEach((i) => {
81
- const o = new p(i);
82
- this.roadList.set(o.id, o);
95
+ g.getStdVecEntries(o.roads, !0).forEach((n) => {
96
+ const i = new S(n);
97
+ this.roadList.set(i.id, i);
83
98
  });
84
99
  } catch (s) {
85
100
  return { status: -1, message: `解析道路失败, ${s}` };
86
101
  }
87
102
  try {
88
- l.getStdVecEntries(
89
- n.junctions,
103
+ g.getStdVecEntries(
104
+ o.junctions,
90
105
  !0
91
- ).forEach((i) => {
92
- const o = new L(i);
93
- this.junctionList.set(i.id, o);
106
+ ).forEach((n) => {
107
+ const i = new p(n);
108
+ i.tableData = this.junctionTableData.get(i.id), this.junctionList.set(n.id, i);
94
109
  });
95
110
  } catch (s) {
96
111
  return { status: -1, message: `解析路口失败, ${s}` };
@@ -98,8 +113,8 @@ class u {
98
113
  console.timeEnd("投影转换用时");
99
114
  const e = [];
100
115
  this.roadList.forEach((s) => {
101
- const i = s.allLaneSections.map((o) => {
102
- const r = o.allLanes.map((a) => ({
116
+ const n = s.allLaneSections.map((i) => {
117
+ const r = i.allLanes.map((a) => ({
103
118
  id: a.id,
104
119
  type: a.type,
105
120
  innerPath: a.innerBorder,
@@ -107,26 +122,21 @@ class u {
107
122
  centerLine: a.centerLine
108
123
  }));
109
124
  return {
110
- id: o.s0,
125
+ id: i.s0,
111
126
  lanePaths: r
112
127
  };
113
128
  });
114
129
  e.push({
115
130
  id: s.id,
116
131
  name: s.name,
117
- laneSections: i,
132
+ laneSections: n,
118
133
  junction: s.junction,
119
134
  refLine: s.refLine
120
135
  });
121
136
  });
122
137
  const t = [];
123
138
  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
- });
139
+ s.tableData && t.push(s.tableData);
130
140
  }), {
131
141
  status: 0,
132
142
  message: "ok",
@@ -137,7 +147,7 @@ class u {
137
147
  * 获取所有道路的采样结果
138
148
  */
139
149
  get allSampledRoads() {
140
- return [...this.roadList.values()].map((n) => n.sampledRoad);
150
+ return [...this.roadList.values()].map((o) => o.sampledRoad);
141
151
  }
142
152
  /**
143
153
  * 获取路网结构
@@ -145,10 +155,10 @@ class u {
145
155
  get roadNetwork() {
146
156
  return [...this.roadList.values()].map((e) => {
147
157
  const t = e.allLaneSections.map((s) => {
148
- const i = s.allLaneIds.filter((o) => o !== 0);
158
+ const n = s.allLaneIds.filter((i) => i !== 0);
149
159
  return {
150
160
  sectionId: s.s0,
151
- laneIds: i
161
+ laneIds: n
152
162
  };
153
163
  });
154
164
  return {
@@ -163,9 +173,9 @@ class u {
163
173
  * 从车道信息获取车道对象
164
174
  * @param laneInfo
165
175
  */
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);
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);
169
179
  }
170
180
  /**
171
181
  * 获取两个车道之间的车道功能
@@ -173,38 +183,38 @@ class u {
173
183
  * @param incoming
174
184
  * @param outgoing
175
185
  */
176
- getFunctionFromIncomingToOutgoing(n, e) {
177
- const t = this.getLane(n), s = this.getLane(e);
186
+ getFunctionFromIncomingToOutgoing(o, e) {
187
+ const t = this.getLane(o), s = this.getLane(e);
178
188
  if (!t || !s || !t.drivingAngle || !s.drivingAngle)
179
189
  return { status: -1, message: "车道信息错误" };
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" };
190
+ let n = s.drivingAngle - t.drivingAngle;
191
+ n > 180 ? n -= 360 : n < -180 && (n += 360);
192
+ let i = "";
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" };
184
194
  }
185
195
  /**
186
196
  * 获取所有路口的轮廓
187
197
  * @returns
188
198
  */
189
- getJunctionOutline(n) {
199
+ getJunctionOutline(o) {
190
200
  const e = [];
191
- if (n !== "") {
192
- const t = this.junctionList.get(n);
201
+ if (o !== "") {
202
+ const t = this.junctionList.get(o);
193
203
  if (t) {
194
204
  const s = t.getJunctionOutline();
195
205
  e.push({
196
- junctionId: n,
206
+ junctionId: o,
197
207
  name: t.name,
198
208
  outline: s
199
209
  });
200
210
  }
201
211
  } else
202
212
  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({
213
+ const s = t[0], n = t[1], i = n.getJunctionOutline();
214
+ i.length <= 4 ? console.log(i, s) : e.push({
205
215
  junctionId: s,
206
- name: i.name,
207
- outline: o
216
+ name: n.name,
217
+ outline: i
208
218
  });
209
219
  }
210
220
  return { status: 0, result: e, message: "ok" };
@@ -214,44 +224,44 @@ class u {
214
224
  * @param laneInfo
215
225
  * @returns
216
226
  */
217
- getLaneLink(n) {
218
- const e = this.getLane(n);
227
+ getLaneLink(o) {
228
+ const e = this.getLane(o);
219
229
  return e ? { status: 0, result: e.getLink(), message: "ok" } : { status: -1, message: "车道信息错误" };
220
230
  }
221
- getRoadLink(n) {
231
+ getRoadLink(o) {
222
232
  const e = [];
223
- if (n !== "") {
224
- const t = this.roadList.get(n);
233
+ if (o !== "") {
234
+ const t = this.roadList.get(o);
225
235
  t && e.push({
226
- roadId: n,
236
+ roadId: o,
227
237
  successor: t.successor,
228
238
  predecessor: t.predecessor
229
239
  });
230
240
  } else
231
241
  [...this.roadList.values()].forEach((s) => {
232
242
  e.push({
233
- roadId: n,
243
+ roadId: o,
234
244
  successor: s.successor,
235
245
  predecessor: s.predecessor
236
246
  });
237
247
  });
238
248
  return { status: 0, result: e, message: "ok" };
239
249
  }
240
- getConnectionLink(n) {
250
+ getConnectionLink(o) {
241
251
  const e = [];
242
252
  for (const t of this.junctionList) {
243
- const s = t[0], i = t[1];
244
- if ((n === "" || s === n) && (e.push({
253
+ const s = t[0], n = t[1];
254
+ if ((o === "" || s === o) && (e.push({
245
255
  id: s,
246
- name: i.name,
247
- links: i.laneLinks
248
- }), n !== ""))
256
+ name: n.name,
257
+ links: n.laneLinks
258
+ }), o !== ""))
249
259
  break;
250
260
  }
251
261
  return { status: 0, result: e, message: "ok" };
252
262
  }
253
- getLaneAngle(n) {
254
- const e = this.getLane(n);
263
+ getLaneAngle(o) {
264
+ const e = this.getLane(o);
255
265
  if (e) {
256
266
  const t = e.drivingAngle;
257
267
  if (t)
@@ -259,28 +269,28 @@ class u {
259
269
  }
260
270
  return { status: -1, message: "车道信息错误" };
261
271
  }
262
- getTurnArrow(n) {
263
- const e = this.getLane(n.incoming);
272
+ getTurnArrow(o) {
273
+ const e = this.getLane(o.incoming);
264
274
  if (!e)
265
275
  return { status: -1, message: "进口道信息错误" };
266
276
  const t = e.drivingAngle;
267
277
  if (!t)
268
278
  return { status: -1, message: "进口道信息错误" };
269
- const s = this.getLane(n.outgoing);
279
+ const s = this.getLane(o.outgoing);
270
280
  if (!s)
271
281
  return { status: -1, message: "出口道信息错误" };
272
- const i = s.drivingAngle;
273
- if (!i)
282
+ const n = s.drivingAngle;
283
+ if (!n)
274
284
  return { status: -1, message: "出口道信息错误" };
275
- let o = i - t;
276
- o > 180 ? o -= 360 : o < -180 && (o += 360);
285
+ let i = n - t;
286
+ i > 180 ? i -= 360 : i < -180 && (i += 360);
277
287
  let r = "";
278
- return -45 < o && o < 45 ? r = "s" : 45 <= o && o <= 135 ? r = "r" : -135 <= o && o <= -45 ? r = "l" : r = "t", {
288
+ return -45 < i && i < 45 ? r = "s" : 45 <= i && i <= 135 ? r = "r" : -135 <= i && i <= -45 ? r = "l" : r = "t", {
279
289
  status: 0,
280
290
  message: "ok",
281
291
  result: {
282
292
  incomingAngle: t,
283
- outgoingAngle: i,
293
+ outgoingAngle: n,
284
294
  direction: r
285
295
  }
286
296
  };
@@ -310,16 +320,16 @@ class u {
310
320
  * @param laneId
311
321
  * @returns
312
322
  */
313
- getPolygon(n, e, t) {
314
- const s = this.roadList.get(n);
323
+ getPolygon(o, e, t) {
324
+ const s = this.roadList.get(o);
315
325
  if (!s)
316
326
  return { status: -1, message: "道路id错误" };
317
327
  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: "车道信息错误" };
328
+ const n = this.getLane({ roadId: o, sectionId: e, laneId: t });
329
+ return n ? { status: 0, message: "ok", result: n.ring } : { status: -1, message: "车道信息错误" };
320
330
  } else if (e !== void 0 && !isNaN(e)) {
321
- const i = s.getLaneSection(e);
322
- return i ? { status: 0, message: "ok", result: i.polygon } : { status: -1, message: "路段信息错误" };
331
+ const n = s.getLaneSection(e);
332
+ return n ? { status: 0, message: "ok", result: n.polygon } : { status: -1, message: "路段信息错误" };
323
333
  } else
324
334
  return { status: 0, message: "ok", result: s.polygon };
325
335
  }
@@ -328,8 +338,8 @@ class u {
328
338
  * @param laneInfo
329
339
  * @returns
330
340
  */
331
- getLaneLength(n) {
332
- const e = this.getLane(n);
341
+ getLaneLength(o) {
342
+ const e = this.getLane(o);
333
343
  if (e) {
334
344
  let t = 0;
335
345
  return e.road.isLastLaneSection(e.laneSection.s0) ? t = e.road.length - e.laneSection.s0 : t = e.road.getNextLaneSection(
@@ -342,33 +352,73 @@ class u {
342
352
  } else
343
353
  return { status: -1, message: "车道信息错误" };
344
354
  }
345
- getRoadStopLine(n) {
355
+ getRoadStopLine(o) {
346
356
  const e = [];
347
357
  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 });
358
+ const s = t[0], n = t[1];
359
+ if (s === o) {
360
+ const i = n.getRoadStopLine();
361
+ e.push({ junctionId: s, stopLines: i });
352
362
  break;
353
- } else if (n === "") {
354
- const o = i.getRoadStopLine();
355
- e.push({ junctionId: s, stopLines: o });
363
+ } else if (o === "") {
364
+ const i = n.getRoadStopLine();
365
+ e.push({ junctionId: s, stopLines: i });
356
366
  }
357
367
  }
358
368
  return { status: 0, message: "ok", result: e };
359
369
  }
360
- getLaneStopLine(n) {
361
- const e = this.getLane(n);
370
+ getLaneStopLine(o) {
371
+ const e = this.getLane(o);
362
372
  return e ? { status: 0, message: "ok", result: e.getStopLine() } : { status: -1, message: "车道信息错误" };
363
373
  }
364
- getLaneCenterLine(n) {
365
- const e = this.getLane(n);
374
+ getLaneCenterLine(o) {
375
+ const e = this.getLane(o);
366
376
  return e ? {
367
377
  status: 0,
368
378
  message: "ok",
369
379
  result: e.getLaneEndPoints("middle")
370
380
  } : { status: -1, message: "车道信息错误" };
371
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
+ }
372
422
  }
373
423
  export {
374
424
  u as default
@@ -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
+ }
@@ -66,9 +66,9 @@ 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;
69
+ static geoReference: string;
70
+ static xOffset: number;
71
+ static yOffset: number;
72
72
  static setGeoData(geoReference: string, xOffset: number, yOffset: number): void;
73
73
  /**
74
74
  * OpenDrive坐标转换为WGS84坐标
@@ -76,6 +76,7 @@ export default class CommonUtils {
76
76
  * @returns
77
77
  */
78
78
  static transformLineProjection(line: number[][]): number[][];
79
+ static transformPointProjection(point: number[]): number[];
79
80
  static pointsEqual(point1: number[], point2: number[]): boolean;
80
81
  static getExtensionLine(pt1: number[], pt2: number[], distance: number): turf.Position;
81
82
  }
@@ -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"),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
+ "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;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("@arcgis/core/Basemap"),z=require("@arcgis/core/Map"),b=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),O=require("@arcgis/core/geometry/support/webMercatorUtils"),S=require("@arcgis/core/layers/GeoJSONLayer"),W=require("@arcgis/core/layers/TileLayer"),x=require("@arcgis/core/layers/WebTileLayer"),L=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.js");function v(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:()=>r[i]})}}return e.default=r,Object.freeze(e)}const T=v(q),p=v(O),G=v(I);function y(r,e){return r.startsWith("http://")||r.startsWith("https://")?r:e+r}class N{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){const i=_.default.useAppDataStore,t=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=t;const{container:o,markerClickCallback:n,mapClickCallback:f}=e;b.assetsPath=`${t.assetsRoot}/ArcgisAssets`,b.fontsUrl=`${t.assetsRoot}/fonts`,b.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const l=new z;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new L({map:l,container:o,...t.mapOptions}):this.view=new R({map:l,container:o,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...t==null?void 0:t.mapOptions}),this.view.on("click",async s=>{var M,P;if(f){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),f([a.x,a.y],[s.screenPoint.x,s.screenPoint.y],s)}if(this.view.type==="3d"){const a=this.view.camera;if(this.view.spatialReference.isWebMercator){const u=p.webMercatorToGeographic(a.position),d={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(d),(M=navigator.clipboard)==null||M.writeText(JSON.stringify(d))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom})}const h=(P=(await this.view.hitTest(s)).results)==null?void 0:P.filter(a=>a.type==="graphic");h.length>0&&h.forEach(a=>{var d;const u=a.graphic;(d=u.attributes)!=null&&d.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),t!=null&&t.baseLayers?t.baseLayers.forEach(s=>{switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const c=y(s.url,t.assetsRoot),h=new x({urlTemplate:c,...s.options});l.add(h);break}case"tile":{const c=y(s.url,t.assetsRoot),h=new W({url:c,...s.options});l.add(h);break}case"arcgis":{const c=new k(s.options);l.basemap=c;break}}}):l.basemap=new k({style:{id:"arcgis/dark-gray",language:"zh-CN"}}),t!=null&&t.hdLayers){const s=t.hdLayers.map(c=>new S({url:y(c.url,t.assetsRoot),...c.options,title:c.options.id}));l.addMany(s)}this.view.ui.remove("attribution"),this.view.ui.add("compass","top-left"),await this.view.when();const w=this.mapConfig.camera;let m;if(this.view.type==="2d"){let s=this.view.center;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={position:s,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return w?w.home=m:this.mapConfig.camera={home:m},this.view}setLayerVisibility(e){const{id:i,visible:t}=e,o=this.view.map.findLayerById(i);return o?(o.visible=t,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type){case"point":e.target=new g.Point(e.target);break;case"polyline":e.target=new g.Polyline(e.target);break;case"polygon":e.target=new g.Polygon(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,t=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:t,tilt:0},{duration:(e.duration||2)*1e3});else{const o=Math.tan(i*Math.PI/180)*e.height,n=H(G.point(e.center),o,t+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:t,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:t=0}=e,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const n=o[i];return n?(await this.view.goTo(n,{duration:t*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let t=0;const n=1e3/30,f=T.watch(()=>this.view.center,()=>{const l=this.transformPoints(e),w=Date.now();w-t>n&&(i(l),t=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const t=new g.Point({x:i[0],y:i[1]}),o=this.view.toScreen(t);return[o.x,o.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:t}=e;!i&&!t||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),t&&o>=t&&(this.view.zoom=t)}))}}exports.default=N;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),y=require("@arcgis/core/config"),z=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/support/webMercatorUtils"),O=require("@arcgis/core/layers/GeoJSONLayer"),S=require("@arcgis/core/layers/TileLayer"),W=require("@arcgis/core/layers/WebTileLayer"),x=require("@arcgis/core/Map"),L=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.js");function b(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:()=>r[i]})}}return e.default=r,Object.freeze(e)}const k=b(z),p=b(q),C=b(I);function T(r,e){return r&&(r.startsWith("http://")||r.startsWith("https://")?r:e+r)}class G{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){const i=_.default.useAppDataStore,t=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=t;const{container:o,markerClickCallback:n,mapClickCallback:f}=e;y.assetsPath=`${t.assetsRoot}/ArcgisAssets`,y.fontsUrl=`${t.assetsRoot}/fonts`,y.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const c=new x;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new L({map:c,container:o,...t.mapOptions}):this.view=new R({map:c,container:o,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...t==null?void 0:t.mapOptions}),this.view.on("click",async s=>{var v,M;if(f){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),f([a.x,a.y],[s.screenPoint.x,s.screenPoint.y],s)}if(this.view.type==="3d"){const a=this.view.camera;if(this.view.spatialReference.isWebMercator){const u=p.webMercatorToGeographic(a.position),d={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(d),(v=navigator.clipboard)==null||v.writeText(JSON.stringify(d))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom})}const l=(M=(await this.view.hitTest(s)).results)==null?void 0:M.filter(a=>a.type==="graphic");l.length>0&&l.forEach(a=>{var d;const u=a.graphic;(d=u.attributes)!=null&&d.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),t!=null&&t.baseLayers?t.baseLayers.forEach(s=>{const h=T(s.url,t.assetsRoot);switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const l=new W({urlTemplate:h,...s.options});c.add(l);break}case"tile":{const l=new S({url:h,...s.options});c.add(l);break}case"arcgis":{const l=new P(s.options);c.basemap=l;break}}}):c.basemap=new P({style:{id:"arcgis/dark-gray",language:"zh-CN"}}),t!=null&&t.hdLayers){const s=t.hdLayers.map(h=>new O({url:T(h.url,t.assetsRoot),...h.options,title:h.options.id}));c.addMany(s)}this.view.ui.remove("attribution"),this.view.ui.add("compass","top-left"),await this.view.when();const w=this.mapConfig.camera;let m;if(this.view.type==="2d"){let s=this.view.center;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={position:s,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return w?w.home=m:this.mapConfig.camera={home:m},this.view}setLayerVisibility(e){const{id:i,visible:t}=e,o=this.view.map.findLayerById(i);return o?(o.visible=t,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type){case"point":e.target=new g.Point(e.target);break;case"polyline":e.target=new g.Polyline(e.target);break;case"polygon":e.target=new g.Polygon(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,t=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:t,tilt:0},{duration:(e.duration||2)*1e3});else{const o=Math.tan(i*Math.PI/180)*e.height,n=H(C.point(e.center),o,t+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:t,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:t=0}=e,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const n=o[i];return n?(await this.view.goTo(n,{duration:t*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let t=0;const n=1e3/30,f=k.watch(()=>this.view.center,()=>{const c=this.transformPoints(e),w=Date.now();w-t>n&&(i(c),t=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const t=new g.Point({x:i[0],y:i[1]}),o=this.view.toScreen(t);return[o.x,o.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:t}=e;!i&&!t||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=k.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),t&&o>=t&&(this.view.zoom=t)}))}}exports.default=G;
@@ -1,8 +1,7 @@
1
- import View from '@arcgis/core/views/View';
2
1
  import { IFindSumoParams, IResult, IShowOpenDriveFromFileParams, ISplitOpenDriveLaneParams } from '../../../types';
3
2
  export default class OpenDriveRenderer {
4
3
  private static instance;
5
- static getInstance(view: View): OpenDriveRenderer;
4
+ static getInstance(view: __esri.MapView | __esri.SceneView): OpenDriveRenderer;
6
5
  private readonly view;
7
6
  private laneLayer;
8
7
  private roadNameLayer;
@@ -10,8 +9,12 @@ export default class OpenDriveRenderer {
10
9
  private highlightLayer;
11
10
  private allLaneGraphics;
12
11
  private allRefLineGraphics;
12
+ private mouseMoveHandler;
13
+ private mouseClickHandler;
13
14
  private wasmLoader;
14
- constructor(view: View);
15
+ constructor(view: __esri.MapView | __esri.SceneView);
16
+ private projectName;
17
+ private openDriveServer;
15
18
  showOpenDriveFromFile(params: IShowOpenDriveFromFileParams): Promise<IResult>;
16
19
  /**
17
20
  * 从服务器载入OpenDrive文件解析结果并显示
@@ -21,6 +24,23 @@ export default class OpenDriveRenderer {
21
24
  showOpenDriveFromServer(server: string, projectName: string): Promise<IResult>;
22
25
  private showAllLanes;
23
26
  private showJunction;
27
+ private currentSectionCode;
28
+ private currentJunctionId;
29
+ private hitGraphic;
30
+ private highlightGraphic;
31
+ /**
32
+ * 监听鼠标移动事件,高亮显示鼠标所在路段和路口
33
+ */
34
+ private monitorMouseMove;
35
+ /**
36
+ * 监听鼠标点击事件,获取高亮要素的拓扑信息
37
+ */
38
+ private monitorMouseClick;
39
+ private increasePictureMarkerSize;
40
+ private decreasePictureMarkerSize;
41
+ /**
42
+ * 清除OpenDrive内容
43
+ */
24
44
  clearOpenDrive(): Promise<void>;
25
45
  /**
26
46
  * 用sumo的id定位车道、基本段、路段