org.geotoolkit.referencing.operation.transform
Class ConcatenatedTransform

Object
  extended by FormattableObject
      extended by AbstractMathTransform
          extended by ConcatenatedTransform
All Implemented Interfaces:
Serializable, Formattable, Parameterized, LenientComparable, MathTransform

@Immutable
public class ConcatenatedTransform
extends AbstractMathTransform
implements Serializable

Base class for concatenated transforms. Instances can be created by calls to the create(MathTransform, MathTransform) method. When possible, the above-cited method tries to concatenate projective transforms before to fallback on the creation of new ConcatenatedTransform instances.

Concatenated transforms are serializable if all their step transforms are serializables.

Since:
1.2
Version:
3.18
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
MathTransformFactory.createConcatenatedTransform(MathTransform, MathTransform), Serialized Form
Module:
referencing/geotk-referencing (download)    View source code for this class

Nested Class Summary
 
Nested classes/interfaces inherited from class AbstractMathTransform
AbstractMathTransform.Inverse
 
Field Summary
 MathTransform transform1
          The first math transform.
 MathTransform transform2
          The second math transform.
 
Fields inherited from class FormattableObject
EPSG, GEOTIFF, INTERNAL, OGC, SINGLE_LINE
 
Constructor Summary
protected ConcatenatedTransform(MathTransform transform1, MathTransform transform2)
          Constructs a concatenated transform.
 
Method Summary
protected  int computeHashCode()
          Computes a hash value for this transform.
static MathTransform1D create(MathTransform1D tr1, MathTransform1D tr2)
          Concatenates the given one-dimensional transforms.
static MathTransform1D create(MathTransform1D tr1, MathTransform1D tr2, MathTransform1D tr3)
          Concatenates the three given one-dimensional transforms.
static MathTransform2D create(MathTransform2D tr1, MathTransform2D tr2)
          Concatenates the given two-dimensional transforms.
static MathTransform2D create(MathTransform2D tr1, MathTransform2D tr2, MathTransform2D tr3)
          Concatenates the three given two-dimensional transforms.
static MathTransform create(MathTransform tr1, MathTransform tr2)
          Concatenates the two given transforms.
static MathTransform create(MathTransform tr1, MathTransform tr2, MathTransform tr3)
          Concatenates the three given transforms.
 Matrix derivative(DirectPosition point)
          Gets the derivative of this transform at a point.
 Matrix derivative(Point2D point)
          Gets the derivative of this transform at a point.
 boolean equals(Object object, ComparisonMode mode)
          Compares the specified object with this math transform for equality.
 String formatWKT(Formatter formatter)
          Formats the inner part of a Well Known Text (WKT) element.
 ParameterDescriptorGroup getParameterDescriptors()
          Returns the parameter descriptor, or null if none.
 ParameterValueGroup getParameterValues()
          Returns the parameter values, or null if none.
 int getSourceDimensions()
          Gets the dimension of input points.
 int getStepCount()
          Returns the number of single math transform steps.
 List<MathTransform> getSteps()
          Returns all concatenated transforms.
 int getTargetDimensions()
          Gets the dimension of output points.
 MathTransform inverse()
          Creates the inverse transform of this object.
 boolean isIdentity()
          Tests whether this transform does not move any points.
 DirectPosition transform(DirectPosition ptSrc, DirectPosition ptDst)
          Transforms the specified ptSrc and stores the result in ptDst.
protected  void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff)
          Transforms a single coordinates in a list of ordinal values.
 void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
          Transforms many coordinates in a list of ordinal values.
 void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms many coordinates in a list of ordinal values.
 void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
          Transforms many coordinates in a list of ordinal values.
 void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
          Transforms many coordinates in a list of ordinal values.
 
Methods inherited from class AbstractMathTransform
createTransformedShape, ensureNonNull, equals, getName, hashCode, rollLongitude, transform
 
Methods inherited from class FormattableObject
getDefaultIndentation, print, setDefaultIndentation, toString, toWKT, toWKT, toWKT
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface MathTransform
toWKT
 

Field Detail

transform1

public final MathTransform transform1
The first math transform.


transform2

public final MathTransform transform2
The second math transform.

Constructor Detail

ConcatenatedTransform

protected ConcatenatedTransform(MathTransform transform1,
                                MathTransform transform2)
Constructs a concatenated transform. This constructor is for subclasses only. To create a concatenated transform, use the factory method create(org.opengis.referencing.operation.MathTransform, org.opengis.referencing.operation.MathTransform) instead.

