Class PowerLines.RefChecker

  • Enclosing class:
    PowerLines

    static class PowerLines.RefChecker
    extends java.lang.Object
    Detects continuous reference numbering sequences. Ignores the first and last node because ways can be connected, and the connection nodes can have different numbering.

    If the numbering switches in the middle of the way, this can also be seen as error, because line relations would require split ways.

    • Method Detail

      • run

        private void run​(Way way)
      • maintain

        private void maintain​(java.lang.Integer ref,
                              int index)
        Maintains class variables and constructs a new segment when necessary.
        Parameters:
        ref - recognised ref=* number
        index - node index in a Way
      • parseRef

        private static java.lang.Integer parseRef​(java.lang.String value)
        Parses integer tag values. Later can be relatively easily extended or rewritten to handle complex references like 25/A, 25/B etc.
        Parameters:
        value - the value to be parsed
        Returns:
        parsed int or null in case of NumberFormatException
      • detectDirection

        private static PowerLines.NumberingDirection detectDirection​(int ref,
                                                                     int previousRef)
        Detects numbering direction. The parameters should follow way direction.
        Parameters:
        ref - last known reference value
        previousRef - reference value before ref
        Returns:
        recognised direction
      • getLongestSegment

        PowerLines.SegmentInfo getLongestSegment()
        Calculates the longest segment.
        Returns:
        the longest segment, or the lowest index if there are more than one with same length and direction, or null if there are more than one with same length and different direction