org.geotools.referencing.operation.transform
Class WarpTransform2D

java.lang.Object
  extended byorg.geotools.referencing.wkt.Formattable
      extended byorg.geotools.referencing.operation.transform.AbstractMathTransform
          extended byorg.geotools.referencing.operation.transform.WarpTransform2D
All Implemented Interfaces:
org.opengis.referencing.operation.MathTransform, org.opengis.referencing.operation.MathTransform2D, java.io.Serializable

public class WarpTransform2D
extends AbstractMathTransform
implements org.opengis.referencing.operation.MathTransform2D, java.io.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 to 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:
2.1
Version:
$Id: WarpTransform2D.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux, Alessio Fabiani
See Also:
LocalizationGrid.getPolynomialTransform(int), Warp, WarpOpImage, WarpDescriptor, Serialized Form

Nested Class Summary
static class WarpTransform2D.Provider
          The provider for the WarpTransform2D.
 
Nested classes inherited from class org.geotools.referencing.operation.transform.AbstractMathTransform
AbstractMathTransform.Inverse
 
Constructor Summary
  WarpTransform2D(java.awt.geom.Point2D[] srcCoords, java.awt.geom.Point2D[] dstCoords, int degree)
          Constructs a warp transform that approximatively maps the given source coordinates to the given destination coordinates.
  WarpTransform2D(java.awt.geom.Rectangle2D srcBounds, float[] srcCoords, int srcOffset, java.awt.geom.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(java.awt.geom.Rectangle2D srcBounds, java.awt.geom.Point2D[] srcCoords, int srcOffset, java.awt.geom.Rectangle2D dstBounds, java.awt.geom.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(javax.media.jai.Warp warp, javax.media.jai.Warp inverse)
          Constructs a transform using the specified warp object.
 
Method Summary
static org.opengis.referencing.operation.MathTransform2D create(javax.media.jai.Warp warp)
          Returns a transform using the specified warp object.
 boolean equals(java.lang.Object object)
          Compares this transform with the specified object for equality.
 org.opengis.parameter.ParameterDescriptorGroup getParameterDescriptors()
          Returns the parameter descriptors for this math transform.
 org.opengis.parameter.ParameterValueGroup getParameterValues()
          Returns the parameter values for this math transform.
 int getSourceDimensions()
          Returns the dimension of input points.
 int getTargetDimensions()
          Returns the dimension of output points.
 javax.media.jai.Warp getWarp()
          Returns image warp wrapped by this transform.
static javax.media.jai.Warp getWarp(java.lang.CharSequence name, org.opengis.referencing.operation.MathTransform2D transform)
          Returns a image warp for the specified transform.
 int hashCode()
          Returns a hash value for this transform.
 org.opengis.referencing.operation.MathTransform inverse()
          Returns the inverse transform.
 boolean isIdentity()
          Tests if this transform is the identity transform.
 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(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).
 java.awt.geom.Point2D transform(java.awt.geom.Point2D ptSrc, java.awt.geom.Point2D ptDst)
          Transforms source coordinates (usually pixel indices) into destination coordinates (usually "real world" coordinates).
 
Methods inherited from class org.geotools.referencing.operation.transform.AbstractMathTransform
createTransformedShape, derivative, derivative, ensureNonNull, formatWKT, getDimSource, getDimTarget, needCopy, rollLongitude, transform
 
Methods inherited from class org.geotools.referencing.wkt.Formattable
toString, toWKT, toWKT, toWKT
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.referencing.operation.MathTransform2D
createTransformedShape, derivative
 
Methods inherited from interface org.opengis.referencing.operation.MathTransform
derivative, toWKT, transform
 

Constructor Detail

WarpTransform2D

public WarpTransform2D(java.awt.geom.Point2D[] srcCoords,
                       java.awt.geom.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 some polynomial warp with the degree supplied in argument. The 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(java.awt.geom.Rectangle2D srcBounds,
                       java.awt.geom.Point2D[] srcCoords,
                       int srcOffset,
                       java.awt.geom.Rectangle2D dstBounds,
                       java.awt.geom.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 if unknow.
srcCoords - Source coordinates.
srcOffset - The inital entry of to be used.
dstBounds - Bounding box of destination coordinates, or if unknow.
dstCoords - Destination coordinates.
dstOffset - The inital entry of to be used.
numCoords - The number of coordinates from and to be used.
degree - The desired degree of the warp polynomials.

WarpTransform2D

public WarpTransform2D(java.awt.geom.Rectangle2D srcBounds,
                       float[] srcCoords,
                       int srcOffset,
                       java.awt.geom.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 if unknow.
srcCoords - Source coordinates with x and y alternating.
srcOffset - The inital entry of to be used.
dstBounds - Bounding box of destination coordinates, or if unknow.
dstCoords - Destination coordinates with x and y alternating.
dstOffset - The inital entry of to be used.
numCoords - The number of coordinates from and to be used.
degree - The desired degree of the warp polynomials.

WarpTransform2D

protected WarpTransform2D(javax.media.jai.Warp warp,
                          javax.media.jai.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 in none.
Method Detail

create

public static org.opengis.referencing.operation.MathTransform2D create(javax.media.jai.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.

getWarp

public static javax.media.jai.Warp getWarp(java.lang.CharSequence name,
                                           org.opengis.referencing.operation.MathTransform2D transform)
Returns a image warp for the specified transform. The 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 if the warp object is going to be used in an image reprojection.

Parameters:
name - The image or coverage name, or in unknow. Used only for formatting error message if some TransformException are thrown by the supplied transform.
transform - The transform to returns as an image warp.
To Do:
We should check for ConcatenatedTransform. If we detect that a is concatenated with only, and if the has scale factors only, then we can ommit the and merge the scale factors with WarpPolynomial preScaleX, preScaleY, postScaleX and postScaleY. Additionnaly, the translation term for the post-AffineTransform may also be merged with the first coefficients of WarpPolynomial.xCoeffs and yCoeffs. See GEOT-521.

getWarp

public javax.media.jai.Warp getWarp()
Returns image warp wrapped by this transform. The 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.


getParameterDescriptors

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

Overrides:
getParameterDescriptors in class AbstractMathTransform
Returns:
The parameter descriptors for this math transform, or .
See Also:
OperationMethod.getParameters()

getParameterValues

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

Overrides:
getParameterValues in class AbstractMathTransform
Returns:
A copy of the parameter values for this math transform, or .
See Also:
Operation.getParameterValues()

getSourceDimensions

public int getSourceDimensions()
Returns the dimension of input points.

Specified by:
getSourceDimensions in interface org.opengis.referencing.operation.MathTransform
Specified by:
getSourceDimensions in class AbstractMathTransform

getTargetDimensions

public int getTargetDimensions()
Returns the dimension of output points.

Specified by:
getTargetDimensions in interface org.opengis.referencing.operation.MathTransform
Specified by:
getTargetDimensions in class AbstractMathTransform

isIdentity

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

Specified by:
isIdentity in interface org.opengis.referencing.operation.MathTransform
Overrides:
isIdentity in class AbstractMathTransform

transform

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

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

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 org.opengis.referencing.operation.MathTransform
Overrides:
transform in class AbstractMathTransform

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 org.opengis.referencing.operation.MathTransform

inverse

public org.opengis.referencing.operation.MathTransform inverse()
                                                        throws org.opengis.referencing.operation.NoninvertibleTransformException
Returns the inverse transform.

Specified by:
inverse in interface org.opengis.referencing.operation.MathTransform
Overrides:
inverse in class AbstractMathTransform
Throws:
org.opengis.referencing.operation.NoninvertibleTransformException - if no inverse warp were specified at construction time.

hashCode

public int hashCode()
Returns a hash value for this transform.

Overrides:
hashCode in class AbstractMathTransform

equals

public boolean equals(java.lang.Object object)
Compares this transform with the specified object for equality.

Overrides:
equals in class AbstractMathTransform


Copyright © GeoTools. All Rights Reserved.