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:
java.lang.Comparable<IWaySegment<N,W>>
- Direct Known Subclasses:
WaySegment
public class IWaySegment<N extends INode,W extends IWay<N>> extends java.lang.Object implements java.lang.Comparable<IWaySegment<N,W>>
A segment consisting of 2 consecutive nodes out of a way.- Since:
- 17862
-
-
Field Summary
Fields Modifier and Type Field Description private intlowerIndexprotected static java.lang.StringNOT_A_SEGMENTprivate Wway
-
Constructor Summary
Constructors Constructor Description IWaySegment(W w, int i)Constructs a newIWaySegment.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(IWaySegment o)booleanequals(java.lang.Object o)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.NgetFirstNode()Returns the first node of the way segment.intgetLowerIndex()Returns the index of the first of the 2 nodes in the way.NgetSecondNode()Returns the second (last) node of the way segment.intgetUpperIndex()Returns the index of the second of the 2 nodes in the way.WgetWay()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).java.lang.StringtoString()WtoWay()Returns this way segment as complete way.
-
-
-
Field Detail
-
NOT_A_SEGMENT
protected static final java.lang.String NOT_A_SEGMENT
- See Also:
- Constant Field Values
-
lowerIndex
private final int lowerIndex
-
-
Constructor Detail
-
IWaySegment
public IWaySegment(W w, int i)
Constructs a newIWaySegment.- Parameters:
w- The wayi- The node lower index- Throws:
java.lang.IllegalArgumentException- in case of invalid index
-
-
Method Detail
-
getLowerIndex
public int 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(),getFirstNode()
-
getUpperIndex
public int 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:
getLowerIndex(),getSecondNode()
-
isUsable
public boolean isUsable()
Determines if the segment is usable (node not deleted).- Returns:
trueif the segment is usable- Since:
- 17986
-
getFirstNode
public N getFirstNode()
Returns the first node of the way segment.- Returns:
- the first node
-
getSecondNode
public N 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:
java.lang.IllegalArgumentException- if the node pair is not a single segment of the way
-
toWay
public W toWay() throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
Returns this way segment as complete way.- Returns:
- the way segment as
Way - Throws:
java.lang.IllegalAccessException- SeeConstructor.newInstance(java.lang.Object...)java.lang.IllegalArgumentException- SeeConstructor.newInstance(java.lang.Object...)java.lang.InstantiationException- SeeConstructor.newInstance(java.lang.Object...)java.lang.reflect.InvocationTargetException- SeeConstructor.newInstance(java.lang.Object...)java.lang.NoSuchMethodException- SeeClass.getConstructor(java.lang.Class<?>...)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(IWaySegment o)
-
intersects
public boolean intersects(IWaySegment<?,?> s2)
Checks whether this segment crosses other segment- Parameters:
s2- The other segment- Returns:
- true if both segments crosses
-
isSimilar
public boolean isSimilar(IWaySegment<?,?> s2)
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-