public enum IterationStrategy extends Enum<IterationStrategy>
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.
AbstractMathTransform
implementation
capable to transform an array of double
coordinates:
public class MyTransform extends AbstractMathTransform { @Override 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) { double x = srcPts[srcOff ]; double y = srcPts[srcOff + 1]; double z = srcPts[srcOff + 2]; // Repeat as many time as needed for dimension of input points. // Transform (x,y,z) here. dstPts[dstOff ] = x; dstPts[dstOff + 1] = y; dstPts[dstOff + 2] = z; // Repeat as many time as needed for dimension of output points. srcOff += srcInc; dstOff += dstInc; } } }
Defined in the sis-referencing
module
Enum Constant and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public static final IterationStrategy ASCENDING
public static final IterationStrategy DESCENDING
public static final IterationStrategy BUFFER_SOURCE
This algorithm can be used as a fallback for any unknown enumeration.
public static final IterationStrategy BUFFER_TARGET
Developers are allowed to ignore this value and fallback on the same algorithm
than BUFFER_SOURCE
, which is often easier to implement.
public static IterationStrategy[] values()
for (IterationStrategy c : IterationStrategy.values()) System.out.println(c);
public static IterationStrategy valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static IterationStrategy suggest(int srcOff, int srcDim, int dstOff, int dstDim, int numPts)
transform
method implementations. It makes the following assumptions:
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.Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.