轨迹线公里标点生成逻辑调整
This commit is contained in:
parent
180712d9c4
commit
331eaf042b
@ -90,31 +90,52 @@ export class PathLine extends JlGraphic {
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 计算stationLine在轨迹线上的垂足距离,计算stationLine与轨迹点距离,寻求最短且垂足在线段上
|
||||
* @param stas stationLine列表
|
||||
*/
|
||||
generatePathLineKilometerPoints(stas: string[]) {
|
||||
const kilometerPoints: KilometerPoint[] = [];
|
||||
stas.forEach((stasId) => {
|
||||
const sta = this.queryStore.queryById(stasId) as StationLine;
|
||||
let fp: Point | null = null;
|
||||
let verticalLength = 100;
|
||||
let fp: IPointData | null = null;
|
||||
const sp = sta.position;
|
||||
let minDistance = Number.MAX_SAFE_INTEGER;
|
||||
this.datas.points.forEach((p, index) => {
|
||||
if (index) {
|
||||
const prep = this.datas.points[index - 1];
|
||||
const fpn = calculateFootPointFromPointToLine(prep, p, sta.position);
|
||||
const length = distance(prep.x, prep.y, p.x, p.y);
|
||||
const fln = distance(fpn.x, fpn.y, sta.position.x, sta.position.y);
|
||||
const fpn = calculateFootPointFromPointToLine(prep, p, sp);
|
||||
const distanceS = distance(prep.x, prep.y, p.x, p.y);
|
||||
const fln = distance(fpn.x, fpn.y, sp.x, sp.y);
|
||||
const distanceP = distance(p.x, p.y, sp.x, sp.y);
|
||||
if (
|
||||
distance(fpn.x, fpn.y, prep.x, prep.y) <= length &&
|
||||
distance(fpn.x, fpn.y, p.x, p.y) <= length &&
|
||||
fln <= verticalLength
|
||||
distance(fpn.x, fpn.y, prep.x, prep.y) <= distanceS &&
|
||||
distance(fpn.x, fpn.y, p.x, p.y) <= distanceS &&
|
||||
fln <= minDistance
|
||||
) {
|
||||
verticalLength = fln;
|
||||
minDistance = fln;
|
||||
fp = fpn;
|
||||
}
|
||||
if (distanceP < minDistance) {
|
||||
if (distanceP < minDistance) {
|
||||
minDistance = distanceP;
|
||||
fp = p;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const distanceP = distance(p.x, p.y, sp.x, sp.y);
|
||||
if (distanceP < minDistance) {
|
||||
minDistance = distanceP;
|
||||
fp = p;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (sta.datas.code === '延平门') {
|
||||
console.log(fp);
|
||||
}
|
||||
if (fp) {
|
||||
kilometerPoints.push({
|
||||
point: fp,
|
||||
point: new Point(fp?.['x'], fp?.['y']),
|
||||
kilometer: 0,
|
||||
stName: sta.datas.code,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user