Class 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.
    • Constructor Detail

      • PowerLines

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

      • addWaterWaySegments

        private void addWaterWaySegments​(Way w)
        Add segments to the appropriate cells
        Parameters:
        w - The way to add segments from
      • 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
      • powerlineChecks

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

        private static double calculateIntersectingLen​(Node ref,
                                                       java.util.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​(java.util.Map<java.awt.geom.Point2D,​java.util.List<WaySegment>> ways,
                                          Way parent,
                                          java.util.Set<Way> crossingWays,
                                          java.util.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
      • detectDiscontinuity

        static boolean detectDiscontinuity​(Way way,
                                           java.util.Set<OsmPrimitive> nRefDiscontinuities,
                                           java.util.List<java.util.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
      • 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
      • 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,
                                         java.util.Collection<java.lang.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,
                                            java.util.Collection<java.lang.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