Class GridDerivation

java.lang.Object
org.apache.sis.coverage.grid.GridDerivation

public class GridDerivation extends Object
Creates a new grid geometry derived from a base grid geometry with different extent or resolution. GridDerivation are created by calls to GridGeometry.derive(). Properties of the desired grid geometry can be specified by calls to the following methods, in that order (each method is optional):
  1. rounding(GridRoundingMode), margin(int...) and/or chunkSize(int...) in any order
  2. subgrid(GridGeometry), subgrid(Envelope, double...) or subgrid(GridExtent, int...)
  3. slice(DirectPosition) and/or sliceByRatio(double, int...)
Then the grid geometry is created by a call to build(). The getIntersection() method can also be invoked for the GridExtent part without subsampling.

All methods in this class preserve the number of dimensions. For example, the slice(DirectPosition) method sets the grid size to 1 in all dimensions specified by the slice point, but does not remove those dimensions from the grid geometry. For dimensionality reduction, see GridGeometry.selectDimensions(int[]).

Since:
1.0
Version:
1.3
See Also:
  • Field Details

    • base

      protected final GridGeometry base
      The base grid geometry from which to derive a new grid geometry.
    • rounding

      private GridRoundingMode rounding
      Controls behavior of rounding from floating point values to integers.
      See Also:
    • clipping

      private GridClippingMode clipping
      Whether to clip the derived grid extent to the original grid extent.
      See Also:
    • margin

      private int[] margin
      If non-null, the extent will be expanded by that amount of cells on each grid dimension. This array is non-null only if at least one non-zero margin has been specified. Trailing zero values are omitted (consequently this array may be shorter than GridExtent number of dimensions).
      See Also:
    • chunkSize

      private int[] chunkSize
      If the grid is divided in tiles or chunks, the size of the chunks. This is used for snapping grid size to multiple values of chunk size. If non-null, cannot be empty. Trailing 1 values are omitted.
      See Also:
    • maximumSubsampling

      private int[] maximumSubsampling
      The maximum subsampling values (inclusive), or null if none.
      See Also:
    • isBaseExtentExpanded

      private boolean isBaseExtentExpanded
      Tells whether the baseExtent has been expanded by addition of margin and rounding to chunk size. We have this flag because it is not always convenient to add margin immediately, depending on how the baseExtent has been updated.
      See Also:
      • #getBaseExtentExpanded()
    • baseExtent

      private GridExtent baseExtent
      The sub-extent of base grid geometry to use for the new grid geometry. This is the intersection of base.extent with any area of interest specified to a subgrid(…) method, potentially with some grid size set to 1 by a slice(DirectPosition) method. This extent is not scaled or subsampled for a given resolution. It may be expanded according the margin and chunkSize values, depending on whether the isBaseExtentExpanded flag value is true.

      This extent is initialized to base.extent if no slice, scale or sub-grid has been requested. This field may be null if the base grid geometry does not define any extent. A successful call to GridGeometry.requireGridToCRS(boolean) guarantees that this field is non-null.

      See Also:
    • scaledExtent

      private GridExtent scaledExtent
      Same as baseExtent (expanded), but takes resolution or subsampling in account. This is null if no scale or subsampling has been applied. Margin and chunk size shall be applied before scaledExtent is computed.
    • toBase

      private LinearTransform toBase
      The conversion from the derived grid to the original grid, or null if no subsampling is applied. A non-null conversion exists only in case of subsampling, because otherwise the derived grid shares the same coordinate space than the base grid. If non-null, the transform has the following properties:
      • The transform has no shear, no rotation, no axis flip.
      • Scale factors on the diagonal are the subsampling values. Those values are strictly positive integers, except if computed by subgrid(Envelope, double...).
      • Translation terms in the last column are integers between 0 inclusive and subsampling factors exclusive. Those values are positive integers, except if computed by subgrid(Envelope, double...).
      This transform maps pixel corners.
      See Also:
    • modifiedDimensions

      private int[] modifiedDimensions
      List of grid dimensions that are modified by the cornerToCRS transform, or null for all dimensions. The length of this array is the number of dimensions of the given Area Of Interest (AOI). Each value in this array is between 0 inclusive and extent.getDimension() exclusive. This is a temporary information set by dropUnusedDimensions(MathTransform, int) and cleared when no longer needed.
    • subGridSetter

      private String subGridSetter
      If subgrid(Envelope, double...) or slice(DirectPosition) has been invoked, the method name. This is used for preventing those methods to be invoked twice or out-of-order, which is currently not supported.
    • intersection

      private GeneralEnvelope intersection
      Intersection between the grid envelope and the area of interest, computed when only envelopes are available. Normally we do not compute this envelope directly; instead we compute the grid extent and the "grid to CRS" transform. This envelope is computed only if it cannot be computed from other grid geometry properties.
      See Also:
  • Constructor Details

    • GridDerivation

      protected GridDerivation(GridGeometry base)
      Creates a new builder for deriving a grid geometry from the specified base.
      Parameters:
      base - the base to use as a template for deriving a new grid geometry.
      See Also:
  • Method Details

    • ensureSubgridNotSet

      private void ensureSubgridNotSet()
      Verifies that a sub-grid has not yet been defined. This method is invoked for enforcing the method call order defined in javadoc.
    • rounding

      public GridDerivation rounding(GridRoundingMode mode)
      Controls behavior of rounding from floating point values to integers. This setting modifies computations performed by the following methods (it has no effect on other methods in this GridDerivation class): If this method is never invoked, the default value is GridRoundingMode.NEAREST. If this method is invoked too late, an IllegalStateException is thrown.
      Parameters:
      mode - the new rounding mode.
      Returns:
      this for method call chaining.
      Throws:
      IllegalStateException - if subgrid(Envelope, double...) or slice(DirectPosition) has already been invoked.
    • clipping

      public GridDerivation clipping(GridClippingMode mode)
      Specifies whether to clip the derived grid extent to the extent of the base grid geometry. The default value is GridClippingMode.STRICT.
      Parameters:
      mode - whether to clip the derived grid extent.
      Returns:
      this for method call chaining.
      Throws:
      IllegalStateException - if subgrid(Envelope, double...) or slice(DirectPosition) has already been invoked.
      Since:
      1.1
    • margin

      public GridDerivation margin(int... cellCounts)
      Specifies an amount of cells by which to expand GridExtent after rounding. This setting modifies computations performed by the following methods: For each dimension i of the grid computed by above methods, the low grid coordinate is subtracted by cellCount[i] and the high grid coordinate is increased by cellCount[i]. This calculation is done in units of the base grid cells, i.e. before subsampling. For example if subsampling is 2, then a margin of 6 cells specified with this method will result in a margin of 3 cells in the grid extent computed by the build() method.
      Use case: if the caller wants to apply bilinear interpolations in an image, (s)he will need 1 more pixel on each image border. If the caller wants to apply bi-cubic interpolations, (s)he will need 2 more pixels on each image border.
      If this method is never invoked, the default value is zero for all dimensions. If this method is invoked too late, an IllegalStateException is thrown. If the cellCounts array length is shorter than the grid dimension, then zero is assumed for all missing dimensions.
      Parameters:
      cellCounts - number of cells by which to expand the grid extent.
      Returns:
      this for method call chaining.
      Throws:
      IllegalArgumentException - if a value is negative.
      IllegalStateException - if subgrid(Envelope, double...) or slice(DirectPosition) has already been invoked.
      See Also:
    • chunkSize

      public GridDerivation chunkSize(int... cellCounts)
      Specifies the size of tiles or chunks in the base grid geometry. If a chunk size is specified, then the grid extent computed by build() will span an integer amount of chunks. The grid coordinates (0, 0, …) locate the corner of a chunk.

      This property operates on the same methods than the margin. If both a margin and a chunk size are specified, then margins are added first and the resulting grid coordinates are rounded to chunk size. This calculation is done in units of the base grid cells, i.e. before subsampling. For example if subsampling is 2, then a tile size of 20×20 pixels specified with this method will result in a tile size of 10×10 cells in the grid extent computed by the build() method.

      If this method is never invoked, the default value is one for all dimensions. If this method is invoked too late, an IllegalStateException is thrown. If the cellCounts array length is shorter than the grid dimension, then one is assumed for all missing dimensions.

      Parameters:
      cellCounts - number of cells in all tiles or chunks.
      Returns:
      this for method call chaining.
      Throws:
      IllegalArgumentException - if a value is zero or negative.
      IllegalStateException - if subgrid(Envelope, double...) or slice(DirectPosition) has already been invoked.
      Since:
      1.1
    • maximumSubsampling

      public GridDerivation maximumSubsampling(int... subsampling)
      Specifies the maximum subsampling values (inclusive) for each dimension. If a subsampling value is greater than a specified value in the corresponding dimension, the subsampling will be clamped to the specified maximal value. Setting a maximum value of 1 in a dimension is equivalent to disabling subsampling in that dimension.

      If this method is never invoked, then there is no maximum value. If this method is invoked too late, an IllegalStateException is thrown. If the cellCounts array length is shorter than the grid dimension, then all missing dimensions have no maximum value.

      Parameters:
      subsampling - maximal subsampling values (inclusive).
      Returns:
      this for method call chaining.
      Throws:
      IllegalArgumentException - if a value is zero or negative.
      IllegalStateException - if subgrid(Envelope, double...) or slice(DirectPosition) has already been invoked.
      Since:
      1.1
    • validateCellCounts

      private static int[] validateCellCounts(String property, int[] values, int defaultValue)
      Returns a copy of the values array with trailing defaultValue trimmed. Returns null if all values are trimmed. This method verifies that values are valid.
      Parameters:
      property - argument name to use in error message in case of errors.
      values - user supplied values.
      Returns:
      values to save in GridDerivation.
    • subgrid

      public GridDerivation subgrid(GridGeometry areaOfInterest)
      Adapts the base grid for the geographic area and resolution of the given grid geometry. The new grid geometry will cover the spatiotemporal region given by areaOfInterest envelope (coordinate operations are applied as needed if the Coordinate Reference Systems are not the same). The new grid geometry resolution will be integer multiples of the base grid geometry resolution.
      Usage: This method can be helpful for implementation of GridCoverageResource.read(GridGeometry, int...). Example:
      If gridExtent contains only an envelope, then this method delegates to subgrid(Envelope, double...). Otherwise if gridExtent contains only an extent, then this method delegates to subgrid(GridExtent, int...). Otherwise the following information are mandatory: The following information are optional but recommended: Optional margin and chunk size can be specified for increasing the size of the grid extent computed by this method. For example if the caller wants to apply bilinear interpolations in an image, (s)he will need 1 more pixel on each image border. If the caller wants to apply bi-cubic interpolations, (s)he will need 2 more pixels on each image border.

      Notes:

      • This method can be invoked only once.
      • This method cannot be used together with another subgrid(…) method.
      • Rounding mode, clipping mode, margin and chunk size, if different than default values, should be set before to invoke this method.
      • Slicing can be applied after this method.
      • This method does not reduce the number of dimensions of the grid geometry. For dimensionality reduction, see GridGeometry.selectDimensions(int[]).
      Parameters:
      areaOfInterest - the area of interest and desired resolution as a grid geometry.
      Returns:
      this for method call chaining.
      Throws:
      DisjointExtentException - if the given grid of interest does not intersect the grid extent.
      IncompleteGridGeometryException - if a mandatory property of a grid geometry is absent.
      IllegalGridGeometryException - if an error occurred while converting the envelope coordinates to grid coordinates.
      IllegalStateException - if a subgrid(…) or slice(…) method has already been invoked.
      See Also:
    • subgrid

      public GridDerivation subgrid(org.opengis.geometry.Envelope areaOfInterest, double... resolution)
      Requests a grid geometry over a sub-envelope and optionally with a coarser resolution. The given envelope does not need to be expressed in the same coordinate reference system (CRS) than the CRS of the base grid geometry; coordinate conversions or transformations will be applied as needed. That envelope CRS may have fewer dimensions than the base grid geometry CRS, in which case grid dimensions not mapped to envelope dimensions will be returned unchanged. The target resolution, if provided, shall be in same units and same order than the given envelope axes. If the length of resolution array is less than the number of dimensions of areaOfInterest, then no subsampling will be applied on the missing dimensions.

      Notes:

      • This method can be invoked only once.
      • This method cannot be used together with another subgrid(…) method.
      • Rounding mode, clipping mode, margin and chunk size, if different than default values, should be set before to invoke this method.
      • Slicing can be applied after this method.
      • This method does not reduce the number of dimensions of the grid geometry. For dimensionality reduction, see GridGeometry.selectDimensions(int[]).
      • If the given envelope is known to be expressed in the same CRS than the grid geometry, then the CRS of the envelope can be left unspecified (null). It may give a slight performance improvement by avoiding the check for coordinate transformation.
      • Subsampling computed by this method may be fractional. Consequently, calls to getSubsampling() and getSubsamplingOffsets() after this method may cause an IllegalStateException to be thrown.
      Parameters:
      areaOfInterest - the desired spatiotemporal region in any CRS (transformations will be applied as needed), or null for not restricting the sub-grid to a sub-area.
      resolution - the desired resolution in the same units and order than the axes of the given envelope, or null or an empty array if no subsampling is desired. The array length should be equal to the areaOfInterest dimension, but this is not mandatory (zero or missing values mean no sub-sampling, extraneous values are ignored).
      Returns:
      this for method call chaining.
      Throws:
      DisjointExtentException - if the given area of interest does not intersect the grid extent.
      IncompleteGridGeometryException - if the base grid geometry has no extent, no "grid to CRS" transform, or no CRS (unless areaOfInterest has no CRS neither, in which case the CRS are assumed the same).
      IllegalGridGeometryException - if an error occurred while converting the envelope coordinates to grid coordinates.
      IllegalStateException - if a subgrid(…) or slice(…) method has already been invoked.
      See Also:
    • findBaseToAOI

      private org.opengis.referencing.operation.MathTransform findBaseToAOI(org.opengis.referencing.crs.CoordinateReferenceSystem target) throws org.opengis.util.FactoryException
      Returns the transform from the CRS of the base grid to the CRS of user supplied argument.
      Parameters:
      target - the CRS of the user supplied argument (envelope ou position).
      Returns:
      transform from base grid to user argument.
      Throws:
      org.opengis.util.FactoryException
    • wraparound

      private WraparoundAdjustment wraparound(org.opengis.referencing.operation.MathTransform baseToAOI, org.opengis.referencing.operation.MathTransform gridToCRS) throws org.opengis.referencing.operation.TransformException
      Creates an instance of the helper class for shifting positions and envelopes inside the grid.
      Parameters:
      baseToAOI - the transform computed by findBaseToAOI(CoordinateReferenceSystem), or null if same as the CRS of the base grid geometry.
      gridToCRS - the transform computed by dropUnusedDimensions(MathTransform, int) (the transform from grid coordinates to the CRS of user supplied AOI/POI).
      Throws:
      org.opengis.referencing.operation.TransformException
    • dropUnusedDimensions

      private org.opengis.referencing.operation.MathTransform dropUnusedDimensions(org.opengis.referencing.operation.MathTransform gridToCRS, int dimension) throws org.opengis.util.FactoryException, org.opengis.referencing.operation.TransformException
      Drops the source dimensions that are not needed for producing the target dimensions. The retained source dimensions are stored in modifiedDimensions. This method is invoked in an effort to make the transform invertible.
      Parameters:
      gridToCRS - transform from grid coordinates to AOI coordinates.
      dimension - value of cornerToCRS.getTargetDimensions().
      Throws:
      org.opengis.util.FactoryException
      org.opengis.referencing.operation.TransformException
    • getPointOfInterest

      private double[] getPointOfInterest()
      Returns the point of interest of current baseExtent, keeping only the remaining dimensions after dropUnusedDimensions(MathTransform, int) execution. The position is in units of base grid coordinates.

      This method assumes that the transform will be used with a "cell corner to CRS" transform instead of the usual "cell center to CRS".

    • setBaseExtentClipped

      private void setBaseExtentClipped(GeneralEnvelope... indices)
      Sets baseExtent to the given envelope clipped to the previous extent. This method shall be invoked for clipping only, without any subsampling applied. The context for invoking this method is: As a consequence of above context, margin and chunk size are in units of the base extent. They are not in units of cells of the size that we get after subsampling.
      Parameters:
      indices - the envelopes to intersect in units of base grid coordinates. Shall contain at least one element.
      Throws:
      DisjointExtentException - if the given envelope does not intersect the grid extent.
      See Also:
    • subgrid

      public GridDerivation subgrid(GridExtent areaOfInterest, int... subsampling)
      Requests a grid geometry over a sub-region of the base grid geometry and optionally with subsampling. The given grid geometry must have the same number of dimension than the base grid geometry. If the length of subsampling array is less than the number of dimensions, then no subsampling will be applied on the missing dimensions.

      Notes:

      • This method can be invoked only once.
      • This method cannot be used together with another subgrid(…) method.
      • Rounding mode, clipping mode, margin and chunk size, if different than default values, should be set before to invoke this method.
      • Slicing can be applied after this method.
      • This method does not reduce the number of dimensions of the grid geometry. For dimensionality reduction, see GridGeometry.selectDimensions(int[]).
      Parameters:
      areaOfInterest - the desired grid extent in unit of base grid cell (i.e. ignoring subsampling), or null for not restricting the sub-grid to a sub-area.
      subsampling - the subsampling to apply on each grid dimension, or null if none. All values shall be greater than zero. If the array length is shorter than the number of dimensions, missing values are assumed to be 1.
      Returns:
      this for method call chaining.
      Throws:
      DisjointExtentException - if the given area of interest does not intersect the grid extent.
      IncompleteGridGeometryException - if the base grid geometry has no extent, no "grid to CRS" transform, or no CRS (unless areaOfInterest has no CRS neither, in which case the CRS are assumed the same).
      IllegalStateException - if a subgrid(…) or slice(…) method has already been invoked.
      Since:
      1.1
      See Also:
    • subsample

      private GridDerivation subsample(int... subsampling)
      Applies a subsampling on the grid geometry to build. This method can be invoked as an alternative to subgrid(…) methods if only the resolution needs to be changed. The extent of the built grid geometry will be derived from getIntersection() as below for each dimension i:
      • The low is divided by subsampling[i], rounded toward zero.
      • The size is divided by subsampling[i], rounded toward zero.
      • The high is recomputed from above low and size.
      The grid to CRS transform is scaled accordingly

      Preconditions

      This method assumes that subsampling are divisors of chunk sizes and are not greater than the maximum subsampling. It is caller responsibility to ensure that those preconditions are met.
      Parameters:
      subsampling - the subsampling to apply on each grid dimension. All values shall be greater than zero. If the array length is shorter than the number of dimensions, missing values are assumed to be 1.
      Returns:
      this for method call chaining.
      Throws:
      IllegalStateException - if a subsampling has already been set, for example by a call to subgrid(…).
      See Also:
    • slice

      public GridDerivation slice(org.opengis.geometry.DirectPosition slicePoint)
      Requests a grid geometry for a slice at the given "real world" position. The given position can be expressed in any coordinate reference system (CRS). The position should not define a coordinate for all dimensions, otherwise the slice would degenerate to a single point. Dimensions can be left unspecified either by assigning to slicePoint a CRS without those dimensions, or by assigning the NaN value to some coordinates.
      Example: if the coordinate reference system of base grid geometry has (longitude, latitude, time) axes, then a (longitude, latitude) slice at time t can be created with one of the following two positions:
      • A three-dimensional position with (Double.NaN, Double.NaN, t) coordinates.
      • A one-dimensional position with (t) coordinate and the coordinate reference system set to the temporal component of the grid geometry CRS.

      Notes:

      • This method can be invoked after subgrid(Envelope, double...), but not before.
      • If a non-default rounding mode is desired, it should be specified before to invoke this method.
      • This method does not reduce the number of dimensions of the grid geometry. For dimensionality reduction, see GridGeometry.selectDimensions(int[]).
      • If the given point is known to be expressed in the same CRS than the grid geometry, then the CRS of the point can be left unspecified (null). It may give a slight performance improvement by avoiding the check for coordinate transformation.
      Parameters:
      slicePoint - the coordinates where to get a slice. If no coordinate reference system is associated, this method assumes that the slice point CRS is the CRS of the base grid geometry.
      Returns:
      this for method call chaining.
      Throws:
      IncompleteGridGeometryException - if the base grid geometry has no extent, no "grid to CRS" transform, or no CRS (unless slicePoint has no CRS neither, in which case the CRS are assumed the same).
      IllegalGridGeometryException - if an error occurred while converting the point coordinates to grid coordinates.
      PointOutsideCoverageException - if the given point is outside the grid extent.
    • sliceByRatio

      public GridDerivation sliceByRatio(double sliceRatio, int... dimensionsToKeep)
      Requests a grid geometry for a slice at the given relative position. The relative position is specified by a ratio between 0 and 1 where 0 maps to low grid coordinates, 1 maps to high grid coordinates and 0.5 maps to the median position. The slicing is applied on all dimensions except the specified dimensions to keep.
      Example: given a n-dimensional cube, the following call creates a slice of the two first dimensions (numbered 0 and 1, typically the dimensions of x and y axes) located at the center (ratio 0.5) of all other dimensions (typically z and/or t axes):
      Parameters:
      sliceRatio - the ratio to apply on all grid dimensions except the ones to keep.
      dimensionsToKeep - the grid dimension to keep unchanged.
      Returns:
      this for method call chaining.
      Throws:
      IncompleteGridGeometryException - if the base grid geometry has no extent.
      IndexOutOfBoundsException - if a dimensionsToKeep value is out of bounds.
    • build

      public GridGeometry build()
      Builds a grid geometry with the configuration specified by the other methods in this GridDerivation class.
      Returns:
      the modified grid geometry. May be the base grid geometry if no change apply.
      Throws:
      IllegalGridGeometryException - if the grid geometry cannot be computed because of arguments given to a subgrid(…) or other methods.
      See Also:
    • getBaseExtentExpanded

      private GridExtent getBaseExtentExpanded(boolean nonNull)
      Returns baseExtent with margin and chunk size applied.
      Parameters:
      nonNull - whether the returned value should be guaranteed non-null.
      Throws:
      IncompleteGridGeometryException - if nonNull is true and the grid geometry has no extent.
      See Also:
      • #setBaseExtentClipped(GeneralEnvelope)
    • getIntersection

      public GridExtent getIntersection()
      Returns the extent of the modified grid geometry, ignoring subsampling or changes in resolution. This is the intersection of the base grid geometry with the (grid or geospatial) envelope given to a subgrid(…) method, expanded by the specified margin (if any) and potentially with some grid sizes set to 1 if a slice(…) method has been invoked. The returned extent is in units of the base grid cells, i.e. subsampling is ignored.

      This method can be invoked after build() for getting additional information.

      Returns:
      intersection of grid geometry extents in units of base grid cells.
      Throws:
      IncompleteGridGeometryException - if the base grid geometry has no extent.
    • getSubsampling

      public int[] getSubsampling()
      Returns the strides for accessing cells along each axis of the base grid. Those values define part of the conversion from derived grid coordinates (x, y, z) to base grid coordinates (x′, y′, z′) as below (generalize to as many dimensions as needed):
      • x′ = s₀⋅x + t₀
      • y′ = s₁⋅y + t₁
      • z′ = s₂⋅z + t₂
      This method returns the {s₀, s₁, s₂} values while getSubsamplingOffsets() returns the {t₀, t₁, t₂} values. All subsampling values are strictly positive integers.
      Application to iterations
      Iteration over areaOfInterest grid coordinates with a stride Δx=1 corresponds to an iteration in base grid coordinates with a stride of Δx′=s₀, a stride Δy=1 corresponds to a stride Δy′=s₁, etc.
      This method can be invoked after build() for getting additional information. If subgrid(GridExtent, int...) has been invoked, then this method returns the values that were given in the subsampling argument.
      Returns:
      an estimation of the strides for accessing cells along each axis of base grid.
      Throws:
      IllegalStateException - if the subsampling factors are not integers. It may happen if the derived grid has been constructed by a call to subgrid(Envelope, double...).
      Since:
      1.1
      See Also:
    • roundSubsampling

      private int roundSubsampling(double scale, int dimension)
      Rounds a subsampling value according the current RoundingMode. If maximumSubsampling values have been specified, then subsampling is clamped if needed. If a chunkSize has been specified, then the subsampling will be a divisor of that size. This is necessary for avoiding a drift of subsampled pixel coordinates computed from tile coordinates.
      Drift example: if the tile size is 16 pixels and the subsampling is 3, then the subsampled tile size is ⌊16/3⌋ = 5 pixels. Pixel coordinates for each tile is as below:
      Tile and pixel coordinates for subsampling of 3 pixels
      Tile index Pixel coordinate Subsampled pixel coordinate
      0 0 0
      1 16 5
      2 32 10
      3 48 16
      Note the last subsampled pixel coordinate: we have ⌊48/3⌋ = 16 pixels while 15 would have been expected for a regular progression of those pixel coordinates. For GridCoverageResource implementations, it would require to read the last row of tile #2 and insert those data as the first row of tile #3. It does not only make implementations much more difficult, but also hurts performance because fetching a single tile would actually require the "physical" reading of 2 or more tiles.
      Parameters:
      scale - the scale factor to round.
      dimension - the dimension of the scale factor to round.
    • tolerance

      private double tolerance(int dimension)
      Returns a tolerance factor for comparing scale factors in the given dimension. The tolerance is such that the errors of pixel coordinates computed using the scale factor should not be greater than 0.5 pixel.
    • getSubsamplingOffsets

      public int[] getSubsamplingOffsets()
      Returns the offsets to be subtracted from pixel coordinates before subsampling. In a conversion from derived grid to base grid coordinates (the opposite direction of subsampling), the offset is the value to add after multiplication by the subsampling factor. It may be negative.

      This method can be invoked after build() for getting additional information.

      Returns:
      conversion from the new grid to the original grid specified to the constructor.
      Throws:
      IllegalStateException - if the subsampling offsets are not integers. It may happen if the derived grid has been constructed by a call to subgrid(Envelope, double...).
      Since:
      1.1
      See Also:
    • toTree

      @Debug private TreeTable toTree(Locale locale)
      Returns a tree representation of this GridDerivation. The tree representation is for debugging purpose only and may change in any future SIS version.
      Parameters:
      locale - the locale to use for textual labels.
      Returns:
      a tree representation of this GridDerivation.
    • toString

      public String toString()
      Returns a string representation of this GridDerivation for debugging purpose. The returned string is implementation dependent and may change in any future version.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this GridDerivation for debugging purpose.