# Class WraparoundAdjustment

Object
WraparoundAdjustment

public class WraparoundAdjustment extends Object
An envelope or position converter making them more compatible with a given domain of validity. For each axes having `RangeMeaning​.WRAPAROUND`, this class can add or subtract an integer number of periods (typically 360° of longitude) in attempt to move positions or envelopes inside a domain of validity specified at construction time.

`WraparoundAdjustment` instances are not thread-safe.

Since:
  1.2

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WraparoundAdjustment(Envelope domain, CoordinateReferenceSystem target)`
  Creates a new instance for adjusting Area Of Interest (AOI) or Point Of Interest (POI) to the given domain.
  `WraparoundAdjustment(Envelope domain, MathTransform domainToInput, MathTransform inputToResult)`
  Creates a new instance with specified transforms from domain to the CRS of inputs, then to the CRS of outputs.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `DirectPosition`
  `shift(DirectPosition pointOfInterest)`
  Computes a position with coordinates equivalent to the given `pointOfInterest`, but potentially shifted to interior of the domain of validity specified at construction time.
  `GeneralEnvelope`
  `shift(Envelope areaOfInterest)`
  Computes an envelope with coordinates equivalent to the given `areaOfInterest`, but potentially shifted for intersecting the domain of validity specified at construction time.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### WraparoundAdjustment

    public WraparoundAdjustment(Envelope domain, CoordinateReferenceSystem target)
    Creates a new instance for adjusting Area Of Interest (AOI) or Point Of Interest (POI) to the given domain. The results of `shift(…)` methods will be transformed (if needed) to the specified CRS.
    Parameters:
      `domain` - the region where a given area or point of interest should be located.
      `target` - the coordinate reference system of objects returned by `shift(…)` methods, or `null` for the same CRS as the `domain` CRS.

  - ### WraparoundAdjustment

    public WraparoundAdjustment(Envelope domain, MathTransform domainToInput, MathTransform inputToResult)
    Creates a new instance with specified transforms from domain to the CRS of inputs, then to the CRS of outputs. This constructor can be used when those transforms are known in advance; it avoids the cost of inferring them. With this constructor, `WraparoundAdjustment` does not verify if a coordinate operation is needed for a pair of CRS; it is caller's responsibility to ensure that input objects use the expected CRS.

    #### Example

    In the context of `GridGeometry`, the `domain` argument may be the geospatial envelope of the grid and the `inputToResult` argument may be the "CRS to grid" transform. This configuration allows to compute grid coordinates having more chances to be inside the grid.
    Parameters:
      `domain` - the region where a given area (AOI) or point of interest (POI) should be located.
      `domainToInput` - if the AOI or POI will use a different CRS than `domain`, the transform from `domain` to the input CRS. Otherwise `null` for same CRS as the domain.
      `inputToResult` - a transform from the `domain` CRS to any user space at caller choice. If `null`, the results will be expressed in same CRS as the inputs.

- ## Method Details

  - ### shift

    public GeneralEnvelope shift(Envelope areaOfInterest) throws TransformException
    Computes an envelope with coordinates equivalent to the given `areaOfInterest`, but potentially shifted for intersecting the domain of validity specified at construction time. The dimensions that may be shifted are the ones having an axis with wraparound meaning. In order to perform this operation, the envelope may be temporarily converted to a geographic CRS and converted back to its original CRS.

    The coordinate reference system should be specified in the `areaOfInterest`. If not, then the CRS is assumed same as the CRS of the domain specified at construction time.

    This method does not intersect the area of interest with the domain of validity. It is up to the caller to compute that intersection after this method call, if desired.

    Parameters:
      `areaOfInterest` - the envelope to potentially shift toward domain of validity. If a shift is needed, then given envelope will be replaced by a new envelope; the given envelope will not be modified.
    Returns:
      envelope potentially expanded or shifted toward the domain of validity.
    Throws:
      `TransformException` - if a coordinate conversion failed.
    See Also:
      - `GeneralEnvelope​.simplify()`

  - ### shift

    public DirectPosition shift(DirectPosition pointOfInterest) throws TransformException
    Computes a position with coordinates equivalent to the given `pointOfInterest`, but potentially shifted to interior of the domain of validity specified at construction time. The dimensions that may be shifted are the ones having an axis with wraparound meaning. In order to perform this operation, the position may be temporarily converted to a geographic CRS and converted back to its original CRS.

    The coordinate reference system should be specified in the `pointOfInterest`. If not, then the CRS is assumed same as the CRS of the domain specified at construction time.

    Parameters:
      `pointOfInterest` - the position to potentially shift to domain of validity interior. If a shift is needed, then the given position will be replaced by a new position; the given position will not be modified.
    Returns:
      position potentially shifted to the domain of validity interior.
    Throws:
      `TransformException` - if a coordinate conversion failed.