gisviewer-vue3-arcgis 1.0.126 → 1.0.128

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,21 @@
1
1
  import p from "@arcgis/core/Graphic";
2
- import * as D from "@arcgis/core/core/promiseUtils";
3
- import { Polygon as N } from "@arcgis/core/geometry";
4
- import * as k from "@arcgis/core/geometry/geometryEngineAsync";
5
- import C from "@arcgis/core/layers/FeatureLayer";
6
- import f from "@arcgis/core/layers/GraphicsLayer";
7
- import g from "axios";
2
+ import * as j from "@arcgis/core/core/promiseUtils";
3
+ import { Polygon as O } from "@arcgis/core/geometry";
4
+ import * as I from "@arcgis/core/geometry/geometryEngine";
5
+ import G from "@arcgis/core/layers/FeatureLayer";
6
+ import w from "@arcgis/core/layers/GraphicsLayer";
7
+ import m from "axios";
8
8
  import F from "md5";
9
- import G from "pako";
10
- import j from "../common-utils.mjs";
11
- import A from "./wasm-loader.mjs";
12
- class S {
13
- constructor(t) {
14
- this.wasmLoader = A.getInstance(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = t, this.view.popup.visibleElements = {
9
+ import S from "pako";
10
+ import A from "../common-utils.mjs";
11
+ import $ from "./wasm-loader.mjs";
12
+ class C {
13
+ constructor(e) {
14
+ this.wasmLoader = $.getInstance(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = e, this.view.popup.visibleElements = {
15
15
  closeButton: !1,
16
16
  collapseButton: !1,
17
17
  actionBar: !1
18
- }, this.laneLayer = new C({
18
+ }, this.laneLayer = new G({
19
19
  id: "OpenDriveLane",
20
20
  fields: [
21
21
  {
@@ -223,7 +223,7 @@ class S {
223
223
  }
224
224
  ]
225
225
  }
226
- }), this.roadNameLayer = new C({
226
+ }), this.roadNameLayer = new G({
227
227
  id: "OpenDriveRoadName",
228
228
  fields: [
229
229
  {
@@ -273,7 +273,7 @@ class S {
273
273
  }
274
274
  }
275
275
  ]
276
- }), this.junctionLayer = new f({ id: "OpenDriveJunction" }), this.sectionLayer = new f({ id: "OpenDriveSection" }), this.highlightLayer = new f({ id: "OpenDriveHighlight" }), this.flashLayer = new f({ id: "OpenDriveFlash" }), this.view.map.addMany([
276
+ }), 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.view.map.addMany([
277
277
  this.laneLayer,
278
278
  this.junctionLayer,
279
279
  this.sectionLayer,
@@ -282,25 +282,38 @@ class S {
282
282
  this.flashLayer
283
283
  ]);
284
284
  }
285
- static getInstance(t) {
286
- return this.instance || (this.instance = new S(t)), this.instance;
285
+ static getInstance(e) {
286
+ return this.instance || (this.instance = new C(e)), this.instance;
287
287
  }
288
- async makeMd5FromFile(t) {
289
- const i = await (await fetch(t)).text();
290
- return F(i);
288
+ async makeMd5FromFile(e) {
289
+ try {
290
+ const s = await (await fetch(e)).text();
291
+ return { status: 0, message: "ok", result: F(s) };
292
+ } catch (t) {
293
+ return { status: -1, message: t.message };
294
+ }
291
295
  }
292
- async showOpenDriveFromFile(t) {
293
- var h, d;
294
- this.openDriveClickCallback = t.selectedCallback, this.projectName = await this.makeMd5FromFile(t.file), this.openDriveServer = t.server, await this.makeMd5FromFile(t.file);
295
- const a = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
296
- let i;
296
+ /**
297
+ * 从本地文件/网络文件显示OpenDrive内容
298
+ * @param params
299
+ * @returns
300
+ */
301
+ async showOpenDriveFromFile(e) {
302
+ var d, f;
303
+ this.openDriveClickCallback = e.selectedCallback, console.time("md5用时");
304
+ const t = await this.makeMd5FromFile(e.file);
305
+ if (t.status !== 0)
306
+ return t;
307
+ this.projectName = t.result, console.timeEnd("md5用时"), this.openDriveServer = e.server, await this.makeMd5FromFile(e.file);
308
+ const s = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
309
+ let o;
297
310
  try {
298
- i = await g.post(
299
- a,
311
+ o = await m.post(
312
+ s,
300
313
  {},
301
314
  {
302
315
  params: {
303
- url: t.file,
316
+ url: e.file,
304
317
  projectName: this.projectName
305
318
  }
306
319
  }
@@ -308,26 +321,26 @@ class S {
308
321
  } catch (u) {
309
322
  return { status: -1, message: u.message };
310
323
  }
311
- if (i.status !== 200)
312
- return { status: -1, message: i.statusText };
324
+ if (o.status !== 200)
325
+ return { status: -1, message: o.statusText };
313
326
  console.time("渲染用时");
314
- const s = i.data.result.geoSetting;
315
- j.setGeoData(
316
- s.geoReference,
317
- s.offsetX,
318
- s.offsetY
327
+ const i = o.data.result.geoSetting;
328
+ A.setGeoData(
329
+ i.geoReference,
330
+ i.offsetX,
331
+ i.offsetY
319
332
  );
320
- let e = i.data.result.json;
321
- e.startsWith(window.location.protocol) || (e = `${window.location.protocol}//${t.server}${e}`);
322
- const r = await (await fetch(e)).arrayBuffer(), n = G.inflate(r, { to: "string" }), o = JSON.parse(n);
333
+ let l = o.data.result.json;
334
+ l.startsWith(window.location.protocol) || (l = `${window.location.protocol}//${e.server}${l}`);
335
+ const n = await (await fetch(l)).arrayBuffer(), r = S.inflate(n, { to: "string" }), c = JSON.parse(r);
323
336
  await this.showAllLanes(
324
- o,
325
- ((h = t.options) == null ? void 0 : h.showJunctionLane) || !1,
326
- ((d = t.options) == null ? void 0 : d.showRoadName) || !0
337
+ c,
338
+ ((d = e.options) == null ? void 0 : d.showJunctionLane) || !1,
339
+ ((f = e.options) == null ? void 0 : f.showRoadName) || !0
327
340
  );
328
- const l = i.data.result.junctions;
329
- if (this.showJunction(l), t.options && t.options.centerMap !== !1) {
330
- const u = j.transformPointProjection([0, 0]);
341
+ const h = o.data.result.junctions;
342
+ if (this.showJunction(h), e.options && e.options.centerMap !== !1) {
343
+ const u = A.transformPointProjection([0, 0]);
331
344
  await this.view.goTo(u);
332
345
  }
333
346
  return this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick(), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
@@ -337,160 +350,173 @@ class S {
337
350
  * @param server
338
351
  * @param projectName
339
352
  */
340
- async showOpenDriveFromServer(t, a) {
341
- const i = `http://${t}/api/openDrive/analyzeXodr`, s = await g.get(i, {
353
+ async showOpenDriveFromServer(e, t) {
354
+ const s = `http://${e}/api/openDrive/analyzeXodr`, o = await m.get(s, {
342
355
  headers: {
343
- projectName: a
356
+ projectName: t
344
357
  },
345
358
  params: {
346
359
  analyze: !1,
347
360
  compressed: !0
348
361
  }
349
362
  });
350
- if (s.status !== 200)
351
- throw new Error(`OpenDriveRenderer: ${s.statusText}`);
352
- let e = s.data.result.json;
353
- e.startsWith(window.location.protocol) || (e = `${window.location.protocol}//${t}${e}`);
354
- const r = await (await fetch(e)).arrayBuffer(), n = G.inflate(r, { to: "string" }), o = JSON.parse(n);
355
- return await this.showAllLanes(o, !1, !1), { status: 0, message: "ok" };
363
+ if (o.status !== 200)
364
+ throw new Error(`OpenDriveRenderer: ${o.statusText}`);
365
+ let i = o.data.result.json;
366
+ i.startsWith(window.location.protocol) || (i = `${window.location.protocol}//${e}${i}`);
367
+ const a = await (await fetch(i)).arrayBuffer(), n = S.inflate(a, { to: "string" }), r = JSON.parse(n);
368
+ return await this.showAllLanes(r, !1, !1), { status: 0, message: "ok" };
356
369
  }
357
- async showAllLanes(t, a, i) {
358
- const s = await this.laneLayer.queryFeatures();
359
- return s.features.length > 0 && this.laneLayer.applyEdits({
360
- deleteFeatures: s.features
361
- }), this.roadNameLayer.visible = i, new Promise((e) => {
362
- let c = 0;
370
+ /**
371
+ * 显示所有车道
372
+ * @param roads 道路列表
373
+ * @param showJunctionLane 是否显示路口内车道
374
+ * @param showRoadName 是否显示道路名称
375
+ * @returns
376
+ */
377
+ async showAllLanes(e, t, s) {
378
+ const o = await this.laneLayer.queryFeatures();
379
+ return o.features.length > 0 && this.laneLayer.applyEdits({
380
+ deleteFeatures: o.features
381
+ }), this.roadNameLayer.visible = s, new Promise((i) => {
382
+ let l = 0;
363
383
  this.allLaneGraphics = [], this.allRefLineGraphics = [];
364
- const r = [];
365
- for (const o of t) {
366
- if (!a && o.junction !== "-1")
384
+ const a = [];
385
+ for (const r of e) {
386
+ if (!t && r.junction !== "-1")
367
387
  continue;
368
- const { id: l, refLine: h } = o;
369
- let d = o.name;
388
+ const { id: c, refLine: h } = r;
389
+ let d = r.name;
370
390
  d.includes("(") && (d = d.slice(0, d.indexOf("("))), d = d.replace(/(.)/g, "$1 ");
371
- const u = new p({
391
+ const f = new p({
372
392
  geometry: {
373
393
  type: "polyline",
374
394
  paths: [h]
375
395
  },
376
396
  attributes: {
377
- ObjectID: c++,
378
- roadId: l,
397
+ ObjectID: l++,
398
+ roadId: c,
379
399
  roadName: d
380
400
  }
381
401
  });
382
- this.allRefLineGraphics.push(u);
383
- for (const v of o.laneSections) {
384
- const b = Number(v.id);
385
- for (const y of v.lanePaths) {
386
- const m = Number(y.id);
387
- if (m === 0)
402
+ this.allRefLineGraphics.push(f), r.laneSections.sort((u, g) => Number(u.id) - Number(g.id));
403
+ for (let u = 0; u < r.laneSections.length; u++) {
404
+ const g = r.laneSections[u], L = Number(g.id);
405
+ for (const y of g.lanePaths) {
406
+ const b = Number(y.id);
407
+ if (b === 0)
388
408
  continue;
389
- const O = y.type, w = y.innerPath.concat(
409
+ const N = y.type, v = y.innerPath.concat(
390
410
  y.outerPath.reverse()
391
411
  );
392
- if (w.length <= 3) {
393
- console.warn(`lane ${m} has less than 3 points`);
412
+ if (v.length <= 3) {
413
+ console.warn(`lane ${b} has less than 3 points`);
394
414
  continue;
395
415
  }
396
- w.push(y.innerPath[0]);
397
- const I = new N({
398
- rings: [w]
416
+ v.push(y.innerPath[0]);
417
+ const D = new O({
418
+ rings: [v]
399
419
  });
400
- if (I) {
401
- const L = new p({
402
- geometry: I,
420
+ if (D) {
421
+ const k = new p({
422
+ geometry: D,
403
423
  attributes: {
404
- ObjectID: c++,
405
- id: `${l}+${b}+${m}`,
406
- roadId: l,
407
- roadName: o.name,
408
- sectionId: b,
409
- laneId: m,
410
- type: O,
424
+ ObjectID: l++,
425
+ id: `${c}+${L}+${b}`,
426
+ roadId: c,
427
+ roadName: r.name,
428
+ sectionId: L,
429
+ sectionIndex: u,
430
+ laneId: b,
431
+ type: N,
411
432
  sumoId: ""
412
433
  }
413
434
  });
414
- this.allLaneGraphics.push(L), r.push(L);
435
+ this.allLaneGraphics.push(k), a.push(k);
415
436
  }
416
437
  }
417
438
  }
418
439
  }
419
440
  const n = setInterval(() => {
420
- if (r.length > 0 || this.allRefLineGraphics.length > 0) {
421
- if (r.length > 0) {
422
- const o = r.splice(0, 100);
441
+ if (a.length > 0 || this.allRefLineGraphics.length > 0) {
442
+ if (a.length > 0) {
443
+ const r = a.splice(0, 100);
423
444
  this.laneLayer.applyEdits({
424
- addFeatures: o
445
+ addFeatures: r
425
446
  });
426
447
  }
427
448
  if (this.allRefLineGraphics.length > 0) {
428
- const o = this.allRefLineGraphics.splice(0, 10);
449
+ const r = this.allRefLineGraphics.splice(0, 10);
429
450
  this.roadNameLayer.applyEdits({
430
- addFeatures: o
451
+ addFeatures: r
431
452
  });
432
453
  }
433
454
  } else
434
- clearInterval(n), e();
455
+ clearInterval(n), i();
435
456
  }, 10);
436
457
  });
437
458
  }
438
- showJunction(t) {
439
- const a = [];
440
- for (const i of t) {
441
- i.nodeType = i.type;
442
- const s = new p({
459
+ /**
460
+ * 显示路口
461
+ * @param params
462
+ * @returns
463
+ */
464
+ showJunction(e) {
465
+ const t = [];
466
+ for (const s of e) {
467
+ s.nodeType = s.type;
468
+ const o = new p({
443
469
  geometry: {
444
470
  type: "point",
445
- x: i.coordinates[0],
446
- y: i.coordinates[1]
471
+ x: s.coordinates[0],
472
+ y: s.coordinates[1]
447
473
  },
448
474
  attributes: {
449
- ...i,
475
+ ...s,
450
476
  selected: !1,
451
477
  type: "OpenDriveJunction"
452
478
  },
453
479
  symbol: {
454
480
  type: "picture-marker",
455
- url: i.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
481
+ url: s.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
456
482
  width: 30,
457
483
  height: 30
458
484
  }
459
485
  });
460
- a.push(s);
486
+ t.push(o);
461
487
  }
462
- this.junctionLayer.addMany(a);
488
+ this.junctionLayer.addMany(t);
463
489
  }
464
490
  /**
465
491
  * 监听鼠标移动事件,高亮显示鼠标所在路段和路口
466
492
  */
467
493
  monitorMouseMove() {
468
- const t = D.debounce(async (a) => {
469
- var c;
470
- const s = (c = (await this.view.hitTest(a, {
494
+ const e = j.debounce(async (t) => {
495
+ var l;
496
+ const o = (l = (await this.view.hitTest(t, {
471
497
  include: [this.laneLayer, this.junctionLayer]
472
- })).results) == null ? void 0 : c.filter(
473
- (r) => r.type === "graphic"
498
+ })).results) == null ? void 0 : l.filter(
499
+ (a) => a.type === "graphic"
474
500
  );
475
- if (s.length === 0) {
501
+ if (o.length === 0) {
476
502
  this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.view.closePopup());
477
503
  return;
478
504
  }
479
- const e = s[0];
480
- if (this.hitGraphic = e.graphic, e.layer.id === "OpenDriveLane") {
481
- const r = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
482
- if (r === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
483
- (h) => h.getAttribute("id") === r
505
+ const i = o[0];
506
+ if (this.hitGraphic = i.graphic, i.layer.id === "OpenDriveLane") {
507
+ const a = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
508
+ if (a === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
509
+ (h) => h.getAttribute("id") === a
484
510
  ) >= 0)
485
511
  return;
486
- this.currentSectionCode = r;
487
- const o = this.allLaneGraphics.filter(
488
- (h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === r
489
- ), l = await k.union(
490
- o.map((h) => h.geometry)
512
+ this.currentSectionCode = a;
513
+ const r = this.allLaneGraphics.filter(
514
+ (h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === a
515
+ ), c = I.union(
516
+ r.map((h) => h.geometry)
491
517
  );
492
518
  this.highlightGraphic = new p({
493
- geometry: l,
519
+ geometry: c,
494
520
  symbol: {
495
521
  type: "simple-fill",
496
522
  color: [0, 255, 255, 0.5],
@@ -502,28 +528,28 @@ class S {
502
528
  },
503
529
  attributes: {
504
530
  type: "OpenDriveSection",
505
- id: r,
531
+ id: a,
506
532
  selected: !1
507
533
  }
508
534
  }), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
509
- } else if (e.layer.id === "OpenDriveJunction") {
510
- const r = this.hitGraphic.getAttribute("id");
511
- if (r === this.currentJunctionId)
535
+ } else if (i.layer.id === "OpenDriveJunction") {
536
+ const a = this.hitGraphic.getAttribute("id");
537
+ if (a === this.currentJunctionId)
512
538
  return;
513
- this.currentJunctionId = r;
514
- const n = this.hitGraphic.getAttribute("name"), o = this.hitGraphic.getAttribute("crossId");
539
+ this.currentJunctionId = a;
540
+ const n = this.hitGraphic.getAttribute("name"), r = this.hitGraphic.getAttribute("crossId");
515
541
  this.view.popup.open({
516
542
  title: n,
517
543
  content: `<table>
518
- <tr><td>路口编号</td><td>${r}</td></tr>
519
- <tr><td>信号机编号</td><td>${o || "无信控"}</td></tr>
544
+ <tr><td>路口编号</td><td>${a}</td></tr>
545
+ <tr><td>信号机编号</td><td>${r || "无信控"}</td></tr>
520
546
  </table>`,
521
547
  location: this.hitGraphic.geometry
522
548
  });
523
549
  }
524
550
  });
525
- this.mouseMoveHandler = this.view.on("pointer-move", async (a) => {
526
- t(a).catch(() => {
551
+ this.mouseMoveHandler = this.view.on("pointer-move", async (t) => {
552
+ e(t).catch(() => {
527
553
  });
528
554
  });
529
555
  }
@@ -531,129 +557,176 @@ class S {
531
557
  * 监听鼠标点击事件,获取高亮要素的拓扑信息
532
558
  */
533
559
  monitorMouseClick() {
534
- const t = D.debounce(async (a) => {
560
+ const e = j.debounce(async (t) => {
535
561
  var n;
536
- const s = (n = (await this.view.hitTest(a, {
562
+ const o = (n = (await this.view.hitTest(t, {
537
563
  include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
538
564
  })).results) == null ? void 0 : n.filter(
539
- (o) => o.type === "graphic"
565
+ (r) => r.type === "graphic"
540
566
  );
541
- if (s.length === 0)
567
+ if (o.length === 0)
542
568
  return;
543
- const e = s[0].graphic, c = e.getAttribute("type"), r = e.getAttribute("id");
544
- if (c === "OpenDriveJunction")
545
- if (e.getAttribute("selected") === !1) {
546
- const o = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, l = await g.get(o, {
569
+ const i = o[0].graphic, l = i.getAttribute("type"), a = i.getAttribute("id");
570
+ if (l === "OpenDriveJunction")
571
+ if (i.getAttribute("selected") === !1) {
572
+ const r = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, c = await m.get(r, {
547
573
  params: {
548
- id: r,
574
+ id: a,
549
575
  projectName: this.projectName
550
576
  }
551
577
  });
552
- l.status === 200 && l.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
578
+ c.status === 200 && c.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
553
579
  type: "OpenDriveJunction",
554
- id: r,
555
- details: l.data.result
556
- }), e.setAttribute("selected", !0), e.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(e, 50));
580
+ id: a,
581
+ details: c.data.result
582
+ }), i.setAttribute("selected", !0), i.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(i, 50));
557
583
  } else {
558
584
  this.openDriveClickCallback && this.openDriveClickCallback({
559
585
  type: "OpenDriveJunction",
560
- id: r,
586
+ id: a,
561
587
  details: void 0
562
- }), e.setAttribute("selected", !1);
563
- const o = e.getAttribute("crossId");
564
- e.symbol.url = o ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(e, 30);
588
+ }), i.setAttribute("selected", !1);
589
+ const r = i.getAttribute("crossId");
590
+ i.symbol.url = r ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(i, 30);
565
591
  }
566
- else if (c === "OpenDriveSection")
567
- if (e.getAttribute("selected"))
568
- this.sectionLayer.remove(e), this.openDriveClickCallback && this.openDriveClickCallback({
592
+ else if (l === "OpenDriveSection")
593
+ if (i.getAttribute("selected"))
594
+ this.sectionLayer.remove(i), this.openDriveClickCallback && this.openDriveClickCallback({
569
595
  type: "OpenDriveSection",
570
- id: r,
596
+ id: a,
571
597
  details: void 0
572
598
  });
573
599
  else {
574
- this.highlightLayer.remove(e), this.sectionLayer.add(e), e.setAttribute("selected", !0);
575
- const o = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, l = await g.get(o, {
600
+ this.highlightLayer.remove(i), this.sectionLayer.add(i), i.setAttribute("selected", !0);
601
+ const r = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, c = await m.get(r, {
576
602
  params: {
577
- id: r,
603
+ id: a,
578
604
  projectName: this.projectName
579
605
  }
580
606
  });
581
- l.status === 200 && l.data.status === 0 && this.openDriveClickCallback && this.openDriveClickCallback({
607
+ c.status === 200 && c.data.status === 0 && this.openDriveClickCallback && (i.setAttribute("edgeId", c.data.result.obj_id), this.openDriveClickCallback({
582
608
  type: "OpenDriveSection",
583
- id: r,
584
- details: l.data.result
585
- });
609
+ id: a,
610
+ details: c.data.result
611
+ }));
586
612
  }
587
613
  });
588
- this.mouseClickHandler = this.view.on("immediate-click", async (a) => {
589
- t(a).catch(() => {
614
+ this.mouseClickHandler = this.view.on("immediate-click", async (t) => {
615
+ e(t).catch(() => {
590
616
  });
591
617
  });
592
618
  }
593
- increasePictureMarkerSize(t, a) {
594
- const i = setInterval(() => {
595
- const s = t.symbol, e = s.width;
596
- e < a ? t.symbol = {
619
+ /**
620
+ * 图标增大动画
621
+ * @param graphic
622
+ * @param targetSize
623
+ */
624
+ increasePictureMarkerSize(e, t) {
625
+ const s = setInterval(() => {
626
+ const o = e.symbol, i = o.width;
627
+ i < t ? e.symbol = {
597
628
  type: "picture-marker",
598
- url: s.url,
599
- width: e + 1,
600
- height: e + 1
601
- } : clearInterval(i);
629
+ url: o.url,
630
+ width: i + 1,
631
+ height: i + 1
632
+ } : clearInterval(s);
602
633
  }, 20);
603
634
  }
604
- decreasePictureMarkerSize(t, a) {
605
- const i = setInterval(() => {
606
- const s = t.symbol, e = s.width;
607
- e > a ? t.symbol = {
635
+ /**
636
+ * 图标缩小动画
637
+ * @param graphic
638
+ * @param targetSize
639
+ */
640
+ decreasePictureMarkerSize(e, t) {
641
+ const s = setInterval(() => {
642
+ const o = e.symbol, i = o.width;
643
+ i > t ? e.symbol = {
608
644
  type: "picture-marker",
609
- url: s.url,
610
- width: e - 1,
611
- height: e - 1
612
- } : clearInterval(i);
645
+ url: o.url,
646
+ width: i - 1,
647
+ height: i - 1
648
+ } : clearInterval(s);
613
649
  }, 20);
614
650
  }
651
+ async getSumoInfo(e) {
652
+ switch (e.type) {
653
+ case "junction": {
654
+ const t = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, s = await m.get(t, {
655
+ params: {
656
+ id: e.id,
657
+ projectName: this.projectName
658
+ }
659
+ });
660
+ return s.status === 200 ? s.data : { status: -1, message: `路口信息查询失败: ${e.id}` };
661
+ }
662
+ case "edge": {
663
+ const t = e.id.split("#");
664
+ let s = t[0];
665
+ s.startsWith("-") && (s = s.slice(1));
666
+ let o = 0;
667
+ t.length === 2 && (o = Number(t[1]));
668
+ const i = this.allLaneGraphics.find(
669
+ (l) => l.getAttribute("roadId") === s && l.getAttribute("sectionIndex") === o
670
+ );
671
+ if (i) {
672
+ const l = `${s}+${i.getAttribute(
673
+ "sectionId"
674
+ )}`, a = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, n = await m.get(a, {
675
+ params: {
676
+ id: l,
677
+ projectName: this.projectName
678
+ }
679
+ });
680
+ return n.status === 200 ? n.data : { status: -1, message: `路段信息查询失败: ${l}` };
681
+ } else
682
+ return { status: -1, message: "未知类型" };
683
+ }
684
+ default:
685
+ return { status: -1, message: "未知类型" };
686
+ }
687
+ }
615
688
  /**
616
689
  * 清除OpenDrive内容
617
690
  */
618
691
  async clearOpenDrive() {
619
- var a, i;
620
- let t = await this.laneLayer.queryFeatures();
621
- t.features.length > 0 && await this.laneLayer.applyEdits({
622
- deleteFeatures: t.features
623
- }), t = await this.roadNameLayer.queryFeatures(), t.features.length > 0 && await this.roadNameLayer.applyEdits({
624
- deleteFeatures: t.features
625
- }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.wasmLoader.clear(), (a = this.mouseMoveHandler) == null || a.remove(), (i = this.mouseClickHandler) == null || i.remove();
692
+ var t, s;
693
+ let e = await this.laneLayer.queryFeatures();
694
+ e.features.length > 0 && await this.laneLayer.applyEdits({
695
+ deleteFeatures: e.features
696
+ }), e = await this.roadNameLayer.queryFeatures(), e.features.length > 0 && await this.roadNameLayer.applyEdits({
697
+ deleteFeatures: e.features
698
+ }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.sectionLayer.removeAll(), this.flashLayer.removeAll(), (t = this.mouseMoveHandler) == null || t.remove(), this.mouseMoveHandler = void 0, (s = this.mouseClickHandler) == null || s.remove(), this.mouseClickHandler = void 0;
626
699
  }
627
700
  /**
628
701
  * 用sumo的id定位车道、基本段、路段
629
702
  * @param params
630
703
  * @returns
631
704
  */
632
- async findSumo(t) {
633
- const { type: a, id: i } = t, s = t.flash === void 0 ? !0 : t.flash;
634
- if (a === "junction")
635
- return await this.findJunction(i, s);
636
- if (a === "edge") {
637
- const e = i.split("+");
638
- if (e.length > 2)
705
+ async findSumo(e) {
706
+ const { type: t, id: s } = e, o = e.flash === void 0 ? !0 : e.flash;
707
+ if (t === "junction")
708
+ return await this.findJunction(s, o);
709
+ if (t === "edge") {
710
+ const i = s.split("+");
711
+ if (i.length > 2)
639
712
  return { status: -1, message: "id格式错误" };
640
- const c = e.length === 2 ? Number(e[1]) : void 0, r = e[0].split("#");
641
- if (r.length > 2)
713
+ const l = i.length === 2 ? Number(i[1]) : void 0, a = i[0].split("#");
714
+ if (a.length > 2)
642
715
  return { status: -1, message: "id格式错误" };
643
- const n = r[0], o = r.length === 2 ? Number(r[1]) : void 0;
644
- return await this.findLane({ roadsectId: n, segmentId: o, laneId: c, flash: s });
716
+ const n = a[0], r = a.length === 2 ? Number(a[1]) : void 0;
717
+ return await this.findLane({ roadsectId: n, segmentId: r, laneId: l, flash: o });
645
718
  } else
646
719
  return { status: -1, message: "未知类型" };
647
720
  }
648
- async findJunction(t, a) {
649
- const i = this.junctionLayer.graphics.find(
650
- (s) => s.attributes.id === t
721
+ async findJunction(e, t) {
722
+ const s = this.junctionLayer.graphics.find(
723
+ (o) => o.attributes.id === e
651
724
  );
652
- if (!i)
725
+ if (!s)
653
726
  return { status: -1, message: "未找到。请检查路口编号" };
654
- if (a) {
655
- const s = new p({
656
- geometry: i.geometry,
727
+ if (t) {
728
+ const o = new p({
729
+ geometry: s.geometry,
657
730
  symbol: {
658
731
  type: "simple-marker",
659
732
  style: "circle",
@@ -665,51 +738,51 @@ class S {
665
738
  }
666
739
  }
667
740
  });
668
- this.flashGraphic(s);
741
+ this.flashGraphic(o);
669
742
  }
670
- return await this.view.goTo(i.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
743
+ return await this.view.goTo(s.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
671
744
  }
672
745
  /**
673
746
  * 用sumo的id定位车道、基本段、路段
674
747
  * @param params
675
748
  * @returns
676
749
  */
677
- async findLane(t) {
678
- let { roadsectId: a, segmentId: i, laneId: s } = t;
679
- a.startsWith("-") && (a = a.slice(1));
680
- let e = this.allLaneGraphics.filter(
681
- (n) => n.attributes.roadId === a
750
+ async findLane(e) {
751
+ let { roadsectId: t, segmentId: s, laneId: o } = e;
752
+ t.startsWith("-") && (t = t.slice(1));
753
+ let i = this.allLaneGraphics.filter(
754
+ (n) => n.attributes.roadId === t
682
755
  );
683
- if (e.length === 0)
756
+ if (i.length === 0)
684
757
  return { status: -1, message: "未找到。请检查路段编号" };
685
- if (i !== void 0) {
758
+ if (s !== void 0) {
686
759
  const n = [];
687
- if (e.forEach((o) => {
688
- const l = Number(o.attributes.sectionId);
689
- n.indexOf(l) === -1 && n.push(l);
690
- }), n.sort((o, l) => o - l), i > n.length - 1)
760
+ if (i.forEach((r) => {
761
+ const c = Number(r.attributes.sectionId);
762
+ n.indexOf(c) === -1 && n.push(c);
763
+ }), n.sort((r, c) => r - c), s > n.length - 1)
691
764
  return { status: -1, message: "未找到。请检查基本段编号" };
692
- i = n[i], e = e.filter(
693
- (o) => Number(o.attributes.sectionId) === i
765
+ s = n[s], i = i.filter(
766
+ (r) => Number(r.attributes.sectionId) === s
694
767
  );
695
768
  }
696
- if (s !== void 0) {
769
+ if (o !== void 0) {
697
770
  const n = [];
698
- if (e.forEach((o) => {
699
- const l = Number(o.attributes.laneId);
700
- n.indexOf(l) === -1 && n.push(l);
701
- }), n.sort((o, l) => o - l), s > n.length - 1)
771
+ if (i.forEach((r) => {
772
+ const c = Number(r.attributes.laneId);
773
+ n.indexOf(c) === -1 && n.push(c);
774
+ }), n.sort((r, c) => r - c), o > n.length - 1)
702
775
  return { status: -1, message: "未找到。请检查车道编号" };
703
- s = n[s], e = e.filter(
704
- (o) => Number(o.attributes.laneId) === s
776
+ o = n[o], i = i.filter(
777
+ (r) => Number(r.attributes.laneId) === o
705
778
  );
706
779
  }
707
- const c = e.map(
780
+ const l = i.map(
708
781
  (n) => n.geometry
709
- ), r = await k.union(c);
710
- if (t.flash) {
782
+ ), a = I.union(l);
783
+ if (e.flash) {
711
784
  const n = new p({
712
- geometry: r,
785
+ geometry: a,
713
786
  symbol: {
714
787
  type: "simple-fill",
715
788
  color: [255, 0, 0, 0.5],
@@ -722,19 +795,97 @@ class S {
722
795
  });
723
796
  this.flashGraphic(n);
724
797
  }
725
- return await this.view.goTo(r, { duration: 1e3 }), { status: 0, message: "ok" };
798
+ return await this.view.goTo(a, { duration: 1e3 }), { status: 0, message: "ok" };
726
799
  }
727
- flashGraphic(t) {
728
- this.flashLayer.removeAll(), this.flashLayer.add(t);
729
- let a = 0, i = !0;
730
- const s = setInterval(() => {
731
- i ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (i = !1, a++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (i = !0)), a >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(s));
800
+ /**
801
+ * graphic渐隐渐显闪烁
802
+ * @param flashGraphic
803
+ */
804
+ flashGraphic(e) {
805
+ this.flashLayer.removeAll(), this.flashLayer.add(e);
806
+ let t = 0, s = !0;
807
+ const o = setInterval(() => {
808
+ s ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (s = !1, t++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (s = !0)), t >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(o));
732
809
  }, 10);
733
810
  }
734
- async splitLane(t) {
735
- return { status: 0, message: "ok", result: t };
811
+ /**
812
+ * 通过接口取消选中
813
+ * @param params
814
+ * @returns
815
+ */
816
+ unselectSumo(e) {
817
+ if ((!e || e.type === "junction") && this.junctionLayer.graphics.forEach((t) => {
818
+ if ((!e || !e.id || e.id === "" || e.id === t.getAttribute("id")) && t.getAttribute("selected")) {
819
+ t.setAttribute("selected", !1);
820
+ const s = t.getAttribute("crossId");
821
+ t.symbol.url = s ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(t, 30);
822
+ }
823
+ }), !e || e.type === "edge")
824
+ if (!e || !e.id || e.id === "")
825
+ this.sectionLayer.graphics.forEach((t) => {
826
+ t.visible = !1, t.setAttribute("selected", !1);
827
+ });
828
+ else {
829
+ const t = this.sectionLayer.graphics.find(
830
+ (s) => s.getAttribute("edgeId") === e.id
831
+ );
832
+ t && (t.visible = !1, t.setAttribute("selected", !1));
833
+ }
834
+ return { status: 0, message: "ok" };
835
+ }
836
+ /**
837
+ * 通过接口选中
838
+ * @param params
839
+ * @returns
840
+ */
841
+ selectSumo(e) {
842
+ switch (e.type) {
843
+ case "junction":
844
+ return this.junctionLayer.graphics.forEach((t) => {
845
+ if (e.id === t.getAttribute("id"))
846
+ return t.setAttribute("selected", !0), t.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(t, 50), { status: 0, message: "ok" };
847
+ }), { status: -1, message: "未找到路口" };
848
+ case "edge": {
849
+ const t = e.id.split("#");
850
+ let s = t[0];
851
+ s.startsWith("-") && (s = s.slice(1));
852
+ let o = 0;
853
+ t.length === 2 && (o = Number(t[1]));
854
+ const i = this.allLaneGraphics.filter(
855
+ (l) => l.getAttribute("roadId") === s && l.getAttribute("sectionIndex") === o
856
+ );
857
+ if (i.length > 0) {
858
+ const l = I.union(
859
+ i.map((n) => n.geometry)
860
+ ), a = new p({
861
+ geometry: l,
862
+ symbol: {
863
+ type: "simple-fill",
864
+ color: [0, 255, 255, 0.5],
865
+ style: "solid",
866
+ outline: {
867
+ color: [0, 255, 255],
868
+ width: 1
869
+ }
870
+ },
871
+ attributes: {
872
+ type: "OpenDriveSection",
873
+ edgeId: e.id,
874
+ selected: !0
875
+ }
876
+ });
877
+ return this.sectionLayer.add(a), { status: 0, message: "ok" };
878
+ } else
879
+ return { status: -1, message: "未找到路段" };
880
+ }
881
+ default:
882
+ return { status: -1, message: "未知类型" };
883
+ }
884
+ }
885
+ async splitLane(e) {
886
+ return { status: 0, message: "ok", result: e };
736
887
  }
737
888
  }
738
889
  export {
739
- S as default
890
+ C as default
740
891
  };