UNPKG

gisviewer-vue3-arcgis

Version:

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

80 lines (79 loc) 2.84 kB
import { QuadrantCode as r } from "../../../types/index.mjs"; import h from "../common-utils.mjs"; import a from "./lane.mjs"; import { Polyline as L } from "@arcgis/core/geometry"; class l { constructor(t) { this.lanes = [], this.id = t; } async addLanes(t) { for (const n of t.lanes) for (const s of t.stopLines) { const e = await h.getIntersectPointsOfStopLineAndLane( s, n, [0.5, -0.5] ); if (e.length === 0) continue; const i = new L({ paths: [e] }), o = new a(); o.lanePolygon = n, o.stopLine = i, o.isEntry = !0, await o.getLaneDirection(), this.addLane(o); break; } } /** * 新增车道,并按道路中线至边线的方向排序 * @param lane * @returns */ addLane(t) { this.furthestLane || (this.furthestLane = t), this.dir || (this.dir = t.laneDirection, this.dir < 45 || this.dir > 315 ? this.quadrantCode = r.North : this.dir < 135 ? this.quadrantCode = r.East : this.dir < 225 ? this.quadrantCode = r.South : this.quadrantCode = r.West); const n = t.stopLine, s = n.paths[0]; switch (this.quadrantCode) { case r.West: t.stopLineCenter.x < this.furthestLane.stopLineCenter.x && (this.furthestLane = t), s[0][1] < s[1][1] && (n.paths = [s.reverse()]); for (let e = 0; e < this.lanes.length; e++) { const i = this.lanes[e]; if (t.stopLineCenter.y > i.stopLineCenter.y) { this.lanes.splice(e, 0, t); return; } } break; case r.North: t.stopLineCenter.y > this.furthestLane.stopLineCenter.y && (this.furthestLane = t), s[0][0] < s[1][0] && (n.paths = [s.reverse()]); for (let e = 0; e < this.lanes.length; e++) { const i = this.lanes[e]; if (t.stopLineCenter.x > i.stopLineCenter.x) { this.lanes.splice(e, 0, t); return; } } break; case r.East: t.stopLineCenter.x > this.furthestLane.stopLineCenter.x && (this.furthestLane = t), s[0][1] > s[1][1] && (n.paths = [s.reverse()]); for (let e = 0; e < this.lanes.length; e++) { const i = this.lanes[e]; if (t.stopLineCenter.y < i.stopLineCenter.y) { this.lanes.splice(e, 0, t); return; } } break; case r.South: t.stopLineCenter.y < this.furthestLane.stopLineCenter.y && (this.furthestLane = t), s[0][0] > s[1][0] && (n.paths = [s.reverse()]); for (let e = 0; e < this.lanes.length; e++) { const i = this.lanes[e]; if (t.stopLineCenter.x < i.stopLineCenter.x) { this.lanes.splice(e, 0, t); return; } } break; } this.lanes.push(t); } } export { l as default };