Commit ca33418b authored by Jakob Schöttl's avatar Jakob Schöttl

Rename method setValue to addValue

parent 5f93c5bc
......@@ -12,6 +12,6 @@ public abstract class AreaDensityProcessor extends AreaProcessor<Double> {
@Override
protected void doUpdate(final SimulationState state) {
this.setValue(new TimestepDataKey(state.getStep()), this.densAlg.getDensity(state));
this.addValue(new TimestepDataKey(state.getStep()), this.densAlg.getDensity(state));
}
}
......@@ -35,7 +35,7 @@ public class AreaSpeedProcessor extends AreaProcessor<Double> {
}
}
this.setValue(new TimestepDataKey(step), sumVelocities / pedCount);
this.addValue(new TimestepDataKey(step), sumVelocities / pedCount);
}
@Override
......
......@@ -24,7 +24,7 @@ public class EvacuationTimeProcessor extends Processor<NoDataKey, Double> {
Collection<Pedestrian> peds = state.getTopography().getElements(Pedestrian.class);
this.setValue(NoDataKey.key(), this.pedEvacTimeProc.getValues().stream().anyMatch(tevac -> tevac == Double.NaN)
this.addValue(NoDataKey.key(), this.pedEvacTimeProc.getValues().stream().anyMatch(tevac -> tevac == Double.NaN)
? Double.NaN
: Collections.max(this.pedEvacTimeProc.getValues()));
}
......
......@@ -32,7 +32,7 @@ public class MeanPedestrianEvacuationTimeProcessor extends Processor<NoDataKey,
.collect(Collectors.toList());
int count = nonNans.size();
this.setValue(NoDataKey.key(), count > 0
this.addValue(NoDataKey.key(), count > 0
? nonNans.stream().reduce(0.0, (val1, val2) -> val1 + val2) / count
: Double.NaN);
}
......
......@@ -17,7 +17,7 @@ public abstract class PedestrianDensityProcessor extends Processor<TimestepPedes
this.pedPosProc.update(state);
state.getTopography().getElements(Pedestrian.class).stream()
.forEach(ped -> this.setValue(new TimestepPedestrianIdDataKey(state.getStep(), ped.getId()),
.forEach(ped -> this.addValue(new TimestepPedestrianIdDataKey(state.getStep(), ped.getId()),
this.densAlg.getDensity(ped.getPosition(), state)));
}
......
......@@ -27,6 +27,6 @@ public class PedestrianEndTimeProcessor extends Processor<PedestrianIdDataKey, D
private void setValues(Collection<Pedestrian> peds, double value) {
peds.stream().map(ped -> new PedestrianIdDataKey(ped.getId()))
.forEach(key -> this.setValue(key, value));
.forEach(key -> this.addValue(key, value));
}
}
......@@ -16,14 +16,14 @@ public class PedestrianEvacuationTimeProcessor extends Processor<PedestrianIdDat
state.getTopography().getElements(Pedestrian.class).stream()
.map(ped -> new PedestrianIdDataKey(ped.getId()))
.forEach(key -> this.setValue(key, state.getSimTimeInSec() - this.pedStTimeProc.getValue(key)));
.forEach(key -> this.addValue(key, state.getSimTimeInSec() - this.pedStTimeProc.getValue(key)));
}
@Override
public void postLoop(final SimulationState state) {
state.getTopography().getElements(Pedestrian.class).stream()
.map(ped -> new PedestrianIdDataKey(ped.getId()))
.forEach(key -> this.setValue(key, Double.NaN));
.forEach(key -> this.addValue(key, Double.NaN));
}
@Override
......
......@@ -24,7 +24,7 @@ public class PedestrianFlowProcessor extends Processor<TimestepPedestrianIdDataK
double velocity = this.pedVelProc.getValue(key);
double density = this.pedDensProc.getValue(key);
this.setValue(key, velocity * density);
this.addValue(key, velocity * density);
}
}
......
......@@ -17,7 +17,7 @@ public class PedestrianLastPositionProcessor extends Processor<PedestrianIdDataK
this.pedPosProc.update(state);
Map<Integer, VPoint> pedPosMap = state.getPedestrainPositionMap();
pedPosMap.keySet().forEach(pedId -> this.setValue(new PedestrianIdDataKey(pedId),
pedPosMap.keySet().forEach(pedId -> this.addValue(new PedestrianIdDataKey(pedId),
this.pedPosProc.getValue(new TimestepPedestrianIdDataKey(state.getStep(), pedId))));
}
......
......@@ -20,7 +20,7 @@ public class PedestrianOSMStrideLengthProcessor extends Processor<TimestepPedest
protected void doUpdate(final SimulationState state) {
Collection<Pedestrian> peds = state.getTopography().getElements(Pedestrian.class);
// TODO: if osm != null then compute stridelength
peds.forEach(ped -> this.setValue(new TimestepPedestrianIdDataKey(state.getStep(), ped.getId()), this.osm == null ? Double.NaN : 0.0));
peds.forEach(ped -> this.addValue(new TimestepPedestrianIdDataKey(state.getStep(), ped.getId()), this.osm == null ? Double.NaN : 0.0));
}
@Override
......
......@@ -16,7 +16,7 @@ public class PedestrianOverlapProcessor extends Processor<TimestepPedestrianIdDa
protected void doUpdate(final SimulationState state) {
Map<Integer, VPoint> pedPosMap = state.getPedestrainPositionMap();
pedPosMap.entrySet().forEach(entry -> this.setValue(new TimestepPedestrianIdDataKey(state.getStep(), entry.getKey()), this.calculateOverlaps(pedPosMap, entry.getValue())));
pedPosMap.entrySet().forEach(entry -> this.addValue(new TimestepPedestrianIdDataKey(state.getStep(), entry.getKey()), this.calculateOverlaps(pedPosMap, entry.getValue())));
}
@Override
......
......@@ -28,7 +28,7 @@ public class PedestrianPositionProcessor extends Processor<TimestepPedestrianIdD
Integer pedId = entry.getKey();
VPoint pos = entry.getValue();
this.setValue(new TimestepPedestrianIdDataKey(timeStep, pedId), pos);
this.addValue(new TimestepPedestrianIdDataKey(timeStep, pedId), pos);
}
}
......
......@@ -15,7 +15,7 @@ public class PedestrianSourceIdProcessor extends Processor<PedestrianIdDataKey,
public void doUpdate(final SimulationState state) {
Collection<Pedestrian> peds = state.getTopography().getElements(Pedestrian.class);
peds.forEach(p -> this.setValue(new PedestrianIdDataKey(p.getId()), -1));
peds.forEach(p -> this.addValue(new PedestrianIdDataKey(p.getId()), -1));
}
@Override
......
......@@ -26,6 +26,6 @@ public class PedestrianStartTimeProcessor extends Processor<PedestrianIdDataKey,
Set<PedestrianIdDataKey> keys = this.getKeys();
if (!keys.contains(pedIdKey))
this.setValue(pedIdKey, startTime);
this.addValue(pedIdKey, startTime);
}
}
......@@ -15,7 +15,7 @@ public class PedestrianTargetIdProcessor extends Processor<TimestepPedestrianIdD
public void doUpdate(final SimulationState state) {
Collection<Pedestrian> peds = state.getTopography().getElements(Pedestrian.class);
peds.forEach(p -> this.setValue(new TimestepPedestrianIdDataKey(state.getStep(), p.getId()),
peds.forEach(p -> this.addValue(new TimestepPedestrianIdDataKey(state.getStep(), p.getId()),
p.getTargets().isEmpty() ? -1 : p.getTargets().getFirst()));
}
......
......@@ -27,7 +27,7 @@ public class PedestrianVelocityProcessor extends Processor<TimestepPedestrianIdD
Integer timeStep = state.getStep();
Stream<Integer> pedIds = state.getTopography().getElements(Pedestrian.class).stream().map(ped -> ped.getId());
pedIds.forEach(pedId -> this.setValue(new TimestepPedestrianIdDataKey(timeStep, pedId),
pedIds.forEach(pedId -> this.addValue(new TimestepPedestrianIdDataKey(timeStep, pedId),
this.getVelocity(timeStep, state.getSimTimeInSec(), pedId)));
if (this.lastSimTimes.size() >= this.backSteps)
......
......@@ -23,7 +23,7 @@ public class PedestrianWaitingEndTimeProcessor extends Processor<PedestrianIdDat
if (this.waitingArea.contains(pos)) {
PedestrianIdDataKey key = new PedestrianIdDataKey(pedId);
this.setValue(key, state.getSimTimeInSec());
this.addValue(key, state.getSimTimeInSec());
}
}
}
......
......@@ -28,7 +28,7 @@ public class PedestrianWaitingTimeProcessor extends Processor<PedestrianIdDataKe
if (this.waitingArea.contains(pos)) {
PedestrianIdDataKey key = new PedestrianIdDataKey(pedId);
this.setValue(key, (this.hasValue(key) ? this.getValue(key) : 0.0) + dt);
this.addValue(key, (this.hasValue(key) ? this.getValue(key) : 0.0) + dt);
}
}
......
......@@ -62,7 +62,7 @@ public abstract class Processor<K extends Comparable<K>, V> {
return column.get(key);
}
protected void setValue(final K key, final V value) {
protected void addValue(final K key, final V value) {
this.column.put(key, value);
}
......
Markdown is supported
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