gisviewer-vue3-arcgis 1.0.146 → 1.0.147

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,5 +1,5 @@
1
1
  import y from "@arcgis/core/Graphic";
2
- import * as D from "@arcgis/core/core/promiseUtils";
2
+ import * as j from "@arcgis/core/core/promiseUtils";
3
3
  import { Polygon as S } from "@arcgis/core/geometry";
4
4
  import * as L from "@arcgis/core/geometry/geometryEngine";
5
5
  import k from "@arcgis/core/layers/FeatureLayer";
@@ -7,12 +7,12 @@ import I from "@arcgis/core/layers/GraphicsLayer";
7
7
  import * as G from "@turf/helpers";
8
8
  import { lineSliceAlong as C } from "@turf/line-slice-along";
9
9
  import b from "axios";
10
- import P from "md5";
10
+ import M from "md5";
11
11
  import O from "pako";
12
12
  import { watch as x } from "vue";
13
13
  import J from "../../stores/index.mjs";
14
- import F from "../common-utils.mjs";
15
- class $ {
14
+ import P from "../common-utils.mjs";
15
+ class F {
16
16
  constructor(e) {
17
17
  this.junctionNames = /* @__PURE__ */ new Map(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = e, this.view.popup.visibleElements = {
18
18
  collapseButton: !1,
@@ -297,12 +297,12 @@ class $ {
297
297
  ]);
298
298
  }
299
299
  static getInstance(e) {
300
- return this.instance || (this.instance = new $(e)), this.instance;
300
+ return this.instance || (this.instance = new F(e)), this.instance;
301
301
  }
302
302
  async makeMd5FromFile(e) {
303
303
  try {
304
304
  const i = await (await fetch(e)).text();
305
- return { status: 0, message: "ok", result: P(i) };
305
+ return { status: 0, message: "ok", result: M(i) };
306
306
  } catch (t) {
307
307
  return { status: -1, message: t.message };
308
308
  }
@@ -313,7 +313,7 @@ class $ {
313
313
  * @returns
314
314
  */
315
315
  async showOpenDriveFromFile(e) {
316
- var g, m;
316
+ var g, p;
317
317
  this.openDriveClickCallback = e.selectedCallback, console.time("md5用时");
318
318
  const t = await this.makeMd5FromFile(e.file);
319
319
  if (t.status !== 0)
@@ -332,14 +332,14 @@ class $ {
332
332
  }
333
333
  }
334
334
  );
335
- } catch (u) {
336
- return { status: -1, message: u.message };
335
+ } catch (m) {
336
+ return { status: -1, message: m.message };
337
337
  }
338
338
  if (o.status !== 200)
339
339
  return { status: -1, message: o.statusText };
340
340
  console.time("渲染用时");
341
341
  const s = o.data.result.geoSetting;
342
- F.setGeoData(
342
+ P.setGeoData(
343
343
  s.geoReference,
344
344
  s.offsetX,
345
345
  s.offsetY
@@ -350,20 +350,16 @@ class $ {
350
350
  await this.showAllLanes(
351
351
  n,
352
352
  ((g = e.options) == null ? void 0 : g.showJunctionLane) || !1,
353
- ((m = e.options) == null ? void 0 : m.showRoadName) || !0
353
+ ((p = e.options) == null ? void 0 : p.showRoadName) || !0
354
354
  );
355
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);
359
- }
360
- this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
356
+ this.showJunction(h), e.options && e.options.centerMap !== !1 && await this.view.goTo(this.allLaneGraphics), this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick();
361
357
  const d = J.useAppDataStore;
362
358
  return x(
363
359
  () => d.isSketching,
364
360
  () => {
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());
361
+ var m, u;
362
+ d.isSketching ? ((m = this.mouseMoveHandler) == null || m.remove(), this.mouseMoveHandler = void 0, (u = this.mouseClickHandler) == null || u.remove(), this.mouseClickHandler = void 0) : (this.monitorMouseMove(), this.monitorMouseClick());
367
363
  }
368
364
  ), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
369
365
  }
@@ -404,6 +400,7 @@ class $ {
404
400
  let c = 0;
405
401
  this.allLaneGraphics = [], this.allRefLineGraphics = [];
406
402
  const a = [];
403
+ console.log(e.length);
407
404
  for (const r of e) {
408
405
  if (!t && r.junction !== "-1")
409
406
  continue;
@@ -421,15 +418,15 @@ class $ {
421
418
  roadName: d
422
419
  }
423
420
  });
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) {
421
+ this.allRefLineGraphics.push(g), r.laneSections.sort((p, m) => Number(p.id) - Number(m.id));
422
+ for (let p = 0; p < r.laneSections.length; p++) {
423
+ const m = r.laneSections[p], u = Number(m.id);
424
+ for (const f of m.lanePaths) {
428
425
  const w = Number(f.id);
429
426
  if (w === 0)
430
427
  continue;
431
- const v = f.type, M = [...f.outerPath], N = f.innerPath.concat(
432
- M.reverse()
428
+ const v = f.type, $ = [...f.outerPath], N = f.innerPath.concat(
429
+ $.reverse()
433
430
  );
434
431
  if (N.length <= 3) {
435
432
  console.warn(`lane ${w} has less than 3 points`);
@@ -440,17 +437,17 @@ class $ {
440
437
  rings: [N]
441
438
  });
442
439
  if (A) {
443
- const j = new y({
440
+ const D = new y({
444
441
  geometry: A,
445
442
  attributes: {
446
443
  ObjectID: c++,
447
- id: `${n}+${p}+${w}`,
444
+ id: `${n}+${u}+${w}`,
448
445
  fromNode: r.fromNode,
449
446
  toNode: r.toNode,
450
447
  roadId: String(n),
451
448
  roadName: r.name,
452
- sectionId: String(p),
453
- sectionIndex: m,
449
+ sectionId: String(u),
450
+ sectionIndex: p,
454
451
  laneId: w,
455
452
  type: v,
456
453
  sumoId: "",
@@ -459,7 +456,7 @@ class $ {
459
456
  rightLine: f.outerPath
460
457
  }
461
458
  });
462
- this.allLaneGraphics.push(j), a.push(j);
459
+ this.allLaneGraphics.push(D), a.push(D);
463
460
  }
464
461
  }
465
462
  }
@@ -538,7 +535,7 @@ class $ {
538
535
  * 监听鼠标移动事件,高亮显示鼠标所在路段和路口
539
536
  */
540
537
  monitorMouseMove() {
541
- const e = D.debounce(async (t) => {
538
+ const e = j.debounce(async (t) => {
542
539
  var c;
543
540
  const o = (c = (await this.view.hitTest(t, {
544
541
  include: [this.laneLayer, this.junctionLayer]
@@ -555,15 +552,15 @@ class $ {
555
552
  "roadId"
556
553
  )}+${this.hitGraphic.getAttribute("sectionId")}`;
557
554
  if (a === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
558
- (p) => p.getAttribute("id") === a
555
+ (u) => u.getAttribute("id") === a
559
556
  ) >= 0)
560
557
  return;
561
558
  this.currentSectionCode = a;
562
559
  const r = this.allLaneGraphics.filter(
563
- (p) => `${p.attributes.roadId}+${p.attributes.sectionId}` === a
560
+ (u) => `${u.attributes.roadId}+${u.attributes.sectionId}` === a
564
561
  ), 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;
562
+ r.map((u) => u.geometry)
563
+ ), h = this.hitGraphic.getAttribute("fromNode"), d = this.hitGraphic.getAttribute("toNode"), g = this.junctionNames.get(h) || h, p = this.junctionNames.get(d) || d;
567
564
  this.highlightGraphic = new y({
568
565
  geometry: n,
569
566
  symbol: {
@@ -580,7 +577,7 @@ class $ {
580
577
  id: a,
581
578
  selected: !1,
582
579
  fromNodeName: g,
583
- toNodeName: m,
580
+ toNodeName: p,
584
581
  laneCount: r.length
585
582
  },
586
583
  popupTemplate: {
@@ -606,10 +603,10 @@ class $ {
606
603
  ]
607
604
  }
608
605
  }), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
609
- const u = this.view.toMap(t);
606
+ const m = this.view.toMap(t);
610
607
  this.view.openPopup({
611
608
  features: [this.highlightGraphic],
612
- location: u
609
+ location: m
613
610
  });
614
611
  } else if (s.layer.id === "OpenDriveJunction") {
615
612
  const a = this.hitGraphic.getAttribute("id");
@@ -630,7 +627,7 @@ class $ {
630
627
  * 监听鼠标点击事件,获取高亮要素的拓扑信息
631
628
  */
632
629
  monitorMouseClick() {
633
- const e = D.debounce(async (t) => {
630
+ const e = j.debounce(async (t) => {
634
631
  var l;
635
632
  const o = (l = (await this.view.hitTest(t, {
636
633
  include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
@@ -1020,12 +1017,12 @@ class $ {
1020
1017
  );
1021
1018
  if (!n)
1022
1019
  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, {
1020
+ const h = e.start || 0, d = e.end || 100, g = G.lineString(n.getAttribute("leftLine")), p = C(g, h, d, {
1024
1021
  units: "meters"
1025
- }), u = G.lineString(n.getAttribute("rightLine")), p = C(u, h, d, {
1022
+ }), m = G.lineString(n.getAttribute("rightLine")), u = C(m, h, d, {
1026
1023
  units: "meters"
1027
- }), f = m.geometry.coordinates.concat(
1028
- p.geometry.coordinates.reverse()
1024
+ }), f = p.geometry.coordinates.concat(
1025
+ u.geometry.coordinates.reverse()
1029
1026
  );
1030
1027
  f.push(f[f.length - 1]);
1031
1028
  const w = new y({
@@ -1044,8 +1041,8 @@ class $ {
1044
1041
  laneId: n.getAttribute("laneId"),
1045
1042
  type: n.getAttribute("type"),
1046
1043
  sumoId: n.getAttribute("sumoId"),
1047
- leftLine: m.geometry.coordinates,
1048
- rightLine: p.geometry.coordinates
1044
+ leftLine: p.geometry.coordinates,
1045
+ rightLine: u.geometry.coordinates
1049
1046
  },
1050
1047
  symbol: {
1051
1048
  type: "simple-fill",
@@ -1062,5 +1059,5 @@ class $ {
1062
1059
  }
1063
1060
  }
1064
1061
  export {
1065
- $ as default
1062
+ F as default
1066
1063
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),J=require("@arcgis/core/core/promiseUtils"),A=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),T=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),E=require("md5"),F=require("pako"),R=require("vue"),_=require("../../stores/index.js"),M=require("../common-utils.js");function j(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const $=j(J),S=j(q),P=j(T);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new C({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new C({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),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([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:E(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var g,m;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(h){return{status:-1,message:h.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;M.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const l=await(await fetch(c)).arrayBuffer(),n=F.inflate(l,{to:"string"}),r=JSON.parse(n);await this.showAllLanes(r,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((m=e.options)==null?void 0:m.showRoadName)||!0);const d=o.data.result.junctions;if(this.showJunction(d),e.options&&e.options.centerMap!==!1){const h=M.default.transformPointProjection([0,0]);await this.view.goTo(h)}this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const u=_.default.useAppDataStore;return R.watch(()=>u.isSketching,()=>{var h,p;u.isSketching?((h=this.mouseMoveHandler)==null||h.remove(),this.mouseMoveHandler=void 0,(p=this.mouseClickHandler)==null||p.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const a=await(await fetch(s)).arrayBuffer(),l=F.inflate(a,{to:"string"}),n=JSON.parse(l);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const a=[];for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:r,refLine:d}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const g=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:r,roadName:u}});this.allRefLineGraphics.push(g),n.laneSections.sort((m,h)=>Number(m.id)-Number(h.id));for(let m=0;m<n.laneSections.length;m++){const h=n.laneSections[m],p=Number(h.id);for(const f of h.lanePaths){const w=Number(f.id);if(w===0)continue;const v=f.type,x=[...f.outerPath],N=f.innerPath.concat(x.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(f.innerPath[0]);const k=new A.Polygon({rings:[N]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${r}+${p}+${w}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(r),roadName:n.name,sectionId:String(p),sectionIndex:m,laneId:w,type:v,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath}});this.allLaneGraphics.push(G),a.push(G)}}}}const l=setInterval(()=>{if(a.length>0||this.allRefLineGraphics.length>0){if(a.length>0){const n=a.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(l),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const o=new y({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=$.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(a=>a.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const a=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(a===this.currentSectionCode||this.sectionLayer.graphics.findIndex(p=>p.getAttribute("id")===a)>=0)return;this.currentSectionCode=a;const n=this.allLaneGraphics.filter(p=>`${p.attributes.roadId}+${p.attributes.sectionId}`===a),r=S.union(n.map(p=>p.geometry)),d=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(d)||d,m=this.junctionNames.get(u)||u;this.highlightGraphic=new y({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,selected:!1,fromNodeName:g,toNodeName:m,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic);const h=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:h})}else if(s.layer.id==="OpenDriveJunction"){const a=this.hitGraphic.getAttribute("id");if(a===this.currentJunctionId)return;this.currentJunctionId=a,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=$.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),a=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:r.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:void 0}),s.setAttribute("selected",!1);const n=s.getAttribute("crossId");s.symbol.url=n?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(c==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",r.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:r.data.result}))}});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,a=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(a,{params:{id:c,projectName:this.projectName}});return l.status===200?l.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),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}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,a=s[0].split("#");if(a.length>2)return{status:-1,message:"id格式错误"};const l=a[0],n=a.length===2?Number(a[1]):void 0;return await this.findLane({roadsectId:l,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new y({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(l=>l.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.sectionId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),i>l.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=l[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.laneId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),o>l.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=l[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(l=>l.geometry),a=S.union(c);if(e.flash){const l=new y({geometry:a,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(l)}return await this.view.goTo(a,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&this.sectionLayer.remove(t)}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o="0";t.length===2&&(o=String(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionId")===o)),s.length>0){const c=S.union(s.map(l=>l.geometry)),a=new y({geometry:c,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(a),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const l of i.features){const n=l.getAttribute("roadId"),r=l.getAttribute("sectionId"),d=`${n}#${r}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const u=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(u,{params:{id:`${n}+${r}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(l=>{const n=l.geometry;return S.contains(t,n)}),a=[];for(const l of c){const n=l.getAttribute("id");this.selectSumo({type:"junction",id:n});const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(r,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&a.push(d.data.result)}return{status:0,message:"ok",result:{junctions:a,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let a=s[0];a.startsWith("-")&&(a=a.slice(1));const l=this.allLaneGraphics.filter(v=>v.getAttribute("roadId")===a&&v.getAttribute("sectionIndex")===c);if(l.length===0)return{status:-1,message:"未找到路段"};const n=l.length-o,r=l.find(v=>Math.abs(v.getAttribute("laneId"))===n);if(!r)return{status:-1,message:"未找到车道"};const d=e.start||0,u=e.end||100,g=P.lineString(r.getAttribute("leftLine")),m=O.lineSliceAlong(g,d,u,{units:"meters"}),h=P.lineString(r.getAttribute("rightLine")),p=O.lineSliceAlong(h,d,u,{units:"meters"}),f=m.geometry.coordinates.concat(p.geometry.coordinates.reverse());f.push(f[f.length-1]);const w=new y({geometry:new A.Polygon({rings:[f]}),attributes:{ObjectID:r.getAttribute("ObjectID"),id:r.getAttribute("id"),fromNode:r.getAttribute("fromNode"),toNode:r.getAttribute("toNode"),roadId:r.getAttribute("roadId"),roadName:r.getAttribute("roadName"),sectionId:r.getAttribute("sectionId"),sectionIndex:r.getAttribute("sectionIndex"),laneId:r.getAttribute("laneId"),type:r.getAttribute("type"),sumoId:r.getAttribute("sumoId"),leftLine:m.geometry.coordinates,rightLine:p.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(w),this.view.goTo(w),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}}exports.default=D;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),x=require("@arcgis/core/core/promiseUtils"),A=require("@arcgis/core/geometry"),J=require("@arcgis/core/geometry/geometryEngine"),C=require("@arcgis/core/layers/FeatureLayer"),I=require("@arcgis/core/layers/GraphicsLayer"),q=require("@turf/helpers"),O=require("@turf/line-slice-along"),b=require("axios"),T=require("md5"),F=require("pako"),E=require("vue"),R=require("../../stores/index.js"),_=require("../common-utils.js");function j(L){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const t in L)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(L,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>L[t]})}}return e.default=L,Object.freeze(e)}const M=j(x),S=j(J),$=j(q);class D{constructor(e){this.junctionNames=new Map,this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={collapseButton:!1,actionBar:!1},this.laneLayer=new C({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"},{name:"fromNode",alias:"起点路口",type:"string"},{name:"toNode",alias:"终点路口",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new C({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),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([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer,this.drawLayer,this.splitLaneLayer])}static getInstance(e){return this.instance||(this.instance=new D(e)),this.instance}async makeMd5FromFile(e){try{const i=await(await fetch(e)).text();return{status:0,message:"ok",result:T(i)}}catch(t){return{status:-1,message:t.message}}}async showOpenDriveFromFile(e){var g,p;this.openDriveClickCallback=e.selectedCallback,console.time("md5用时");const t=await this.makeMd5FromFile(e.file);if(t.status!==0)return t;this.projectName=t.result,console.timeEnd("md5用时"),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const i=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let o;try{o=await b.post(i,{},{params:{url:e.file,projectName:this.projectName}})}catch(m){return{status:-1,message:m.message}}if(o.status!==200)return{status:-1,message:o.statusText};console.time("渲染用时");const s=o.data.result.geoSetting;_.default.setGeoData(s.geoReference,s.offsetX,s.offsetY);let c=o.data.result.json;c.startsWith(window.location.protocol)||(c=`${window.location.protocol}//${e.server}${c}`);const l=await(await fetch(c)).arrayBuffer(),n=F.inflate(l,{to:"string"}),r=JSON.parse(n);await this.showAllLanes(r,((g=e.options)==null?void 0:g.showJunctionLane)||!1,((p=e.options)==null?void 0:p.showRoadName)||!0);const d=o.data.result.junctions;this.showJunction(d),e.options&&e.options.centerMap!==!1&&await this.view.goTo(this.allLaneGraphics),this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick();const u=R.default.useAppDataStore;return E.watch(()=>u.isSketching,()=>{var m,h;u.isSketching?((m=this.mouseMoveHandler)==null||m.remove(),this.mouseMoveHandler=void 0,(h=this.mouseClickHandler)==null||h.remove(),this.mouseClickHandler=void 0):(this.monitorMouseMove(),this.monitorMouseClick())}),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,o=await b.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let s=o.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const a=await(await fetch(s)).arrayBuffer(),l=F.inflate(a,{to:"string"}),n=JSON.parse(l);return await this.showAllLanes(n,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=i,new Promise(s=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const a=[];console.log(e.length);for(const n of e){if(!t&&n.junction!=="-1")continue;const{id:r,refLine:d}=n;let u=n.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const g=new y({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:c++,roadId:r,roadName:u}});this.allRefLineGraphics.push(g),n.laneSections.sort((p,m)=>Number(p.id)-Number(m.id));for(let p=0;p<n.laneSections.length;p++){const m=n.laneSections[p],h=Number(m.id);for(const f of m.lanePaths){const w=Number(f.id);if(w===0)continue;const v=f.type,P=[...f.outerPath],N=f.innerPath.concat(P.reverse());if(N.length<=3){console.warn(`lane ${w} has less than 3 points`);continue}N.push(f.innerPath[0]);const k=new A.Polygon({rings:[N]});if(k){const G=new y({geometry:k,attributes:{ObjectID:c++,id:`${r}+${h}+${w}`,fromNode:n.fromNode,toNode:n.toNode,roadId:String(r),roadName:n.name,sectionId:String(h),sectionIndex:p,laneId:w,type:v,sumoId:"",leftLine:f.innerPath,rightLine:f.outerPath}});this.allLaneGraphics.push(G),a.push(G)}}}}const l=setInterval(()=>{if(a.length>0||this.allRefLineGraphics.length>0){if(a.length>0){const n=a.splice(0,100);this.laneLayer.applyEdits({addFeatures:n})}if(this.allRefLineGraphics.length>0){const n=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:n})}}else clearInterval(l),s()},10)})}showJunction(e){const t=[];for(const i of e){if(!i)continue;this.junctionNames.set(i.id,i.name),i.nodeType=i.type;const o=new y({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30},popupTemplate:{title:i.name,content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"路口编号"},{fieldName:"crossId",label:"信号机编号"}]}]}});t.push(o)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=M.debounce(async t=>{var c;const o=(c=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(a=>a.type==="graphic");if(o.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.closePopup());return}const s=o[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const a=`${this.hitGraphic.getAttribute("roadId")}+${this.hitGraphic.getAttribute("sectionId")}`;if(a===this.currentSectionCode||this.sectionLayer.graphics.findIndex(h=>h.getAttribute("id")===a)>=0)return;this.currentSectionCode=a;const n=this.allLaneGraphics.filter(h=>`${h.attributes.roadId}+${h.attributes.sectionId}`===a),r=S.union(n.map(h=>h.geometry)),d=this.hitGraphic.getAttribute("fromNode"),u=this.hitGraphic.getAttribute("toNode"),g=this.junctionNames.get(d)||d,p=this.junctionNames.get(u)||u;this.highlightGraphic=new y({geometry:r,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",id:a,selected:!1,fromNodeName:g,toNodeName:p,laneCount:n.length},popupTemplate:{title:this.hitGraphic.getAttribute("roadName"),content:[{type:"fields",fieldInfos:[{fieldName:"fromNodeName",label:"起点路口"},{fieldName:"toNodeName",label:"终点路口"},{fieldName:"laneCount",label:"车道数量"}]}]}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic);const m=this.view.toMap(t);this.view.openPopup({features:[this.highlightGraphic],location:m})}else if(s.layer.id==="OpenDriveJunction"){const a=this.hitGraphic.getAttribute("id");if(a===this.currentJunctionId)return;this.currentJunctionId=a,this.view.openPopup({features:[this.hitGraphic],location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){const e=M.debounce(async t=>{var l;const o=(l=(await this.view.hitTest(t,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:l.filter(n=>n.type==="graphic");if(o.length===0)return;const s=o[0].graphic,c=s.getAttribute("type"),a=s.getAttribute("id");if(c==="OpenDriveJunction")if(s.getAttribute("selected")===!1){const n=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:r.data.result}),s.setAttribute("selected",!0),s.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(s,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:a,details:void 0}),s.setAttribute("selected",!1);const n=s.getAttribute("crossId");s.symbol.url=n?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(s,30)}else if(c==="OpenDriveSection")if(s.getAttribute("selected"))this.sectionLayer.remove(s),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:void 0});else{this.highlightLayer.remove(s),this.sectionLayer.add(s),s.setAttribute("selected",!0);const n=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,r=await b.get(n,{params:{id:a,projectName:this.projectName}});r.status===200&&r.data.status===0&&this.openDriveClickCallback&&(s.setAttribute("edgeId",r.data.result.obj_id),this.openDriveClickCallback({type:"OpenDriveSection",id:a,details:r.data.result}))}});this.mouseClickHandler=this.view.on("immediate-click",async t=>{e(t).catch(()=>{})})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s<t?e.symbol={type:"picture-marker",url:o.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const o=e.symbol,s=o.width;s>t?e.symbol={type:"picture-marker",url:o.url,width:s-1,height:s-1}:clearInterval(i)},20)}async getSumoInfo(e){switch(e.type){case"junction":{const t=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,i=await b.get(t,{params:{id:e.id,projectName:this.projectName}});return i.status===200?i.data:{status:-1,message:`路口信息查询失败: ${e.id}`}}case"edge":{const t=e.id.split("#");let i=t[0];i.startsWith("-")&&(i=i.slice(1));let o=0;t.length===2&&(o=Number(t[1]));const s=this.allLaneGraphics.find(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionIndex")===o);if(s){const c=`${i}+${s.getAttribute("sectionId")}`,a=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await b.get(a,{params:{id:c,projectName:this.projectName}});return l.status===200?l.data:{status:-1,message:`路段信息查询失败: ${c}`}}else return{status:-1,message:"未知类型"}}default:return{status:-1,message:"未知类型"}}}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),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}async findSumo(e){const{type:t,id:i}=e,o=e.flash===void 0?!0:e.flash;if(t==="junction")return await this.findJunction(i,o);if(t==="edge"){const s=i.split("_");if(s.length>2)return{status:-1,message:"id格式错误"};const c=s.length===2?Number(s[1]):void 0,a=s[0].split("#");if(a.length>2)return{status:-1,message:"id格式错误"};const l=a[0],n=a.length===2?Number(a[1]):void 0;return await this.findLane({roadsectId:l,segmentId:n,laneId:c,flash:o})}else return{status:-1,message:"未知类型"}}async findJunction(e,t){const i=this.junctionLayer.graphics.find(o=>o.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(t){const o=new y({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(o)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:t,segmentId:i,laneId:o}=e;t.startsWith("-")&&(t=t.slice(1));let s=this.allLaneGraphics.filter(l=>l.attributes.roadId===t);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.sectionId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),i>l.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=l[i],s=s.filter(n=>Number(n.attributes.sectionId)===i)}if(o!==void 0){const l=[];if(s.forEach(n=>{const r=Number(n.attributes.laneId);l.indexOf(r)===-1&&l.push(r)}),l.sort((n,r)=>n-r),o>l.length-1)return{status:-1,message:"未找到。请检查车道编号"};o=l[o],s=s.filter(n=>Number(n.attributes.laneId)===o)}const c=s.map(l=>l.geometry),a=S.union(c);if(e.flash){const l=new y({geometry:a,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(l)}return await this.view.goTo(a,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let t=0,i=!0;const o=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,t++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),t>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(o))},10)}unselectSumo(e){if((!e||e.type==="junction")&&this.junctionLayer.graphics.forEach(t=>{if((!e||!e.id||e.id===""||e.id===t.getAttribute("id"))&&t.getAttribute("selected")){t.setAttribute("selected",!1);const i=t.getAttribute("crossId");t.symbol.url=i?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}}),!e||e.type==="edge")if(!e||!e.id||e.id==="")this.sectionLayer.removeAll();else{const t=this.sectionLayer.graphics.find(i=>i.getAttribute("edgeId")===e.id);t&&this.sectionLayer.remove(t)}return{status:0,message:"ok"}}selectSumo(e){switch(e.type){case"junction":return this.junctionLayer.graphics.forEach(t=>{if(e.id===t.getAttribute("id"))return t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50),{status:0,message:"ok"}}),{status:-1,message:"未找到路口"};case"edge":{const t=e.id.split("#");let i=String(t[0]);i.startsWith("-")&&(i=i.slice(1));let o="0";t.length===2&&(o=String(t[1]));let s=[];if(t.length===1?s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i):t.length===2&&(s=this.allLaneGraphics.filter(c=>c.getAttribute("roadId")===i&&c.getAttribute("sectionId")===o)),s.length>0){const c=S.union(s.map(l=>l.geometry)),a=new y({geometry:c,symbol:{type:"simple-fill",color:[0,255,255,.5],style:"solid",outline:{color:[0,255,255],width:1}},attributes:{type:"OpenDriveSection",edgeId:e.id,selected:!0}});return this.sectionLayer.add(a),{status:0,message:"ok"}}else return{status:-1,message:"未找到路段"}}default:return{status:-1,message:"未知类型"}}}async geometrySearch(e){const t=new A.Polygon({rings:[e]}),i=await this.laneLayer.queryFeatures({geometry:t,outFields:["*"]}),o=[],s=[];for(const l of i.features){const n=l.getAttribute("roadId"),r=l.getAttribute("sectionId"),d=`${n}#${r}`;if(o.indexOf(d)===-1){o.push(d),this.selectSumo({type:"edge",id:d});const u=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,g=await b.get(u,{params:{id:`${n}+${r}`,projectName:this.projectName}});g.status===200&&g.data.status===0&&s.push(g.data.result)}}const c=this.junctionLayer.graphics.filter(l=>{const n=l.geometry;return S.contains(t,n)}),a=[];for(const l of c){const n=l.getAttribute("id");this.selectSumo({type:"junction",id:n});const r=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,d=await b.get(r,{params:{id:n,projectName:this.projectName}});d.status===200&&d.data.status===0&&a.push(d.data.result)}return{status:0,message:"ok",result:{junctions:a,edges:s}}}async splitLane(e){const i=e.id.split("_");if(i.length!==2)return{status:-1,message:"车道编号格式错误"};const o=Number(i[1]),s=i[0].split("#"),c=s.length===2?Number(s[1]):0;let a=s[0];a.startsWith("-")&&(a=a.slice(1));const l=this.allLaneGraphics.filter(v=>v.getAttribute("roadId")===a&&v.getAttribute("sectionIndex")===c);if(l.length===0)return{status:-1,message:"未找到路段"};const n=l.length-o,r=l.find(v=>Math.abs(v.getAttribute("laneId"))===n);if(!r)return{status:-1,message:"未找到车道"};const d=e.start||0,u=e.end||100,g=$.lineString(r.getAttribute("leftLine")),p=O.lineSliceAlong(g,d,u,{units:"meters"}),m=$.lineString(r.getAttribute("rightLine")),h=O.lineSliceAlong(m,d,u,{units:"meters"}),f=p.geometry.coordinates.concat(h.geometry.coordinates.reverse());f.push(f[f.length-1]);const w=new y({geometry:new A.Polygon({rings:[f]}),attributes:{ObjectID:r.getAttribute("ObjectID"),id:r.getAttribute("id"),fromNode:r.getAttribute("fromNode"),toNode:r.getAttribute("toNode"),roadId:r.getAttribute("roadId"),roadName:r.getAttribute("roadName"),sectionId:r.getAttribute("sectionId"),sectionIndex:r.getAttribute("sectionIndex"),laneId:r.getAttribute("laneId"),type:r.getAttribute("type"),sumoId:r.getAttribute("sumoId"),leftLine:p.geometry.coordinates,rightLine:h.geometry.coordinates},symbol:{type:"simple-fill",color:[255,0,0,.8],outline:{color:"red"}}});return this.splitLaneLayer.add(w),this.view.goTo(w),{status:0,message:"ok",result:e}}clearSplitLane(){this.splitLaneLayer.removeAll()}}exports.default=D;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.146",
3
+ "version": "1.0.147",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [