java.lang.Object
org.openstreetmap.josm.data.validation.Test
org.openstreetmap.josm.data.validation.tests.PowerLines
All Implemented Interfaces:
OsmPrimitiveVisitor

public class PowerLines extends Test
Checks for
  • nodes in power lines/minor_lines that do not have a power=tower/pole/portal tag
  • nodes where the reference numbering not consistent
  • ways where are unusually long segments without line support feature
  • ways where the line type is possibly misused
See #7812 and #20716 for discussions about this test.
  • Field Details

  • Constructor Details

    • PowerLines

      public PowerLines()
      Constructs a new PowerLines test.
  • Method Details

    • visit

      public void visit(Node n)
      Description copied from interface: OsmPrimitiveVisitor
      Visiting call for points.
      Specified by:
      visit in interface OsmPrimitiveVisitor
      Overrides:
      visit in class Test
      Parameters:
      n - The node to inspect.
    • 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.
    • addWaterWaySegments

      private void addWaterWaySegments(Way w)
      Add segments to the appropriate cells
      Parameters:
      w - The way to add segments from
    • visit

      public void visit(Relation r)
      Description copied from interface: OsmPrimitiveVisitor
      Visiting call for relations.
      Specified by:
      visit in interface OsmPrimitiveVisitor
      Overrides:
      visit in class Test
      Parameters:
      r - The relation 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
    • getAllPrimitives

      Combine the node and the related objects.
      Parameters:
      entry - a map entry with a node and related objects
      Returns:
      set containing the node and the related objects
    • powerlineChecks

      private void powerlineChecks(Way w)
      The base powerline checks
      Parameters:
      w - The powerline to check
    • calculateIntersectingLen

      private static double calculateIntersectingLen(Node ref, Set<ILatLon> crossingNodes)
      The summarized length (in metres) of a way where a power line hangs over a water area.
      Parameters:
      ref - Reference point
      crossingNodes - Crossing nodes, unordered
      Returns:
      The summarized length (in metres) of a way where a power line hangs over a water area
    • findCrossings

      private static void findCrossings(Map<Point2D,List<WaySegment>> ways, Way parent, Set<Way> crossingWays, Set<ILatLon> crossingPositions)
      Searches for way intersections, which intersect the pair attribute.
      Parameters:
      ways - collection of ways to search for crossings
      parent - parent powerline way to find crossings for
      crossingWays - found crossing ways
      crossingPositions - collection of the crossing positions Inspired by utilsplugin2/selection/NodeWayUtils.java#addWaysIntersectingWay()
    • detectDiscontinuity

      static boolean detectDiscontinuity(Way way, Set<OsmPrimitive> nRefDiscontinuities, List<Set<Node>> sRefDiscontinuities)
      Detects ref=* numbering discontinuities in the given way.
      Parameters:
      way - checked way
      nRefDiscontinuities - single node ref=* discontinuities
      sRefDiscontinuities - continuous node ref=* discontinuities
      Returns:
      true if warning needs to be issued for the whole way
    • isSegmentAlign

      private static boolean isSegmentAlign(PowerLines.SegmentInfo reference, PowerLines.SegmentInfo candidate)
      Checks if parameter segments align. The reference is expected to be at least as long as the candidate.
      Parameters:
      reference - Reference segment to check against
      candidate - Candidate segment
      Returns:
      true if the two segments ref=* numbering align
    • isRelatedToPower

      private static boolean isRelatedToPower(Way way)
    • isConnectedToStationLine

      private static boolean isConnectedToStationLine(Node n, Way w)
      Determines if the current node connected to a line which usually used inside power stations.
      Parameters:
      n - node to check
      w - parent way of n
      Returns:
      true if n connected to power=line + line=*
    • isContinuesAsMinorLine

      private static boolean isContinuesAsMinorLine(Way way)
      Checks if the way continues as a power=minor_line.
      Parameters:
      way - Way to be checked
      Returns:
      true if the way continues as a power=minor_line
    • isMinorLine

      private static boolean isMinorLine(OsmPrimitive p)
      Checks if the given primitive denotes a power=minor_line.
      Parameters:
      p - primitive to be checked
      Returns:
      true if the given primitive denotes a power=minor_line
    • concernsWaterArea

      private static boolean concernsWaterArea(OsmPrimitive p)
      Check if primitive has a tag that marks it as a water area or boundary of a water area.
      Parameters:
      p - the primitive
      Returns:
      true if primitive has a tag that marks it as a water area or boundary of a water area
    • isInPowerStation

      protected final boolean isInPowerStation(Node n)
      Checks if the given node is inside a power station.
      Parameters:
      n - Node to be checked
      Returns:
      true if the given node is inside a power station
    • isPowerLine

      protected static boolean isPowerLine(Way w)
      Determines if the specified way denotes a power line.
      Parameters:
      w - The way to be tested
      Returns:
      true if power key is set and equal to line/minor_line
    • isPowerLineOrCable

      protected static boolean isPowerLineOrCable(Way w)
      Determines if the specified way denotes a power line or cable.
      Parameters:
      w - The way to be tested
      Returns:
      true if power key is set and equal to line,minor_line or cable
    • isPowerStation

      protected static boolean isPowerStation(OsmPrimitive p)
      Determines if the specified primitive denotes a power station.
      Parameters:
      p - The primitive to be tested
      Returns:
      true if power key is set and equal to generator/substation/plant
    • isPowerTower

      protected static boolean isPowerTower(Node n)
      Determines if the specified node denotes a power support feature.
      Parameters:
      n - The node to be tested
      Returns:
      true if power key is set and equal to pole/tower/portal/catenary_mast
    • isPowerInfrastructure

      protected static boolean isPowerInfrastructure(Node n)
      Determines if the specified node denotes a power infrastructure allowed on a power line.
      Parameters:
      n - The node to be tested
      Returns:
      true if power key is set and equal to compensator/converter/generator/insulator /switch/switchgear/terminal/transformer
    • isPowerIn

      private static boolean isPowerIn(OsmPrimitive p, Collection<String> values)
      Helper function to check if power tag is a certain value.
      Parameters:
      p - The primitive to be tested
      values - List of possible values
      Returns:
      true if power key is set and equal to possible values
    • isBuildingIn

      private static boolean isBuildingIn(OsmPrimitive p, Collection<String> values)
      Helper function to check if building tag is a certain value.
      Parameters:
      p - The primitive to be tested
      values - List of possible values
      Returns:
      true if power key is set and equal to possible values
    • clear

      public void clear()
      Description copied from class: Test
      Free resources.
      Overrides:
      clear in class Test