org.geotoolkit.referencing.operation.transform
Class WarpTransform2D

Object
  extended by FormattableObject
      extended by AbstractMathTransform
          extended by AbstractMathTransform2D
              extended by WarpTransform2D
All Implemented Interfaces:
Serializable, Formattable, Parameterized, LenientComparable, MathTransform, MathTransform2D

@Immutable
public class WarpTransform2D
extends AbstractMathTransform2D
implements Serializable

Wraps an arbitrary Warp object as a two-dimensional transform. Calls to transform methods are forwarded to the warpPoint method, or something equivalent. This implies that source coordinates may be rounded to nearest integers before the transformation is applied.

This transform is typically used with grid coverage "Resample" operation for reprojecting an image. Source and destination coordinates are usually pixel coordinates in source and target image, which is why this transform may use integer arithmetic.

This math transform can be created alone (by invoking its public constructors directly), or it can be created by a factory like LocalizationGrid.

For more information on image warp, see Geometric Image Manipulation in the Programming in Java Advanced Imaging guide.

Since:
1.2
Version:
3.18
Author:
Martin Desruisseaux (IRD, Geomatys), Alessio Fabiani (Geosolutions)
See Also:
LocalizationGrid.getPolynomialTransform(int), Warp, WarpOpImage, WarpDescriptor, Serialized Form
Module:
coverage/geotk-coverage (download)    View source code for this class

Nested Class Summary
 
Nested classes/interfaces inherited from class AbstractMathTransform2D
AbstractMathTransform2D.Inverse, AbstractMathTransform2D.Parameters
 
Field Summary
static int MAX_DEGREE
          The maximal polynomial degree allowed.
 
Fields inherited from class FormattableObject
EPSG, GEOTIFF, INTERNAL, OGC, SINGLE_LINE
 
Constructor Summary
  WarpTransform2D(Point2D[] srcCoords, Point2D[] dstCoords, int degree)
          Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates.
  WarpTransform2D(Rectangle2D srcBounds, float[] srcCoords, int srcOffset, Rectangle2D dstBounds, float[] dstCoords, int dstOffset, int numCoords, int degree)
          Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates.
  WarpTransform2D(Rectangle2D srcBounds, Point2D[] srcCoords, int srcOffset, Rectangle2D dstBounds, Point2D[] dstCoords, int dstOffset, int numCoords, int degree)
          Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates.
protected WarpTransform2D(Warp warp, Warp inverse)
          Constructs a transform using the specified warp object.
 
Method Summary
protected  int computeHashCode()
          Computes a hash value for this transform.
static MathTransform2D create(Warp warp)
          Returns a transform using the specified warp object.
 boolean equals(Object object, ComparisonMode mode)
          Compares this transform with the specified object for equality.
 ParameterDescriptorGroup getParameterDescriptors()
          Returns the parameter descriptors for this math transform.
 ParameterValueGroup getParameterValues()
          Returns the parameter values for this math transform.
 Warp getWarp()
          Returns the Warp wrapped by this transform.
 MathTransform2D inverse()
          Returns the inverse transform.
 boolean isIdentity()
          Tests if this transform is the identity transform.
 Matrix transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate)
          Transforms a single source coordinate (usually pixel indices) into destination coordinate (usually "real world" coordinates).
 void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
          Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).
 void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).
 void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
          Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).
 void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).
 Point2D transform(Point2D ptSrc, Point2D ptDst)
          Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).
 
Methods inherited from class AbstractMathTransform2D
getSourceDimensions, getTargetDimensions, getUnmarshalledParameters
 
Methods inherited from class AbstractMathTransform
createTransformedShape, derivative, derivative, ensureNonNull, equals, formatWKT, getName, hashCode, rollLongitude, transform
 
Methods inherited from class FormattableObject
getDefaultIndentation, print, setDefaultIndentation, toString, toWKT, toWKT, toWKT, toWKT
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface MathTransform2D
createTransformedShape, derivative
 
Methods inherited from interface MathTransform
derivative, toWKT, transform
 

Field Detail

MAX_DEGREE

public static final int MAX_DEGREE
The maximal polynomial degree allowed.

Since:
2.4
See Also:
Constant Field Values
Constructor Detail

WarpTransform2D

