Package org.apache.sis.storage.aggregate
Class GridSliceLocator
java.lang.Object
org.apache.sis.storage.aggregate.GridSliceLocator
Coordinates of slices together with search methods.
- Since:
- 1.3
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long[][]
Translation from source coordinates ofGroupByTransform.gridToCRS
to grid coordinates ofGridslice#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
ConstructorsConstructorDescriptionGridSliceLocator
(List<GridSlice> slices, int searchDimension, GridCoverageResource[] resources) Creates a new locator for slices at given coordinates. -
Method Summary
Modifier and TypeMethodDescription(package private) final String
getDimensionName
(GridExtent extent) 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) Returnstrue
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.
-
Field Details
-
searchDimension
final int searchDimensionThe dimension on which the searches are done. -
sliceLows
private final long[] sliceLowsLows 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[] sliceHighsHighs grid coordinates of each slice (inclusive) in the search dimension. Values are for slices in the same order assliceLows
. This is not not guaranteed to be sorted in increasing order. -
offsets
private final long[][] offsetsTranslation from source coordinates ofGroupByTransform.gridToCRS
to grid coordinates ofGridslice#geometry
. Values are for slices in the same order assliceLows
.
-
-
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
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
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
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
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 withtoIndex
parameter set togetUpper(GridExtent, int, int)
value.Limitations
Current implementation assumes thatsliceHighs
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
Returnstrue
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
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.
-