Commit 9f8b8855 authored by Maxim Dudin's avatar Maxim Dudin
Browse files

added a minimal time for a contact to be counted, attribute is adjustable over json

parent 8917e4ab
......@@ -13,8 +13,7 @@ import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.LinkedCellsGrid;
import org.vadere.util.geometry.shapes.VPoint;
import java.util.Collection;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -26,6 +25,7 @@ public class PedestriansNearbyProcessor extends DataProcessor<TimestepPedestrian
private double maxDistance; // todo adjustable with json
private int sampleEveryNthStep;
private int allowedAbsenceTimestepsIfContactReturns;
private int minTimespanOfContactTimesteps;
public PedestriansNearbyProcessor() {
......@@ -54,6 +54,19 @@ public class PedestriansNearbyProcessor extends DataProcessor<TimestepPedestrian
}
}
@Override
public void postLoop(final SimulationState state) {
List<TimestepPedestriansNearbyIdKey> toBeRemoved = new ArrayList<>();
for (TimestepPedestriansNearbyIdKey key : getKeys()) {
if (getValue(key).getDurationTimesteps() < minTimespanOfContactTimesteps) {
toBeRemoved.add(key);
}
}
for (TimestepPedestriansNearbyIdKey toRemove: toBeRemoved) {
removeKey(toRemove);
}
}
public String[] toStrings(final TimestepPedestriansNearbyIdKey key) {
return this.hasValue(key) ? this.getValue(key).toStrings() : new String[]{"N/A", "N/A"};
}
......@@ -79,6 +92,7 @@ public class PedestriansNearbyProcessor extends DataProcessor<TimestepPedestrian
maxDistance = att.getMaxDistanceForANearbyPedestrian();
sampleEveryNthStep = att.getSampleEveryNthStep();
allowedAbsenceTimestepsIfContactReturns = att.getAllowedAbsenceTimestepsIfContactReturns();
minTimespanOfContactTimesteps = att.getMinTimespanOfContactTimesteps();
}
private List<DynamicElement> getDynElementsAtPosition(final Topography topography, VPoint sourcePosition, double radius) {
......
......@@ -9,6 +9,7 @@ public class AttributesPedestrianNearbyProcessor extends AttributesProcessor {
private double maxDistanceForANearbyPedestrian = 1.5;
private int sampleEveryNthStep = 1;
private int allowedAbsenceTimestepsIfContactReturns = 0;
private int minTimespanOfContactTimesteps = 1;
public double getMaxDistanceForANearbyPedestrian() {
return maxDistanceForANearbyPedestrian;
......@@ -21,4 +22,8 @@ public class AttributesPedestrianNearbyProcessor extends AttributesProcessor {
public int getAllowedAbsenceTimestepsIfContactReturns() {
return allowedAbsenceTimestepsIfContactReturns;
}
public int getMinTimespanOfContactTimesteps() {
return minTimespanOfContactTimesteps;
}
}
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