Parameters:
transform1 - The first math transform.
transform2 - The second math transform.
Method Detail

create

public static MathTransform create(MathTransform tr1,
                                   MathTransform tr2)
Concatenates the two given transforms. This factory method checks for step transforms dimension. The returned transform will implement MathTransform2D if source and target dimensions are equal to 2. Likewise, it will implement MathTransform1D if source and target dimensions are equal to 1. MathTransform implementations are available in two versions: direct and non-direct. The "non-direct" versions use an intermediate buffer when performing transformations; they are slower and consume more memory. They are used only as a fallback when a "direct" version can't be created.

Parameters:
tr1 - The first math transform.
tr2 - The second math transform.
Returns:
The concatenated transform.

create

public static MathTransform2D create(MathTransform2D tr1,
                                     MathTransform2D tr2)
Concatenates the given two-dimensional transforms. This is a convenience methods delegating to create(MathTransform, MathTransform) and casting the result to a MathTransform2D instance.

Parameters:
tr1 - The first math transform.
tr2 - The second math transform.
Returns:
The concatenated transform.
Since:
3.14

create

public static MathTransform1D create(MathTransform1D tr1,
                                     MathTransform1D tr2)
Concatenates the given one-dimensional transforms. This is a convenience methods delegating to create(MathTransform, MathTransform) and casting the result to a MathTransform1D instance.

Parameters:
tr1 - The first math transform.
tr2 - The second math transform.
Returns:
The concatenated transform.
Since:
3.14

create

public static MathTransform create(MathTransform tr1,
                                   MathTransform tr2,
                                   MathTransform tr3)
Concatenates the three given transforms. This is a convenience methods doing its job as two consecutive concatenations.

Parameters:
tr1 - The first math transform.
tr2 - The second math transform.
tr3 - The third math transform.
Returns:
The concatenated transform.
Since:
3.00

create

public static MathTransform2D create(MathTransform2D tr1,
                                     MathTransform2D tr2,
                                     MathTransform2D tr3)
Concatenates the three given two-dimensional transforms. This is a convenience methods delegating to create(MathTransform, MathTransform, MathTransform) and casting the result to a MathTransform2D instance.

Parameters:
tr1 - The first math transform.
tr2 - The second math transform.
tr3 - The third math transform.
Returns:
The concatenated transform.
Since:
3.14

create

public static MathTransform1D create(MathTransform1D tr1,
                                     MathTransform1D tr2,
                                     MathTransform1D tr3)
Concatenates the three given one-dimensional transforms. This is a convenience methods delegating to create(MathTransform, MathTransform, MathTransform) and casting the result to a MathTransform1D instance.

Parameters:
tr1 - The first math transform.
tr2 - The second math transform.
tr3 - The third math transform.
Returns:
The concatenated transform.
Since:
3.14

getSourceDimensions

public final int getSourceDimensions()
Gets the dimension of input points.

Specified by:
getSourceDimensions in interface MathTransform
Specified by:
getSourceDimensions in class AbstractMathTransform

getTargetDimensions

public final int getTargetDimensions()
Gets the dimension of output points.

Specified by:
getTargetDimensions in interface MathTransform
Specified by:
getTargetDimensions in class AbstractMathTransform

getStepCount

public final int getStepCount()
Returns the number of single math transform steps. Nested concatenated transforms (if any) are explored recursively in order to get the count of single (non-nested) transforms.

Returns:
The number of single transform steps.
Since:
2.5

getSteps

public final List<MathTransform> getSteps()
Returns all concatenated transforms. The returned list contains only single transforms, i.e. all nested concatenated transforms (if any) have been expanded.

The size of the returned list is equals to the value returned by getStepCount().

Returns:
All single math transforms performed by this concatenated transform.
Since:
3.00

getParameterDescriptors

public ParameterDescriptorGroup getParameterDescriptors()
Returns the parameter descriptor, or null if none. This method performs the same special check than getParameterValues().

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

getParameterValues

public ParameterValueGroup getParameterValues()
Returns the parameter values, or null if none. Concatenated transforms usually have no parameters; instead the parameters of the individual components (transform1 and transform2) need to be inspected. However map projections in Geotk are implemented as (normalizenon-linear kerneldenormalize) tuples. This method detects such concatenation chains in order to return the parameter values that describe the projection as a whole.

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()

transform

