Class CycleDetector
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.Test
-
- org.openstreetmap.josm.data.validation.tests.CycleDetector
-
- All Implemented Interfaces:
OsmPrimitiveVisitor
public class CycleDetector extends Test
Test for detecting cycles in a directed graph, currently used for waterways only. The processed graph consists of ways labeled as waterway.- Since:
- 19062
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.validation.Test
Test.TagTest
-
-
Field Summary
Fields Modifier and Type Field Description protected static intCYCLE_DETECTEDprivate java.util.List<java.lang.String>directionalWaterwaysCurrently used directional waterways from the OSM wikiprotected static java.lang.StringPREFIXprivate java.util.Set<Way>usableWaterwaysAll waterways for cycle detectionprivate java.util.Set<java.lang.Long>visitedWaysAlready visited primitive unique IDs-
Fields inherited from class org.openstreetmap.josm.data.validation.Test
checkBeforeUpload, checkEnabled, description, enabled, errors, IN_DOWNLOADED_AREA, IN_DOWNLOADED_AREA_STRICT, isBeforeUpload, name, partialSelection, progressMonitor, stopwatch, testBeforeUpload
-
-
Constructor Summary
Constructors Constructor Description CycleDetector()Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.Collection<Way>buildGraph(Way way)Returns a collection of ways, which belongs to the same graph.private static java.util.Collection<WaySegment>createSegments(java.util.Map<Node,java.util.List<Node>> graphMap, java.util.Collection<Node> nodes)Creates WaySegments from Nodes for the error highlight function.voidendTest()Notification of the end of the test.private java.util.Collection<java.util.Collection<Way>>getGraphs()Returns all directional waterways which connect to at least one other usable way.private static booleanisConsecutive(Way w, Node n, Node m)Determines if the given nodes are consecutive part of the parent way.booleanisPrimitiveUsable(OsmPrimitive p)Determines if the primitive is usable for tests.voidstartTest(ProgressMonitor progressMonitor)Start the test using a given progress monitorvoidvisit(Way w)Visiting call for lines.-
Methods inherited from class org.openstreetmap.josm.data.validation.Test
addGui, clear, deletePrimitivesIfNeeded, fixError, getErrors, getName, getSource, initialize, isBuilding, isCanceled, isFixable, isResidentialArea, ok, removeIrrelevantErrors, setBeforeUpload, setPartialSelection, setShowElements, testBeforeUpload, visit, visit, visit
-
-
-
-
Field Detail
-
CYCLE_DETECTED
protected static final int CYCLE_DETECTED
- See Also:
- Constant Field Values
-
usableWaterways
private final java.util.Set<Way> usableWaterways
All waterways for cycle detection
-
visitedWays
private final java.util.Set<java.lang.Long> visitedWays
Already visited primitive unique IDs
-
directionalWaterways
private java.util.List<java.lang.String> directionalWaterways
Currently used directional waterways from the OSM wiki
-
PREFIX
protected static final java.lang.String PREFIX
-
-
Constructor Detail
-
CycleDetector
public CycleDetector()
Constructor
-
-
Method Detail
-
isPrimitiveUsable
public boolean isPrimitiveUsable(OsmPrimitive p)
Description copied from class:TestDetermines if the primitive is usable for tests.- Overrides:
isPrimitiveUsablein classTest- Parameters:
p- The primitive- Returns:
trueif the primitive can be tested,falseotherwise
-
visit
public void visit(Way w)
Description copied from interface:OsmPrimitiveVisitorVisiting call for lines.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Overrides:
visitin classTest- Parameters:
w- The way to inspect.
-
startTest
public void startTest(ProgressMonitor progressMonitor)
Description copied from class:TestStart the test using a given progress monitor
-
endTest
public void endTest()
Description copied from class:TestNotification of the end of the test. The tester may perform additional actions and destroy the used structures.If you override this method, don't forget to cleanup
progressMonitor(most overrides callsuper.endTest()to do this).
-
createSegments
private static java.util.Collection<WaySegment> createSegments(java.util.Map<Node,java.util.List<Node>> graphMap, java.util.Collection<Node> nodes)
Creates WaySegments from Nodes for the error highlight function.- Parameters:
graphMap- the complete graph datanodes- nodes to build the way segments from- Returns:
- WaySegments from the Nodes
-
isConsecutive
private static boolean isConsecutive(Way w, Node n, Node m)
Determines if the given nodes are consecutive part of the parent way.- Parameters:
w- parent wayn- the first node to look up in the way directionm- the second, possibly consecutive node- Returns:
trueif the nodes are consecutive order in the way direction
-
getGraphs
private java.util.Collection<java.util.Collection<Way>> getGraphs()
Returns all directional waterways which connect to at least one other usable way.- Returns:
- all directional waterways which connect to at least one other usable way
-
buildGraph
private java.util.Collection<Way> buildGraph(Way way)
Returns a collection of ways, which belongs to the same graph.- Parameters:
way- starting way to extend the graph from- Returns:
- a collection of ways which belongs to the same graph
-
-