Commit 9042126f authored by Marion Goedel's avatar Marion Goedel
Browse files

Added a check if pedestrians that are generated are overlapping with obstacles.

parent be202fad
Pipeline #71957 failed with stages
in 48 seconds
...@@ -117,8 +117,9 @@ public class SingleSourceController extends SourceController { ...@@ -117,8 +117,9 @@ public class SingleSourceController extends SourceController {
VPoint randomPoint = new VPoint(rec.getMinX() + random.nextDouble() * rec.getWidth(), rec.getMinY() + random.nextDouble() * rec.getHeight()); VPoint randomPoint = new VPoint(rec.getMinX() + random.nextDouble() * rec.getWidth(), rec.getMinY() + random.nextDouble() * rec.getHeight());
VShape freeSpaceRequired = dynamicElementFactory.getDynamicElementRequiredPlace(randomPoint); VShape freeSpaceRequired = dynamicElementFactory.getDynamicElementRequiredPlace(randomPoint);
// no intersection with other free spaces. // no intersection with other free spaces (obstacles & other pedestrians)
if(blockPedestrianShapes.stream().noneMatch(shape -> shape.intersects(freeSpaceRequired))) { if(blockPedestrianShapes.stream().noneMatch(shape -> shape.intersects(freeSpaceRequired))
&& this.getTopography().getObstacles().stream().noneMatch(obs -> obs.getShape().intersects(freeSpaceRequired))) {
return Optional.of(randomPoint); return Optional.of(randomPoint);
} }
} }
......
...@@ -26,10 +26,11 @@ import java.util.Random; ...@@ -26,10 +26,11 @@ import java.util.Random;
public abstract class SourceController { public abstract class SourceController {
protected final double NO_EVENT = Double.MAX_VALUE; protected final double NO_EVENT = Double.MAX_VALUE;
public static final double SPAWN_BUFFER_SIZE = 0.01; public static final double SPAWN_BUFFER_SIZE = 0.03;
protected final Source source; protected final Source source;
private final DynamicElementFactory dynamicElementFactory; private final DynamicElementFactory dynamicElementFactory;
private final Topography topography; private final Topography topography;
protected final Random random; protected final Random random;
...@@ -111,6 +112,10 @@ public abstract class SourceController { ...@@ -111,6 +112,10 @@ public abstract class SourceController {
abstract protected void determineNumberOfSpawnsAndNextEvent(double simTimeInSec); abstract protected void determineNumberOfSpawnsAndNextEvent(double simTimeInSec);
protected Topography getTopography() {
return topography;
}
protected void createNextEvent() { protected void createNextEvent() {
if (isSourceWithOneSingleSpawnEvent()) { if (isSourceWithOneSingleSpawnEvent()) {
timeOfNextEvent = NO_EVENT; timeOfNextEvent = NO_EVENT;
......
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