运行线生成关联车站限制增加

This commit is contained in:
fan 2023-06-29 09:59:16 +08:00
parent 632371b64c
commit 2f5a932c58

View File

@ -6,6 +6,7 @@ import {
getNormalVector, getNormalVector,
movePointAlongNormal, movePointAlongNormal,
getIntersectionPoint, getIntersectionPoint,
distance,
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import { RunLineName } from './RunLineName'; import { RunLineName } from './RunLineName';
import { PathLine } from '../pathLine/PathLine'; import { PathLine } from '../pathLine/PathLine';
@ -249,17 +250,28 @@ export class RunLine extends JlGraphic {
this.datas.points.forEach((p, index) => { this.datas.points.forEach((p, index) => {
if (index) { if (index) {
stations.forEach((station) => { stations.forEach((station) => {
const distance = calculateDistanceFromPointToLine( const sp = station.position;
const prep = this.datas.points[index - 1];
const distanceF = calculateDistanceFromPointToLine(
p, p,
this.datas.points[index - 1], this.datas.points[index - 1],
station.position station.position
); );
if (distance < 4) { const distance1 = distance(sp.x, sp.y, prep.x, prep.y);
const distance2 = distance(sp.x, sp.y, p.x, p.y);
const distance3 = distance(p.x, p.y, prep.x, prep.y);
if (
distanceF < 4 &&
distance1 < distance3 + distanceF &&
distance2 < distance3 + distanceF &&
!containSta.includes(station.id)
) {
containSta.push(station.id); containSta.push(station.id);
} }
}); });
} }
}); });
console.log(containSta);
this.datas.containSta = containSta; this.datas.containSta = containSta;
} }
generatePathLineKilometerPoints(): void { generatePathLineKilometerPoints(): void {