Class SliceGeometry
- All Implemented Interfaces:
Function<RenderedImage,GridGeometry>
GridCoverage. This is the implementation of
GridGeometry.selectDimensions(int[]) and ImageRenderer.getImageGeometry(int) methods.
This class implements Function for allowing apply(…) to be invoked from outside this package.
That function is invoked (indirectly) by TiledImage.getProperty(String).
- Since:
- 1.1
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.opengis.referencing.operation.MathTransformFactoryFactory to use for creating new transforms, ornullfor default.private final GridGeometryThe coverage grid geometry from which to take a slice.private final int[]Dimensions of the slice to retain.private final GridExtentExtents of the slice to take in the geometry. -
Constructor Summary
ConstructorsConstructorDescriptionSliceGeometry(GridGeometry geometry, GridExtent sliceExtent, int[] gridDimensions, org.opengis.referencing.operation.MathTransformFactory factory) Creates a new builder of slice geometry. -
Method Summary
Modifier and TypeMethodDescriptionapply(RenderedImage image) Computes the "org.apache.sis.GridGeometry" property value for the given image.(package private) static ImagingOpExceptioncanNotCompute(org.opengis.util.FactoryException e) Invoked if an error occurred while computing theImageRenderer.getImageGeometry(int)value.private static int[]findTargetDimensions(org.opengis.referencing.operation.MathTransform gridToCRS, GridExtent extent, double[] resolution, int[] gridDimensions, int dimCRS) Finds CRS (target) dimensions that are related to the given grid (source) dimensions.(package private) final GridGeometryreduce(GridExtent relativeExtent, int dimCRS) Creates a new grid geometry over the specified dimensions of the geometry specified at construction time.
-
Field Details
-
geometry
The coverage grid geometry from which to take a slice. -
sliceExtent
Extents of the slice to take in the geometry. -
gridDimensions
private final int[] gridDimensionsDimensions of the slice to retain. All dimensions not in this sequence will be discarded. This is usually the array computed byGridExtent.getSubspaceDimensions(int). -
factory
private final org.opengis.referencing.operation.MathTransformFactory factoryFactory to use for creating new transforms, ornullfor default.
-
-
Constructor Details
-
SliceGeometry
SliceGeometry(GridGeometry geometry, GridExtent sliceExtent, int[] gridDimensions, org.opengis.referencing.operation.MathTransformFactory factory) Creates a new builder of slice geometry.- Parameters:
geometry- the grid geometry for which the transform is desired.sliceExtent- the requested extent, ornullfor the whole coverage.gridDimensions- the grid (not CRS) dimensions to select, in strictly increasing order.
-
-
Method Details
-
apply
Computes the "org.apache.sis.GridGeometry" property value for the given image.- Specified by:
applyin interfaceFunction<RenderedImage,GridGeometry> - Parameters:
image- the image for which to compute the image geometry.- Throws:
ImagingOpException- if the property cannot be computed.
-
reduce
final GridGeometry reduce(GridExtent relativeExtent, int dimCRS) throws org.opengis.util.FactoryException Creates a new grid geometry over the specified dimensions of the geometry specified at construction time. The number of grid dimensions will be the length of thegridDimensionsarray, and the number of CRS dimensions will be reduced by the same amount.If a non-null
sliceExtenthas been specified, that extent shall be a sub-extent of the extent of the original grid geometry. In particular it must have the same number of dimensions in same order and the original "grid to CRS" transform shall be valid with thatsliceExtent. That sub-extent will be used in replacement of the original extent for computing the geospatial area and the resolution.If a non-null
relativeExtentis specified, a translation will be inserted before "grid to CRS" conversion in order that lowest coordinate values ofsliceExtent(or original extent if there is no slice extent) will map to (0,0,…,0) coordinate values in relative extent. This is used for taking in account the translation betweensliceExtentcoordinates and coordinates of the image returned byGridCoverage.render(GridExtent), in which case the relative extent is the location and size of theRenderedImage. The number of dimensions of relative extent must be equal togridDimensionsarray length (i.e. the dimensionality reduction must be already done).- Parameters:
relativeExtent- if non-null, an extent relative tosliceExtentto assign to the grid geometry to return. Dimensionality reduction shall be already applied.dimCRS- desired number of CRS dimensions, or -1 for automatic.- Throws:
org.opengis.util.FactoryException- if an error occurred while separating the "grid to CRS" transform.- See Also:
-
findTargetDimensions
private static int[] findTargetDimensions(org.opengis.referencing.operation.MathTransform gridToCRS, GridExtent extent, double[] resolution, int[] gridDimensions, int dimCRS) Finds CRS (target) dimensions that are related to the given grid (source) dimensions. This method returns an array where the number of CRS dimensions has been reduced by the same amount than the reduction in number of grid dimensions.If this method is not invoked, then
TransformSeparatorwill retain as many target dimensions as possible, which may be more than expected if a dimension that would normally be dropped is actually a constant (all scale coefficients set to zero). This method tries to avoid this effect by forcing the removal of CRS dimensions too. The CRS dimensions to remove are the ones that seem the less related to the grid dimensions that we keep. This method is not provided inTransformSeparatorbecause of assumptions on the gridded nature of source coordinates.The algorithm used by this method (which is to compare the magnitude of scale coefficients anywhere in the matrix) assumes that grid cells are "square", e.g. that a translation of 1 pixel to the left is comparable in "real world" to a translation of 1 pixel to the bottom. This is often true but not always. To compensate, we divide scale coefficients by the GridGeometry.resolution for that CRS dimension.
- Parameters:
gridToCRS- value ofGridGeometry.gridToCRS(may benull).extent- value ofGridGeometry.extent(may benull).resolution- value ofGridGeometry.resolution(may benull).gridDimensions- the grid (source) dimensions to keep.dimCRS- desired number of CRS dimensions, or -1 for automatic.- Returns:
- the CRS (target) dimensions to keep, or
nullif this method cannot compute them.
-
canNotCompute
Invoked if an error occurred while computing theImageRenderer.getImageGeometry(int)value. This exception should never occur actually, unless a custom factory implementation is used (instead of the Apache SIS default) and there is a problem with that factory.
-