Module org.arakhne.afc.gis.giscore
Package org.arakhne.afc.gis.grid
Class AbstractGISGridSet<P extends GISPrimitive>
- java.lang.Object
-
- org.arakhne.afc.gis.grid.AbstractGISGridSet<P>
-
- Type Parameters:
P
- is the type of the user data inside the node.
- All Implemented Interfaces:
Iterable<P>
,Collection<P>
,Set<P>
,GISSet<P>
- Direct Known Subclasses:
MapElementGridSet
,StandardGISGridSet
abstract class AbstractGISGridSet<P extends GISPrimitive> extends Object implements GISSet<P>
This class describes a grid that contains GIS primitives and thatp permits to find them according to there geo-location.- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:53
- Author:
- Stéphane GALLAND
- See Also:
GISPrimitive
- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- giscore
-
-
Constructor Summary
Constructors Constructor Description AbstractGISGridSet(int nRows, int nColumns, double boundsX, double boundsY, double boundsWidth, double boundsHeight)
Constructor.AbstractGISGridSet(int nRows, int nColumns, Rectangle2d bounds)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addAll(Collection<? extends P> col)
Iterator<Rectangle2afp<?,?,?,?,?,?>>
boundsIterator()
Replies the bounding rectangles of the internal data-structure elements.void
clear()
int
computeSize()
Force the deep computation of the element count in this set.boolean
contains(Object obj)
boolean
containsAll(Collection<?> col)
protected static <E> Class<? extends E>
extractClassFrom(Collection<? extends E> collection)
Extract the upper class that contains all the elements of this array.P
get(int index)
Replies the element at the specified index.P
get(GeoId identifier)
Replies the element which as the specified identifier.P
get(GeoLocation location)
Replies the element which as the specified location.Rectangle2d
getBounds()
Replies the bounds of the cell.int
getColumnCount()
Replies the number of columns in the grid.Class<? extends P>
getElementType()
Replies the class of the components in this list.int
getRowCount()
Replies the number of rows in the grid.int
indexOf(Object obj)
Replies the index of the first instance the specified element.boolean
isEmpty()
boolean
isTypeRecomputedAfterRemoval()
Replies if this informed tree set is trying to compute the best fitting type after a removal.Iterator<P>
iterator()
Iterator<P>
iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds)
Replies the set of elements that have an intersection with the specified rectangle.Iterator<P>
iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds, int budget)
Replies the set of elements that have an intersection with the specified rectangle.boolean
remove(Object obj)
boolean
removeAll(Collection<?> col)
boolean
retainAll(Collection<?> col)
void
setTypeRecomputedAfterRemoval(boolean update)
Set if this informed tree set is trying to compute the best fitting type after a removal.int
size()
boolean
slowContains(Object obj)
Replies if the given object is inside the set by user a depth-first iteration on the internal tree.Object[]
toArray()
<T> T[]
toArray(T[] array)
Iterable<P>
toIterable(Rectangle2afp<?,?,?,?,?,?> clipBounds)
Replies the set of elements that have an intersection with the specified rectangle.Iterable<P>
toIterable(Rectangle2afp<?,?,?,?,?,?> clipBounds, int budget)
Replies the set of elements that have an intersection with the specified rectangle.protected void
updateComponentType(Collection<? extends P> newElements)
Update the component type information with the type of the new array element.protected void
updateComponentType(P newElement)
Update the component type information with the type of the new array element.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
add, equals, hashCode, spliterator
-
-
-
-
Field Detail
-
grid
protected final Grid<P extends GISPrimitive> grid
Internal representation.
-
-
Constructor Detail
-
AbstractGISGridSet
AbstractGISGridSet(int nRows, int nColumns, Rectangle2d bounds)
Constructor.- Parameters:
nRows
- numbers of rows in the gridnColumns
- numbers of columns in the gridbounds
- are the bounds of the grid cell.
-
AbstractGISGridSet
AbstractGISGridSet(int nRows, int nColumns, double boundsX, double boundsY, double boundsWidth, double boundsHeight)
Constructor.- Parameters:
nRows
- numbers of rows in the gridnColumns
- numbers of columns in the gridboundsX
- is the bounds of the scene.boundsY
- is the bounds of the scene.boundsWidth
- is the bounds of the scene.boundsHeight
- is the bounds of the scene.
-
-
Method Detail
-
extractClassFrom
protected static <E> Class<? extends E> extractClassFrom(Collection<? extends E> collection)
Extract the upper class that contains all the elements of this array.- Type Parameters:
E
- is the type of the list's elements.- Parameters:
collection
- is the collection to scan- Returns:
- the top class of all the elements.
-
getBounds
@Pure public Rectangle2d getBounds()
Replies the bounds of the cell.- Returns:
- the cell.
-
getRowCount
@Pure public int getRowCount()
Replies the number of rows in the grid.- Returns:
- the number of rows in the grid.
-
getColumnCount
@Pure public int getColumnCount()
Replies the number of columns in the grid.- Returns:
- the number of columns in the grid.
-
isTypeRecomputedAfterRemoval
public boolean isTypeRecomputedAfterRemoval()
Description copied from interface:GISSet
Replies if this informed tree set is trying to compute the best fitting type after a removal. Iffalse
, this class will keep unchanged the previously computed type.- Specified by:
isTypeRecomputedAfterRemoval
in interfaceGISSet<P extends GISPrimitive>
- Returns:
true
if the type is recomputed after a removal,false
if not.
-
setTypeRecomputedAfterRemoval
public void setTypeRecomputedAfterRemoval(boolean update)
Description copied from interface:GISSet
Set if this informed tree set is trying to compute the best fitting type after a removal. Iffalse
, this class will keep unchanged the previously computed type.- Specified by:
setTypeRecomputedAfterRemoval
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
update
- istrue
if the type is recomputed after a removal,false
if not.
-
updateComponentType
protected final void updateComponentType(P newElement)
Update the component type information with the type of the new array element.- Parameters:
newElement
- is the element for which the known top type in this array must be eventually updated.
-
updateComponentType
protected final void updateComponentType(Collection<? extends P> newElements)
Update the component type information with the type of the new array element.- Parameters:
newElements
- are the elements for which the known top type in this array must be eventually updated.
-
getElementType
@Pure public Class<? extends P> getElementType()
Description copied from interface:GISSet
Replies the class of the components in this list.- Specified by:
getElementType
in interfaceGISSet<P extends GISPrimitive>
- Returns:
- the top most type of the array's elements.
-
get
@Pure public P get(GeoId identifier)
Description copied from interface:GISSet
Replies the element which as the specified identifier.This function is time consuming because the location of the primitive could not be retreived from the geoId.
- Specified by:
get
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
identifier
- is the identifier to text.- Returns:
- the entity or
null
if none was found.
-
get
@Pure public P get(GeoLocation location)
Description copied from interface:GISSet
Replies the element which as the specified location.- Specified by:
get
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
location
- is the location of the element to find.- Returns:
- the entity or
null
if none was found.
-
get
@Pure public P get(int index)
Description copied from interface:GISSet
Replies the element at the specified index.This method iterates until the right index.
- Specified by:
get
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
index
- the index.- Returns:
- the element at the given index.
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<P extends GISPrimitive>
- Specified by:
clear
in interfaceSet<P extends GISPrimitive>
-
isEmpty
@Pure public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<P extends GISPrimitive>
- Specified by:
isEmpty
in interfaceSet<P extends GISPrimitive>
-
size
@Pure public int size()
- Specified by:
size
in interfaceCollection<P extends GISPrimitive>
- Specified by:
size
in interfaceSet<P extends GISPrimitive>
-
computeSize
@Pure public int computeSize()
Description copied from interface:GISSet
Force the deep computation of the element count in this set.- Specified by:
computeSize
in interfaceGISSet<P extends GISPrimitive>
- Returns:
- the count of elements inside the tree.
-
iterator
@Pure public Iterator<P> iterator()
- Specified by:
iterator
in interfaceCollection<P extends GISPrimitive>
- Specified by:
iterator
in interfaceIterable<P extends GISPrimitive>
- Specified by:
iterator
in interfaceSet<P extends GISPrimitive>
-
iterator
@Pure public Iterator<P> iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds)
Description copied from interface:GISSet
Replies the set of elements that have an intersection with the specified rectangle.This function replies the elements with a broad-first iteration on the elements' tree.
- Specified by:
iterator
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
clipBounds
- is the bounds outside which the elements will not be replied- Returns:
- the elements inside the specified bounds.
-
iterator
@Pure public Iterator<P> iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds, int budget)
Description copied from interface:GISSet
Replies the set of elements that have an intersection with the specified rectangle.This function replies the elements with a broad-first iteration on the elements' tree.
- Specified by:
iterator
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
clipBounds
- is the bounds outside which the elements will not be repliedbudget
- is the maximal size of the replied list. If this value is negative, all the elements will be replied.- Returns:
- the elements inside the specified bounds.
-
toArray
@Pure public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<P extends GISPrimitive>
- Specified by:
toArray
in interfaceSet<P extends GISPrimitive>
-
toArray
@Pure public <T> T[] toArray(T[] array)
- Specified by:
toArray
in interfaceCollection<P extends GISPrimitive>
- Specified by:
toArray
in interfaceSet<P extends GISPrimitive>
-
contains
@Pure public boolean contains(Object obj)
- Specified by:
contains
in interfaceCollection<P extends GISPrimitive>
- Specified by:
contains
in interfaceSet<P extends GISPrimitive>
-
slowContains
@Pure public boolean slowContains(Object obj)
Description copied from interface:GISSet
Replies if the given object is inside the set by user a depth-first iteration on the internal tree.- Specified by:
slowContains
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
obj
- the object.- Returns:
true
of o is inside, otherwisefalse
- See Also:
Set.contains(Object)
-
containsAll
@Pure public boolean containsAll(Collection<?> col)
- Specified by:
containsAll
in interfaceCollection<P extends GISPrimitive>
- Specified by:
containsAll
in interfaceSet<P extends GISPrimitive>
-
remove
public boolean remove(Object obj)
- Specified by:
remove
in interfaceCollection<P extends GISPrimitive>
- Specified by:
remove
in interfaceSet<P extends GISPrimitive>
-
removeAll
public boolean removeAll(Collection<?> col)
- Specified by:
removeAll
in interfaceCollection<P extends GISPrimitive>
- Specified by:
removeAll
in interfaceSet<P extends GISPrimitive>
-
retainAll
public boolean retainAll(Collection<?> col)
- Specified by:
retainAll
in interfaceCollection<P extends GISPrimitive>
- Specified by:
retainAll
in interfaceSet<P extends GISPrimitive>
-
addAll
public boolean addAll(Collection<? extends P> col)
- Specified by:
addAll
in interfaceCollection<P extends GISPrimitive>
- Specified by:
addAll
in interfaceSet<P extends GISPrimitive>
-
indexOf
@Pure public int indexOf(Object obj)
Description copied from interface:GISSet
Replies the index of the first instance the specified element.This method iterates until the right index.
- Specified by:
indexOf
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
obj
- the object to search for.- Returns:
- the index or
-1
if the object was not inside this set.
-
boundsIterator
@Pure public Iterator<Rectangle2afp<?,?,?,?,?,?>> boundsIterator()
Description copied from interface:GISSet
Replies the bounding rectangles of the internal data-structure elements.- Specified by:
boundsIterator
in interfaceGISSet<P extends GISPrimitive>
- Returns:
- the bounding boxes in the data-structure.
-
toIterable
@Pure public Iterable<P> toIterable(Rectangle2afp<?,?,?,?,?,?> clipBounds)
Description copied from interface:GISSet
Replies the set of elements that have an intersection with the specified rectangle.This function replies the elements with a broad-first iteration on the elements' tree.
- Specified by:
toIterable
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
clipBounds
- is the bounds outside which the elements will not be replied- Returns:
- the elements inside the specified bounds.
-
toIterable
@Pure public Iterable<P> toIterable(Rectangle2afp<?,?,?,?,?,?> clipBounds, int budget)
Description copied from interface:GISSet
Replies the set of elements that have an intersection with the specified rectangle.This function replies the elements with a broad-first iteration on the elements' tree.
- Specified by:
toIterable
in interfaceGISSet<P extends GISPrimitive>
- Parameters:
clipBounds
- is the bounds outside which the elements will not be repliedbudget
- is the maximal size of the replied list. If this value is negative, all the elements will be replied.- Returns:
- the elements inside the specified bounds.
-
-