Enum IterationStrategy

java.lang.Object
java.lang.Enum<IterationStrategy>
org.apache.sis.referencing.operation.transform.IterationStrategy
All Implemented Interfaces:
Serializable, Comparable<IterationStrategy>, java.lang.constant.Constable

public enum IterationStrategy extends Enum<IterationStrategy>
Strategy for iterating over the point arrays given to AbstractMathTransform.transform(…) methods. If the source and destination arrays are the same and the region of the array to be written overlaps the region of the array to be read, it may be necessary to iterate over the points in reverse order or to copy some points in a temporary array. The suggest(…) method in this class returns a strategy suitable to the transform arguments.

Usage

The following code gives a skeleton for a AbstractMathTransform implementation capable to transform an array of double coordinates:
Since:
0.5
Version:
1.1
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Iterate over the points in ascending index order.
    Copy the points to transform in a temporary array before to apply the transform.
    Write the transformed points in a temporary array and copies them to the destination subarray when the transformation is finished.
    Iterate over the points in descending index order.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final boolean
    true if this iteration strategy requires the use of a buffer.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    IterationStrategy(boolean needBuffer)
    Creates a new enum.
  • Method Summary

    Modifier and Type
    Method
    Description
    suggest(int srcOff, int srcDim, int dstOff, int dstDim, int numPts)
    Suggests a strategy for iterating over the points to transform in an array.
    Returns the enum constant of this type with the specified name.
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • ASCENDING

      public static final IterationStrategy ASCENDING
      Iterate over the points in ascending index order. There is no need to copy the array.
    • DESCENDING

      public static final IterationStrategy DESCENDING
      Iterate over the points in descending index order. There is no need to copy the array.
    • BUFFER_SOURCE

      public static final IterationStrategy BUFFER_SOURCE
      Copy the points to transform in a temporary array before to apply the transform. The temporary array will be used for fetching the source coordinates.

      This algorithm can be used as a fallback for any unknown enumeration.

    • BUFFER_TARGET

      public static final IterationStrategy BUFFER_TARGET
      Write the transformed points in a temporary array and copies them to the destination subarray when the transformation is finished.

      Developers are allowed to ignore this value and fallback on the same algorithm than BUFFER_SOURCE, which is often easier to implement.

  • Field Details

    • needBuffer

      final boolean needBuffer
      true if this iteration strategy requires the use of a buffer.
  • Constructor Details

    • IterationStrategy

      private IterationStrategy(boolean needBuffer)
      Creates a new enum.
      Parameters:
      needBuffer - true if this iteration strategy requires the use of a buffer.
  • Method Details

    • values

      public static IterationStrategy[] 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 IterationStrategy 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
    • suggest

      public static IterationStrategy suggest(int srcOff, int srcDim, int dstOff, int dstDim, int numPts)
      Suggests a strategy for iterating over the points to transform in an array. This convenience method is provided for transform method implementations. It makes the following assumptions:
      • Source and target array are the same.
      • For each coordinate to be transformed, all coordinate values are read before the transformation process starts. For example if a transform goes from geographic to projected CRS, the (longitude, latitude, height) tuple must be completely read before to start writing the (x,y,z) tuple.
      Parameters:
      srcOff - the offset in the source coordinate array.
      srcDim - the dimension of input points.
      dstOff - the offset in the destination coordinate array.
      dstDim - the dimension of output points.
      numPts - the number of points to transform.
      Returns:
      a strategy for iterating over the points during the transformation process.
      Throws:
      ArithmeticException - if the given offsets or number of points are too high.