org.geotoolkit.referencing.operation.transform
Enum IterationStrategy

Object
  extended by Enum<IterationStrategy>
      extended by IterationStrategy
All Implemented Interfaces:
Serializable, Comparable<IterationStrategy>

public enum IterationStrategy
extends Enum<IterationStrategy>

Strategy for iterating over the point arrays given to 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.

Implementation example:

public void transform(double[] srcPts, int srcOff,
                      double[] dstPts, int dstOff, int numPts)
{
    int srcInc = getSourceDimension();
    int dstInc = getTargetDimension();
    if (srcPts == dstPts) {
        switch (IterationStrategy.suggest(srcOff, srcInc, dstOff, dstInc, numPts)) {
            case ASCENDING: {
                break;
            }
            case DESCENDING: {
                srcOff += (numPts-1) * srcInc; srcInc = -srcInc;
                dstOff += (numPts-1) * dstInc; dstInc = -dstInc;
                break;
            }
            default: {
                srcPts = Arrays.copyOfRange(srcPts, srcOff, srcOff + numPts*srcInc);
                srcOff = 0;
                break;
            }
        }
    }
    while (--numPts >= 0) {
        // TODO by the implementor here:
        //   1. Read the coordinate starting at srcPts[srcOff].
        //   2. Tranform it.
        //   3. Store the result starting at dstPts[dstOff].
        srcOff += srcInc;
        dstOff += dstInc;
    }
}

Since:
3.00
Version:
3.00
Author:
Martin Desruisseaux (Geomatys)
Module:
referencing/geotk-referencing (download)    View source code for this class

Enum Constant Summary
ASCENDING
          Iterate over the points in ascending index order.
BUFFER_SOURCE
          Copies the points to transform in a temporary array before to apply the transform.
BUFFER_TARGET
          Writes the transformed points in a temporary array and copies them to the destination subarray when the transformation is finished.
DESCENDING
          Iterate over the points in descending index order.
 
Method Summary
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.
static IterationStrategy valueOf(String name)
          Returns the enum constant of this type with the specified name.
static IterationStrategy[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

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
Copies the points to transform in a temporary array before to apply the transform. The temporary array will be used for fetching the source ordinates.

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


BUFFER_TARGET

public static final IterationStrategy BUFFER_TARGET
Writes 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.

Method Detail

values

public static IterationStrategy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (IterationStrategy c : IterationStrategy.values())
    System.out.println(c);

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:

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.


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.