public DirectPosition transform(DirectPosition ptSrc,
                                DirectPosition ptDst)
                         throws TransformException
Transforms the specified ptSrc and stores the result in ptDst.

Specified by:
transform in interface MathTransform
Overrides:
transform in class AbstractMathTransform
Parameters:
ptSrc - the coordinate point to be transformed.
ptDst - the coordinate point that stores the result of transforming ptSrc, or null.
Returns:
the coordinate point after transforming ptSrc and storing the result in ptDst, or a newly created point if ptDst was null.
Throws:
TransformException - If transform1 or transform2 failed.

transform

protected void transform(double[] srcPts,
                         int srcOff,
                         double[] dstPts,
                         int dstOff)
                  throws TransformException
Transforms a single coordinates in a list of ordinal values.

Specified by:
transform in class AbstractMathTransform
Parameters:
srcPts - The array containing the source point coordinates.
srcOff - The offset to the point to be transformed in the source array.
dstPts - the array into which the transformed point coordinate are returned. May be the same than srcPts.
dstOff - The offset to the location of the transformed point that is stored in the destination array.
Throws:
TransformException - If transform1 or transform2 failed.

transform

public void transform(double[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
               throws TransformException
Transforms many coordinates in a list of ordinal values. The source points are first transformed by transform1, then the intermediate points are transformed by transform2. The transformations are performed without intermediate buffer if it can be avoided.

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.
Throws:
TransformException - If transform1 or transform2 failed.

transform

public void transform(float[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
               throws TransformException
Transforms many coordinates in a list of ordinal values. The source points are first transformed by transform1, then the intermediate points are transformed by transform2. An intermediate buffer of type double[] for intermediate results is used for reducing rounding errors.

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.
Throws:
TransformException - If transform1 or transform2 failed.

transform

public void transform(double[] srcPts,
                      int srcOff,
                      float[] dstPts,
                      int dstOff,
                      int numPts)
               throws TransformException
Transforms many coordinates in a list of ordinal values. The source points are first transformed by transform1, then the intermediate points are transformed by transform2. An intermediate buffer of type double[] for intermediate results is used for reducing rounding errors.

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.
Throws:
TransformException - If transform1 or transform2 failed.

transform

public void transform(float[] srcPts,
                      int srcOff,
                      double[] dstPts,
                      int dstOff,
                      int numPts)
               throws TransformException
Transforms many coordinates in a list of ordinal values. The source points are first transformed by transform1, then the intermediate points are transformed by transform2. The transformations are performed without intermediate buffer if it can be avoided.

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.
Throws:
TransformException - If transform1 or transform2 failed.

inverse

public MathTransform inverse()
                      throws NoninvertibleTransformException
Creates the inverse transform of this object.

Specified by:
inverse in interface MathTransform
Overrides:
inverse in class AbstractMathTransform
Throws:
NoninvertibleTransformException

derivative

public Matrix derivative(Point2D point)
                  throws TransformException
Gets the derivative of this transform at a point. This method delegates to the derivative(DirectPosition) method because the transformation steps transform1 and transform2 may not be instances of MathTransform2D.

Overrides:
derivative in class AbstractMathTransform
Parameters:
point - The coordinate point where to evaluate the derivative.
Returns:
The derivative at the specified point as a 2×2 matrix.
Throws:
TransformException - if the derivative can't be evaluated at the specified point.
See Also:
MathTransform2D.derivative(Point2D)

derivative

public Matrix derivative(DirectPosition point)
                  throws TransformException
Gets the derivative of this transform at a point.

Specified by:
derivative in interface MathTransform
Overrides:
derivative in class AbstractMathTransform
Parameters:
point - The coordinate point where to evaluate the derivative.
Returns:
The derivative at the specified point (never null).
Throws:
TransformException - if the derivative can't be evaluated at the specified point.

isIdentity

public final boolean isIdentity()
Tests whether this transform does not move any points. Default implementation check if the two transforms are identity.

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

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 final boolean equals(Object object,
                            ComparisonMode mode)
Compares the specified object with this math transform 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.

formatWKT

public String formatWKT(Formatter formatter)
Formats the inner part of a Well Known Text (WKT) element.

Specified by:
formatWKT in interface Formattable
Overrides:
formatWKT in class AbstractMathTransform
Parameters:
formatter - The formatter to use.
Returns:
The WKT element name, which is "CONCAT_MT".
See Also:
FormattableObject.toWKT(), FormattableObject.toString()


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