Commit 7fcdf2ed authored by hm-lehmberg's avatar hm-lehmberg

initial code for new processor

parent 6c75b16b
Pipeline #113098 passed with stages
in 139 minutes and 19 seconds
package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.state.attributes.processor.AttributesAreaDensityCountingProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.Pedestrian;
import java.util.Collection;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
/**
* @author Daniel Lehmberg
* Processor counts number of pedestrians in a measurement area of any shape.
*/
@DataProcessorClass(label = "AreaDensityCountingProcessor")
public class AreaDensityCountingProcessor extends AreaDataProcessor<Integer> {
public AreaDensityCountingProcessor() {
super("areaDensityCounting");
setAttributes(new AttributesAreaDensityCountingProcessor());
}
@Override
protected void doUpdate(final SimulationState state) {
int step = state.getStep();
int pedCount = 0;
Collection<Pedestrian> pedestrians = state.getTopography().getPedestrianDynamicElements().getElements();
for (Pedestrian p : pedestrians) {
if(this.getMeasurementArea().getShape().contains(p.getPosition())){
pedCount++;
}
}
this.putValue(new TimestepKey(step), pedCount);
}
@Override
public AttributesProcessor getAttributes() {
if(super.getAttributes() == null) {
setAttributes(new AttributesAreaDensityCountingProcessor());
}
return super.getAttributes();
}
}
package org.vadere.state.attributes.processor;
/**
* @author Daniel Lehmberg
*/
public class AttributesAreaDensityCountingProcessor extends AttributesAreaProcessor {
}
...@@ -2,6 +2,7 @@ package org.vadere.state.attributes.processor; ...@@ -2,6 +2,7 @@ package org.vadere.state.attributes.processor;
/** /**
* @author Mario Teixeira Parente * @author Mario Teixeira Parente
* @author Stefan Schuhbäck (major update)
*/ */
public class AttributesAreaProcessor extends AttributesProcessor { public class AttributesAreaProcessor extends AttributesProcessor {
......
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