Class IWaySegment<N extends INode,​W extends IWay<N>>

  • Type Parameters:
    N - The node type
    W - 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 int lowerIndex  
      protected static java.lang.String NOT_A_SEGMENT  
      private W way  
    • Constructor Summary

      Constructors 
      Constructor Description
      IWaySegment​(W w, int i)
      Constructs a new IWaySegment.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(IWaySegment o)  
      boolean equals​(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.
      N getFirstNode()
      Returns the first node of the way segment.
      int getLowerIndex()
      Returns the index of the first of the 2 nodes in the way.
      N getSecondNode()
      Returns the second (last) node of the way segment.
      int getUpperIndex()
      Returns the index of the second of the 2 nodes in the way.
      W getWay()
      Returns the way.
      int hashCode()  
      boolean intersects​(IWaySegment<?,​?> s2)
      Checks whether this segment crosses other segment
      boolean isSimilar​(IWaySegment<?,​?> s2)
      Checks whether this segment and another way segment share the same points
      boolean isUsable()
      Determines if the segment is usable (node not deleted).
      java.lang.String toString()  
      W toWay()
      Returns this way segment as complete way.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • IWaySegment

        public IWaySegment​(W w,
                           int i)
        Constructs a new IWaySegment.
        Parameters:
        w - The way
        i - The node lower index
        Throws:
        java.lang.IllegalArgumentException - in case of invalid index
    • Method Detail

      • getWay

        public W getWay()
        Returns the way.
        Returns:
        the way
      • isUsable

        public boolean isUsable()
        Determines if the segment is usable (node not deleted).
        Returns:
        true if 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 node
        W - type of way
        Parameters:
        way - way
        first - first node
        second - 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 - See Constructor.newInstance(java.lang.Object...)
        java.lang.IllegalArgumentException - See Constructor.newInstance(java.lang.Object...)
        java.lang.InstantiationException - See Constructor.newInstance(java.lang.Object...)
        java.lang.reflect.InvocationTargetException - See Constructor.newInstance(java.lang.Object...)
        java.lang.NoSuchMethodException - See Class.getConstructor(java.lang.Class<?>...)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(IWaySegment o)
        Specified by:
        compareTo in interface java.lang.Comparable<N extends INode>
      • 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:
        toString in class java.lang.Object