列车图例显示位置调整

This commit is contained in:
tiger_zhou 2023-04-26 16:28:52 +08:00
parent f4df139cbb
commit 7a20c4a659
2 changed files with 12 additions and 1 deletions

View File

@ -23,8 +23,10 @@ public class SortDiagramStation {
return IntStream.range(0,stationList.size()).filter(d-> Objects.equals(stationList.get(d).getCode(),station.getCode())).findFirst().getAsInt();
}
public Station findLastNotDepotStation(boolean isRight){
int index =isRight ? stationList.size() - 1 : 0 ;
// int index = this.findFirstIndex(isRight);
Station station1 = stationList.get(index);
if(isRight){
if(station1.isDepot()){
@ -39,6 +41,7 @@ public class SortDiagramStation {
}
public Station findFirstNotDepotStation(boolean isRight){
int index = isRight ? 0 : stationList.size() - 1;
// int index = this.findFirstIndex(isRight);
Station station1 = stationList.get(index);
if(isRight){
if(station1.isDepot()){

View File

@ -47,12 +47,17 @@ public class RuningService implements CalculateDiagram{
Station targetStation = diagramStation.findNext(leaveSeaction.getStation(),train.isRight());
Section targetStand = targetStation.getStandOf(train.isRight()).get(0).getSection();
Float complateDis = this.calculateStationRatio(leaveSeaction,targetStand,train);
if(Objects.isNull(complateDis)){
Long mapId = simulation.getBuildParams().getMap().getId();
log.debug("计算图例位置失败 线路id[{}] 仿真时间[{}] 列车[{}] 方向[{}] 计算开始区段[{}] 结束区段[{}]"
,mapId,simulation.getCorrectSystemTime(),train.getGroupNumber(),train.isRight(),leaveSeaction.getCode(),targetStand.getCode());
return Optional.empty();
}
StationDiagram stationDiagram = new StationDiagram(train,true,complateDis,false);
stationDiagram.setStartStation(leaveSeaction.getStation());
stationDiagram.setEndStation(targetStand.getStation());
return Optional.of(stationDiagram);
}
}
private Float calculateStationRatio(Section begin,Section end,VirtualRealityTrain train){
@ -66,6 +71,9 @@ public class RuningService implements CalculateDiagram{
try{
double t = runOffset / totalDis;
float d = new BigDecimal(t).setScale(3, RoundingMode.HALF_UP).floatValue();
if(d >= 1F){
d = 1F;
}
log.debug("车次[{}] 方向[{}] 车头区段[{}] 车头位置[{}] 车尾区段[{}] 是否停靠[{}] 查找开始区段[{}] 结束区段[{}] 距离总长[{}] 剩余距离[{}] 已行驶[{}] 行驶完成度[{}]"
,train.getGroupNumber(),train.isRight(),train.getHeadPosition().getSection().getCode(),train.getHeadPosition().getOffset()
,train.getTailPosition().getSection().getCode(),train.isParkingAt(),begin.getCode(),end.getCode() , totalDis ,(totalDis - runOffset),runOffset ,d);