24.09., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit d822b11b authored by Marion Goedel's avatar Marion Goedel

Refactoring:

TimestepPedestrianIdOverlap -> TimestepPedestrianIdOverlapKey
pedestrianMaxOverlapProcessorId -> pedestrianOverlapDistProcessorId
parent ab02a3ef
......@@ -6,20 +6,20 @@ import org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestria
import java.util.Objects;
@OutputFileMap(outputFileClass = TimestepPedestrianIdOverlapOutputFile.class)
public class TimestepPedestrianIdOverlap implements DataKey<TimestepPedestrianIdOverlap> {
public class TimestepPedestrianIdOverlapKey implements DataKey<TimestepPedestrianIdOverlapKey> {
private final int timeStep;
private final int pedId1;
private final int pedId2;
public TimestepPedestrianIdOverlap(int timeStep, int pedId1, int pedId2) {
public TimestepPedestrianIdOverlapKey(int timeStep, int pedId1, int pedId2) {
this.timeStep = timeStep;
this.pedId1 = pedId1;
this.pedId2 = pedId2;
}
public static String[] getHeaders(){
return new String[]{TimestepKey.getHeader(), PedestrianIdKey.getHeader(), "overlapedWithPedestrianId"};
return new String[]{TimestepKey.getHeader(), PedestrianIdKey.getHeader(), "overlapPedestrianId"};
}
public int getTimeStep() {
......@@ -39,7 +39,7 @@ public class TimestepPedestrianIdOverlap implements DataKey<TimestepPedestrianId
}
@Override
public int compareTo(@NotNull TimestepPedestrianIdOverlap o) {
public int compareTo(@NotNull TimestepPedestrianIdOverlapKey o) {
int result = Integer.compare(this.timeStep, o.timeStep);
if (result == 0) {
result = Integer.compare(this.pedId1, o.pedId1);
......@@ -54,7 +54,7 @@ public class TimestepPedestrianIdOverlap implements DataKey<TimestepPedestrianId
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TimestepPedestrianIdOverlap that = (TimestepPedestrianIdOverlap) o;
TimestepPedestrianIdOverlapKey that = (TimestepPedestrianIdOverlapKey) o;
return timeStep == that.timeStep &&
pedId1 == that.pedId1 &&
pedId2 == that.pedId2;
......@@ -68,7 +68,7 @@ public class TimestepPedestrianIdOverlap implements DataKey<TimestepPedestrianId
@Override
public String toString() {
return "TimestepPedestrianIdOverlap{" +
return "TimestepPedestrianIdOverlapKey{" +
"timeStep=" + timeStep +
", pedId1=" + pedId1 +
", pedId2=" + pedId2 +
......
package org.vadere.simulator.projects.dataprocessing.outputfile;
import org.vadere.annotation.factories.outputfiles.OutputFileClass;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdOverlap;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdOverlapKey;
@OutputFileClass(dataKeyMapping = TimestepPedestrianIdOverlap.class)
public class TimestepPedestrianIdOverlapOutputFile extends OutputFile<TimestepPedestrianIdOverlap>{
@OutputFileClass(dataKeyMapping = TimestepPedestrianIdOverlapKey.class)
public class TimestepPedestrianIdOverlapOutputFile extends OutputFile<TimestepPedestrianIdOverlapKey>{
public TimestepPedestrianIdOverlapOutputFile() {
super(TimestepPedestrianIdOverlap.getHeaders());
super(TimestepPedestrianIdOverlapKey.getHeaders());
}
@Override
public String[] toStrings(final TimestepPedestrianIdOverlap key){
public String[] toStrings(final TimestepPedestrianIdOverlapKey key){
return key.toStrings();
}
}
......@@ -5,12 +5,9 @@ import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.NoDataKey;
import org.vadere.state.attributes.processor.AttributesMaxOverlapProcessor;
import org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import javax.swing.*;
import java.util.OptionalDouble;
import java.util.OptionalInt;
/**
* This processor saves the largest overlap (2*pedRadius - distance between the pedestrian's centers) for one simulation.
......@@ -68,7 +65,7 @@ public class MaxOverlapProcessor extends DataProcessor<NoDataKey, Double> {
public void init(final ProcessorManager manager) {
super.init(manager);
AttributesMaxOverlapProcessor att = (AttributesMaxOverlapProcessor) this.getAttributes();
this.pedOverlapProc = (PedestrianOverlapDistProcessor) manager.getProcessor(att.getPedestrianMaxOverlapProcessorId());
this.pedOverlapProc = (PedestrianOverlapDistProcessor) manager.getProcessor(att.getPedestrianOverlapDistProcessorId());
}
......
......@@ -4,7 +4,7 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.OverlapData;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdOverlap;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdOverlapKey;
import org.vadere.state.scenario.DynamicElement;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
......@@ -18,8 +18,9 @@ import java.util.stream.Collectors;
/**
* @author Mario Teixeira Parente
*/
@DataProcessorClass()
public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrianIdOverlap, OverlapData> {
public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrianIdOverlapKey, OverlapData> {
private double minDist;
......@@ -45,11 +46,11 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
.filter(OverlapData::isNotSelfOverlap)
.filter(OverlapData::isOverlap)
.collect(Collectors.toList());
overlaps.forEach(o -> this.putValue(new TimestepPedestrianIdOverlap(timeStep, o.getPed1Id(), o.getPed2Id()), o));
overlaps.forEach(o -> this.putValue(new TimestepPedestrianIdOverlapKey(timeStep, o.getPed1Id(), o.getPed2Id()), o));
}
}
public String[] toStrings(final TimestepPedestrianIdOverlap key) {
public String[] toStrings(final TimestepPedestrianIdOverlapKey key) {
return this.hasValue(key) ? this.getValue(key).toStrings() : new String[]{"N/A", "N/A"};
}
......
......@@ -2,7 +2,7 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.mockito.Mockito;
import org.vadere.simulator.projects.dataprocessing.datakey.OverlapData;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdOverlap;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdOverlapKey;
import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.DynamicElement;
......@@ -18,10 +18,9 @@ import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import static org.mockito.ArgumentMatchers.doubleThat;
import static org.mockito.Mockito.mock;
public class PedestrianOverlapProcessorTestEnv extends ProcessorTestEnv<TimestepPedestrianIdOverlap, OverlapData> {
public class PedestrianOverlapProcessorTestEnv extends ProcessorTestEnv<TimestepPedestrianIdOverlapKey, OverlapData> {
private PedestrianListBuilder b = new PedestrianListBuilder();
......@@ -35,7 +34,7 @@ public class PedestrianOverlapProcessorTestEnv extends ProcessorTestEnv<Timestep
try {
outputFile = outputFileFactory.createDefaultOutputfileByDataKey(
TimestepPedestrianIdOverlap.class,
TimestepPedestrianIdOverlapKey.class,
testedProcessor.getId());
} catch (ClassNotFoundException e) {
e.printStackTrace();
......@@ -82,10 +81,10 @@ public class PedestrianOverlapProcessorTestEnv extends ProcessorTestEnv<Timestep
Mockito.when(state.getTopography().getAttributesPedestrian().getRadius()).thenReturn(0.195);
int step = state.getStep();
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 1, 5), b.overlapData(1,5,minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 5, 1), b.overlapData(5,1,minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 1, 3), b.overlapData(1,3,minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 3, 1), b.overlapData(3,1, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 1, 5), b.overlapData(1,5,minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 5, 1), b.overlapData(5,1,minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 1, 3), b.overlapData(1,3,minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 3, 1), b.overlapData(3,1, minDist));
}
});
......@@ -101,21 +100,21 @@ public class PedestrianOverlapProcessorTestEnv extends ProcessorTestEnv<Timestep
Mockito.when(state.getTopography().getAttributesPedestrian().getRadius()).thenReturn(0.195);
int step = state.getStep();
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 1, 2), b.overlapData(1, 2, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 1, 3), b.overlapData(1, 3, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 1, 4), b.overlapData(1, 4, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 1, 2), b.overlapData(1, 2, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 1, 3), b.overlapData(1, 3, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 1, 4), b.overlapData(1, 4, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 2, 1), b.overlapData(2, 1, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 2, 3), b.overlapData(2, 3, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 2, 4), b.overlapData(2, 4, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 2, 1), b.overlapData(2, 1, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 2, 3), b.overlapData(2, 3, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 2, 4), b.overlapData(2, 4, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 3, 1), b.overlapData(3, 1, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 3, 2), b.overlapData(3, 2, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 3, 4), b.overlapData(3, 4, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 3, 1), b.overlapData(3, 1, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 3, 2), b.overlapData(3, 2, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 3, 4), b.overlapData(3, 4, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 4, 1), b.overlapData(4, 1, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 4, 2), b.overlapData(4, 2, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 4, 3), b.overlapData(4, 3, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 4, 1), b.overlapData(4, 1, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 4, 2), b.overlapData(4, 2, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 4, 3), b.overlapData(4, 3, minDist));
}
});
}
......@@ -127,12 +126,12 @@ public class PedestrianOverlapProcessorTestEnv extends ProcessorTestEnv<Timestep
addMockStates(a.getRadius(), distAtAxis, new VPoint(vertDistAt45deg, vertDistAt45deg));
double minDist = 0.195*2;
int step = 1;
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 1, 2), b.overlapData(1, 2, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 2, 1), b.overlapData(2, 1, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 3, 4), b.overlapData(3, 4, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 4, 3), b.overlapData(4, 3, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 5, 6), b.overlapData(5, 6, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlap(step, 6, 5), b.overlapData(6, 5, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 1, 2), b.overlapData(1, 2, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 2, 1), b.overlapData(2, 1, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 3, 4), b.overlapData(3, 4, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 4, 3), b.overlapData(4, 3, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 5, 6), b.overlapData(5, 6, minDist));
addToExpectedOutput(new TimestepPedestrianIdOverlapKey(step, 6, 5), b.overlapData(6, 5, minDist));
}
......
......@@ -6,14 +6,14 @@ package org.vadere.state.attributes.processor;
*/
public class AttributesMaxOverlapProcessor extends AttributesProcessor {
private int pedestrianMaxOverlapProcessorId;
private int pedestrianOverlapDistProcessorId;
public int getPedestrianMaxOverlapProcessorId() {
return this.pedestrianMaxOverlapProcessorId;
public int getPedestrianOverlapDistProcessorId() {
return this.pedestrianOverlapDistProcessorId;
}
public void getPedestrianMaxOverlapProcessorId(int pedestrianMaxOverlapProcessorId) {
public void getPedestrianOverlapDistProcessorId(int pedestrianOverlapDistProcessorId) {
checkSealed();
this.pedestrianMaxOverlapProcessorId = pedestrianMaxOverlapProcessorId;
this.pedestrianOverlapDistProcessorId = pedestrianOverlapDistProcessorId;
}
}
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