public WarpTransform2D(Point2D[] srcCoords,
                       Point2D[] dstCoords,
                       int degree)
Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates. The transformation is performed using a polynomial warp with the degree supplied in argument. The minimal number of points required for each degree of warp are as follows:

Degree of WarpNumber of Points
13
26
310
415
521
628
736

Parameters:
srcCoords - Source coordinates.
dstCoords - Destination coordinates.
degree - The desired degree of the warp polynomials.

WarpTransform2D

public WarpTransform2D(Rectangle2D srcBounds,
                       Point2D[] srcCoords,
                       int srcOffset,
                       Rectangle2D dstBounds,
                       Point2D[] dstCoords,
                       int dstOffset,
                       int numCoords,
                       int degree)
Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates. The transformation is performed using some polynomial warp with the degree supplied in argument.

Parameters:
srcBounds - Bounding box of source coordinates, or null if unknown.
srcCoords - Source coordinates.
srcOffset - The initial entry of srcCoords to be used.
dstBounds - Bounding box of destination coordinates, or null if unknown.
dstCoords - Destination coordinates.
dstOffset - The initial entry of destCoords to be used.
numCoords - The number of coordinates from srcCoords and destCoords to be used.
degree - The desired degree of the warp polynomials.

WarpTransform2D

public WarpTransform2D(Rectangle2D srcBounds,
                       float[] srcCoords,
                       int srcOffset,
                       Rectangle2D dstBounds,
                       float[] dstCoords,
                       int dstOffset,
                       int numCoords,
                       int degree)
Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates. The transformation is performed using some polynomial warp with the degree supplied in argument.

Parameters:
srcBounds - Bounding box of source coordinates, or null if unknown.
srcCoords - Source coordinates with x and y alternating.
srcOffset - The initial entry of srcCoords to be used.
dstBounds - Bounding box of destination coordinates, or null if unknown.
dstCoords - Destination coordinates with x and y alternating.
dstOffset - The initial entry of destCoords to be used.
numCoords - The number of coordinates from srcCoords and destCoords to be used.
degree - The desired degree of the warp polynomials.

WarpTransform2D

protected WarpTransform2D(Warp warp,
                          Warp inverse)
Constructs a transform using the specified warp object. Transformations will be applied using the warpPoint method or something equivalent.

Parameters:
warp - The image warp to wrap into a math transform.
inverse - An image warp to uses for the inverse transform, or null in none.
See Also:
create(javax.media.jai.Warp)
Method Detail

create

public static MathTransform2D create(Warp warp)
Returns a transform using the specified warp object. Transformations will be applied using the warpPoint method or something equivalent.

Parameters:
warp - The image warp to wrap into a math transform.
Returns:
The transform for the given warp.

getWarp

public Warp getWarp()
Returns the Warp wrapped by this transform. Its Warp.warpPoint method transforms coordinates from source to target CRS. Note that JAI's warp operation needs a warp object with the opposite semantic (i.e. the image warp must transforms coordinates from target to source CRS). Consequently, consider invoking inverse.getWarp() if the warp object is going to be used in an image reprojection.

Returns:
The image warp from source to target CRS.

getParameterDescriptors

public ParameterDescriptorGroup getParameterDescriptors()
Returns the parameter descriptors for this math transform.

Specified by:
getParameterDescriptors in interface Parameterized
Overrides:
getParameterDescriptors in class AbstractMathTransform2D
Returns:
The parameter descriptors for this math transform, or null.
See Also:
OperationMethod.getParameters()

getParameterValues

public ParameterValueGroup getParameterValues()
Returns the parameter values for this math transform.

Specified by:
getParameterValues in interface Parameterized
Overrides:
getParameterValues in class AbstractMathTransform
Returns:
A copy of the parameter values for this math transform, or null. Since this method returns a copy of the parameter values, any change to a value will have no effect on this math transform.
See Also:
SingleOperation.getParameterValues()

isIdentity

public boolean isIdentity()
Tests if this transform is the identity transform.

Specified by:
isIdentity in interface MathTransform
Overrides:
isIdentity in class AbstractMathTransform

transform

public Point2D transform(Point2D ptSrc,
                         Point2D ptDst)
Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).

