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

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 ...@@ -299,6 +299,7 @@ TopographyCreator.btnSimplePolygon.label=Simple Polygon
TopographyCreator.btnCircle.label=Circle TopographyCreator.btnCircle.label=Circle
TopographyCreator.btnRectangle.label=Rectangle TopographyCreator.btnRectangle.label=Rectangle
TopographyCreator.btnChecker.tooltip=Show Topography Checker Messages TopographyCreator.btnChecker.tooltip=Show Topography Checker Messages
TopographyCreator.btnMakro.tooltip=Generate not set IDs.
select_shape_tooltip=Select Shape select_shape_tooltip=Select Shape
...@@ -309,16 +310,23 @@ TopographyChecker.source.targetIdNotFound=The following target ids where not fou ...@@ -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.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.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.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.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.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.speedsetup=speedDistributionMean must be within min/max range.
TopographyChecker.pedestrian.speedNotLogical=Min or Max speed of pedestrian is bigger than world record. TopographyChecker.pedestrian.speedNotLogical=Min or Max speed of pedestrian is bigger than world record.
TopographyChecker.pedestrian.speedIsNegative=Min or Max speed is negative. TopographyChecker.pedestrian.speedIsNegative=Min or Max speed is negative.
#TopographyChecker.obstacles.overlap=
#TopographyChecker.source.overlap= TopographyChecker.overlap.stair.stair=Stairs cannot overlap.
#TopographyChecker.target.overlap= TopographyChecker.overlap.target.stair=A target and a stairs element overlap in scenario.
#TopographyChecker.stairs.overlap= 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 # tab titles Topography creator / postvis
......
...@@ -298,6 +298,7 @@ TopographyCreator.btnSimplePolygon.label=Einfaches Polygon ...@@ -298,6 +298,7 @@ TopographyCreator.btnSimplePolygon.label=Einfaches Polygon
TopographyCreator.btnCircle.label=Kreis TopographyCreator.btnCircle.label=Kreis
TopographyCreator.btnRectangle.label=Rechteck TopographyCreator.btnRectangle.label=Rechteck
TopographyCreator.btnChecker.tooltip=Topography Linter Nachrichten TopographyCreator.btnChecker.tooltip=Topography Linter Nachrichten
TopographyCreator.btnMakro.tooltip=Erzeuge nicht gesetzte IDs.
# TopographyChecker # TopographyChecker
TopographyChecker.type.error=Fehler TopographyChecker.type.error=Fehler
...@@ -306,16 +307,23 @@ TopographyChecker.source.targetIdNotFound=Die folgenden Ziel-IDs wurden nicht im ...@@ -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.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.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.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.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.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.speedsetup=speedDistributionMean muss im Bereich min/max liegen.
TopographyChecker.pedestrian.speedNotLogical=Min or Max Geschwindigkeit ist gr\u00f6\u00dfer als Weltrekord. TopographyChecker.pedestrian.speedNotLogical=Min or Max Geschwindigkeit ist gr\u00f6\u00dfer als Weltrekord.
TopographyChecker.pedestrian.speedIsNegative=Min or Max Geschwindigkeit ist negativ. TopographyChecker.pedestrian.speedIsNegative=Min or Max Geschwindigkeit ist negativ.
#TopographyChecker.obstacles.overlap= TopographyChecker.overlap.stair.stair=Treppen d\u00fcrfen nicht \u00fcberlappen.
#TopographyChecker.source.overlap= TopographyChecker.overlap.target.stair=Ein Ziel und eine Treppen \u00fcberlappen im Scenario.
#TopographyChecker.target.overlap= TopographyChecker.overlap.source.stair=Eine Quelle und eine Treppe \u00fcberlappen im Scenario.
#TopographyChecker.stairs.overlap= 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 titles Topography creator / postvis
Tab.Simulation.title=Simulation 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; ...@@ -30,6 +30,7 @@ import org.vadere.gui.topographycreator.control.ActionSelectSelectShape;
import org.vadere.gui.topographycreator.control.ActionSwitchCategory; import org.vadere.gui.topographycreator.control.ActionSwitchCategory;
import org.vadere.gui.topographycreator.control.ActionSwitchSelectionMode; import org.vadere.gui.topographycreator.control.ActionSwitchSelectionMode;
import org.vadere.gui.topographycreator.control.ActionTopographyCheckerMenu; 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.ActionUndo;
import org.vadere.gui.topographycreator.control.ActionZoomIn; import org.vadere.gui.topographycreator.control.ActionZoomIn;
import org.vadere.gui.topographycreator.control.ActionZoomOut; import org.vadere.gui.topographycreator.control.ActionZoomOut;
...@@ -309,6 +310,12 @@ public class TopographyWindow extends JPanel { ...@@ -309,6 +310,12 @@ public class TopographyWindow extends JPanel {
new ImageIcon(Resources.class.getResource("/icons/topography_icon.png")), new ImageIcon(Resources.class.getResource("/icons/topography_icon.png")),
panelModel, selectShape); panelModel, selectShape);
/* Makros */
ActionTopographyMakroMenu actionTopographyMakroMenu =
new ActionTopographyMakroMenu("TopographyMakros",
new ImageIcon(Resources.class.getResource("/icons/setting32x32.png")),
panelModel);
/* Topography checker*/ /* Topography checker*/
ActionTopographyCheckerMenu actionTopographyCheckerMenu = ActionTopographyCheckerMenu actionTopographyCheckerMenu =
new ActionTopographyCheckerMenu("TopographyChecker", panelModel, jsonValidIndicator); new ActionTopographyCheckerMenu("TopographyChecker", panelModel, jsonValidIndicator);
...@@ -350,6 +357,7 @@ public class TopographyWindow extends JPanel { ...@@ -350,6 +357,7 @@ public class TopographyWindow extends JPanel {
addActionToToolbar(toolbar, undoAction, "TopographyCreator.btnUndo.tooltip"); addActionToToolbar(toolbar, undoAction, "TopographyCreator.btnUndo.tooltip");
addActionToToolbar(toolbar, redoAction, "TopographyCreator.btnRedo.tooltip"); addActionToToolbar(toolbar, redoAction, "TopographyCreator.btnRedo.tooltip");
toolbar.add(Box.createHorizontalGlue()); toolbar.add(Box.createHorizontalGlue());
addActionToToolbar(toolbar, actionTopographyMakroMenu, "TopographyCreator.btnMakro.tooltip");
addActionToToolbar(toolbar, actionTopographyCheckerMenu, "TopographyCreator.btnChecker.tooltip"); addActionToToolbar(toolbar, actionTopographyCheckerMenu, "TopographyCreator.btnChecker.tooltip");
toolbar.add(infoButton); toolbar.add(infoButton);
infoButton.setToolTipText("About"); infoButton.setToolTipText("About");
......
...@@ -4,15 +4,18 @@ import org.apache.commons.math3.util.Pair; ...@@ -4,15 +4,18 @@ import org.apache.commons.math3.util.Pair;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.vadere.state.scenario.Obstacle; import org.vadere.state.scenario.Obstacle;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.ScenarioElement;
import org.vadere.state.scenario.Source; import org.vadere.state.scenario.Source;
import org.vadere.state.scenario.Stairs; import org.vadere.state.scenario.Stairs;
import org.vadere.state.scenario.Target; import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.state.types.ScenarioElementType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.function.BiFunction;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TopographyChecker { public class TopographyChecker {
...@@ -43,33 +46,199 @@ public class TopographyChecker { ...@@ -43,33 +46,199 @@ public class TopographyChecker {
return checkObstacleOverlap().size() > 0; return checkObstacleOverlap().size() > 0;
} }
public List<TopographyCheckerMessage> checkSourceObstacleOverlap(){ public List<TopographyCheckerMessage> checkOverlap(BiFunction<ScenarioElementType, ScenarioElementType, Boolean> useTest) {
List<TopographyCheckerMessage> ret = new ArrayList<>(); List<TopographyCheckerMessage> ret = new ArrayList<>();
final List<Source> sources = topography.getSources();
final List<Obstacle> obstacles = topography.getObstacles();
for (Obstacle obstacle : obstacles) { ArrayList<ScenarioElement> all = topography.getAllScenarioElements();
for(Source source: sources){ for (int i = 0; i < all.size(); i++) {
if (obstacle.getShape().intersects(source.getShape())){ for (int j = i + 1; j < all.size(); j++) {
ret.add(msgBuilder.error() ScenarioElement elementA = all.get(i);
.reason(TopographyCheckerReason.SOURCE_OVERLAP_WITH_OBSTACLE) ScenarioElement elementB = all.get(j);
.target(source, obstacle)
.build()); // 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; 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<>(); List<TopographyCheckerMessage> ret = new ArrayList<>();
ret.addAll(checkValidTargetsInSource()); ret.addAll(checkValidTargetsInSource());
ret.addAll(checkUniqueSourceId()); ret.addAll(checkUniqueSourceId());
ret.addAll(checkSourceObstacleOverlap());
ret.addAll(checkUnusedTargets()); ret.addAll(checkUnusedTargets());
ret.addAll(checkStairTreadSanity()); ret.addAll(checkStairTreadSanity());
ret.addAll(checkPedestrianSpeedSetup()); ret.addAll(checkPedestrianSpeedSetup());
ret.addAll(checkOverlap((type, type2) -> true));
return ret; return ret;
} }
...@@ -77,7 +246,7 @@ public class TopographyChecker { ...@@ -77,7 +246,7 @@ public class TopographyChecker {
List<TopographyCheckerMessage> ret = new ArrayList<>(); List<TopographyCheckerMessage> ret = new ArrayList<>();
topography.getPedestrianDynamicElements().getInitialElements().forEach(p -> { topography.getPedestrianDynamicElements().getInitialElements().forEach(p -> {
double speedMean = p.getSpeedDistributionMean(); 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 ret.add(msgBuilder
.error() .error()
.target(p) .target(p)
...@@ -85,10 +254,10 @@ public class TopographyChecker { ...@@ -85,10 +254,10 @@ public class TopographyChecker {
"(" + p.getAttributes().getMinimumSpeed() "(" + p.getAttributes().getMinimumSpeed()
+ " &lt; treadDepth &lt; " + " &lt; treadDepth &lt; "
+ p.getAttributes().getMaximumSpeed() + + p.getAttributes().getMaximumSpeed() +
") current SpeedDistributionMean is: " + String.format("%.2f",speedMean)) ") current SpeedDistributionMean is: " + String.format("%.2f", speedMean))
.build()); .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 ret.add(msgBuilder
.warning() .warning()
.target(p) .target(p)
...@@ -97,7 +266,7 @@ public class TopographyChecker { ...@@ -97,7 +266,7 @@ public class TopographyChecker {
p.getAttributes().getMaximumSpeed(), Pedestrian.HUMAN_MAX_SPEED)) p.getAttributes().getMaximumSpeed(), Pedestrian.HUMAN_MAX_SPEED))
.build()); .build());
} }
if (p.getAttributes().getMinimumSpeed() < 0 || p.getAttributes().getMaximumSpeed() < 0){ if (p.getAttributes().getMinimumSpeed() < 0 || p.getAttributes().getMaximumSpeed() < 0) {
ret.add(msgBuilder ret.add(msgBuilder
.error() .error()
.target(p) .target(p)
...@@ -111,15 +280,15 @@ public class TopographyChecker { ...@@ -111,15 +280,15 @@ public class TopographyChecker {
public List<TopographyCheckerMessage> checkStairTreadSanity() { public List<TopographyCheckerMessage> checkStairTreadSanity() {
List<TopographyCheckerMessage> ret = new ArrayList<>(); List<TopographyCheckerMessage> ret = new ArrayList<>();
topography.getStairs().forEach( stairs -> { topography.getStairs().forEach(stairs -> {
double treadDepth = stairs.getTreadDepth(); 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 ret.add(msgBuilder
.warning() .warning()
.target(stairs) .target(stairs)
.reason(TopographyCheckerReason.STAIRS_TREAD_DIM_WRONG .reason(TopographyCheckerReason.STAIRS_TREAD_DIM_WRONG
, "(" + Stairs.MIN_TREAD_DEPTH + "m &lt; treadDepth &gt; " + Stairs.MAX_TREAD_DEPTH + , "(" + 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() .build()
); );
} }
...@@ -136,7 +305,7 @@ public class TopographyChecker { ...@@ -136,7 +305,7 @@ public class TopographyChecker {
.forEach(s -> usedTargetIds.addAll(s.getAttributes().getTargetIds())); .forEach(s -> usedTargetIds.addAll(s.getAttributes().getTargetIds()));
topography.getTargets().forEach(t -> { topography.getTargets().forEach(t -> {
if (!usedTargetIds.contains(t.getId())){ if (!usedTargetIds.contains(t.getId())) {
ret.add(msgBuilder ret.add(msgBuilder
.warning() .warning()
.reason(TopographyCheckerReason.TARGET_UNUSED) .reason(TopographyCheckerReason.TARGET_UNUSED)
...@@ -155,9 +324,9 @@ public class TopographyChecker { ...@@ -155,9 +324,9 @@ public class TopographyChecker {
.map(Target::getId) .map(Target::getId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
for(Source s : topography.getSources()){ for (Source s : topography.getSources()) {
if (s.getAttributes().getTargetIds().size() == 0){ if (s.getAttributes().getTargetIds().size() == 0) {
if (s.getAttributes().getSpawnNumber() == 0){ if (s.getAttributes().getSpawnNumber() == 0) {
ret.add(msgBuilder ret.add(msgBuilder
.warning() .warning()
.target(s) .target(s)
...@@ -195,8 +364,8 @@ public class TopographyChecker { ...@@ -195,8 +364,8 @@ public class TopographyChecker {
List<TopographyCheckerMessage> ret = new ArrayList<>(); List<TopographyCheckerMessage> ret = new ArrayList<>();
Set<Integer> sourceId = new HashSet<>(); Set<Integer> sourceId = new HashSet<>();
for(Source s : topography.getSources()){ for (Source s : topography.getSources()) {
if (!sourceId.add(s.getId())){ if (!sourceId.add(s.getId())) {
ret.add(msgBuilder.warning() ret.add(msgBuilder.warning()
.target(s) .target(s)
.reason(TopographyCheckerReason.SOURCE_ID_NOT_UNIQUE) .reason(TopographyCheckerReason.SOURCE_ID_NOT_UNIQUE)
......
...@@ -12,13 +12,23 @@ public enum TopographyCheckerReason { ...@@ -12,13 +12,23 @@ public enum TopographyCheckerReason {
SOURCE_NO_TARGET_ID_SET("TopographyChecker.source.noTargetIdSet"), SOURCE_NO_TARGET_ID_SET("TopographyChecker.source.noTargetIdSet"),
SOURCE_NO_TARGET_ID_NO_SPAWN("TopographyChecker.source.noTargetIdAndNoSpawn"), SOURCE_NO_TARGET_ID_NO_SPAWN("TopographyChecker.source.noTargetIdAndNoSpawn"),
SOURCE_ID_NOT_UNIQUE("TopographyChecker.source.idNotUnique"), SOURCE_ID_NOT_UNIQUE("TopographyChecker.source.idNotUnique"),
SOURCE_OVERLAP_WITH_OBSTACLE("TopographyChecker.source.overlapWithObstacle"),
STAIRS_TREAD_DIM_WRONG("TopographyChecker.stairs.wrongTreadDim"), 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"),