列车图例显示位置调整

This commit is contained in:
tiger_zhou 2023-04-26 17:55:46 +08:00
parent 7a20c4a659
commit af74502f37

View File

@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
@ -26,7 +27,6 @@ public class RuningService implements CalculateDiagram{
@Override
public Optional<StationDiagram> calculate(Simulation simulation, TrainInfo trainInfo, VirtualRealityTrain train, SortDiagramStation diagramStation){
String d = Objects.isNull(trainInfo.getEstimatedLeaveStandTrack()) ? trainInfo.getActualLeaveStandTrack() : trainInfo.getEstimatedLeaveStandTrack();
if(StringUtils.isEmpty(d)){
StationDiagram sd = new StationDiagram(train);
Station nextStation = diagramStation.findNext(train.getNextStation(),train.isRight());
@ -46,11 +46,8 @@ public class RuningService implements CalculateDiagram{
}else{
Station targetStation = diagramStation.findNext(leaveSeaction.getStation(),train.isRight());
Section targetStand = targetStation.getStandOf(train.isRight()).get(0).getSection();
Float complateDis = this.calculateStationRatio(leaveSeaction,targetStand,train);
Float complateDis = this.calculateStationRatio(simulation,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);
@ -60,11 +57,23 @@ public class RuningService implements CalculateDiagram{
}
}
private Float calculateStationRatio(Section begin,Section end,VirtualRealityTrain train){
float totalDis = CalculateService.calculateDistance(begin,end,train.isRight());
float off = begin.getStopPointByDirection(train.isRight());
float runOffset = CalculateService.calculateDistanceIgnoreSwitchFromStationToTrainHead(new SectionPosition(begin,off),train.getHeadPosition(),train.isRight());// - 188;// - train.getHeadPosition().getOffset();
private Float calculateStationRatio(Simulation simulation,Section begin,Section end,VirtualRealityTrain train){
Long mapId = simulation.getBuildParams().getMap().getId();
LocalDateTime simulationDateTime = simulation.getCorrectSystemTime();
Float totalDis;
Float runOffset;
try{
totalDis = CalculateService.calculateDistance(begin,end,train.isRight());
float off = begin.getStopPointByDirection(train.isRight());
runOffset = CalculateService.calculateDistanceIgnoreSwitchFromStationToTrainHead(new SectionPosition(begin,off),train.getHeadPosition(),train.isRight());
}catch (Exception e){
log.debug("计算失败 线路id:{} 仿真时间:{} 车次[{}] 方向[{}] 车头区段[{}] 车头位置[{}] 车尾区段[{}] 查找开始区段[{}] 结束区段[{}] 错误信息[{}] "
,mapId,simulationDateTime
,train.getGroupNumber(),train.isRight(),train.getHeadPosition().getSection().getCode(),train.getHeadPosition().getOffset()
,train.getTailPosition().getSection().getCode(),begin.getCode(),end.getCode(),e.getMessage(),e);
return null;
}
if(totalDis == 0F){
return 1F;
}
@ -74,12 +83,14 @@ public class RuningService implements CalculateDiagram{
if(d >= 1F){
d = 1F;
}
log.debug("车次[{}] 方向[{}] 车头区段[{}] 车头位置[{}] 车尾区段[{}] 是否停靠[{}] 查找开始区段[{}] 结束区段[{}] 距离总长[{}] 剩余距离[{}] 已行驶[{}] 行驶完成度[{}]"
log.debug("计算失败 线路id:{} 仿真时间:{} 车次[{}] 方向[{}] 车头区段[{}] 车头位置[{}] 车尾区段[{}] 查找开始区段[{}] 结束区段[{}] 距离总长[{}] 剩余距离[{}] 已行驶[{}] 行驶完成度[{}]"
,mapId,simulationDateTime
,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);
,train.getTailPosition().getSection().getCode(), begin.getCode(),end.getCode() , totalDis ,(totalDis - runOffset),runOffset ,d);
return Math.abs(d);
}catch (Exception e){
log.error("计算失败 groupNum:{},isRight:{},begin:{},end:{},totalDis:{},targetDis:{}",train.getGroupNumber() ,train.isRight(),begin.getCode() ,end.getCode() ,totalDis , runOffset);
log.error("计算失败 线路id:{} 仿真时间:{} groupNum:{},isRight:{},begin:{},end:{},totalDis:{},targetDis:{} 错误信息:{}",mapId,simulationDateTime
,train.getGroupNumber() ,train.isRight(),begin.getCode() ,end.getCode() ,totalDis , runOffset,e.getMessage(),e);
return null;
}
}