Class PowerLines
- 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPowerLines.NumberingDirectionPower line support features ref=* numbering direction.(package private) static classPowerLines.RefCheckerDetects continuous reference numbering sequences.private static classPowerLines.SegmentInfoHelper class for reference numbering test.-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.validation.Test
Test.TagTest
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<Node>badConnectionsprivate static java.lang.StringBUILDING(package private) static java.util.Collection<java.lang.String>BUILDING_STATION_TAGSValues forbuildingkey interpreted as power stationsprivate java.util.Map<java.awt.geom.Point2D,java.util.List<WaySegment>>cellSegmentsWaterAll waterway segments, grouped by cellsprivate java.util.Collection<Way>foundPowerLinesprivate doublehillyCompensationprivate doublehillyThresholdprivate static java.lang.StringMINOR_LINEprivate java.util.Set<WaySegment>missingNodesprivate java.util.Set<Node>missingTagsprivate static java.lang.StringPOWERprotected static intPOWER_CONNECTION(package private) static java.util.Collection<java.lang.String>POWER_INFRASTRUCTURE_TAGSValues forpowerkey interpreted as allowed power items(package private) static java.util.Collection<java.lang.String>POWER_LINE_TAGSValues forpowerkey interpreted as power linesprotected static intPOWER_LINE_TYPEprotected static intPOWER_LOCAL_REF_CONTINUITYprotected static intPOWER_SEGMENT_LENGTH(package private) static java.util.Collection<java.lang.String>POWER_STATION_TAGSValues forpowerkey interpreted as power stationsprotected static intPOWER_SUPPORT(package private) static java.util.Collection<java.lang.String>POWER_TOWER_TAGSValues forpowerkey interpreted as power towersprotected static intPOWER_WAY_REF_CONTINUITYprivate java.util.List<OsmPrimitive>powerStationsprotected static java.lang.StringPREFIXprivate java.util.Set<OsmPrimitive>refDiscontinuitiesprivate java.util.List<java.util.Set<Node>>segmentRefDiscontinuitiesprivate java.util.Set<Way>wrongLineType-
Fields inherited from class org.openstreetmap.josm.data.validation.Test
checkBeforeUpload, checkEnabled, description, enabled, errors, IN_DOWNLOADED_AREA, IN_DOWNLOADED_AREA_STRICT, isBeforeUpload, name, partialSelection, progressMonitor, stopwatch, testBeforeUpload
-
-
Constructor Summary
Constructors Constructor Description PowerLines()Constructs a newPowerLinestest.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddWaterWaySegments(Way w)Add segments to the appropriate cellsprivate static doublecalculateIntersectingLen(Node ref, java.util.Set<ILatLon> crossingNodes)The summarized length (in metres) of a way where a power line hangs over a water area.voidclear()Free resources.private static booleanconcernsWaterArea(OsmPrimitive p)Check if primitive has a tag that marks it as a water area or boundary of a water area.(package private) static booleandetectDiscontinuity(Way way, java.util.Set<OsmPrimitive> nRefDiscontinuities, java.util.List<java.util.Set<Node>> sRefDiscontinuities)Detects ref=* numbering discontinuities in the given way.voidendTest()Notification of the end of the test.private static voidfindCrossings(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 thepairattribute.private static booleanisBuildingIn(OsmPrimitive p, java.util.Collection<java.lang.String> values)Helper function to check if building tag is a certain value.private static booleanisConnectedToStationLine(Node n, Way w)Determines if the current node connected to a line which usually used inside power stations.private static booleanisContinuesAsMinorLine(Way way)Checks if the way continues as a power=minor_line.protected booleanisInPowerStation(Node n)Checks if the given node is inside a power station.private static booleanisMinorLine(OsmPrimitive p)Checks if the given primitive denotes a power=minor_line.private static booleanisPowerIn(OsmPrimitive p, java.util.Collection<java.lang.String> values)Helper function to check if power tag is a certain value.protected static booleanisPowerInfrastructure(Node n)Determines if the specified node denotes a power infrastructure allowed on a power line.protected static booleanisPowerLine(Way w)Determines if the specified way denotes a power line.protected static booleanisPowerStation(OsmPrimitive p)Determines if the specified primitive denotes a power station.protected static booleanisPowerTower(Node n)Determines if the specified node denotes a power support feature.private static booleanisRelatedToPower(Way way)private static booleanisSegmentAlign(PowerLines.SegmentInfo reference, PowerLines.SegmentInfo candidate)Checks if parameter segments align.private voidpowerlineChecks(Way w)The base powerline checksvoidstartTest(ProgressMonitor progressMonitor)Start the test using a given progress monitorvoidvisit(Node n)Visiting call for points.voidvisit(Relation r)Visiting call for relations.voidvisit(Way w)Visiting call for lines.-
Methods inherited from class org.openstreetmap.josm.data.validation.Test
addGui, deletePrimitivesIfNeeded, fixError, getErrors, getName, getSource, initialize, isBuilding, isCanceled, isFixable, isPrimitiveUsable, isResidentialArea, ok, removeIrrelevantErrors, setBeforeUpload, setPartialSelection, setShowElements, testBeforeUpload, visit
-
-
-
-
Field Detail
-
MINOR_LINE
private static final java.lang.String MINOR_LINE
- See Also:
- Constant Field Values
-
BUILDING
private static final java.lang.String BUILDING
- See Also:
- Constant Field Values
-
POWER
private static final java.lang.String POWER
- See Also:
- Constant Field Values
-
POWER_SUPPORT
protected static final int POWER_SUPPORT
- See Also:
- Constant Field Values
-
POWER_CONNECTION
protected static final int POWER_CONNECTION
- See Also:
- Constant Field Values
-
POWER_SEGMENT_LENGTH
protected static final int POWER_SEGMENT_LENGTH
- See Also:
- Constant Field Values
-
POWER_LOCAL_REF_CONTINUITY
protected static final int POWER_LOCAL_REF_CONTINUITY
- See Also:
- Constant Field Values
-
POWER_WAY_REF_CONTINUITY
protected static final int POWER_WAY_REF_CONTINUITY
- See Also:
- Constant Field Values
-
POWER_LINE_TYPE
protected static final int POWER_LINE_TYPE
- See Also:
- Constant Field Values
-
PREFIX
protected static final java.lang.String PREFIX
-
POWER_LINE_TAGS
static final java.util.Collection<java.lang.String> POWER_LINE_TAGS
Values forpowerkey interpreted as power lines
-
POWER_TOWER_TAGS
static final java.util.Collection<java.lang.String> POWER_TOWER_TAGS
Values forpowerkey interpreted as power towers
-
POWER_STATION_TAGS
static final java.util.Collection<java.lang.String> POWER_STATION_TAGS
Values forpowerkey interpreted as power stations
-
BUILDING_STATION_TAGS
static final java.util.Collection<java.lang.String> BUILDING_STATION_TAGS
Values forbuildingkey interpreted as power stations
-
POWER_INFRASTRUCTURE_TAGS
static final java.util.Collection<java.lang.String> POWER_INFRASTRUCTURE_TAGS
Values forpowerkey interpreted as allowed power items
-
hillyCompensation
private double hillyCompensation
-
hillyThreshold
private double hillyThreshold
-
badConnections
private final java.util.Set<Node> badConnections
-
missingTags
private final java.util.Set<Node> missingTags
-
wrongLineType
private final java.util.Set<Way> wrongLineType
-
missingNodes
private final java.util.Set<WaySegment> missingNodes
-
refDiscontinuities
private final java.util.Set<OsmPrimitive> refDiscontinuities
-
segmentRefDiscontinuities
private final java.util.List<java.util.Set<Node>> segmentRefDiscontinuities
-
powerStations
private final java.util.List<OsmPrimitive> powerStations
-
foundPowerLines
private final java.util.Collection<Way> foundPowerLines
-
cellSegmentsWater
private final java.util.Map<java.awt.geom.Point2D,java.util.List<WaySegment>> cellSegmentsWater
All waterway segments, grouped by cells
-
-
Constructor Detail
-
PowerLines
public PowerLines()
Constructs a newPowerLinestest.
-
-
Method Detail
-
visit
public void visit(Node n)
Description copied from interface:OsmPrimitiveVisitorVisiting call for points.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Overrides:
visitin classTest- Parameters:
n- The node to inspect.
-
visit
public void visit(Way w)
Description copied from interface:OsmPrimitiveVisitorVisiting call for lines.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Overrides:
visitin classTest- 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:OsmPrimitiveVisitorVisiting call for relations.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Overrides:
visitin classTest- Parameters:
r- The relation to inspect.
-
startTest
public void startTest(ProgressMonitor progressMonitor)
Description copied from class:TestStart the test using a given progress monitor
-
endTest
public void endTest()
Description copied from class:TestNotification 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 callsuper.endTest()to do this).
-
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 pointcrossingNodes- 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 thepairattribute.- Parameters:
ways- collection of ways to search for crossingsparent- parent powerline way to find crossings forcrossingWays- found crossing wayscrossingPositions- 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 waynRefDiscontinuities- single node ref=* discontinuitiessRefDiscontinuities- continuous node ref=* discontinuities- Returns:
trueif 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. Thereferenceis expected to be at least as long as thecandidate.- Parameters:
reference- Reference segment to check againstcandidate- Candidate segment- Returns:
trueif 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 checkw- parent way ofn- Returns:
trueifnconnected 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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 testedvalues- List of possible values- Returns:
trueif 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 testedvalues- List of possible values- Returns:
trueif power key is set and equal to possible values
-
-