Specified by:
transform in interface MathTransform2D
Overrides:
transform in class AbstractMathTransform2D
Parameters:
ptSrc - the specified coordinate point to be transformed.
ptDst - the specified coordinate point that stores the result of transforming ptSrc, or null.
Returns:
the coordinate point after transforming ptSrc and storing the result in ptDst.
See Also:
MathTransform2D.transform(Point2D,Point2D)

transform

public Matrix transform(double[] srcPts,
                        int srcOff,
                        double[] dstPts,
                        int dstOff,
                        boolean derivate)
                 throws TransformException
Transforms a single source coordinate (usually pixel indices) into destination coordinate (usually "real world" coordinates).

Specified by:
transform in class AbstractMathTransform
Parameters:
srcPts - The array containing the source coordinate (can not be null).
srcOff - The offset to the point to be transformed in the source array.
dstPts - the array into which the transformed coordinate is returned. May be the same than srcPts. May be null if only the derivative matrix is desired.
dstOff - The offset to the location of the transformed point that is stored in the destination array.
derivate - true for computing the derivative, or false if not needed.
Returns:
The matrix of the transform derivative at the given source position, or null if the derivate argument is false.
Throws:
TransformException - If the point can't be transformed or if a problem occurred while calculating the derivative.
Since:
3.20 (derived from 3.00)
See Also:
AbstractMathTransform.derivative(DirectPosition), AbstractMathTransform.transform(DirectPosition, DirectPosition), MathTransforms.derivativeAndTransform(MathTransform, double[], int, double[], int)

transform

public void transform(double[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).

Specified by:
transform in interface MathTransform
Overrides:
transform in class AbstractMathTransform
Parameters:
srcPts - The array containing the source point coordinates.
srcOff - The offset to the first point to be transformed in the source array.
dstPts - The array into which the transformed point coordinates are returned. May be the same than srcPts.
dstOff - The offset to the location of the first transformed point that is stored in the destination array.
numPts - The number of point objects to be transformed.

transform

public void transform(float[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).

Specified by:
transform in interface MathTransform
Overrides:
transform in class AbstractMathTransform
Parameters:
srcPts - The array containing the source point coordinates.
srcOff - The offset to the first point to be transformed in the source array.
dstPts - The array into which the transformed point coordinates are returned. May be the same than srcPts.
dstOff - The offset to the location of the first transformed point that is stored in the destination array.
numPts - The number of point objects to be transformed.

transform

public void transform(double[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).

Specified by:
transform in interface MathTransform
Overrides:
transform in class AbstractMathTransform
Parameters:
srcPts - The array containing the source point coordinates.
srcOff - The offset to the first point to be transformed in the source array.
dstPts - The array into which the transformed point coordinates are returned.
dstOff - The offset to the location of the first transformed point that is stored in the destination array.
numPts - The number of point objects to be transformed.

transform

public void transform(float[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).

Specified by:
transform in interface MathTransform
Overrides:
transform in class AbstractMathTransform
Parameters:
srcPts - The array containing the source point coordinates.
srcOff - The offset to the first point to be transformed in the source array.
dstPts - The array into which the transformed point coordinates are returned.
dstOff - The offset to the location of the first transformed point that is stored in the destination array.
numPts - The number of point objects to be transformed.

inverse

public MathTransform2D inverse()
                        throws NoninvertibleTransformException
Returns the inverse transform.

Specified by:
inverse in interface MathTransform
Specified by:
inverse in interface MathTransform2D
Overrides:
inverse in class AbstractMathTransform2D
Throws:
NoninvertibleTransformException - if no inverse warp were specified at construction time.

computeHashCode

protected int computeHashCode()
Computes a hash value for this transform. This method is invoked by AbstractMathTransform.hashCode() when first needed.

Overrides:
computeHashCode in class AbstractMathTransform
Returns:
The hash code value. This value may change between different execution of the Geotk library.

equals

public boolean equals(Object object,
                      ComparisonMode mode)
Compares this transform with the specified object for equality.

Specified by:
equals in interface LenientComparable
Overrides:
equals in class AbstractMathTransform
Parameters:
object - The object to compare with this transform.
mode - The strictness level of the comparison. Default to STRICT.
Returns:
true if the given object is a transform of the same class and if, given identical source position, the transformed position would be the equals.
See Also:
Utilities.deepEquals(Object, Object, ComparisonMode)


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