Class ClusteredRoadPath

  • All Implemented Interfaces:
    Iterable<RoadPath>, Collection<RoadPath>

    public class ClusteredRoadPath
    extends Object
    implements Collection<RoadPath>
    This class describes a road path with is clustered into several unconnected paths. It is assumed that the ClusteredRoadPath does nto allow multiple connections at the same point, as for a standard RoadPath. The difference between a RoadPath and a ClusteredRoadPath is the fact that a ClusteredRoadPath allows to have holes in the path.

    Caution: ClusteredRoadPath may change the content of the RoadPath added inside. Be sure that you pass to CluseteredRoadPath instances that you are agree to be changed.

    Since:
    14.0
    Version:
    17.0 2020-01-04 14:41:55
    Author:
    Stéphane GALLAND
    See Also:
    RoadPath
    Maven Group Id:
    org.arakhne.afc.gis
    Maven Artifact Id:
    gisroad
    • Constructor Detail

      • ClusteredRoadPath

        public ClusteredRoadPath()
        Constructor.
      • ClusteredRoadPath

        public ClusteredRoadPath​(RoadPath... paths)
        Constructor.
        Parameters:
        paths - are the path to add in the cluster.
      • ClusteredRoadPath

        public ClusteredRoadPath​(Collection<? extends RoadPath> paths)
        Constructor.
        Parameters:
        paths - are the path to add in the cluster.
    • Method Detail

      • getLength

        @Pure
        public double getLength()
        Replies the length of the path.
        Returns:
        the length of the path.
      • invert

        public void invert()
        Invert the order of the road paths in this ClusteredRoadPath.
        See Also:
        GraphPath.invert()
      • first

        @Pure
        public RoadPath first()
        Replies the first road path in this clustered road-path.
        Returns:
        the first road path in this clustered road-path.
      • last

        @Pure
        public RoadPath last()
        Replies the last road path in this clustered road-path.
        Returns:
        the last road path in this clustered road-path.
      • getRoadSegmentCount

        @Pure
        public int getRoadSegmentCount()
        Replies the number of road segments in this clustered path.
        Returns:
        the number of road segments in this clustered path.
      • getRoadPathAt

        @Pure
        public RoadPath getRoadPathAt​(int index)
        Replies the road path at the given position.
        Parameters:
        index - an index.
        Returns:
        the road path at the given position.
      • indexOf

        @Pure
        public int indexOf​(RoadSegment segment)
        Replies the index of the first occurrence. of the given road segment.
        Parameters:
        segment - a segment.
        Returns:
        the index of the first occurrence. of the given road segment or -1 if the road segment was not found.
      • lastIndexOf

        @Pure
        public int lastIndexOf​(RoadSegment segment)
        Replies the index of the last occurrence. of the given road segment.
        Parameters:
        segment - a segment.
        Returns:
        the index of the last occurrence. of the given road segment or -1 if the road segment was not found.
      • getRoadSegmentAt

        @Pure
        public RoadSegment getRoadSegmentAt​(int index)
        Replies the road segment at the given index.
        Parameters:
        index - an index.
        Returns:
        the road segment.
      • getPathForRoadSegmentAt

        @Pure
        public RoadPath getPathForRoadSegmentAt​(int index)
        Replies the road path which is containing the road segment at the given index.
        Parameters:
        index - is the index of the road segment.
        Returns:
        the road path, never null.
      • getRoadSegmentDirectionAt

        @Pure
        public Direction1D getRoadSegmentDirectionAt​(int index)
        Replies the direction of this path on the road segment at the given index.
        Parameters:
        index - is the index of the road segment.
        Returns:
        the direction of the segment at the given index for this path.
      • removeRoadSegmentAt

        public RoadSegment removeRoadSegmentAt​(int index)
        Remove the road segment at the given index.
        Parameters:
        index - an index.
        Returns:
        the removed road segment.
      • addAndGetPath

        public RoadPath addAndGetPath​(RoadPath end)
        Add the given road path into this cluster of road paths.
        Parameters:
        end - is the road path to add
        Returns:
        the road path inside which the road segments are added; it could be e itself; return null if the elements cannot be added.
      • sync

        public void sync()
        Force this clustered path to count the number of road segments in the clusters. This function may be invoke when you have change the road paths in this clustered road path outside the control of the clustered road path.
        Since:
        4.0
      • toRoadPath

        @Pure
        public RoadPath toRoadPath()
        Replies the standard road path which is inside this ClusteredRoadPath. If this ClusteredRoadPath does not contains exactly one road path, this function returns null.
        Returns:
        the road path inside this ClusteredRoadPath, or null if no road path or too many road path in this ClusteredRoadPath.
      • roadSegments

        @Pure
        public Iterator<RoadSegment> roadSegments()
        Replies an iterator on the road segments in this ClusteredRoadPath.
        Returns:
        an iterator on the road segments.