Class 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
    • Field Detail

      • 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
    • Method Detail

      • isPrimitiveUsable

        public boolean isPrimitiveUsable​(OsmPrimitive p)
        Description copied from class: Test
        Determines if the primitive is usable for tests.
        Overrides:
        isPrimitiveUsable in class Test
        Parameters:
        p - The primitive
        Returns:
        true if the primitive can be tested, false otherwise
      • startTest

        public void startTest​(ProgressMonitor progressMonitor)
        Description copied from class: Test
        Start the test using a given progress monitor
        Overrides:
        startTest in class Test
        Parameters:
        progressMonitor - the progress monitor
      • endTest

        public void endTest()
        Description copied from class: Test
        Notification 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 call super.endTest() to do this).

        Overrides:
        endTest in class Test
      • createSegments

        private static java.util.Collection<WaySegmentcreateSegments​(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 data
        nodes - 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 way
        n - the first node to look up in the way direction
        m - the second, possibly consecutive node
        Returns:
        true if 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<WaybuildGraph​(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