Class PowerLines.RefChecker
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.tests.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.
-
-
Field Summary
Fields Modifier and Type Field Description private PowerLines.NumberingDirection
direction
private java.lang.Integer
previousRef
private java.util.List<PowerLines.SegmentInfo>
segments
private java.lang.Integer
startIndex
-
Constructor Summary
Constructors Constructor Description RefChecker(Way way)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static PowerLines.NumberingDirection
detectDirection(int ref, int previousRef)
Detects numbering direction.(package private) PowerLines.SegmentInfo
getLongestSegment()
Calculates the longest segment.(package private) java.util.List<PowerLines.SegmentInfo>
getSegments()
Get the detected segmentsprivate void
maintain(java.lang.Integer ref, int index)
Maintains class variables and constructs a new segment when necessary.private static java.lang.Integer
parseRef(java.lang.String value)
Parses integer tag values.private void
run(Way way)
-
-
-
Field Detail
-
segments
private final java.util.List<PowerLines.SegmentInfo> segments
-
direction
private PowerLines.NumberingDirection direction
-
startIndex
private java.lang.Integer startIndex
-
previousRef
private java.lang.Integer previousRef
-
-
Constructor Detail
-
RefChecker
RefChecker(Way way)
-
-
Method Detail
-
maintain
private void maintain(java.lang.Integer ref, int index)
Maintains class variables and constructs a new segment when necessary.- Parameters:
ref
- recognised ref=* numberindex
- node index in aWay
-
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 ofNumberFormatException
-
detectDirection
private static PowerLines.NumberingDirection detectDirection(int ref, int previousRef)
Detects numbering direction. The parameters should follow way direction.- Parameters:
ref
- last known reference valuepreviousRef
- reference value beforeref
- 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
-
getSegments
java.util.List<PowerLines.SegmentInfo> getSegments()
Get the detected segments- Returns:
- the detected segments
-
-