gisviewer-vue3-arcgis
Version:
在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:
87 lines (86 loc) • 2.6 kB
JavaScript
import p from "../common-utils.mjs";
import f from "./lane.mjs";
import { Polyline as h } from "@arcgis/core/geometry";
import * as y from "@arcgis/core/geometry/geometryEngineAsync";
import { QuadrantCode as o } from "../../../types/index.mjs";
class C {
constructor(t) {
this.lanes = [], this.id = t;
}
/**
* 寻找对应的进口道
* @param entrances
*/
async findCorrespondingEntrance(t) {
var a;
const e = this.lanes[0], n = e.lanePolygon.centroid;
let s, r = 1 / 0, i;
for (const c of t) {
s = c.lanes[0].lanePolygon.centroid;
const d = new h({
paths: [
[
[s.x, s.y],
[n.x, n.y]
]
]
}), l = await y.geodesicLength(d, "meters");
l < r && (r = l, i = c);
}
const L = i.furthestLane.extendedStopLine;
(await p.getIntersectPointsOfStopLineAndLane(
L,
e.lanePolygon,
[5]
)).length && (this.entrance = i, await this.splitStopLine(), console.log(`${this.id}的对应进口道是${(a = this.entrance) == null ? void 0 : a.id}`));
}
addLanes(t) {
for (const e of t.lanes) {
const n = new f();
n.lanePolygon = e, n.isEntry = !1, this.lanes.push(n);
}
}
async splitStopLine() {
if (this.entrance) {
for (const t of this.lanes) {
const e = await p.getIntersectPointsOfStopLineAndLane(
this.entrance.furthestLane.extendedStopLine,
t.lanePolygon,
[0.5, 1, 2, 3, 4, 5, 6, 7, 8]
);
if (e.length !== 0) {
switch (this.entrance.quadrantCode) {
case o.West:
e.sort((n, s) => n[1] - s[1]);
break;
case o.North:
e.sort((n, s) => n[0] - s[0]);
break;
case o.East:
e.sort((n, s) => s[1] - n[1]);
break;
case o.South:
e.sort((n, s) => s[0] - n[0]);
break;
}
t.stopLine = new h({ paths: [e] }), await t.getLaneDirection();
}
}
this.lanes.sort((t, e) => {
switch (this.entrance.quadrantCode) {
case o.West:
return t.stopLine.extent.center.y - e.stopLine.extent.center.y;
case o.North:
return t.stopLine.extent.center.x - e.stopLine.extent.center.x;
case o.East:
return e.stopLine.extent.center.y - t.stopLine.extent.center.y;
case o.South:
return e.stopLine.extent.center.x - t.stopLine.extent.center.x;
}
});
}
}
}
export {
C as default
};