Class AbstractGISGridSet<P extends GISPrimitive>

  • 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
    • Field Detail

    • Constructor Detail

      • AbstractGISGridSet

        AbstractGISGridSet​(int nRows,
                           int nColumns,
                           Rectangle2d bounds)
        Constructor.
        Parameters:
        nRows - numbers of rows in the grid
        nColumns - numbers of columns in the grid
        bounds - 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 grid
        nColumns - numbers of columns in the grid
        boundsX - 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. If false, this class will keep unchanged the previously computed type.
        Specified by:
        isTypeRecomputedAfterRemoval in interface GISSet<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. If false, this class will keep unchanged the previously computed type.
        Specified by:
        setTypeRecomputedAfterRemoval in interface GISSet<P extends GISPrimitive>
        Parameters:
        update - is true 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 interface GISSet<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 interface GISSet<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 interface GISSet<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 interface GISSet<P extends GISPrimitive>
        Parameters:
        index - the index.
        Returns:
        the element at the given index.
      • 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 interface GISSet<P extends GISPrimitive>
        Returns:
        the count of elements inside the tree.
      • 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 interface GISSet<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 interface GISSet<P extends GISPrimitive>
        Parameters:
        clipBounds - is the bounds outside which the elements will not be replied
        budget - 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.
      • 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 interface GISSet<P extends GISPrimitive>
        Parameters:
        obj - the object.
        Returns:
        true of o is inside, otherwise false
        See Also:
        Set.contains(Object)
      • 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 interface GISSet<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 interface GISSet<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 interface GISSet<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 interface GISSet<P extends GISPrimitive>
        Parameters:
        clipBounds - is the bounds outside which the elements will not be replied
        budget - 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.