Class CycleDetector
java.lang.Object
org.openstreetmap.josm.data.validation.Test
org.openstreetmap.josm.data.validation.tests.CycleDetector
- All Implemented Interfaces:
OsmPrimitiveVisitor
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
FieldsModifier and TypeFieldDescriptionprotected static final intCurrently used directional waterways from the OSM wikiprotected static final StringAll waterways for cycle detectionAlready visited primitive unique IDsFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprivate Collection<Way>buildGraph(Way way) Returns a collection of ways, which belongs to the same graph.private static Collection<WaySegment>createSegments(Map<Node, List<Node>> graphMap, Collection<Node> nodes) Creates WaySegments from Nodes for the error highlight function.voidendTest()Notification of the end of the test.private Collection<Collection<Way>>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.booleanDetermines if the primitive is usable for tests.voidstartTest(ProgressMonitor progressMonitor) Start the test using a given progress monitorvoidVisiting 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 Details
-
CYCLE_DETECTED
- See Also:
-
usableWaterways
All waterways for cycle detection -
visitedWays
Already visited primitive unique IDs -
directionalWaterways
Currently used directional waterways from the OSM wiki -
PREFIX
-
-
Constructor Details
-
CycleDetector
public CycleDetector()Constructor
-
-
Method Details
-
isPrimitiveUsable
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
Description copied from interface:OsmPrimitiveVisitorVisiting call for lines.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Overrides:
visitin classTest- Parameters:
w- The way to inspect.
-
startTest
Description copied from class:TestStart the test using a given progress monitor -
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 Collection<WaySegment> createSegments(Map<Node, List<Node>> graphMap, 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
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
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
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
-