Package org.openstreetmap.josm.actions
Class JoinAreasAction.WayTraverser
- java.lang.Object
-
- org.openstreetmap.josm.actions.JoinAreasAction.WayTraverser
-
- Enclosing class:
- JoinAreasAction
private static class JoinAreasAction.WayTraverser extends java.lang.Object
This helper class implements algorithm traversing through connected ways. Assumes you are going in clockwise orientation.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<JoinAreasAction.WayInPolygon>
availableWays
Set ofJoinAreasAction.WayInPolygon
to be joined by walk algorithmprivate JoinAreasAction.WayInPolygon
lastWay
Current state of walk algorithmprivate boolean
lastWayReverse
Direction of current way
-
Constructor Summary
Constructors Constructor Description WayTraverser(java.util.Collection<JoinAreasAction.WayInPolygon> ways)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static double
getAngle(Node n1, Node n2, Node n3)
Returns oriented angle (N1N2, N1N3) in range [0; 2*Math.PI[private Node
getHeadNode()
Walking throughJoinAreasAction.WayInPolygon
segments, head node is the current positionprivate Node
getPrevNode()
Node just before head node.JoinAreasAction.WayInPolygon
leftComingWay()
Search for another way coming to the same head node at left side from last way.void
removeWay(JoinAreasAction.WayInPolygon way)
Remove a single way from available waysvoid
removeWays(java.util.Collection<JoinAreasAction.WayInPolygon> ways)
Remove ways from available waysvoid
setStartWay(JoinAreasAction.WayInPolygon way)
Reset walk algorithm to a new start pointJoinAreasAction.WayInPolygon
startNewWay()
Reset walk algorithm to a new start point.JoinAreasAction.WayInPolygon
walk()
Get the next way creating a clockwise path, ensure it is the most right way.
-
-
-
Field Detail
-
availableWays
private final java.util.Set<JoinAreasAction.WayInPolygon> availableWays
Set ofJoinAreasAction.WayInPolygon
to be joined by walk algorithm
-
lastWay
private JoinAreasAction.WayInPolygon lastWay
Current state of walk algorithm
-
lastWayReverse
private boolean lastWayReverse
Direction of current way
-
-
Constructor Detail
-
WayTraverser
WayTraverser(java.util.Collection<JoinAreasAction.WayInPolygon> ways)
Constructor- Parameters:
ways
- available ways
-
-
Method Detail
-
removeWays
public void removeWays(java.util.Collection<JoinAreasAction.WayInPolygon> ways)
Remove ways from available ways- Parameters:
ways
- Collection of WayInPolygon
-
removeWay
public void removeWay(JoinAreasAction.WayInPolygon way)
Remove a single way from available ways- Parameters:
way
- WayInPolygon
-
setStartWay
public void setStartWay(JoinAreasAction.WayInPolygon way)
Reset walk algorithm to a new start point- Parameters:
way
- New start point
-
startNewWay
public JoinAreasAction.WayInPolygon startNewWay()
Reset walk algorithm to a new start point.- Returns:
- The new start point or null if no available way remains
-
getHeadNode
private Node getHeadNode()
Walking throughJoinAreasAction.WayInPolygon
segments, head node is the current position- Returns:
- Head node
-
getPrevNode
private Node getPrevNode()
Node just before head node.- Returns:
- Previous node
-
getAngle
private static double getAngle(Node n1, Node n2, Node n3)
Returns oriented angle (N1N2, N1N3) in range [0; 2*Math.PI[- Parameters:
n1
- first noden2
- second noden3
- third node- Returns:
- oriented angle (N1N2, N1N3) in range [0; 2*Math.PI[
-
walk
public JoinAreasAction.WayInPolygon walk()
Get the next way creating a clockwise path, ensure it is the most right way. #7959- Returns:
- The next way.
-
leftComingWay
public JoinAreasAction.WayInPolygon leftComingWay()
Search for another way coming to the same head node at left side from last way. #9951- Returns:
- left way or null if none found
-
-