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
  • Field Details

  • Constructor Details

  • Method Details

    • 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
    • visit

      public void visit(Way w)
      Description copied from interface: OsmPrimitiveVisitor
      Visiting call for lines.
      Specified by:
      visit in interface OsmPrimitiveVisitor
      Overrides:
      visit in class Test
      Parameters:
      w - The way to inspect.
    • 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 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 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

      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 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