Class GridSliceLocator

java.lang.Object
org.apache.sis.storage.aggregate.GridSliceLocator

final class GridSliceLocator extends Object
Coordinates of slices together with search methods.
Since:
1.3
Version:
1.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final long[][]
    Translation from source coordinates of GroupByTransform.gridToCRS to grid coordinates of Gridslice#geometry.
    (package private) final int
    The dimension on which the searches are done.
    private final long[]
    Highs grid coordinates of each slice (inclusive) in the search dimension.
    private final long[]
    Lows grid coordinates of each slice (inclusive) in the search dimension.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GridSliceLocator(List<GridSlice> slices, int searchDimension, GridCoverageResource[] resources)
    Creates a new locator for slices at given coordinates.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) final String
    Return the name of the extent axis in the search dimension.
    (package private) final int
    getLower(GridExtent sliceExtent, int fromIndex, int toIndex)
    Returns the index of the first slice which intersect the given extent.
    (package private) final int
    getUpper(GridExtent sliceExtent, int fromIndex, int toIndex)
    Returns the index after the last slice which may intersect the given extent.
    (package private) final boolean
    isSlice(GridExtent sliceExtent)
    Returns true if the grid extent in the search dimension is a slice of size 1.
    (package private) final GridExtent
    toSliceExtent(GridExtent extent, int slice)
    Returns the extent to use for querying a coverage from the slice at the given index.
    (package private) final <E> GridGeometry
    union(GridGeometry base, List<E> slices, Function<E,GridExtent> getter)
    Creates a new grid geometry which is the union of all grid extent in the concatenated resource.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • searchDimension

      final int searchDimension
      The dimension on which the searches are done.
      See Also:
    • sliceLows

      private final long[] sliceLows
      Lows grid coordinates of each slice (inclusive) in the search dimension. Values must be sorted in increasing order. Duplicated values may exist.
    • sliceHighs

      private final long[] sliceHighs
      Highs grid coordinates of each slice (inclusive) in the search dimension. Values are for slices in the same order as sliceLows. This is not not guaranteed to be sorted in increasing order.
    • offsets

      private final long[][] offsets
      Translation from source coordinates of GroupByTransform.gridToCRS to grid coordinates of Gridslice#geometry. Values are for slices in the same order as sliceLows.
  • Constructor Details

    • GridSliceLocator

      GridSliceLocator(List<GridSlice> slices, int searchDimension, GridCoverageResource[] resources)
      Creates a new locator for slices at given coordinates.
      Parameters:
      slices - descriptions of the grid resources to use as slices in a multi-dimensional cube.
      searchDimension - the dimension on which the searches for grid slices are done.
      resources - an array of initially null elements where to store the resources.
  • Method Details

    • union

      final <E> GridGeometry union(GridGeometry base, List<E> slices, Function<E,GridExtent> getter)
      Creates a new grid geometry which is the union of all grid extent in the concatenated resource.
      Type Parameters:
      E - type of slice objects.
      Parameters:
      base - base geometry to expand.
      slices - objects providing the grid extents.
      getter - getter method for getting the grid extents from slices.
      Returns:
      expanded grid geometry.
    • toSliceExtent

      final GridExtent toSliceExtent(GridExtent extent, int slice)
      Returns the extent to use for querying a coverage from the slice at the given index.
      Parameters:
      extent - extent in units of aggregated grid coverage cells.
      slice - index of the slice on which to delegate an operation.
      Returns:
      extent in units of the slice grid coverage.
    • getUpper

      final int getUpper(GridExtent sliceExtent, int fromIndex, int toIndex)
      Returns the index after the last slice which may intersect the given extent.
      Parameters:
      sliceExtent - the extent to search.
      fromIndex - index of the first slice to include in the search.
      toIndex - index after the last slice to include in the search.
    • getLower

      final int getLower(GridExtent sliceExtent, int fromIndex, int toIndex)
      Returns the index of the first slice which intersect the given extent. This method performs a linear search. For better performance, it should be invoked with toIndex parameter set to getUpper(GridExtent, int, int) value.

      Limitations

      Current implementation assumes that sliceHighs are sorted in increasing order, which is not guaranteed. For a robust search, we would need an R-Tree.
      Parameters:
      sliceExtent - the extent to search.
      fromIndex - index of the first slice to include in the search.
      toIndex - index after the last slice to include in the search.
    • isSlice

      final boolean isSlice(GridExtent sliceExtent)
      Returns true if the grid extent in the search dimension is a slice of size 1.
      Parameters:
      sliceExtent - the extent to search.
      Returns:
      whether the extent is a slice in the search dimension.
    • getDimensionName

      final String getDimensionName(GridExtent extent)
      Return the name of the extent axis in the search dimension.
      Parameters:
      extent - the extent from which to get an axis label.
      Returns:
      label for the search axis.