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

Commit ce1611ad authored by Daniel Lehmberg's avatar Daniel Lehmberg
Browse files

change PedestrianFootStepProcessor to use EventtimePedestrianIdKey

parent 7664b98c
Pipeline #130699 failed with stages
in 78 minutes and 58 seconds
......@@ -18,6 +18,7 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
* description of what the processor does.
* See e.g. AreaDensityVoronoiProcessor / AreaDensityVoronoiAlgorithm
*/
@DataProcessorClass(label = "AreaDensityCountingProcessor")
public class AreaDensityCountingProcessor extends AreaDataProcessor<Integer> {
......
......@@ -3,44 +3,44 @@ package org.vadere.simulator.projects.dataprocessing.processor;
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.TimestepPedestrianIdKey;
import org.vadere.simulator.projects.dataprocessing.datakey.EventtimePedestrianIdKey;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.simulation.FootStep;
import org.vadere.state.simulation.VTrajectory;
import org.vadere.state.util.StateJsonConverter;
import java.util.Arrays;
import java.util.LinkedList;
/**
* <p>During one time step a pedestrian my move multiple times which is saved by
* {@link Pedestrian#getFootSteps()}, i.e. the {@link VTrajectory} will be adjusted
* after each update(simTimeInSec) call such that it contains the foot steps which
* started at the lastSimTimeInSec!</p>
* <p>During one time step a pedestrian my move multiple times which is saved by {@link Pedestrian#getFootSteps()}, i.e.
* the {@link VTrajectory} will be adjusted after each update(simTimeInSec) call such that it contains the foot steps
* which started at the lastSimTimeInSec!</p>
*
* <p>This processor writes out all those {@link FootStep}s using the standard JSON-format, e.g. one foot steps:
* [{"startTime":26.588661014252686,"endTime":27.123123483931312,"start":{"x":29.4730189272315,"y":24.965262390895376},"end":{"x":29.59817287115996,"y":25.182035380547074}}]
* <p>This processor writes out all those {@link FootStep}s. The index is the simulation time where the event occurred
* and the pedestrian id. The "endTime" of the foot step is part of the data. Each row corresponds to one foot step.
* </p>
*
* <p>This is especially useful if one
* uses the {@link org.vadere.simulator.models.osm.OptimalStepsModel} or any other
* {@link org.vadere.simulator.models.MainModel} for which pedestrians do multiple steps during
* a simulation time step.</p>
* <p>This is especially useful if one uses the {@link org.vadere.simulator.models.osm.OptimalStepsModel} or any other
* {@link org.vadere.simulator.models.MainModel} for which pedestrians do multiple steps during a simulation time step.
* </p>
*
* @author Benedikt Zoennchen
*/
@DataProcessorClass()
public class PedestrianFootStepProcessor extends DataProcessor<TimestepPedestrianIdKey, VTrajectory>{
public class PedestrianFootStepProcessor extends DataProcessor<EventtimePedestrianIdKey, FootStep> {
public PedestrianFootStepProcessor() {
super("strides");
super("endTime", "startX", "startY", "endX", "endY");
}
@Override
protected void doUpdate(final SimulationState state) {
Integer timeStep = state.getStep();
for (Pedestrian pedestrian : state.getTopography().getElements(Pedestrian.class)) {
VTrajectory copy = pedestrian.getFootSteps().clone();
putValue(new TimestepPedestrianIdKey(timeStep, pedestrian.getId()), copy);
LinkedList<FootStep> footSteps = pedestrian.getFootSteps().clone().getFootSteps();
for (FootStep fs : footSteps) {
putValue(new EventtimePedestrianIdKey(fs.getStartTime(), pedestrian.getId()), fs);
}
}
}
......@@ -50,19 +50,9 @@ public class PedestrianFootStepProcessor extends DataProcessor<TimestepPedestria
}
@Override
public String[] toStrings(TimestepPedestrianIdKey key) {
LinkedList<FootStep> strides = this.getValue(key).getFootSteps();
StringBuilder builder = new StringBuilder();
if(strides == null) {
return new String[]{"{}"};
}
else {
builder.append("[");
String stridesString = StateJsonConverter.serialidzeObject(strides);
builder.append("]");
return new String[]{stridesString};
}
public String[] toStrings(EventtimePedestrianIdKey key) {
String[] footStepLine = this.getValue(key).getValueString();
return Arrays.copyOfRange(footStepLine, 1, footStepLine.length);
}
}
\ No newline at end of file
......@@ -126,4 +126,10 @@ public final class FootStep {
public String toString() {
return start + "->" + end;
}
public String[] getValueString(){
String[] valueLine = {""+startTime, ""+endTime, ""+start.x, ""+start.y, ""+end.x, ""+end.y};
return valueLine;
}
}
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