Commit 3c6a10c9 authored by Marion Goedel's avatar Marion Goedel
Browse files

Minor changes to Overlap Processors so that they also work if no overlap...

Minor changes to Overlap Processors so that they also work if no overlap happens during the simulation.
parent b8f80c58
Pipeline #68110 passed with stages
in 58 minutes and 39 seconds
...@@ -5,11 +5,19 @@ import org.vadere.state.scenario.DynamicElement; ...@@ -5,11 +5,19 @@ import org.vadere.state.scenario.DynamicElement;
public class OverlapData { public class OverlapData {
public static final OverlapData noOverLap = new OverlapData();
private final int ped1Id; private final int ped1Id;
private final int ped2Id; private final int ped2Id;
private final double dist; private final Double dist;
private final double overlap; private final Double overlap;
private OverlapData() {
this.ped1Id = -1;
this.ped2Id = -1;
this.dist = Double.POSITIVE_INFINITY;
this.overlap = 0.0;
}
public OverlapData(final DynamicElement ped1, final DynamicElement ped2, final double minDist){ public OverlapData(final DynamicElement ped1, final DynamicElement ped2, final double minDist){
...@@ -35,7 +43,7 @@ public class OverlapData { ...@@ -35,7 +43,7 @@ public class OverlapData {
return ped2Id; return ped2Id;
} }
public double getOverlap() { public Double getOverlap() {
return overlap; return overlap;
} }
......
...@@ -42,23 +42,13 @@ public class MaxOverlapProcessor extends DataProcessor<NoDataKey, Double> { ...@@ -42,23 +42,13 @@ public class MaxOverlapProcessor extends DataProcessor<NoDataKey, Double> {
public void postLoop(final SimulationState state) { public void postLoop(final SimulationState state) {
this.pedOverlapProc.postLoop(state); this.pedOverlapProc.postLoop(state);
Optional<OverlapData> maximumOverlap = this.pedOverlapProc.getData().values().stream().max(OverlapData::maxDist); OverlapData maximumOverlap = this.pedOverlapProc.getData().values().stream().max(OverlapData::maxDist).orElse(OverlapData.noOverLap);
this.putValue(NoDataKey.key(),maximumOverlap.getOverlap());
if(maximumOverlap.isPresent()){
this.putValue(NoDataKey.key(),maximumOverlap.get().getOverlap());
/* // Uncomment if you want a info box to inform you about the maximum overlap
MaxOverlapProcessor.infoBox("Minimum distance between centers: " + maximumOverlap + " meters" , "Maximum Overlap");
*/
}else{
this.putValue(NoDataKey.key(), null);
}
} }
public void postLoopAddResultInfo(final SimulationState state, SimulationResult result){ public void postLoopAddResultInfo(final SimulationState state, SimulationResult result){
result.setMaxOverlap(this.getValue(NoDataKey.key())); result.setMaxOverlap(this.getValue(NoDataKey.key()));
} }
......
...@@ -45,7 +45,7 @@ public class NumberOverlapsProcessor extends DataProcessor<NoDataKey, Long> { ...@@ -45,7 +45,7 @@ public class NumberOverlapsProcessor extends DataProcessor<NoDataKey, Long> {
@Override @Override
public void postLoopAddResultInfo(final SimulationState state, SimulationResult result){ public void postLoopAddResultInfo(final SimulationState state, SimulationResult result){
result.setTotalOverlaps(this.pedOverlapProc.getData().size()); result.setTotalOverlaps(this.getValue(NoDataKey.key()).intValue());
} }
@Override @Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment