UNPKG

gisviewer-vue3-arcgis

Version:

在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:

2 lines (1 loc) 2.62 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("@arcgis/core/geometry"),d=require("../common-utils.js"),u=require("./entrance.js"),f=require("./exit.js");class g{constructor(n){this.nearbyFeatures=new Map,this.entrances=[],this.exits=[],this.initialized=!1,this.id=n.id,this.crossCenter=new a.Point({x:n.center[0],y:n.center[1]})}async initialize(n){n.lanes.forEach(e=>{const t=e.getAttribute("RoadSecID"),s=e.geometry,i=this.nearbyFeatures.get(t);i?i.lanes.push(s):this.nearbyFeatures.set(t,{lanes:[s],stopLines:[]})}),n.stopLines.forEach(e=>{const t=e.getAttribute("RoadSecID"),s=e.geometry,i=this.nearbyFeatures.get(t);i?i.stopLines.push(s):this.nearbyFeatures.set(t,{lanes:[],stopLines:[s]})}),await this.createEntranceAndExit(),console.log(`${this.id} has ${this.entrances.length} entrance`),this.entrances.forEach(e=>{console.log(`${e.id} has ${e.lanes.length} lanes`)}),this.orderEntrance(),this.initialized=!0}getLaneNumberInfo(){const n=[];return this.entrances.forEach(e=>{e.lanes.forEach((t,s)=>{n.push({crossId:this.id,laneNumber:e.id+String(s+1),stopLineCenter:[t.stopLineCenter.x,t.stopLineCenter.y],laneDirection:t.laneDirection-180})})}),this.exits.forEach(e=>{e.lanes.forEach((t,s)=>{n.push({crossId:this.id,laneNumber:"-"+e.id+String(s+1),stopLineCenter:[t.stopLineCenter.x,t.stopLineCenter.y],laneDirection:t.laneDirection-180})})}),n}async calCrossIndicatorArea(){const n=[];for(let e=0;e<this.entrances.length;e++){const t=this.entrances[e],s=this.entrances[(e+1)%this.entrances.length],i=t.furthestLane.extendedStopLine,c=s.furthestLane.extendedStopLine,o=await d.default.getIntersectPointOfTwoLines(i,c);if(o)n.push(o);else{const r=this.findExitOfEntrance(t),h=(r?r.lanes[r.lanes.length-1]:t.lanes[t.lanes.length-1]).stopLine.getPoint(0,1);n.push(h);const l=s.lanes[s.lanes.length-1].stopLine.getPoint(0,1);n.push(l)}}if(n.length>2)return new a.Polygon({rings:[n.map(e=>[e.x,e.y])]})}async createEntranceAndExit(){for(const n of this.nearbyFeatures){const e=n[0],t=n[1];if(t.stopLines.length===0){const s=new f.default(e);s.addLanes(t),this.exits.push(s)}else{const s=new u.default(e);await s.addLanes(t),this.entrances.push(s)}}for(const n of this.exits)await n.findCorrespondingEntrance(this.entrances)}orderEntrance(){this.entrances.sort((n,e)=>{let t=n.dir,s=e.dir;return t<225&&(t+=360),s<225&&(s+=360),t-s}),this.entrances.forEach((n,e)=>{n.id=String(e+1);const t=this.findExitOfEntrance(n);t&&(t.id=String(e+1))})}findExitOfEntrance(n){for(const e of this.exits)if(e.entrance===n)return e}}exports.default=g;