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 class
PowerLines.NumberingDirection
Power line support features ref=* numbering direction.(package private) static class
PowerLines.RefChecker
Detects continuous reference numbering sequences.private static class
PowerLines.SegmentInfo
Helper 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>
badConnections
private static java.lang.String
BUILDING
(package private) static java.util.Collection<java.lang.String>
BUILDING_STATION_TAGS
Values forbuilding
key interpreted as power stationsprivate java.util.Map<java.awt.geom.Point2D,java.util.List<WaySegment>>
cellSegmentsWater
All waterway segments, grouped by cellsprivate java.util.Collection<Way>
foundPowerLines
private double
hillyCompensation
private double
hillyThreshold
private static java.lang.String
MINOR_LINE
private java.util.Set<WaySegment>
missingNodes
private java.util.Set<Node>
missingTags
private static java.lang.String
POWER
protected static int
POWER_CONNECTION
(package private) static java.util.Collection<java.lang.String>
POWER_INFRASTRUCTURE_TAGS
Values forpower
key interpreted as allowed power items(package private) static java.util.Collection<java.lang.String>
POWER_LINE_TAGS
Values forpower
key interpreted as power linesprotected static int
POWER_LINE_TYPE
protected static int
POWER_LOCAL_REF_CONTINUITY
protected static int
POWER_SEGMENT_LENGTH
(package private) static java.util.Collection<java.lang.String>
POWER_STATION_TAGS
Values forpower
key interpreted as power stationsprotected static int
POWER_SUPPORT
(package private) static java.util.Collection<java.lang.String>
POWER_TOWER_TAGS
Values forpower
key interpreted as power towersprotected static int
POWER_WAY_REF_CONTINUITY
private java.util.List<OsmPrimitive>
powerStations
protected static java.lang.String
PREFIX
private java.util.Set<OsmPrimitive>
refDiscontinuities
private java.util.List<java.util.Set<Node>>
segmentRefDiscontinuities
private 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 newPowerLines
test.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addWaterWaySegments(Way w)
Add segments to the appropriate cellsprivate 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.void
clear()
Free resources.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.(package private) 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.void
endTest()
Notification of the end of the test.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 thepair
attribute.private static boolean
isBuildingIn(OsmPrimitive p, java.util.Collection<java.lang.String> values)
Helper function to check if building tag is a certain value.private static boolean
isConnectedToStationLine(Node n, Way w)
Determines if the current node connected to a line which usually used inside power stations.private static boolean
isContinuesAsMinorLine(Way way)
Checks if the way continues as a power=minor_line.protected boolean
isInPowerStation(Node n)
Checks if the given node is inside a power station.private static boolean
isMinorLine(OsmPrimitive p)
Checks if the given primitive denotes a power=minor_line.private static boolean
isPowerIn(OsmPrimitive p, java.util.Collection<java.lang.String> values)
Helper function to check if power tag is a certain value.protected static boolean
isPowerInfrastructure(Node n)
Determines if the specified node denotes a power infrastructure allowed on a power line.protected static boolean
isPowerLine(Way w)
Determines if the specified way denotes a power line.protected static boolean
isPowerStation(OsmPrimitive p)
Determines if the specified primitive denotes a power station.protected static boolean
isPowerTower(Node n)
Determines if the specified node denotes a power support feature.private static boolean
isRelatedToPower(Way way)
private static boolean
isSegmentAlign(PowerLines.SegmentInfo reference, PowerLines.SegmentInfo candidate)
Checks if parameter segments align.private void
powerlineChecks(Way w)
The base powerline checksvoid
startTest(ProgressMonitor progressMonitor)
Start the test using a given progress monitorvoid
visit(Node n)
Visiting call for points.void
visit(Relation r)
Visiting call for relations.void
visit(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 forpower
key interpreted as power lines
-
POWER_TOWER_TAGS
static final java.util.Collection<java.lang.String> POWER_TOWER_TAGS
Values forpower
key interpreted as power towers
-
POWER_STATION_TAGS
static final java.util.Collection<java.lang.String> POWER_STATION_TAGS
Values forpower
key interpreted as power stations
-
BUILDING_STATION_TAGS
static final java.util.Collection<java.lang.String> BUILDING_STATION_TAGS
Values forbuilding
key interpreted as power stations
-
POWER_INFRASTRUCTURE_TAGS
static final java.util.Collection<java.lang.String> POWER_INFRASTRUCTURE_TAGS
Values forpower
key 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 newPowerLines
test.
-
-
Method Detail
-
visit
public void visit(Node n)
Description copied from interface:OsmPrimitiveVisitor
Visiting call for points.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Overrides:
visit
in classTest
- 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 interfaceOsmPrimitiveVisitor
- Overrides:
visit
in 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:OsmPrimitiveVisitor
Visiting call for relations.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Overrides:
visit
in classTest
- 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
-
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 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 thepair
attribute.- 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:
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. Thereference
is expected to be at least as long as thecandidate
.- Parameters:
reference
- Reference segment to check againstcandidate
- 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 checkw
- parent way ofn
- Returns:
true
ifn
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 testedvalues
- 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 testedvalues
- List of possible values- Returns:
true
if power key is set and equal to possible values
-
-