Commit 13b33141 authored by BZoennchen's avatar BZoennchen

bug fix and test update.

parent f50e2e76
Pipeline #126944 passed with stages
in 109 minutes and 57 seconds
......@@ -29,7 +29,7 @@ public class TestTrajectory extends TestCase {
@Override
protected void setUp() throws Exception {
pedestriansByStep = new HashMap<>();
List<Step> steps = Arrays.asList(new Step(2), new Step(4), new Step(5), new Step(7));
List<Step> steps = Arrays.asList(new Step(1), new Step(4), new Step(5), new Step(7));
List<Pedestrian> pedestrians = Arrays.asList(
new Pedestrian(new AttributesAgent(1), new Random()),
new Pedestrian(new AttributesAgent(2), new Random()),
......@@ -47,7 +47,7 @@ public class TestTrajectory extends TestCase {
@Test
public void testGetPedestrian() {
Trajectory trajectory = new Trajectory(pedestriansByStep, 1);
Trajectory trajectory = new Trajectory(pedestriansByStep, 1, 0.4);
assertEquals(trajectory.getAgent(new Step(3)), (trajectory.getAgent(new Step(2))));
assertTrue(trajectory.getAgent(new Step(3)).isPresent());
assertEquals(trajectory.getAgent(new Step(6)), (trajectory.getAgent(new Step(5))));
......@@ -66,8 +66,9 @@ public class TestTrajectory extends TestCase {
@Test
public void testGetPositionReverse() {
Trajectory trajectory = new Trajectory(pedestriansByStep, 2);
IntStream.rangeClosed(1, 17).forEach(stepNumber -> assertTrue(
Trajectory trajectory = new Trajectory(pedestriansByStep, 2, 0.4);
trajectory.fill();
IntStream.rangeClosed(1, 7).forEach(stepNumber -> assertTrue(
trajectory.getPositionsReverse(new Step(stepNumber)).count() + "!=" + stepNumber,
trajectory.getPositionsReverse(new Step(stepNumber)).count() == stepNumber));
List<VPoint> reversePositions = trajectory.getPositionsReverse(new Step(12)).collect(Collectors.toList());
......
......@@ -38,7 +38,7 @@ public class OfflineSimulation {
.flatMap(entry -> entry.getValue().stream())
.map(ped -> ped.getId())
.distinct()
.map(id -> new Trajectory(pedestriansByStep, id))
.map(id -> new Trajectory(pedestriansByStep, id, vadere.getAttributesSimulation().getSimTimeStepLength()))
.collect(Collectors.toMap(t -> t.getPedestrianId(), t -> t));
topographyController.prepareTopography();
......
......@@ -58,11 +58,7 @@ public class Step implements Comparable<Step> {
* @return the decremented step or this step (if this step is the minimal step).
*/
public Step decrement() {
if(stepNumber > MINIMAL_STEP) {
return new Step(stepNumber - 1);
} else {
return this;
}
return new Step(stepNumber - 1);
}
public boolean isGreaterThan(final Step step) {
......
......@@ -55,11 +55,13 @@ public class Trajectory {
* since the complete {@link Map} <tt>pedestrianByStep</tt> has to be iterated for each
* pedestrian. A better way is to construct all {@link Trajectory} objects at once.
*
* @param pedestrianByStep container for a set of trajectories
* @param pedestrianId a specific and unique pedestrian id
* @param pedestrianByStep container for a set of trajectories
* @param pedestrianId a specific and unique pedestrian id
* @param simStepLengthInSec step length of one time step in seconds
*/
public Trajectory(final Map<Step, List<Agent>> pedestrianByStep, final int pedestrianId) {
public Trajectory(final Map<Step, List<Agent>> pedestrianByStep, final int pedestrianId, final double simStepLengthInSec) {
this.pedestrianId = pedestrianId;
this.simStepLengthInSec = simStepLengthInSec;
// create for each step that contains an pedestrian with the specific pedestrianId
this.trajectoryPoints = pedestrianByStep.entrySet().stream()
......
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