gisviewer-vue3-arcgis 1.0.144 → 1.0.145

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,21 +1,23 @@
1
- import m from "@arcgis/core/Graphic";
2
- import * as k from "@arcgis/core/core/promiseUtils";
3
- import { Polygon as O } from "@arcgis/core/geometry";
1
+ import y from "@arcgis/core/Graphic";
2
+ import * as D from "@arcgis/core/core/promiseUtils";
3
+ import { Polygon as S } from "@arcgis/core/geometry";
4
4
  import * as L from "@arcgis/core/geometry/geometryEngine";
5
- import S from "@arcgis/core/layers/FeatureLayer";
6
- import w from "@arcgis/core/layers/GraphicsLayer";
7
- import y from "axios";
8
- import F from "md5";
9
- import j from "pako";
10
- import { watch as $ } from "vue";
11
- import M from "../../stores/index.mjs";
12
- import G from "../common-utils.mjs";
13
- class A {
5
+ import k from "@arcgis/core/layers/FeatureLayer";
6
+ import I from "@arcgis/core/layers/GraphicsLayer";
7
+ import * as G from "@turf/helpers";
8
+ import { lineSliceAlong as C } from "@turf/line-slice-along";
9
+ import b from "axios";
10
+ import P from "md5";
11
+ import O from "pako";
12
+ import { watch as x } from "vue";
13
+ import J from "../../stores/index.mjs";
14
+ import F from "../common-utils.mjs";
15
+ class $ {
14
16
  constructor(e) {
15
17
  this.junctionNames = /* @__PURE__ */ new Map(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = e, this.view.popup.visibleElements = {
16
18
  collapseButton: !1,
17
19
  actionBar: !1
18
- }, this.laneLayer = new S({
20
+ }, this.laneLayer = new k({
19
21
  id: "OpenDriveLane",
20
22
  fields: [
21
23
  {
@@ -233,7 +235,7 @@ class A {
233
235
  }
234
236
  ]
235
237
  }
236
- }), this.roadNameLayer = new S({
238
+ }), this.roadNameLayer = new k({
237
239
  id: "OpenDriveRoadName",
238
240
  fields: [
239
241
  {
@@ -283,25 +285,26 @@ class A {
283
285
  }
284
286
  }
285
287
  ]
286
- }), this.junctionLayer = new w({ id: "OpenDriveJunction" }), this.sectionLayer = new w({ id: "OpenDriveSection" }), this.highlightLayer = new w({ id: "OpenDriveHighlight" }), this.flashLayer = new w({ id: "OpenDriveFlash" }), this.drawLayer = new w({ id: "Draw" }), this.view.map.addMany([
288
+ }), this.junctionLayer = new I({ id: "OpenDriveJunction" }), this.sectionLayer = new I({ id: "OpenDriveSection" }), this.highlightLayer = new I({ id: "OpenDriveHighlight" }), this.flashLayer = new I({ id: "OpenDriveFlash" }), this.drawLayer = new I({ id: "Draw" }), this.splitLaneLayer = new I({ id: "SplitLane" }), this.view.map.addMany([
287
289
  this.laneLayer,
288
290
  this.junctionLayer,
289
291
  this.sectionLayer,
290
292
  this.roadNameLayer,
291
293
  this.highlightLayer,
292
294
  this.flashLayer,
293
- this.drawLayer
295
+ this.drawLayer,
296
+ this.splitLaneLayer
294
297
  ]);
295
298
  }
296
299
  static getInstance(e) {
297
- return this.instance || (this.instance = new A(e)), this.instance;
300
+ return this.instance || (this.instance = new $(e)), this.instance;
298
301
  }
299
302
  async makeMd5FromFile(e) {
300
303
  try {
301
- const t = await (await fetch(e)).text();
302
- return { status: 0, message: "ok", result: F(t) };
303
- } catch (i) {
304
- return { status: -1, message: i.message };
304
+ const i = await (await fetch(e)).text();
305
+ return { status: 0, message: "ok", result: P(i) };
306
+ } catch (t) {
307
+ return { status: -1, message: t.message };
305
308
  }
306
309
  }
307
310
  /**
@@ -310,17 +313,17 @@ class A {
310
313
  * @returns
311
314
  */
312
315
  async showOpenDriveFromFile(e) {
313
- var h, p;
316
+ var g, m;
314
317
  this.openDriveClickCallback = e.selectedCallback, console.time("md5用时");
315
- const i = await this.makeMd5FromFile(e.file);
316
- if (i.status !== 0)
317
- return i;
318
- this.projectName = i.result, console.timeEnd("md5用时"), this.openDriveServer = e.server, await this.makeMd5FromFile(e.file);
319
- const t = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
318
+ const t = await this.makeMd5FromFile(e.file);
319
+ if (t.status !== 0)
320
+ return t;
321
+ this.projectName = t.result, console.timeEnd("md5用时"), this.openDriveServer = e.server, await this.makeMd5FromFile(e.file);
322
+ const i = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
320
323
  let o;
321
324
  try {
322
- o = await y.post(
323
- t,
325
+ o = await b.post(
326
+ i,
324
327
  {},
325
328
  {
326
329
  params: {
@@ -329,42 +332,50 @@ class A {
329
332
  }
330
333
  }
331
334
  );
332
- } catch (d) {
333
- return { status: -1, message: d.message };
335
+ } catch (u) {
336
+ return { status: -1, message: u.message };
334
337
  }
335
338
  if (o.status !== 200)
336
339
  return { status: -1, message: o.statusText };
337
340
  console.time("渲染用时");
338
341
  const s = o.data.result.geoSetting;
339
- G.setGeoData(
342
+ F.setGeoData(
340
343
  s.geoReference,
341
344
  s.offsetX,
342
345
  s.offsetY
343
346
  );
344
- let n = o.data.result.json;
345
- n.startsWith(window.location.protocol) || (n = `${window.location.protocol}//${e.server}${n}`);
346
- const r = await (await fetch(n)).arrayBuffer(), a = j.inflate(r, { to: "string" }), c = JSON.parse(a);
347
+ let c = o.data.result.json;
348
+ c.startsWith(window.location.protocol) || (c = `${window.location.protocol}//${e.server}${c}`);
349
+ const l = await (await fetch(c)).arrayBuffer(), r = O.inflate(l, { to: "string" }), n = JSON.parse(r);
347
350
  await this.showAllLanes(
348
- c,
349
- ((h = e.options) == null ? void 0 : h.showJunctionLane) || !1,
350
- ((p = e.options) == null ? void 0 : p.showRoadName) || !0
351
+ n,
352
+ ((g = e.options) == null ? void 0 : g.showJunctionLane) || !1,
353
+ ((m = e.options) == null ? void 0 : m.showRoadName) || !0
351
354
  );
352
- const g = o.data.result.junctions;
353
- if (this.showJunction(g), e.options && e.options.centerMap !== !1) {
354
- const d = G.transformPointProjection([0, 0]);
355
- await this.view.goTo(d);
355
+ const h = o.data.result.junctions;
356
+ if (this.showJunction(h), e.options && e.options.centerMap !== !1) {
357
+ const u = F.transformPointProjection([0, 0]);
358
+ await this.view.goTo(u);
356
359
  }
357
- return this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick(), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
360
+ this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
361
+ const d = J.useAppDataStore;
362
+ return x(
363
+ () => d.isSketching,
364
+ () => {
365
+ var u, p;
366
+ d.isSketching ? ((u = this.mouseMoveHandler) == null || u.remove(), this.mouseMoveHandler = void 0, (p = this.mouseClickHandler) == null || p.remove(), this.mouseClickHandler = void 0) : (this.monitorMouseMove(), this.monitorMouseClick());
367
+ }
368
+ ), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
358
369
  }
359
370
  /**
360
371
  * 从服务器载入OpenDrive文件解析结果并显示
361
372
  * @param server
362
373
  * @param projectName
363
374
  */
364
- async showOpenDriveFromServer(e, i) {
365
- const t = `http://${e}/api/openDrive/analyzeXodr`, o = await y.get(t, {
375
+ async showOpenDriveFromServer(e, t) {
376
+ const i = `http://${e}/api/openDrive/analyzeXodr`, o = await b.get(i, {
366
377
  headers: {
367
- projectName: i
378
+ projectName: t
368
379
  },
369
380
  params: {
370
381
  analyze: !1,
@@ -375,8 +386,8 @@ class A {
375
386
  throw new Error(`OpenDriveRenderer: ${o.statusText}`);
376
387
  let s = o.data.result.json;
377
388
  s.startsWith(window.location.protocol) || (s = `${window.location.protocol}//${e}${s}`);
378
- const l = await (await fetch(s)).arrayBuffer(), r = j.inflate(l, { to: "string" }), a = JSON.parse(r);
379
- return await this.showAllLanes(a, !1, !1), { status: 0, message: "ok" };
389
+ const a = await (await fetch(s)).arrayBuffer(), l = O.inflate(a, { to: "string" }), r = JSON.parse(l);
390
+ return await this.showAllLanes(r, !1, !1), { status: 0, message: "ok" };
380
391
  }
381
392
  /**
382
393
  * 显示所有车道
@@ -385,87 +396,90 @@ class A {
385
396
  * @param showRoadName 是否显示道路名称
386
397
  * @returns
387
398
  */
388
- async showAllLanes(e, i, t) {
399
+ async showAllLanes(e, t, i) {
389
400
  const o = await this.laneLayer.queryFeatures();
390
401
  return o.features.length > 0 && this.laneLayer.applyEdits({
391
402
  deleteFeatures: o.features
392
- }), this.roadNameLayer.visible = t, new Promise((s) => {
393
- let n = 0;
403
+ }), this.roadNameLayer.visible = i, new Promise((s) => {
404
+ let c = 0;
394
405
  this.allLaneGraphics = [], this.allRefLineGraphics = [];
395
- const l = [];
396
- for (const a of e) {
397
- if (!i && a.junction !== "-1")
406
+ const a = [];
407
+ for (const r of e) {
408
+ if (!t && r.junction !== "-1")
398
409
  continue;
399
- const { id: c, refLine: g } = a;
400
- let h = a.name;
401
- h.includes("(") && (h = h.slice(0, h.indexOf("("))), h = h.replace(/(.)/g, "$1 ");
402
- const p = new m({
410
+ const { id: n, refLine: h } = r;
411
+ let d = r.name;
412
+ d.includes("(") && (d = d.slice(0, d.indexOf("("))), d = d.replace(/(.)/g, "$1 ");
413
+ const g = new y({
403
414
  geometry: {
404
415
  type: "polyline",
405
- paths: [g]
416
+ paths: [h]
406
417
  },
407
418
  attributes: {
408
- ObjectID: n++,
409
- roadId: c,
410
- roadName: h
419
+ ObjectID: c++,
420
+ roadId: n,
421
+ roadName: d
411
422
  }
412
423
  });
413
- this.allRefLineGraphics.push(p), a.laneSections.sort((d, f) => Number(d.id) - Number(f.id));
414
- for (let d = 0; d < a.laneSections.length; d++) {
415
- const f = a.laneSections[d], b = Number(f.id);
416
- for (const u of f.lanePaths) {
417
- const v = Number(u.id);
418
- if (v === 0)
424
+ this.allRefLineGraphics.push(g), r.laneSections.sort((m, u) => Number(m.id) - Number(u.id));
425
+ for (let m = 0; m < r.laneSections.length; m++) {
426
+ const u = r.laneSections[m], p = Number(u.id);
427
+ for (const f of u.lanePaths) {
428
+ const w = Number(f.id);
429
+ if (w === 0)
419
430
  continue;
420
- const C = u.type, I = u.innerPath.concat(
421
- u.outerPath.reverse()
431
+ const v = f.type, M = [...f.outerPath], N = f.innerPath.concat(
432
+ M.reverse()
422
433
  );
423
- if (I.length <= 3) {
424
- console.warn(`lane ${v} has less than 3 points`);
434
+ if (N.length <= 3) {
435
+ console.warn(`lane ${w} has less than 3 points`);
425
436
  continue;
426
437
  }
427
- I.push(u.innerPath[0]);
428
- const N = new O({
429
- rings: [I]
438
+ N.push(f.innerPath[0]);
439
+ const A = new S({
440
+ rings: [N]
430
441
  });
431
- if (N) {
432
- const D = new m({
433
- geometry: N,
442
+ if (A) {
443
+ const j = new y({
444
+ geometry: A,
434
445
  attributes: {
435
- ObjectID: n++,
436
- id: `${c}+${b}+${v}`,
437
- fromNode: a.fromNode,
438
- toNode: a.toNode,
439
- roadId: c,
440
- roadName: a.name,
441
- sectionId: b,
442
- sectionIndex: d,
443
- laneId: v,
444
- type: C,
445
- sumoId: ""
446
+ ObjectID: c++,
447
+ id: `${n}+${p}+${w}`,
448
+ fromNode: r.fromNode,
449
+ toNode: r.toNode,
450
+ roadId: String(n),
451
+ roadName: r.name,
452
+ sectionId: String(p),
453
+ sectionIndex: m,
454
+ laneId: w,
455
+ type: v,
456
+ sumoId: "",
457
+ // 记录左右边线的起始点,用于按长度高亮车道的一部分
458
+ leftLine: f.innerPath,
459
+ rightLine: f.outerPath
446
460
  }
447
461
  });
448
- this.allLaneGraphics.push(D), l.push(D);
462
+ this.allLaneGraphics.push(j), a.push(j);
449
463
  }
450
464
  }
451
465
  }
452
466
  }
453
- const r = setInterval(() => {
454
- if (l.length > 0 || this.allRefLineGraphics.length > 0) {
455
- if (l.length > 0) {
456
- const a = l.splice(0, 100);
467
+ const l = setInterval(() => {
468
+ if (a.length > 0 || this.allRefLineGraphics.length > 0) {
469
+ if (a.length > 0) {
470
+ const r = a.splice(0, 100);
457
471
  this.laneLayer.applyEdits({
458
- addFeatures: a
472
+ addFeatures: r
459
473
  });
460
474
  }
461
475
  if (this.allRefLineGraphics.length > 0) {
462
- const a = this.allRefLineGraphics.splice(0, 10);
476
+ const r = this.allRefLineGraphics.splice(0, 10);
463
477
  this.roadNameLayer.applyEdits({
464
- addFeatures: a
478
+ addFeatures: r
465
479
  });
466
480
  }
467
481
  } else
468
- clearInterval(r), s();
482
+ clearInterval(l), s();
469
483
  }, 10);
470
484
  });
471
485
  }
@@ -475,30 +489,30 @@ class A {
475
489
  * @returns
476
490
  */
477
491
  showJunction(e) {
478
- const i = [];
479
- for (const t of e) {
480
- if (!t)
492
+ const t = [];
493
+ for (const i of e) {
494
+ if (!i)
481
495
  continue;
482
- this.junctionNames.set(t.id, t.name), t.nodeType = t.type;
483
- const o = new m({
496
+ this.junctionNames.set(i.id, i.name), i.nodeType = i.type;
497
+ const o = new y({
484
498
  geometry: {
485
499
  type: "point",
486
- x: t.coordinates[0],
487
- y: t.coordinates[1]
500
+ x: i.coordinates[0],
501
+ y: i.coordinates[1]
488
502
  },
489
503
  attributes: {
490
- ...t,
504
+ ...i,
491
505
  selected: !1,
492
506
  type: "OpenDriveJunction"
493
507
  },
494
508
  symbol: {
495
509
  type: "picture-marker",
496
- url: t.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
510
+ url: i.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
497
511
  width: 30,
498
512
  height: 30
499
513
  },
500
514
  popupTemplate: {
501
- title: t.name,
515
+ title: i.name,
502
516
  content: [
503
517
  {
504
518
  type: "fields",
@@ -516,42 +530,42 @@ class A {
516
530
  ]
517
531
  }
518
532
  });
519
- i.push(o);
533
+ t.push(o);
520
534
  }
521
- this.junctionLayer.addMany(i);
535
+ this.junctionLayer.addMany(t);
522
536
  }
523
537
  /**
524
538
  * 监听鼠标移动事件,高亮显示鼠标所在路段和路口
525
539
  */
526
540
  monitorMouseMove() {
527
- const e = k.debounce(async (t) => {
528
- var l;
529
- const s = (l = (await this.view.hitTest(t, {
541
+ const e = D.debounce(async (t) => {
542
+ var c;
543
+ const o = (c = (await this.view.hitTest(t, {
530
544
  include: [this.laneLayer, this.junctionLayer]
531
- })).results) == null ? void 0 : l.filter(
532
- (r) => r.type === "graphic"
545
+ })).results) == null ? void 0 : c.filter(
546
+ (a) => a.type === "graphic"
533
547
  );
534
- if (s.length === 0) {
548
+ if (o.length === 0) {
535
549
  this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.view.closePopup());
536
550
  return;
537
551
  }
538
- const n = s[0];
539
- if (this.hitGraphic = n.graphic, n.layer.id === "OpenDriveLane") {
540
- const r = `${this.hitGraphic.getAttribute(
552
+ const s = o[0];
553
+ if (this.hitGraphic = s.graphic, s.layer.id === "OpenDriveLane") {
554
+ const a = `${this.hitGraphic.getAttribute(
541
555
  "roadId"
542
556
  )}+${this.hitGraphic.getAttribute("sectionId")}`;
543
- if (r === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
544
- (u) => u.getAttribute("id") === r
557
+ if (a === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
558
+ (p) => p.getAttribute("id") === a
545
559
  ) >= 0)
546
560
  return;
547
- this.currentSectionCode = r;
548
- const c = this.allLaneGraphics.filter(
549
- (u) => `${u.attributes.roadId}+${u.attributes.sectionId}` === r
550
- ), g = L.union(
551
- c.map((u) => u.geometry)
552
- ), h = this.hitGraphic.getAttribute("fromNode"), p = this.hitGraphic.getAttribute("toNode"), d = this.junctionNames.get(h) || h, f = this.junctionNames.get(p) || p;
553
- this.highlightGraphic = new m({
554
- geometry: g,
561
+ this.currentSectionCode = a;
562
+ const r = this.allLaneGraphics.filter(
563
+ (p) => `${p.attributes.roadId}+${p.attributes.sectionId}` === a
564
+ ), n = L.union(
565
+ r.map((p) => p.geometry)
566
+ ), h = this.hitGraphic.getAttribute("fromNode"), d = this.hitGraphic.getAttribute("toNode"), g = this.junctionNames.get(h) || h, m = this.junctionNames.get(d) || d;
567
+ this.highlightGraphic = new y({
568
+ geometry: n,
555
569
  symbol: {
556
570
  type: "simple-fill",
557
571
  color: [0, 255, 255, 0.5],
@@ -563,11 +577,11 @@ class A {
563
577
  },
564
578
  attributes: {
565
579
  type: "OpenDriveSection",
566
- id: r,
580
+ id: a,
567
581
  selected: !1,
568
- fromNodeName: d,
569
- toNodeName: f,
570
- laneCount: c.length
582
+ fromNodeName: g,
583
+ toNodeName: m,
584
+ laneCount: r.length
571
585
  },
572
586
  popupTemplate: {
573
587
  title: this.hitGraphic.getAttribute("roadName"),
@@ -592,16 +606,16 @@ class A {
592
606
  ]
593
607
  }
594
608
  }), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
595
- const b = this.view.toMap(t);
609
+ const u = this.view.toMap(t);
596
610
  this.view.openPopup({
597
611
  features: [this.highlightGraphic],
598
- location: b
612
+ location: u
599
613
  });
600
- } else if (n.layer.id === "OpenDriveJunction") {
601
- const r = this.hitGraphic.getAttribute("id");
602
- if (r === this.currentJunctionId)
614
+ } else if (s.layer.id === "OpenDriveJunction") {
615
+ const a = this.hitGraphic.getAttribute("id");
616
+ if (a === this.currentJunctionId)
603
617
  return;
604
- this.currentJunctionId = r, this.view.openPopup({
618
+ this.currentJunctionId = a, this.view.openPopup({
605
619
  features: [this.hitGraphic],
606
620
  location: this.hitGraphic.geometry
607
621
  });
@@ -611,81 +625,67 @@ class A {
611
625
  e(t).catch(() => {
612
626
  });
613
627
  });
614
- const i = M.useAppDataStore;
615
- $(
616
- () => i.isSketching,
617
- () => {
618
- var t;
619
- i.isSketching ? (t = this.mouseMoveHandler) == null || t.remove() : this.mouseMoveHandler = this.view.on(
620
- "pointer-move",
621
- async (o) => {
622
- e(o).catch(() => {
623
- });
624
- }
625
- );
626
- }
627
- );
628
628
  }
629
629
  /**
630
630
  * 监听鼠标点击事件,获取高亮要素的拓扑信息
631
631
  */
632
632
  monitorMouseClick() {
633
- const e = k.debounce(async (i) => {
634
- var r;
635
- const o = (r = (await this.view.hitTest(i, {
633
+ const e = D.debounce(async (t) => {
634
+ var l;
635
+ const o = (l = (await this.view.hitTest(t, {
636
636
  include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
637
- })).results) == null ? void 0 : r.filter(
638
- (a) => a.type === "graphic"
637
+ })).results) == null ? void 0 : l.filter(
638
+ (r) => r.type === "graphic"
639
639
  );
640
640
  if (o.length === 0)
641
641
  return;
642
- const s = o[0].graphic, n = s.getAttribute("type"), l = s.getAttribute("id");
643
- if (n === "OpenDriveJunction")
642
+ const s = o[0].graphic, c = s.getAttribute("type"), a = s.getAttribute("id");
643
+ if (c === "OpenDriveJunction")
644
644
  if (s.getAttribute("selected") === !1) {
645
- const a = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, c = await y.get(a, {
645
+ const r = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, n = await b.get(r, {
646
646
  params: {
647
- id: l,
647
+ id: a,
648
648
  projectName: this.projectName
649
649
  }
650
650
  });
651
- c.status === 200 && c.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
651
+ n.status === 200 && n.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
652
652
  type: "OpenDriveJunction",
653
- id: l,
654
- details: c.data.result
653
+ id: a,
654
+ details: n.data.result
655
655
  }), s.setAttribute("selected", !0), s.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(s, 50));
656
656
  } else {
657
657
  this.openDriveClickCallback && this.openDriveClickCallback({
658
658
  type: "OpenDriveJunction",
659
- id: l,
659
+ id: a,
660
660
  details: void 0
661
661
  }), s.setAttribute("selected", !1);
662
- const a = s.getAttribute("crossId");
663
- s.symbol.url = a ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(s, 30);
662
+ const r = s.getAttribute("crossId");
663
+ s.symbol.url = r ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(s, 30);
664
664
  }
665
- else if (n === "OpenDriveSection")
665
+ else if (c === "OpenDriveSection")
666
666
  if (s.getAttribute("selected"))
667
667
  this.sectionLayer.remove(s), this.openDriveClickCallback && this.openDriveClickCallback({
668
668
  type: "OpenDriveSection",
669
- id: l,
669
+ id: a,
670
670
  details: void 0
671
671
  });
672
672
  else {
673
673
  this.highlightLayer.remove(s), this.sectionLayer.add(s), s.setAttribute("selected", !0);
674
- const a = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, c = await y.get(a, {
674
+ const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, n = await b.get(r, {
675
675
  params: {
676
- id: l,
676
+ id: a,
677
677
  projectName: this.projectName
678
678
  }
679
679
  });
680
- c.status === 200 && c.data.status === 0 && this.openDriveClickCallback && (s.setAttribute("edgeId", c.data.result.obj_id), this.openDriveClickCallback({
680
+ n.status === 200 && n.data.status === 0 && this.openDriveClickCallback && (s.setAttribute("edgeId", n.data.result.obj_id), this.openDriveClickCallback({
681
681
  type: "OpenDriveSection",
682
- id: l,
683
- details: c.data.result
682
+ id: a,
683
+ details: n.data.result
684
684
  }));
685
685
  }
686
686
  });
687
- this.mouseClickHandler = this.view.on("immediate-click", async (i) => {
688
- e(i).catch(() => {
687
+ this.mouseClickHandler = this.view.on("immediate-click", async (t) => {
688
+ e(t).catch(() => {
689
689
  });
690
690
  });
691
691
  }
@@ -694,15 +694,15 @@ class A {
694
694
  * @param graphic
695
695
  * @param targetSize
696
696
  */
697
- increasePictureMarkerSize(e, i) {
698
- const t = setInterval(() => {
697
+ increasePictureMarkerSize(e, t) {
698
+ const i = setInterval(() => {
699
699
  const o = e.symbol, s = o.width;
700
- s < i ? e.symbol = {
700
+ s < t ? e.symbol = {
701
701
  type: "picture-marker",
702
702
  url: o.url,
703
703
  width: s + 1,
704
704
  height: s + 1
705
- } : clearInterval(t);
705
+ } : clearInterval(i);
706
706
  }, 20);
707
707
  }
708
708
  /**
@@ -710,47 +710,47 @@ class A {
710
710
  * @param graphic
711
711
  * @param targetSize
712
712
  */
713
- decreasePictureMarkerSize(e, i) {
714
- const t = setInterval(() => {
713
+ decreasePictureMarkerSize(e, t) {
714
+ const i = setInterval(() => {
715
715
  const o = e.symbol, s = o.width;
716
- s > i ? e.symbol = {
716
+ s > t ? e.symbol = {
717
717
  type: "picture-marker",
718
718
  url: o.url,
719
719
  width: s - 1,
720
720
  height: s - 1
721
- } : clearInterval(t);
721
+ } : clearInterval(i);
722
722
  }, 20);
723
723
  }
724
724
  async getSumoInfo(e) {
725
725
  switch (e.type) {
726
726
  case "junction": {
727
- const i = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, t = await y.get(i, {
727
+ const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, i = await b.get(t, {
728
728
  params: {
729
729
  id: e.id,
730
730
  projectName: this.projectName
731
731
  }
732
732
  });
733
- return t.status === 200 ? t.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
733
+ return i.status === 200 ? i.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
734
734
  }
735
735
  case "edge": {
736
- const i = e.id.split("#");
737
- let t = i[0];
738
- t.startsWith("-") && (t = t.slice(1));
736
+ const t = e.id.split("#");
737
+ let i = t[0];
738
+ i.startsWith("-") && (i = i.slice(1));
739
739
  let o = 0;
740
- i.length === 2 && (o = Number(i[1]));
740
+ t.length === 2 && (o = Number(t[1]));
741
741
  const s = this.allLaneGraphics.find(
742
- (n) => n.getAttribute("roadId") === t && n.getAttribute("sectionIndex") === o
742
+ (c) => c.getAttribute("roadId") === i && c.getAttribute("sectionIndex") === o
743
743
  );
744
744
  if (s) {
745
- const n = `${t}+${s.getAttribute(
745
+ const c = `${i}+${s.getAttribute(
746
746
  "sectionId"
747
- )}`, l = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, r = await y.get(l, {
747
+ )}`, a = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, l = await b.get(a, {
748
748
  params: {
749
- id: n,
749
+ id: c,
750
750
  projectName: this.projectName
751
751
  }
752
752
  });
753
- return r.status === 200 ? r.data : { status: -1, message: `路段信息查询失败: ${n}` };
753
+ return l.status === 200 ? l.data : { status: -1, message: `路段信息查询失败: ${c}` };
754
754
  } else
755
755
  return { status: -1, message: "未知类型" };
756
756
  }
@@ -762,13 +762,13 @@ class A {
762
762
  * 清除OpenDrive内容
763
763
  */
764
764
  async clearOpenDrive() {
765
- var i, t;
765
+ var t, i;
766
766
  let e = await this.laneLayer.queryFeatures();
767
767
  e.features.length > 0 && await this.laneLayer.applyEdits({
768
768
  deleteFeatures: e.features
769
769
  }), e = await this.roadNameLayer.queryFeatures(), e.features.length > 0 && await this.roadNameLayer.applyEdits({
770
770
  deleteFeatures: e.features
771
- }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), (i = this.mouseMoveHandler) == null || i.remove(), this.mouseMoveHandler = void 0, (t = this.mouseClickHandler) == null || t.remove(), this.mouseClickHandler = void 0;
771
+ }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), (t = this.mouseMoveHandler) == null || t.remove(), this.mouseMoveHandler = void 0, (i = this.mouseClickHandler) == null || i.remove(), this.mouseClickHandler = void 0;
772
772
  }
773
773
  /**
774
774
  * 用sumo的id定位车道、基本段、路段
@@ -776,30 +776,30 @@ class A {
776
776
  * @returns
777
777
  */
778
778
  async findSumo(e) {
779
- const { type: i, id: t } = e, o = e.flash === void 0 ? !0 : e.flash;
780
- if (i === "junction")
781
- return await this.findJunction(t, o);
782
- if (i === "edge") {
783
- const s = t.split("+");
779
+ const { type: t, id: i } = e, o = e.flash === void 0 ? !0 : e.flash;
780
+ if (t === "junction")
781
+ return await this.findJunction(i, o);
782
+ if (t === "edge") {
783
+ const s = i.split("+");
784
784
  if (s.length > 2)
785
785
  return { status: -1, message: "id格式错误" };
786
- const n = s.length === 2 ? Number(s[1]) : void 0, l = s[0].split("#");
787
- if (l.length > 2)
786
+ const c = s.length === 2 ? Number(s[1]) : void 0, a = s[0].split("#");
787
+ if (a.length > 2)
788
788
  return { status: -1, message: "id格式错误" };
789
- const r = l[0], a = l.length === 2 ? Number(l[1]) : void 0;
790
- return await this.findLane({ roadsectId: r, segmentId: a, laneId: n, flash: o });
789
+ const l = a[0], r = a.length === 2 ? Number(a[1]) : void 0;
790
+ return await this.findLane({ roadsectId: l, segmentId: r, laneId: c, flash: o });
791
791
  } else
792
792
  return { status: -1, message: "未知类型" };
793
793
  }
794
- async findJunction(e, i) {
795
- const t = this.junctionLayer.graphics.find(
794
+ async findJunction(e, t) {
795
+ const i = this.junctionLayer.graphics.find(
796
796
  (o) => o.attributes.id === e
797
797
  );
798
- if (!t)
798
+ if (!i)
799
799
  return { status: -1, message: "未找到。请检查路口编号" };
800
- if (i) {
801
- const o = new m({
802
- geometry: t.geometry,
800
+ if (t) {
801
+ const o = new y({
802
+ geometry: i.geometry,
803
803
  symbol: {
804
804
  type: "simple-marker",
805
805
  style: "circle",
@@ -813,7 +813,7 @@ class A {
813
813
  });
814
814
  this.flashGraphic(o);
815
815
  }
816
- return await this.view.goTo(t.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
816
+ return await this.view.goTo(i.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
817
817
  }
818
818
  /**
819
819
  * 用sumo的id定位车道、基本段、路段
@@ -821,41 +821,41 @@ class A {
821
821
  * @returns
822
822
  */
823
823
  async findLane(e) {
824
- let { roadsectId: i, segmentId: t, laneId: o } = e;
825
- i.startsWith("-") && (i = i.slice(1));
824
+ let { roadsectId: t, segmentId: i, laneId: o } = e;
825
+ t.startsWith("-") && (t = t.slice(1));
826
826
  let s = this.allLaneGraphics.filter(
827
- (r) => r.attributes.roadId === i
827
+ (l) => l.attributes.roadId === t
828
828
  );
829
829
  if (s.length === 0)
830
830
  return { status: -1, message: "未找到。请检查路段编号" };
831
- if (t !== void 0) {
832
- const r = [];
833
- if (s.forEach((a) => {
834
- const c = Number(a.attributes.sectionId);
835
- r.indexOf(c) === -1 && r.push(c);
836
- }), r.sort((a, c) => a - c), t > r.length - 1)
831
+ if (i !== void 0) {
832
+ const l = [];
833
+ if (s.forEach((r) => {
834
+ const n = Number(r.attributes.sectionId);
835
+ l.indexOf(n) === -1 && l.push(n);
836
+ }), l.sort((r, n) => r - n), i > l.length - 1)
837
837
  return { status: -1, message: "未找到。请检查基本段编号" };
838
- t = r[t], s = s.filter(
839
- (a) => Number(a.attributes.sectionId) === t
838
+ i = l[i], s = s.filter(
839
+ (r) => Number(r.attributes.sectionId) === i
840
840
  );
841
841
  }
842
842
  if (o !== void 0) {
843
- const r = [];
844
- if (s.forEach((a) => {
845
- const c = Number(a.attributes.laneId);
846
- r.indexOf(c) === -1 && r.push(c);
847
- }), r.sort((a, c) => a - c), o > r.length - 1)
843
+ const l = [];
844
+ if (s.forEach((r) => {
845
+ const n = Number(r.attributes.laneId);
846
+ l.indexOf(n) === -1 && l.push(n);
847
+ }), l.sort((r, n) => r - n), o > l.length - 1)
848
848
  return { status: -1, message: "未找到。请检查车道编号" };
849
- o = r[o], s = s.filter(
850
- (a) => Number(a.attributes.laneId) === o
849
+ o = l[o], s = s.filter(
850
+ (r) => Number(r.attributes.laneId) === o
851
851
  );
852
852
  }
853
- const n = s.map(
854
- (r) => r.geometry
855
- ), l = L.union(n);
853
+ const c = s.map(
854
+ (l) => l.geometry
855
+ ), a = L.union(c);
856
856
  if (e.flash) {
857
- const r = new m({
858
- geometry: l,
857
+ const l = new y({
858
+ geometry: a,
859
859
  symbol: {
860
860
  type: "simple-fill",
861
861
  color: [255, 0, 0, 0.5],
@@ -866,9 +866,9 @@ class A {
866
866
  }
867
867
  }
868
868
  });
869
- this.flashGraphic(r);
869
+ this.flashGraphic(l);
870
870
  }
871
- return await this.view.goTo(l, { duration: 1e3 }), { status: 0, message: "ok" };
871
+ return await this.view.goTo(a, { duration: 1e3 }), { status: 0, message: "ok" };
872
872
  }
873
873
  /**
874
874
  * graphic渐隐渐显闪烁
@@ -876,9 +876,9 @@ class A {
876
876
  */
877
877
  flashGraphic(e) {
878
878
  this.flashLayer.removeAll(), this.flashLayer.add(e);
879
- let i = 0, t = !0;
879
+ let t = 0, i = !0;
880
880
  const o = setInterval(() => {
881
- t ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (t = !1, i++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (t = !0)), i >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(o));
881
+ i ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (i = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (i = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(o));
882
882
  }, 10);
883
883
  }
884
884
  /**
@@ -887,20 +887,20 @@ class A {
887
887
  * @returns
888
888
  */
889
889
  unselectSumo(e) {
890
- if ((!e || e.type === "junction") && this.junctionLayer.graphics.forEach((i) => {
891
- if ((!e || !e.id || e.id === "" || e.id === i.getAttribute("id")) && i.getAttribute("selected")) {
892
- i.setAttribute("selected", !1);
893
- const t = i.getAttribute("crossId");
894
- i.symbol.url = t ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(i, 30);
890
+ if ((!e || e.type === "junction") && this.junctionLayer.graphics.forEach((t) => {
891
+ if ((!e || !e.id || e.id === "" || e.id === t.getAttribute("id")) && t.getAttribute("selected")) {
892
+ t.setAttribute("selected", !1);
893
+ const i = t.getAttribute("crossId");
894
+ t.symbol.url = i ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(t, 30);
895
895
  }
896
896
  }), !e || e.type === "edge")
897
897
  if (!e || !e.id || e.id === "")
898
898
  this.sectionLayer.removeAll();
899
899
  else {
900
- const i = this.sectionLayer.graphics.find(
901
- (t) => t.getAttribute("edgeId") === e.id
900
+ const t = this.sectionLayer.graphics.find(
901
+ (i) => i.getAttribute("edgeId") === e.id
902
902
  );
903
- i && this.sectionLayer.remove(i);
903
+ t && this.sectionLayer.remove(t);
904
904
  }
905
905
  return { status: 0, message: "ok" };
906
906
  }
@@ -912,24 +912,26 @@ class A {
912
912
  selectSumo(e) {
913
913
  switch (e.type) {
914
914
  case "junction":
915
- return this.junctionLayer.graphics.forEach((i) => {
916
- if (e.id === i.getAttribute("id"))
917
- return i.setAttribute("selected", !0), i.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(i, 50), { status: 0, message: "ok" };
915
+ return this.junctionLayer.graphics.forEach((t) => {
916
+ if (e.id === t.getAttribute("id"))
917
+ return t.setAttribute("selected", !0), t.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(t, 50), { status: 0, message: "ok" };
918
918
  }), { status: -1, message: "未找到路口" };
919
919
  case "edge": {
920
- const i = e.id.split("#");
921
- let t = i[0];
922
- t.startsWith("-") && (t = t.slice(1));
923
- let o = 0;
924
- i.length === 2 && (o = Number(i[1]));
925
- const s = this.allLaneGraphics.filter(
926
- (n) => n.getAttribute("roadId") === t && n.getAttribute("sectionIndex") === o
927
- );
928
- if (s.length > 0) {
929
- const n = L.union(
930
- s.map((r) => r.geometry)
931
- ), l = new m({
932
- geometry: n,
920
+ const t = e.id.split("#");
921
+ let i = String(t[0]);
922
+ i.startsWith("-") && (i = i.slice(1));
923
+ let o = "0";
924
+ t.length === 2 && (o = String(t[1]));
925
+ let s = [];
926
+ if (t.length === 1 ? s = this.allLaneGraphics.filter(
927
+ (c) => c.getAttribute("roadId") === i
928
+ ) : t.length === 2 && (s = this.allLaneGraphics.filter(
929
+ (c) => c.getAttribute("roadId") === i && c.getAttribute("sectionId") === o
930
+ )), s.length > 0) {
931
+ const c = L.union(
932
+ s.map((l) => l.geometry)
933
+ ), a = new y({
934
+ geometry: c,
933
935
  symbol: {
934
936
  type: "simple-fill",
935
937
  color: [0, 255, 255, 0.5],
@@ -945,7 +947,7 @@ class A {
945
947
  selected: !0
946
948
  }
947
949
  });
948
- return this.sectionLayer.add(l), { status: 0, message: "ok" };
950
+ return this.sectionLayer.add(a), { status: 0, message: "ok" };
949
951
  } else
950
952
  return { status: -1, message: "未找到路段" };
951
953
  }
@@ -953,10 +955,112 @@ class A {
953
955
  return { status: -1, message: "未知类型" };
954
956
  }
955
957
  }
958
+ async geometrySearch(e) {
959
+ const t = new S({
960
+ rings: [e]
961
+ }), i = await this.laneLayer.queryFeatures({
962
+ geometry: t,
963
+ outFields: ["*"]
964
+ }), o = [], s = [];
965
+ for (const l of i.features) {
966
+ const r = l.getAttribute("roadId"), n = l.getAttribute("sectionId"), h = `${r}#${n}`;
967
+ if (o.indexOf(h) === -1) {
968
+ o.push(h), this.selectSumo({
969
+ type: "edge",
970
+ id: h
971
+ });
972
+ const d = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, g = await b.get(d, {
973
+ params: {
974
+ id: `${r}+${n}`,
975
+ projectName: this.projectName
976
+ }
977
+ });
978
+ g.status === 200 && g.data.status === 0 && s.push(g.data.result);
979
+ }
980
+ }
981
+ const c = this.junctionLayer.graphics.filter((l) => {
982
+ const r = l.geometry;
983
+ return L.contains(t, r);
984
+ }), a = [];
985
+ for (const l of c) {
986
+ const r = l.getAttribute("id");
987
+ this.selectSumo({
988
+ type: "junction",
989
+ id: r
990
+ });
991
+ const n = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, h = await b.get(n, {
992
+ params: {
993
+ id: r,
994
+ projectName: this.projectName
995
+ }
996
+ });
997
+ h.status === 200 && h.data.status === 0 && a.push(h.data.result);
998
+ }
999
+ return {
1000
+ status: 0,
1001
+ message: "ok",
1002
+ result: {
1003
+ junctions: a,
1004
+ edges: s
1005
+ }
1006
+ };
1007
+ }
956
1008
  async splitLane(e) {
957
- return { status: 0, message: "ok", result: e };
1009
+ const i = e.id.split("+");
1010
+ if (i.length !== 2)
1011
+ return { status: -1, message: "车道编号格式错误" };
1012
+ const o = Number(i[1]), s = i[0].split("#"), c = s.length === 2 ? Number(s[1]) : 0;
1013
+ let a = s[0];
1014
+ a.startsWith("-") && (a = a.slice(1));
1015
+ const l = this.allLaneGraphics.filter((v) => v.getAttribute("roadId") === a && v.getAttribute("sectionIndex") === c);
1016
+ if (l.length === 0)
1017
+ return { status: -1, message: "未找到路段" };
1018
+ const r = l.length - o, n = l.find(
1019
+ (v) => Math.abs(v.getAttribute("laneId")) === r
1020
+ );
1021
+ if (!n)
1022
+ return { status: -1, message: "未找到车道" };
1023
+ const h = e.start || 0, d = e.end || 100, g = G.lineString(n.getAttribute("leftLine")), m = C(g, h, d, {
1024
+ units: "meters"
1025
+ }), u = G.lineString(n.getAttribute("rightLine")), p = C(u, h, d, {
1026
+ units: "meters"
1027
+ }), f = m.geometry.coordinates.concat(
1028
+ p.geometry.coordinates.reverse()
1029
+ );
1030
+ f.push(f[f.length - 1]);
1031
+ const w = new y({
1032
+ geometry: new S({
1033
+ rings: [f]
1034
+ }),
1035
+ attributes: {
1036
+ ObjectID: n.getAttribute("ObjectID"),
1037
+ id: n.getAttribute("id"),
1038
+ fromNode: n.getAttribute("fromNode"),
1039
+ toNode: n.getAttribute("toNode"),
1040
+ roadId: n.getAttribute("roadId"),
1041
+ roadName: n.getAttribute("roadName"),
1042
+ sectionId: n.getAttribute("sectionId"),
1043
+ sectionIndex: n.getAttribute("sectionIndex"),
1044
+ laneId: n.getAttribute("laneId"),
1045
+ type: n.getAttribute("type"),
1046
+ sumoId: n.getAttribute("sumoId"),
1047
+ leftLine: m.geometry.coordinates,
1048
+ rightLine: p.geometry.coordinates
1049
+ },
1050
+ symbol: {
1051
+ type: "simple-fill",
1052
+ color: [255, 0, 0, 0.8],
1053
+ outline: {
1054
+ color: "red"
1055
+ }
1056
+ }
1057
+ });
1058
+ return this.splitLaneLayer.add(w), this.view.goTo(w), { status: 0, message: "ok", result: e };
1059
+ }
1060
+ clearSplitLane() {
1061
+ this.splitLaneLayer.removeAll();
958
1062
  }
959
1063
  }
960
1064
  export {
961
- A as default
1065
+ $ as default
962
1066
  };