Package org.openstreetmap.josm.data.osm
Class IWaySegment<N extends INode,W extends IWay<N>>
java.lang.Object
org.openstreetmap.josm.data.osm.IWaySegment<N,W>
- Type Parameters:
N- The node typeW- The way type
- All Implemented Interfaces:
Comparable<IWaySegment<N,W>>
- Direct Known Subclasses:
WaySegment
public class IWaySegment<N extends INode,W extends IWay<N>>
extends Object
implements Comparable<IWaySegment<N,W>>
A segment consisting of 2 consecutive nodes out of a way.
- Since:
- 17862
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanstatic <N extends INode,W extends IWay<N>>
IWaySegment<N,W> forNodePair(W way, N first, N second) Determines and returns the way segment for the given way and node pair.Returns the first node of the way segment.intReturns the index of the first of the 2 nodes in the way.Returns the second (last) node of the way segment.intReturns the index of the second of the 2 nodes in the way.getWay()Returns the way.inthashCode()booleanintersects(IWaySegment<?, ?> s2) Checks whether this segment crosses other segmentbooleanisSimilar(IWaySegment<?, ?> s2) Checks whether this segment and another way segment share the same pointsbooleanisUsable()Determines if the segment is usable (node not deleted).toString()toWay()Returns this way segment as complete way.
-
Field Details
-
NOT_A_SEGMENT
- See Also:
-
way
-
lowerIndex
-
-
Constructor Details
-
IWaySegment
Constructs a newIWaySegment.- Parameters:
w- The wayi- The node lower index- Throws:
IllegalArgumentException- in case of invalid index
-
-
Method Details
-
getWay
Returns the way.- Returns:
- the way
-
getLowerIndex
Returns the index of the first of the 2 nodes in the way.- Returns:
- index of the first of the 2 nodes in the way
- See Also:
-
getUpperIndex
Returns the index of the second of the 2 nodes in the way.- Returns:
- the index of the second of the 2 nodes in the way
- See Also:
-
isUsable
Determines if the segment is usable (node not deleted).- Returns:
trueif the segment is usable- Since:
- 17986
-
getFirstNode
Returns the first node of the way segment.- Returns:
- the first node
-
getSecondNode
Returns the second (last) node of the way segment.- Returns:
- the second node
-
forNodePair
public static <N extends INode,W extends IWay<N>> IWaySegment<N,W> forNodePair(W way, N first, N second) Determines and returns the way segment for the given way and node pair.- Type Parameters:
N- type of nodeW- type of way- Parameters:
way- wayfirst- first nodesecond- second node- Returns:
- way segment
- Throws:
IllegalArgumentException- if the node pair is not a single segment of the way
-
toWay
public W toWay() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetExceptionReturns this way segment as complete way.- Returns:
- the way segment as
Way - Throws:
IllegalAccessException- SeeConstructor.newInstance(java.lang.Object...)IllegalArgumentException- SeeConstructor.newInstance(java.lang.Object...)InstantiationException- SeeConstructor.newInstance(java.lang.Object...)InvocationTargetException- SeeConstructor.newInstance(java.lang.Object...)NoSuchMethodException- SeeClass.getConstructor(java.lang.Class<?>...)
-
equals
-
hashCode
-
compareTo
- Specified by:
compareToin interfaceComparable<N extends INode>
-
intersects
Checks whether this segment crosses other segment- Parameters:
s2- The other segment- Returns:
- true if both segments crosses
-
isSimilar
Checks whether this segment and another way segment share the same points- Parameters:
s2- The other segment- Returns:
- true if other way segment is the same or reverse
-
toString
-