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 booleanaddAll(Collection<? extends P> col)Iterator<Rectangle2afp<?,?,?,?,?,?>>boundsIterator()Replies the bounding rectangles of the internal data-structure elements.voidclear()intcomputeSize()Force the deep computation of the element count in this set.booleancontains(Object obj)booleancontainsAll(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.Pget(int index)Replies the element at the specified index.Pget(GeoId identifier)Replies the element which as the specified identifier.Pget(GeoLocation location)Replies the element which as the specified location.Rectangle2dgetBounds()Replies the bounds of the cell.intgetColumnCount()Replies the number of columns in the grid.Class<? extends P>getElementType()Replies the class of the components in this list.intgetRowCount()Replies the number of rows in the grid.intindexOf(Object obj)Replies the index of the first instance the specified element.booleanisEmpty()booleanisTypeRecomputedAfterRemoval()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.booleanremove(Object obj)booleanremoveAll(Collection<?> col)booleanretainAll(Collection<?> col)voidsetTypeRecomputedAfterRemoval(boolean update)Set if this informed tree set is trying to compute the best fitting type after a removal.intsize()booleanslowContains(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 voidupdateComponentType(Collection<? extends P> newElements)Update the component type information with the type of the new array element.protected voidupdateComponentType(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:GISSetReplies 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:
isTypeRecomputedAfterRemovalin interfaceGISSet<P extends GISPrimitive>- Returns:
trueif the type is recomputed after a removal,falseif not.
-
setTypeRecomputedAfterRemoval
public void setTypeRecomputedAfterRemoval(boolean update)
Description copied from interface:GISSetSet 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:
setTypeRecomputedAfterRemovalin interfaceGISSet<P extends GISPrimitive>- Parameters:
update- istrueif the type is recomputed after a removal,falseif 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:GISSetReplies the class of the components in this list.- Specified by:
getElementTypein 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:GISSetReplies 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:
getin interfaceGISSet<P extends GISPrimitive>- Parameters:
identifier- is the identifier to text.- Returns:
- the entity or
nullif none was found.
-
get
@Pure public P get(GeoLocation location)
Description copied from interface:GISSetReplies the element which as the specified location.- Specified by:
getin interfaceGISSet<P extends GISPrimitive>- Parameters:
location- is the location of the element to find.- Returns:
- the entity or
nullif none was found.
-
get
@Pure public P get(int index)
Description copied from interface:GISSetReplies the element at the specified index.This method iterates until the right index.
- Specified by:
getin interfaceGISSet<P extends GISPrimitive>- Parameters:
index- the index.- Returns:
- the element at the given index.
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<P extends GISPrimitive>- Specified by:
clearin interfaceSet<P extends GISPrimitive>
-
isEmpty
@Pure public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<P extends GISPrimitive>- Specified by:
isEmptyin interfaceSet<P extends GISPrimitive>
-
size
@Pure public int size()
- Specified by:
sizein interfaceCollection<P extends GISPrimitive>- Specified by:
sizein interfaceSet<P extends GISPrimitive>
-
computeSize
@Pure public int computeSize()
Description copied from interface:GISSetForce the deep computation of the element count in this set.- Specified by:
computeSizein interfaceGISSet<P extends GISPrimitive>- Returns:
- the count of elements inside the tree.
-
iterator
@Pure public Iterator<P> iterator()
- Specified by:
iteratorin interfaceCollection<P extends GISPrimitive>- Specified by:
iteratorin interfaceIterable<P extends GISPrimitive>- Specified by:
iteratorin interfaceSet<P extends GISPrimitive>
-
iterator
@Pure public Iterator<P> iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds)
Description copied from interface:GISSetReplies 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:
iteratorin 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:GISSetReplies 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:
iteratorin 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:
toArrayin interfaceCollection<P extends GISPrimitive>- Specified by:
toArrayin interfaceSet<P extends GISPrimitive>
-
toArray
@Pure public <T> T[] toArray(T[] array)
- Specified by:
toArrayin interfaceCollection<P extends GISPrimitive>- Specified by:
toArrayin interfaceSet<P extends GISPrimitive>
-
contains
@Pure public boolean contains(Object obj)
- Specified by:
containsin interfaceCollection<P extends GISPrimitive>- Specified by:
containsin interfaceSet<P extends GISPrimitive>
-
slowContains
@Pure public boolean slowContains(Object obj)
Description copied from interface:GISSetReplies if the given object is inside the set by user a depth-first iteration on the internal tree.- Specified by:
slowContainsin interfaceGISSet<P extends GISPrimitive>- Parameters:
obj- the object.- Returns:
trueof o is inside, otherwisefalse- See Also:
Set.contains(Object)
-
containsAll
@Pure public boolean containsAll(Collection<?> col)
- Specified by:
containsAllin interfaceCollection<P extends GISPrimitive>- Specified by:
containsAllin interfaceSet<P extends GISPrimitive>
-
remove
public boolean remove(Object obj)
- Specified by:
removein interfaceCollection<P extends GISPrimitive>- Specified by:
removein interfaceSet<P extends GISPrimitive>
-
removeAll
public boolean removeAll(Collection<?> col)
- Specified by:
removeAllin interfaceCollection<P extends GISPrimitive>- Specified by:
removeAllin interfaceSet<P extends GISPrimitive>
-
retainAll
public boolean retainAll(Collection<?> col)
- Specified by:
retainAllin interfaceCollection<P extends GISPrimitive>- Specified by:
retainAllin interfaceSet<P extends GISPrimitive>
-
addAll
public boolean addAll(Collection<? extends P> col)
- Specified by:
addAllin interfaceCollection<P extends GISPrimitive>- Specified by:
addAllin interfaceSet<P extends GISPrimitive>
-
indexOf
@Pure public int indexOf(Object obj)
Description copied from interface:GISSetReplies the index of the first instance the specified element.This method iterates until the right index.
- Specified by:
indexOfin interfaceGISSet<P extends GISPrimitive>- Parameters:
obj- the object to search for.- Returns:
- the index or
-1if the object was not inside this set.
-
boundsIterator
@Pure public Iterator<Rectangle2afp<?,?,?,?,?,?>> boundsIterator()
Description copied from interface:GISSetReplies the bounding rectangles of the internal data-structure elements.- Specified by:
boundsIteratorin interfaceGISSet<P extends GISPrimitive>- Returns:
- the bounding boxes in the data-structure.
-
toIterable
@Pure public Iterable<P> toIterable(Rectangle2afp<?,?,?,?,?,?> clipBounds)
Description copied from interface:GISSetReplies 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:
toIterablein 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:GISSetReplies 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:
toIterablein 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.
-
-