Commit d2f526c3 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Add object of class "LastFootSteps" to class "VTrajectory".

parent d8df7e8d
......@@ -31,6 +31,9 @@ public class AttributesAgent extends AttributesDynamicElement {
// only used for the GNM and SFM
private double acceleration = 2.0;
// store n last foot steps for speed calculation
private int footStepsToStore = 10;
public AttributesAgent() {
this(-1);
}
......@@ -51,6 +54,7 @@ public class AttributesAgent extends AttributesDynamicElement {
this.minimumSpeed = other.minimumSpeed;
this.maximumSpeed = other.maximumSpeed;
this.acceleration = other.acceleration;
this.footStepsToStore = other.footStepsToStore;
}
// Getters...
......@@ -83,6 +87,10 @@ public class AttributesAgent extends AttributesDynamicElement {
return acceleration;
}
public int getFootStepsToStore() { return footStepsToStore; }
// Setters...
public void setRadius(double radius) {
checkSealed();
this.radius = radius;
......@@ -117,4 +125,9 @@ public class AttributesAgent extends AttributesDynamicElement {
checkSealed();
this.acceleration = acceleration;
}
public void setFootStepsToStore(int footStepsToStore) {
checkSealed();
this.footStepsToStore = footStepsToStore;
}
}
......@@ -59,7 +59,7 @@ public class Pedestrian extends Agent {
groupIds = new LinkedList<>();
groupSizes = new LinkedList<>();
modelPedestrianMap = new HashMap<>();
trajectory = new VTrajectory();
trajectory = new VTrajectory(attributesAgent.getFootStepsToStore());
}
private Pedestrian(Pedestrian other) {
......
......@@ -4,6 +4,8 @@ import java.util.ArrayList;
/**
* Store the last foot steps of an agent to calculate the agent's average speed during simulation.
*
* TODO: Maybe, rename to "FootStepHistory".
*/
public class LastFootSteps {
......
......@@ -16,9 +16,15 @@ import java.util.stream.Stream;
public class VTrajectory implements Iterable<FootStep> {
private LinkedList<FootStep> footSteps;
private transient LastFootSteps lastFootSteps;
public VTrajectory(){
this(10);
}
public VTrajectory(int lastFootStepCapacity){
footSteps = new LinkedList<>();
lastFootSteps = new LastFootSteps(lastFootStepCapacity);
}
public Optional<Double> speed(@NotNull final VRectangle rectangle) {
......@@ -83,7 +89,9 @@ public class VTrajectory implements Iterable<FootStep> {
public void add(@NotNull final FootStep footStep) {
assert footSteps.isEmpty() || footSteps.peekLast().getEndTime() <= footStep.getStartTime();
footSteps.add(footStep);
lastFootSteps.add(footStep);
}
public VTrajectory cut(@NotNull final VRectangle rectangle) {
......
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