Package org.apache.sis.coverage.grid

# Enum GridRoundingMode

Object
Enum<GridRoundingMode>
GridRoundingMode

All Implemented Interfaces:
  `Serializable`, `Comparable<GridRoundingMode>`, `Constable`

public enum GridRoundingMode extends Enum<GridRoundingMode>
Specifies rounding behavior during computations of `GridExtent` from floating-point values. The rounding mode controls how real numbers are converted into `GridExtent`'s low, high and size integer values.

Since:
  1.0

Defined in the `sis-feature` module

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class Enum

  `Enum​.EnumDesc<E extends Enum<E>>`

- ## Enum Constant Summary

  Enum Constants
  Enum Constant
  Description
  `CONTAINED`
  Converts grid low and high to values that are fully contained in the envelope.
  `ENCLOSING`
  Converts grid low and high to values that fully encloses the envelope.
  `NEAREST`
  Converts grid low, high and size to nearest integer values.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static GridRoundingMode`
  `valueOf(String name)`
  Returns the enum constant of this type with the specified name.
  `static GridRoundingMode[]`
  `values()`
  Returns an array containing the constants of this enum type, in the order they are declared.

  ### Methods inherited from class Enum

  `clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

  ### Methods inherited from class Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### NEAREST

    public static final GridRoundingMode NEAREST
    Converts grid low, high and size to nearest integer values. This mode applies the following steps:
    1. Floating point values are converted to integers with `Math​.round(double)`.
    2. On the three integer values (low, high and size) obtained after rounding, add or subtract 1 to the value which is farthest from an integer value in order to keep unchanged the two values that are closer to integers.
    Example: the [low … high] range may be slightly larger than desired in some rounding error situations. For example if low before rounding was 1.49999 and high before rounding was 2.50001, then the range after rounding will be [1…3] while the expected size is actually only 2 pixels. This `NEAREST` rounding mode detects those rounding issues by comparing the size before and after rounding. In this example, the size is 2.00002 pixels, which is closer to an integer value than the low and high values. Consequently this `NEAREST` mode will rather adjust low or high (depending which one is farthest from integer values) in order to keep size at its closest integer value, which is 2.

  - ### ENCLOSING

    public static final GridRoundingMode ENCLOSING
    Converts grid low and high to values that fully encloses the envelope. This mode applies the following steps:
    - Grid low are converted to integers with `Math​.floor(double)`.
    - Grid high are converted to integers with `Math​.ceil(double)`.
    In operations receiving grid coverages as inputs and producing grid coverages as outputs, this rounding mode is convenient for computing the inputs extent because it gives an extent large enough for providing data in the whole region to be computed.

  - ### CONTAINED

    public static final GridRoundingMode CONTAINED
    Converts grid low and high to values that are fully contained in the envelope. This mode applies the following steps:
    - Grid low are converted to integers with `Math​.ceil(double)`.
    - Grid high are converted to integers with `Math​.floor(double)`.
    In operations receiving grid coverages as inputs and producing grid coverages as outputs, this rounding mode is convenient for computing the outputs extent because it gives an extent small enough for allowing inputs to provide data in the whole region.
    Since:
      1.1

- ## Method Details

  - ### values

    public static GridRoundingMode[] values()
    Returns an array containing the constants of this enum type, in the order they are declared.
    Returns:
      an array containing the constants of this enum type, in the order they are declared

  - ### valueOf

    public static GridRoundingMode valueOf(String name)
    Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
    Parameters:
      `name` - the name of the enum constant to be returned.
    Returns:
      the enum constant with the specified name
    Throws:
      `IllegalArgumentException` - if this enum type has no constant with the specified name
      `NullPointerException` - if the argument is null