Commit 7d67883e authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

add overlap checks. Add new gui button to generate ids for ScenarioElements

parent 560d835f
Pipeline #69553 failed with stages
in 47 seconds
......@@ -299,6 +299,7 @@ TopographyCreator.btnSimplePolygon.label=Simple Polygon
TopographyCreator.btnCircle.label=Circle
TopographyCreator.btnRectangle.label=Rectangle
TopographyCreator.btnChecker.tooltip=Show Topography Checker Messages
TopographyCreator.btnMakro.tooltip=Generate not set IDs.
select_shape_tooltip=Select Shape
......@@ -309,16 +310,23 @@ TopographyChecker.source.targetIdNotFound=The following target ids where not fou
TopographyChecker.source.noTargetIdSet=No Target Ids set for Source.
TopographyChecker.source.noTargetIdAndNoSpawn=No Target Ids set for Source with SpawnNumber 0. This might be an error.
TopographyChecker.source.idNotUnique=Multiple Sources have the same ID.
TopographyChecker.source.overlapWithObstacle=Source overlaps with Obstacle. This leads to pedestrians spawn in obstacle.
TopographyChecker.stairs.wrongTreadDim=Stair treadDepth outside of allowed dimension.
TopographyChecker.target.unused=The target is not used in any source. Remove target to increase performance.
TopographyChecker.pedestrian.speedsetup=speedDistributionMean must be within min/max range.
TopographyChecker.pedestrian.speedNotLogical=Min or Max speed of pedestrian is bigger than world record.
TopographyChecker.pedestrian.speedIsNegative=Min or Max speed is negative.
#TopographyChecker.obstacles.overlap=
#TopographyChecker.source.overlap=
#TopographyChecker.target.overlap=
#TopographyChecker.stairs.overlap=
TopographyChecker.overlap.stair.stair=Stairs cannot overlap.
TopographyChecker.overlap.target.stair=A target and a stairs element overlap in scenario.
TopographyChecker.overlap.source.stair=A source and a stairs element overlap in scenario.
TopographyChecker.overlap.source.target=A source and a target element overlap in scenario.
TopographyChecker.overlap.source.source=Two source overlap. This can cause overlapping when useFreeSpaceOnly is not set.
TopographyChecker.overlap.obstacle.stairs.err=Stairs is completely contained in an obstacle.
TopographyChecker.overlap.obstacle.stairs.warn=Stairs contains an obstacle. This setup works put is not tested. Split in two stairs.
TopographyChecker.overlap.obstacle.target.err=Target is completely contained in an obstacle.
TopographyChecker.overlap.obstacle.target.warn=Target contains an obstacle. This setup works but reduces the actual size of the target.
TopographyChecker.overlap.obstacle.source=Obstacle overlaps with a source. This setup will spawn pedestrians within the obstacle.
TopographyChecker.overlap.obstacle.obstacle=Two obstacles overlap / is enclosed completely. Delete one for better performance.
# tab titles Topography creator / postvis
......
......@@ -298,6 +298,7 @@ TopographyCreator.btnSimplePolygon.label=Einfaches Polygon
TopographyCreator.btnCircle.label=Kreis
TopographyCreator.btnRectangle.label=Rechteck
TopographyCreator.btnChecker.tooltip=Topography Linter Nachrichten
TopographyCreator.btnMakro.tooltip=Erzeuge nicht gesetzte IDs.
# TopographyChecker
TopographyChecker.type.error=Fehler
......@@ -306,16 +307,23 @@ TopographyChecker.source.targetIdNotFound=Die folgenden Ziel-IDs wurden nicht im
TopographyChecker.source.noTargetIdSet=In der Quelle wurden keine Ziel Ids vergeben.
TopographyChecker.source.noTargetIdAndNoSpawn=In der Quelle wurden keine Ziel Ids vergeben, aber die Spawn Anzahl ist bei 0.
TopographyChecker.source.idNotUnique=Quellen haben keine eindeutige ID.
TopographyChecker.source.overlapWithObstacle=Quelle und Hinderniss \u00fcberlappen sich. Dies kann f\u00fcrt zuf\u00fchren, dass Personen im Hinderniss erzeugt werden.
TopographyChecker.stairs.wrongTreadDim=Stufentiefe ist au\u00dferhalb des Definitionsbereichs.
TopographyChecker.target.unused=Das Ziel wird von keiner Quelle verwendet. Entferne das Ziel um die Performance zu erh\u00f6hen
TopographyChecker.pedestrian.speedsetup=speedDistributionMean muss im Bereich min/max liegen.
TopographyChecker.pedestrian.speedNotLogical=Min or Max Geschwindigkeit ist gr\u00f6\u00dfer als Weltrekord.
TopographyChecker.pedestrian.speedIsNegative=Min or Max Geschwindigkeit ist negativ.
#TopographyChecker.obstacles.overlap=
#TopographyChecker.source.overlap=
#TopographyChecker.target.overlap=
#TopographyChecker.stairs.overlap=
TopographyChecker.overlap.stair.stair=Treppen d\u00fcrfen nicht \u00fcberlappen.
TopographyChecker.overlap.target.stair=Ein Ziel und eine Treppen \u00fcberlappen im Scenario.
TopographyChecker.overlap.source.stair=Eine Quelle und eine Treppe \u00fcberlappen im Scenario.
TopographyChecker.overlap.source.target=Eine Quelle und eine Ziel \u00fcberappen im Scenario.
TopographyChecker.overlap.source.source=Zwei Quellen \u00fcberlappen. Wenn useFreeSpaceOnly nicht gesetzt ist kann dies zu \u00fcberlappungen von Pedestrians f\u00fchren.
TopographyChecker.overlap.obstacle.stairs.err=Treppe ist komplett in einem Hinderniss eingeschossen.
TopographyChecker.overlap.obstacle.stairs.warn=Treppe hat ein Hinderiss in sich. Dies ist m\u00f6glich aber nicht getestet. Wenn m\u00f6glich in zwei treppen aufteilen.
TopographyChecker.overlap.obstacle.target.err=Ziel ist komplett in einem Hinderniss eingeschlossen
TopographyChecker.overlap.obstacle.target.warn=Ziel hat ein Hinderniss in sich. Dies ist m\u00f6glich reduziert aber die tats\u00c4chliche Fl\u00c4che des Ziels.
TopographyChecker.overlap.obstacle.source=Hinderniss \u00fcberdeckt Quelle. Die f\u00fchrt dazu, dass Pedestrians im Hinderniss erzeugt werden.
TopographyChecker.overlap.obstacle.obstacle=Zwei identische bzw. eingeschlossene Obstacles gefunden. L\u00f6sche eins f\u00fcr bessere Performance
# tab titles Topography creator / postvis
Tab.Simulation.title=Simulation
......
package org.vadere.gui.topographycreator.control;
import org.vadere.gui.topographycreator.model.IDrawPanelModel;
import java.awt.event.ActionEvent;
import javax.swing.*;
public class ActionTopographyMakroMenu extends TopographyAction {
public ActionTopographyMakroMenu(String name, ImageIcon icon, IDrawPanelModel<?> panelModel) {
super(name, icon, panelModel);
}
@Override
public void actionPerformed(ActionEvent e) {
getScenarioPanelModel().getTopography().generateUniqueIdIfNotSet();
getScenarioPanelModel().notifyObservers();
}
}
......@@ -30,6 +30,7 @@ import org.vadere.gui.topographycreator.control.ActionSelectSelectShape;
import org.vadere.gui.topographycreator.control.ActionSwitchCategory;
import org.vadere.gui.topographycreator.control.ActionSwitchSelectionMode;
import org.vadere.gui.topographycreator.control.ActionTopographyCheckerMenu;
import org.vadere.gui.topographycreator.control.ActionTopographyMakroMenu;
import org.vadere.gui.topographycreator.control.ActionUndo;
import org.vadere.gui.topographycreator.control.ActionZoomIn;
import org.vadere.gui.topographycreator.control.ActionZoomOut;
......@@ -309,6 +310,12 @@ public class TopographyWindow extends JPanel {
new ImageIcon(Resources.class.getResource("/icons/topography_icon.png")),
panelModel, selectShape);
/* Makros */
ActionTopographyMakroMenu actionTopographyMakroMenu =
new ActionTopographyMakroMenu("TopographyMakros",
new ImageIcon(Resources.class.getResource("/icons/setting32x32.png")),
panelModel);
/* Topography checker*/
ActionTopographyCheckerMenu actionTopographyCheckerMenu =
new ActionTopographyCheckerMenu("TopographyChecker", panelModel, jsonValidIndicator);
......@@ -350,6 +357,7 @@ public class TopographyWindow extends JPanel {
addActionToToolbar(toolbar, undoAction, "TopographyCreator.btnUndo.tooltip");
addActionToToolbar(toolbar, redoAction, "TopographyCreator.btnRedo.tooltip");
toolbar.add(Box.createHorizontalGlue());
addActionToToolbar(toolbar, actionTopographyMakroMenu, "TopographyCreator.btnMakro.tooltip");
addActionToToolbar(toolbar, actionTopographyCheckerMenu, "TopographyCreator.btnChecker.tooltip");
toolbar.add(infoButton);
infoButton.setToolTipText("About");
......
......@@ -4,72 +4,241 @@ import org.apache.commons.math3.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.vadere.state.scenario.Obstacle;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.state.scenario.Source;
import org.vadere.state.scenario.Stairs;
import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography;
import org.vadere.state.types.ScenarioElementType;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
public class TopographyChecker {
private final Topography topography;
private TopographyCheckerMessageBuilder msgBuilder;
public TopographyChecker(@NotNull final Topography topography) {
this.topography = topography;
this.msgBuilder = new TopographyCheckerMessageBuilder();
}
public List<Pair<Obstacle, Obstacle>> checkObstacleOverlap() {
List<Pair<Obstacle, Obstacle>> intersectList = new ArrayList<>();
for (int i = 0; i < topography.getObstacles().size(); i++) {
for (int j = i + 1; j < topography.getObstacles().size(); j++) {
Obstacle obs1 = topography.getObstacles().get(i);
Obstacle obs2 = topography.getObstacles().get(j);
if (obs1.getShape().intersects(obs2.getShape())) {
intersectList.add(Pair.create(obs1, obs2));
}
}
}
return intersectList;
}
public boolean hasObstacleOverlaps() {
return checkObstacleOverlap().size() > 0;
}
public List<TopographyCheckerMessage> checkSourceObstacleOverlap(){
private final Topography topography;
private TopographyCheckerMessageBuilder msgBuilder;
public TopographyChecker(@NotNull final Topography topography) {
this.topography = topography;
this.msgBuilder = new TopographyCheckerMessageBuilder();
}
public List<Pair<Obstacle, Obstacle>> checkObstacleOverlap() {
List<Pair<Obstacle, Obstacle>> intersectList = new ArrayList<>();
for (int i = 0; i < topography.getObstacles().size(); i++) {
for (int j = i + 1; j < topography.getObstacles().size(); j++) {
Obstacle obs1 = topography.getObstacles().get(i);
Obstacle obs2 = topography.getObstacles().get(j);
if (obs1.getShape().intersects(obs2.getShape())) {
intersectList.add(Pair.create(obs1, obs2));
}
}
}
return intersectList;
}
public boolean hasObstacleOverlaps() {
return checkObstacleOverlap().size() > 0;
}
public List<TopographyCheckerMessage> checkOverlap(BiFunction<ScenarioElementType, ScenarioElementType, Boolean> useTest) {
List<TopographyCheckerMessage> ret = new ArrayList<>();
final List<Source> sources = topography.getSources();
final List<Obstacle> obstacles = topography.getObstacles();
for (Obstacle obstacle : obstacles) {
for(Source source: sources){
if (obstacle.getShape().intersects(source.getShape())){
ret.add(msgBuilder.error()
.reason(TopographyCheckerReason.SOURCE_OVERLAP_WITH_OBSTACLE)
.target(source, obstacle)
.build());
ArrayList<ScenarioElement> all = topography.getAllScenarioElements();
for (int i = 0; i < all.size(); i++) {
for (int j = i + 1; j < all.size(); j++) {
ScenarioElement elementA = all.get(i);
ScenarioElement elementB = all.get(j);
// same Type complete overlap
if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.OBSTACLE, ScenarioElementType.OBSTACLE)) {
handelObstacleObstacleOverlap(elementA, elementB, ret);
} else if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.OBSTACLE, ScenarioElementType.SOURCE)) {
handelObstacleSourceOverlap(elementA, elementB, ret);
} else if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.OBSTACLE, ScenarioElementType.TARGET)) {
handelObstacleTargetOverlap(elementA, elementB, ret);
} else if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.OBSTACLE, ScenarioElementType.STAIRS)) {
handelObstacleStairsOverlap(elementA, elementB, ret);
} else if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.SOURCE, ScenarioElementType.SOURCE)) {
handelSourceSourceOverlap(elementA, elementB, ret);
} else if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.SOURCE, ScenarioElementType.TARGET)) {
handelSourceTargetOverlap(elementA, elementB, ret);
} else if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.SOURCE, ScenarioElementType.STAIRS)) {
handelSourceStairsOverlap(elementA, elementB, ret);
} else if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.TARGET, ScenarioElementType.TARGET)) {
handelTargetTargetOverlap(elementA, elementB, ret);
} else if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.TARGET, ScenarioElementType.STAIRS)) {
handelTargetStairsOverlap(elementA, elementB, ret);
} else if (isTestActive(useTest, elementA, elementB,
ScenarioElementType.STAIRS, ScenarioElementType.STAIRS)) {
handelStairStairOverlap(elementA, elementB, ret);
}
}
}
return ret;
}
public List<TopographyCheckerMessage> checkBuildingStep(){
private boolean isTestActive(BiFunction<ScenarioElementType, ScenarioElementType, Boolean> checkTest,
ScenarioElement eA, ScenarioElement eB,
ScenarioElementType type1, ScenarioElementType type2) {
return (checkTest.apply(type1, type2) &&
((eA.getType().equals(type1) && eB.getType().equals(type2)) ||
(eA.getType().equals(type2) && eB.getType().equals(type1)))
);
}
private ScenarioElement elementOfType(ScenarioElement e1, ScenarioElement e2, ScenarioElementType type) {
return e1.getType().equals(type) ? e1 : e2;
}
private void handelObstacleObstacleOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
if (e1.enclosesScenarioElement(e2)) {
ret.add(msgBuilder.warning().target(e1, e2)
.reason(TopographyCheckerReason.OVERLAP_OBSTACLE_OBSTACLE).build());
} else if (e2.enclosesScenarioElement(e1)){
ret.add(msgBuilder.warning().target(e2, e1)
.reason(TopographyCheckerReason.OVERLAP_OBSTACLE_OBSTACLE).build());
} else if (e1.totalOverlapWith(e2)){
ret.add(msgBuilder.warning().target(e2, e1)
.reason(TopographyCheckerReason.OVERLAP_OBSTACLE_OBSTACLE).build());
}
}
private void handelObstacleSourceOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
Obstacle obstacle = (Obstacle) elementOfType(e1, e2, ScenarioElementType.OBSTACLE);
Source source = (Source) elementOfType(e1, e2, ScenarioElementType.SOURCE);
if (source.overlapWith(obstacle)) {
ret.add(msgBuilder.error().target(source, obstacle)
.reason(TopographyCheckerReason.OVERLAP_OBSTACLE_SOURCE).build());
}
}
private void handelObstacleTargetOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
Obstacle obstacle = (Obstacle) elementOfType(e1, e2, ScenarioElementType.OBSTACLE);
Target target = (Target) elementOfType(e1, e2, ScenarioElementType.TARGET);
if (obstacle.enclosesScenarioElement(target)) {
ret.add(msgBuilder.error().target(obstacle, target)
.reason(TopographyCheckerReason.OVERLAP_OBSTACLE_TARGET_ERR).build());
}else if (obstacle.overlapWith(target)) {
ret.add(msgBuilder.warning().target(obstacle, target)
.reason(TopographyCheckerReason.OVERLAP_OBSTACLE_TARGET_ERR).build());
}
}
private void handelObstacleStairsOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
Obstacle obstacle = (Obstacle) elementOfType(e1, e2, ScenarioElementType.OBSTACLE);
Stairs stairs = (Stairs) elementOfType(e1, e2, ScenarioElementType.STAIRS);
if (obstacle.enclosesScenarioElement(stairs)) {
ret.add(msgBuilder.error().target(obstacle, stairs)
.reason(TopographyCheckerReason.OVERLAP_OBSTACLE_STAIRS_ERR).build());
} else if (obstacle.overlapWith(stairs)) {
ret.add(msgBuilder.warning().target(obstacle, stairs)
.reason(TopographyCheckerReason.OVERLAP_OBSTACLE_STAIRS_WARN).build());
}
}
private void handelSourceSourceOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
if (e1.overlapWith(e2)) {
ret.add(msgBuilder.warning().target(e1, e2)
.reason(TopographyCheckerReason.OVERLAP_SOURCE_SOURCE).build());
}
}
private void handelSourceTargetOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
Source source= (Source) elementOfType(e1, e2, ScenarioElementType.SOURCE);
Target target = (Target) elementOfType(e1, e2, ScenarioElementType.TARGET);
if (source.overlapWith(target)) {
ret.add(msgBuilder.warning().target(source, target)
.reason(TopographyCheckerReason.OVERLAP_SOURCE_TARGET).build());
}
}
private void handelSourceStairsOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
Source source = (Source) elementOfType(e1, e2, ScenarioElementType.SOURCE);
Stairs stairs = (Stairs) elementOfType(e1, e2, ScenarioElementType.STAIRS);
if (source.overlapWith(stairs)) {
ret.add(msgBuilder.warning().target(source, stairs)
.reason(TopographyCheckerReason.OVERLAP_SOURCE_STAIR).build());
}
}
private void handelTargetTargetOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
//todo
}
// WARN total overlap == partial overlap
private void handelTargetStairsOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
Target target = (Target) elementOfType(e1, e2, ScenarioElementType.TARGET);
Stairs stairs = (Stairs) elementOfType(e1, e2, ScenarioElementType.STAIRS);
if (target.overlapWith(stairs)) {
ret.add(msgBuilder.warning().target(target, stairs)
.reason(TopographyCheckerReason.OVERLAP_TARGET_STAIR).build());
}
}
// ERROR total overlap == partial overlap
private void handelStairStairOverlap(ScenarioElement e1, ScenarioElement e2, List<TopographyCheckerMessage> ret) {
if (e1.overlapWith(e2)) {
ret.add(msgBuilder.error().target(e1, e2)
.reason(TopographyCheckerReason.OVERLAP_STAIR_STAIR).build());
}
}
public List<TopographyCheckerMessage> checkBuildingStep() {
List<TopographyCheckerMessage> ret = new ArrayList<>();
ret.addAll(checkValidTargetsInSource());
ret.addAll(checkUniqueSourceId());
ret.addAll(checkSourceObstacleOverlap());
ret.addAll(checkUnusedTargets());
ret.addAll(checkStairTreadSanity());
ret.addAll(checkPedestrianSpeedSetup());
ret.addAll(checkOverlap((type, type2) -> true));
return ret;
}
......@@ -77,7 +246,7 @@ public class TopographyChecker {
List<TopographyCheckerMessage> ret = new ArrayList<>();
topography.getPedestrianDynamicElements().getInitialElements().forEach(p -> {
double speedMean = p.getSpeedDistributionMean();
if (speedMean < p.getAttributes().getMinimumSpeed() || speedMean > p.getAttributes().getMaximumSpeed()){
if (speedMean < p.getAttributes().getMinimumSpeed() || speedMean > p.getAttributes().getMaximumSpeed()) {
ret.add(msgBuilder
.error()
.target(p)
......@@ -85,10 +254,10 @@ public class TopographyChecker {
"(" + p.getAttributes().getMinimumSpeed()
+ " &lt; treadDepth &lt; "
+ p.getAttributes().getMaximumSpeed() +
") current SpeedDistributionMean is: " + String.format("%.2f",speedMean))
") current SpeedDistributionMean is: " + String.format("%.2f", speedMean))
.build());
}
if (p.getAttributes().getMinimumSpeed() > Pedestrian.HUMAN_MAX_SPEED || p.getAttributes().getMaximumSpeed() > Pedestrian.HUMAN_MAX_SPEED){
if (p.getAttributes().getMinimumSpeed() > Pedestrian.HUMAN_MAX_SPEED || p.getAttributes().getMaximumSpeed() > Pedestrian.HUMAN_MAX_SPEED) {
ret.add(msgBuilder
.warning()
.target(p)
......@@ -97,7 +266,7 @@ public class TopographyChecker {
p.getAttributes().getMaximumSpeed(), Pedestrian.HUMAN_MAX_SPEED))
.build());
}
if (p.getAttributes().getMinimumSpeed() < 0 || p.getAttributes().getMaximumSpeed() < 0){
if (p.getAttributes().getMinimumSpeed() < 0 || p.getAttributes().getMaximumSpeed() < 0) {
ret.add(msgBuilder
.error()
.target(p)
......@@ -111,22 +280,22 @@ public class TopographyChecker {
public List<TopographyCheckerMessage> checkStairTreadSanity() {
List<TopographyCheckerMessage> ret = new ArrayList<>();
topography.getStairs().forEach( stairs -> {
topography.getStairs().forEach(stairs -> {
double treadDepth = stairs.getTreadDepth();
if (treadDepth < Stairs.MIN_TREAD_DEPTH || treadDepth > Stairs.MAX_TREAD_DEPTH){
if (treadDepth < Stairs.MIN_TREAD_DEPTH || treadDepth > Stairs.MAX_TREAD_DEPTH) {
ret.add(msgBuilder
.warning()
.target(stairs)
.reason(TopographyCheckerReason.STAIRS_TREAD_DIM_WRONG
, "(" + Stairs.MIN_TREAD_DEPTH + "m &lt; treadDepth &gt; " + Stairs.MAX_TREAD_DEPTH +
"m) current treadDepth is: " + String.format("%.3fm",stairs.getTreadDepth()))
"m) current treadDepth is: " + String.format("%.3fm", stairs.getTreadDepth()))
.build()
);
}
});
return ret;
}
}
public List<TopographyCheckerMessage> checkUnusedTargets() {
......@@ -136,7 +305,7 @@ public class TopographyChecker {
.forEach(s -> usedTargetIds.addAll(s.getAttributes().getTargetIds()));
topography.getTargets().forEach(t -> {
if (!usedTargetIds.contains(t.getId())){
if (!usedTargetIds.contains(t.getId())) {
ret.add(msgBuilder
.warning()
.reason(TopographyCheckerReason.TARGET_UNUSED)
......@@ -149,15 +318,15 @@ public class TopographyChecker {
}
public List<TopographyCheckerMessage> checkValidTargetsInSource() {
public List<TopographyCheckerMessage> checkValidTargetsInSource() {
List<TopographyCheckerMessage> ret = new ArrayList<>();
Set<Integer> targetIds = topography.getTargets().stream()
.map(Target::getId)
.collect(Collectors.toSet());
for(Source s : topography.getSources()){
if (s.getAttributes().getTargetIds().size() == 0){
if (s.getAttributes().getSpawnNumber() == 0){
for (Source s : topography.getSources()) {
if (s.getAttributes().getTargetIds().size() == 0) {
if (s.getAttributes().getSpawnNumber() == 0) {
ret.add(msgBuilder
.warning()
.target(s)
......@@ -170,7 +339,7 @@ public class TopographyChecker {
.build());
}
} else {
List<String> notFoundTargetIds = s.getAttributes().getTargetIds().stream()
List<String> notFoundTargetIds = s.getAttributes().getTargetIds().stream()
.filter(tId -> !targetIds.contains(tId))
.map(tId -> Integer.toString(tId))
.collect(Collectors.toList());
......@@ -188,15 +357,15 @@ public class TopographyChecker {
}
}
return ret;
}
return ret;
}
public List<TopographyCheckerMessage> checkUniqueSourceId() {
List<TopographyCheckerMessage> ret = new ArrayList<>();
Set<Integer> sourceId = new HashSet<>();
for(Source s : topography.getSources()){
if (!sourceId.add(s.getId())){
for (Source s : topography.getSources()) {
if (!sourceId.add(s.getId())) {
ret.add(msgBuilder.warning()
.target(s)
.reason(TopographyCheckerReason.SOURCE_ID_NOT_UNIQUE)
......@@ -207,7 +376,7 @@ public class TopographyChecker {
}
public void doCreatorChecks() {
public void doCreatorChecks() {
}
}
}
......@@ -12,13 +12,23 @@ public enum TopographyCheckerReason {
SOURCE_NO_TARGET_ID_SET("TopographyChecker.source.noTargetIdSet"),
SOURCE_NO_TARGET_ID_NO_SPAWN("TopographyChecker.source.noTargetIdAndNoSpawn"),
SOURCE_ID_NOT_UNIQUE("TopographyChecker.source.idNotUnique"),
SOURCE_OVERLAP_WITH_OBSTACLE("TopographyChecker.source.overlapWithObstacle"),
STAIRS_TREAD_DIM_WRONG("TopographyChecker.stairs.wrongTreadDim"),
OVERLAP_STAIR_STAIR("TopographyChecker.overlap.stair.stair"),
OVERLAP_TARGET_STAIR("TopographyChecker.overlap.target.stair"),
OVERLAP_SOURCE_STAIR("TopographyChecker.overlap.source.stair"),
OVERLAP_SOURCE_TARGET("TopographyChecker.overlap.source.target"),
OVERLAP_SOURCE_SOURCE("TopographyChecker.overlap.source.source"),
OVERLAP_OBSTACLE_STAIRS_ERR("TopographyChecker.overlap.obstacle.stairs.err"),
OVERLAP_OBSTACLE_STAIRS_WARN("TopographyChecker.overlap.obstacle.stairs.warn"),
OVERLAP_OBSTACLE_TARGET_ERR("TopographyChecker.overlap.obstacle.target.err"),
OVERLAP_OBSTACLE_TARGET_WARN("TopographyChecker.overlap.obstacle.target.warn"),
OVERLAP_OBSTACLE_SOURCE("TopographyChecker.overlap.obstacle.source"),
OVERLAP_OBSTACLE_OBSTACLE("TopographyChecker.overlap.obstacle.obstacle"),
OVERLAP_OBSTACLE_OBSTACLE_ENCLOSE("TopographyChecker.overlap.obstacle.obstacle.enclose"),
TARGET_UNUSED("TopographyChecker.target.unused"),
OBSTACLES_OVERLAP("TopographyChecker.obstacles.overlap"),
SOURCE_OVERLAP("TopographyChecker.source.overlap"),
TARGET_OVERLAP("TopographyChecker.target.overlap"),
STAIRS_OVERLAP("TopographyChecker.stairs.overlap"),
PEDESTRIAN_SPEED_SETUP("TopographyChecker.pedestrian.speedsetup"),
PEDESTRIAN_SPEED_NOT_LOGICAL("TopographyChecker.pedestrian.speedNotLogical"),
PEDESTRIAN_SPEED_NEGATIVE("TopographyChecker.pedestrian.speedIsNegative");
......
......@@ -2,6 +2,7 @@ package org.vadere.simulator.util;
import org.apache.commons.math3.util.Pair;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.vadere.state.attributes.scenario.AttributesObstacle;
import org.vadere.state.attributes.scenario.builder.AttributesAgentBuilder;
......@@ -15,7 +16,9 @@ import org.vadere.state.scenario.Source;