This commit is contained in:
DU 2021-01-28 18:16:19 +08:00
commit a89d0735f7
2 changed files with 30 additions and 1 deletions

View File

@ -428,7 +428,7 @@ public class AtsTrainLoadService {
break;
} else {
RoutePath routePath = this.selectDefaultRoutePath(repository, startStationPlan.getSection(), endStationPlan.getSection());
if (routePath.containsSection(headPosition.getSection())) {
if (routePath.containsPosition(headPosition)) {
// 站间运行
train.setSpeed(0.1f);
trainInfo.updatePlanInfo(endStationPlan);

View File

@ -308,6 +308,35 @@ public class RoutePath {
return null;
}
public boolean containsPosition(SectionPosition position) {
if (this.sectionList.contains(position.getSection())) {
return true;
}
if (Objects.equals(position.getSection(), this.start)) {
if (this.isRight()) {
if (this.start.getStopPointRight() < position.getOffset()) {
return true;
}
} else {
if (position.getOffset() < this.start.getStopPointLeft()) {
return true;
}
}
}
if (Objects.equals(position.getSection(), this.end)) {
if (this.isRight()) {
if (this.end.getStopPointRight() >= position.getOffset()) {
return true;
}
} else {
if (position.getOffset() >= this.end.getStopPointLeft()) {
return true;
}
}
}
return false;
}
public boolean isStartSection(Section section) {
return Objects.equals(this.start, section);
}