Commit c6997cb8 authored by hm-lehmberg's avatar hm-lehmberg

some comments and minor code changes

parent 3fba9b7e
Pipeline #113335 passed with stages
in 142 minutes and 47 seconds
...@@ -4,7 +4,6 @@ import org.vadere.simulator.projects.dataprocessing.ProcessorManager; ...@@ -4,7 +4,6 @@ import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey; import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.state.attributes.processor.AttributesAreaProcessor; import org.vadere.state.attributes.processor.AttributesAreaProcessor;
import org.vadere.state.scenario.MeasurementArea; import org.vadere.state.scenario.MeasurementArea;
import org.vadere.util.geometry.shapes.VRectangle;
/** /**
* @author Mario Teixeira Parente * @author Mario Teixeira Parente
......
...@@ -5,7 +5,6 @@ import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey; ...@@ -5,7 +5,6 @@ import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.state.attributes.processor.AttributesAreaDensityCountingProcessor; import org.vadere.state.attributes.processor.AttributesAreaDensityCountingProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor; import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import java.util.Collection; import java.util.Collection;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
...@@ -13,9 +12,14 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; ...@@ -13,9 +12,14 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
/** /**
* @author Daniel Lehmberg * @author Daniel Lehmberg
* Processor counts number of pedestrians in a measurement area of any shape. * Processor counts number of pedestrians in a measurement area of any shape.
*
* To avoid unneccessary complicated structures this class does *not* extend from @AreaDensityProcessor (which requires
* an intern class or a separate class implementing the density algorithm). However, AreaDensityProcessor is a better
* description of what the processor does.
* See e.g. AreaDensityVoronoiProcessor / AreaDensityVoronoiAlgorithm
*/ */
@DataProcessorClass(label = "AreaDensityCountingProcessor") @DataProcessorClass(label = "AreaDensityCountingProcessor")
public class AreaDensityCountingProcessor extends AreaDataProcessor<Integer> { public class AreaDensityCountingProcessor extends AreaDataProcessor<Integer> {
public AreaDensityCountingProcessor() { public AreaDensityCountingProcessor() {
super("areaDensityCounting"); super("areaDensityCounting");
...@@ -24,18 +28,23 @@ public class AreaDensityCountingProcessor extends AreaDataProcessor<Integer> { ...@@ -24,18 +28,23 @@ public class AreaDensityCountingProcessor extends AreaDataProcessor<Integer> {
@Override @Override
protected void doUpdate(final SimulationState state) { protected void doUpdate(final SimulationState state) {
int step = state.getStep();
// Compute density by counting the pedestrians
// With the area of the shape the density can be normalized to [ped/m^2] "pedCount/area"
int pedCount = 0; int pedCount = 0;
// Here could also be another processor. However, because a processor uses more memory, all pedestrians
// are collected from the state directly.
Collection<Pedestrian> pedestrians = state.getTopography().getPedestrianDynamicElements().getElements(); Collection<Pedestrian> pedestrians = state.getTopography().getPedestrianDynamicElements().getElements();
// Alternatively, this could be implemented with "Streams"
for (Pedestrian p : pedestrians) { for (Pedestrian p : pedestrians) {
if(this.getMeasurementArea().getShape().contains(p.getPosition())){ if(this.getMeasurementArea().getShape().contains(p.getPosition())){
pedCount++; pedCount++;
} }
} }
this.putValue(new TimestepKey(step), pedCount); this.putValue(new TimestepKey(state.getStep()), pedCount);
} }
@Override @Override
......
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