- java.lang.Object
-
- org.arakhne.afc.gis.road.path.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 standardRoadPath
. 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 Summary
Constructors Constructor Description ClusteredRoadPath()
Constructor.ClusteredRoadPath(Collection<? extends RoadPath> paths)
Constructor.ClusteredRoadPath(RoadPath... paths)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(RoadPath path)
boolean
addAll(Collection<? extends RoadPath> col)
RoadPath
addAndGetPath(RoadPath end)
Add the given road path into this cluster of road paths.void
clear()
boolean
contains(Object obj)
boolean
containsAll(Collection<?> col)
RoadPath
first()
Replies the first road path in this clustered road-path.double
getLength()
Replies the length of the path.RoadPath
getPathForRoadSegmentAt(int index)
Replies the road path which is containing the road segment at the given index.RoadPath
getRoadPathAt(int index)
Replies the road path at the given position.RoadSegment
getRoadSegmentAt(int index)
Replies the road segment at the given index.int
getRoadSegmentCount()
Replies the number of road segments in this clustered path.Direction1D
getRoadSegmentDirectionAt(int index)
Replies the direction of this path on the road segment at the given index.int
indexOf(RoadSegment segment)
Replies the index of the first occurrence. of the given road segment.void
invert()
Invert the order of the road paths in this ClusteredRoadPath.boolean
isEmpty()
Iterator<RoadPath>
iterator()
RoadPath
last()
Replies the last road path in this clustered road-path.int
lastIndexOf(RoadSegment segment)
Replies the index of the last occurrence. of the given road segment.boolean
remove(Object obj)
boolean
removeAll(Collection<?> col)
RoadSegment
removeRoadSegmentAt(int index)
Remove the road segment at the given index.boolean
retainAll(Collection<?> col)
Iterator<RoadSegment>
roadSegments()
Replies an iterator on the road segments in this ClusteredRoadPath.int
size()
void
sync()
Force this clustered path to count the number of road segments in the clusters.Object[]
toArray()
<T> T[]
toArray(T[] array)
RoadPath
toRoadPath()
Replies the standard road path which is inside this ClusteredRoadPath.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
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.
-
add
public final boolean add(RoadPath path)
- Specified by:
add
in interfaceCollection<RoadPath>
-
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.
-
addAll
public boolean addAll(Collection<? extends RoadPath> col)
- Specified by:
addAll
in interfaceCollection<RoadPath>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<RoadPath>
-
contains
@Pure public boolean contains(Object obj)
- Specified by:
contains
in interfaceCollection<RoadPath>
-
containsAll
@Pure public boolean containsAll(Collection<?> col)
- Specified by:
containsAll
in interfaceCollection<RoadPath>
-
isEmpty
@Pure public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<RoadPath>
-
remove
public boolean remove(Object obj)
- Specified by:
remove
in interfaceCollection<RoadPath>
-
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
-
removeAll
public boolean removeAll(Collection<?> col)
- Specified by:
removeAll
in interfaceCollection<RoadPath>
-
retainAll
public boolean retainAll(Collection<?> col)
- Specified by:
retainAll
in interfaceCollection<RoadPath>
-
size
@Pure public int size()
- Specified by:
size
in interfaceCollection<RoadPath>
-
toArray
@Pure public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<RoadPath>
-
toArray
@Pure public <T> T[] toArray(T[] array)
- Specified by:
toArray
in interfaceCollection<RoadPath>
-
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 returnsnull
.- 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.
-
-