Class WraparoundApplicator

java.lang.Object
org.apache.sis.internal.referencing.WraparoundApplicator

public final class WraparoundApplicator extends Object
Appends a WraparoundTransform to an existing MathTransform. Each WraparoundTransform instance should be used only once.
Since:
1.1
Version:
1.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.opengis.geometry.DirectPosition
    Coordinates at the center of source envelope, or null if none.
    private final org.opengis.referencing.cs.CoordinateSystem
    The target coordinate system.
    private final org.opengis.geometry.DirectPosition
    Coordinates to put at the center of new coordinate ranges, or null for standard axis center.
  • Constructor Summary

    Constructors
    Constructor
    Description
    WraparoundApplicator(org.opengis.geometry.DirectPosition sourceMedian, org.opengis.geometry.DirectPosition targetMedian, org.opengis.referencing.cs.CoordinateSystem targetCS)
    Creates a new applicator.
  • Method Summary

    Modifier and Type
    Method
    Description
    private org.opengis.referencing.operation.MathTransform
    concatenate(org.opengis.referencing.operation.MathTransform tr, int wraparoundDimension)
    Concatenates the given transform with a "wrap around" transform if applicable.
    private static double
    error(double m, int n)
    Returns an arbitrary measurement of the error of given value.
    org.opengis.referencing.operation.MathTransform
    forDomainOfUse(org.opengis.referencing.operation.MathTransform tr)
    Returns the given transform augmented with a "wrap around" behavior if applicable.
    static org.opengis.referencing.operation.MathTransform
    forTargetCRS(org.opengis.referencing.operation.CoordinateOperation op)
    Returns the transform of the given coordinate operation augmented with a "wrap around" behavior if applicable.
    (package private) static double
    range(org.opengis.referencing.cs.CoordinateSystem cs, int dimension)
    Returns the range (maximum - minimum) of axis in specified dimension if it has wraparound meaning, or Double.NaN otherwise.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • sourceMedian

      private final org.opengis.geometry.DirectPosition sourceMedian
      Coordinates at the center of source envelope, or null if none. This coordinate shall be expressed in the source CRS of the WraparoundTransform, not in the source CRS of the concatenated transform to be created by this applicator.
    • targetMedian

      private final org.opengis.geometry.DirectPosition targetMedian
      Coordinates to put at the center of new coordinate ranges, or null for standard axis center.
    • targetCS

      private final org.opengis.referencing.cs.CoordinateSystem targetCS
      The target coordinate system.
  • Constructor Details

    • WraparoundApplicator

      public WraparoundApplicator(org.opengis.geometry.DirectPosition sourceMedian, org.opengis.geometry.DirectPosition targetMedian, org.opengis.referencing.cs.CoordinateSystem targetCS)
      Creates a new applicator. The median coordinates are optional and can be null. Coordinates shall be in the source and target CRS of the WraparoundTransform, not in the source CRS of the concatenated transform to be created by this applicator.
      Parameters:
      sourceMedian - the coordinates at the center of source envelope, or null if none.
      targetMedian - the coordinates to put at the center of new range, or null for standard axis center.
      targetCS - the target coordinate system.
  • Method Details

    • forTargetCRS

      public static org.opengis.referencing.operation.MathTransform forTargetCRS(org.opengis.referencing.operation.CoordinateOperation op) throws org.opengis.referencing.operation.TransformException
      Returns the transform of the given coordinate operation augmented with a "wrap around" behavior if applicable. The wraparound is applied on target coordinates and aims to clamp coordinate values inside the range of target coordinate system axes.

      This method tries to avoid unnecessary wraparounds on a best-effort basis. It makes its decision based on an inspection of source and target CRS axes. For a method making decision based on a domain of use, see forDomainOfUse(…) instead.

      Parameters:
      op - the coordinate operation for which to get the math transform.
      Returns:
      the math transform for the given coordinate operation.
      Throws:
      org.opengis.referencing.operation.TransformException - if a coordinate cannot be computed.
    • forDomainOfUse

      public org.opengis.referencing.operation.MathTransform forDomainOfUse(org.opengis.referencing.operation.MathTransform tr) throws org.opengis.referencing.operation.TransformException
      Returns the given transform augmented with a "wrap around" behavior if applicable. The wraparound is applied on target coordinates and aims to clamp coordinate values in a range centered on the target median given at construction time.

      The centered ranges may be different than the range declared by the coordinate system axes. In such case, the wraparound range applied by this method will have a translation compared to the range declared by the axis. This translation is useful when the target domain is known (e.g. when transforming a raster) and we want that output coordinates to be continuous in that domain, independently of axis ranges.

      If a non-null sourceMedian position has been specified at construction time, those coordinates shall be expressed in the target CRS of given transform.

      Parameters:
      tr - the transform to augment with "wrap around" behavior.
      Returns:
      the math transform with wraparound if needed.
      Throws:
      org.opengis.referencing.operation.TransformException - if a coordinate cannot be computed.
    • concatenate

      private org.opengis.referencing.operation.MathTransform concatenate(org.opengis.referencing.operation.MathTransform tr, int wraparoundDimension) throws org.opengis.referencing.operation.TransformException
      Concatenates the given transform with a "wrap around" transform if applicable. The wraparound is implemented by concatenations of affine transforms before and after the WraparoundTransform instance. If there is no wraparound to apply, then this method returns tr unchanged.
      Parameters:
      tr - the transform to concatenate with a wraparound transform.
      wraparoundDimension - the dimension where "wrap around" behavior may apply.
      Returns:
      the math transform with "wrap around" behavior in the specified dimension.
      Throws:
      org.opengis.referencing.operation.TransformException - if a coordinate cannot be computed.
    • error

      private static double error(double m, int n)
      Returns an arbitrary measurement of the error of given value. We use this measurement for arbitrarily taking the value closest to an integer.
    • range

      static double range(org.opengis.referencing.cs.CoordinateSystem cs, int dimension)
      Returns the range (maximum - minimum) of axis in specified dimension if it has wraparound meaning, or Double.NaN otherwise. This method implements a fallback for longitude axis if it does not declare the minimum and maximum values as expected.
      Parameters:
      cs - the coordinate system for which to get wraparound range.
      dimension - dimension of the axis to test.
      Returns:
      the wraparound range, or Double.NaN if none.