org.geotoolkit.referencing.operation.transform
Class PassThroughTransform

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

@Immutable
public class PassThroughTransform
extends AbstractMathTransform
implements Serializable

Transform which passes through a subset of ordinates to another transform. This allows transforms to operate on a subset of ordinates. For example giving (latitude, longitude, height) coordinates, PassThroughTransform can convert the height values from feet to meters without affecting the latitude and longitude values.

Since:
1.2
Version:
3.18
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
DimensionFilter, 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
protected  int firstAffectedOrdinate
          Index of the first affected ordinate.
protected  int numTrailingOrdinates
          Number of unaffected ordinates after the affected ones.
protected  MathTransform subTransform
          The sub transform.
 
Fields inherited from class FormattableObject
EPSG, GEOTIFF, INTERNAL, OGC, SINGLE_LINE
 
Constructor Summary
protected PassThroughTransform(int firstAffectedOrdinate, MathTransform subTransform, int numTrailingOrdinates)
          Creates a pass through transform.
 
Method Summary
protected  int computeHashCode()
          Computes a hash value for this transform.
static MathTransform create(int firstAffectedOrdinate, MathTransform subTransform, int numTrailingOrdinates)
          Creates a transform which passes through a subset of ordinates to another transform.
 Matrix derivative(DirectPosition 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.
 int[] getModifiedCoordinates()
          Ordered sequence of positive integers defining the positions in a coordinate tuple of the coordinates affected by this pass-through transform.
 int getSourceDimensions()
          Gets the dimension of input points.
 MathTransform getSubTransform()
          Returns the sub transform.
 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.
protected  void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff)
          Transforms a single coordinate 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, derivative, ensureNonNull, equals, getName, getParameterDescriptors, getParameterValues, hashCode, rollLongitude, transform, 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

firstAffectedOrdinate

protected final int firstAffectedOrdinate
Index of the first affected ordinate.


numTrailingOrdinates

protected final int numTrailingOrdinates
Number of unaffected ordinates after the affected ones. Always 0 when used through the strict OpenGIS API.


subTransform

protected final MathTransform subTransform
The sub transform.

See Also:
getSubTransform()
Constructor Detail

PassThroughTransform

protected PassThroughTransform(int firstAffectedOrdinate,
                               MathTransform subTransform,
                               int numTrailingOrdinates)
Creates a pass through transform.

Parameters:
firstAffectedOrdinate - Index of the first affected ordinate.
subTransform - The sub transform.
numTrailingOrdinates - Number of trailing ordinates to pass through.
See Also:
create(int, org.opengis.referencing.operation.MathTransform, int)
Method Detail

create

public static MathTransform create(int firstAffectedOrdinate,
                                   MathTransform subTransform,
                                   int numTrailingOrdinates)
Creates a transform which passes through a subset of ordinates to another transform. This method returns a transform having the following dimensions:
Source: firstAffectedOrdinate + subTransform.getSourceDimensions() + numTrailingOrdinates
Target: firstAffectedOrdinate + subTransform.getTargetDimensions() + numTrailingOrdinates
Affected ordinates will range from firstAffectedOrdinate inclusive to dimTarget - numTrailingOrdinates exclusive.

Parameters:
firstAffectedOrdinate - Index of the first affected ordinate.
subTransform - The sub transform.
numTrailingOrdinates - Number of trailing ordinates to pass through.
Returns:
A pass through transform.

getSubTransform

public final MathTransform getSubTransform()
Returns the sub transform.

Returns:
The sub transform.
Since:
2.2

getModifiedCoordinates

public final int[] getModifiedCoordinates()
Ordered sequence of positive integers defining the positions in a coordinate tuple of the coordinates affected by this pass-through transform. The returned index are for source coordinates.

Returns:
The modified coordinates.

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

isIdentity

public boolean isIdentity()
Tests whether this transform does not move any points.

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

transform

protected void transform(double[] srcPts,
                         int srcOff,
                         double[] dstPts,
                         int dstOff)
                  throws TransformException
Transforms a single coordinate 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 the sub-transform 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.

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 the sub-transform 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.

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 the sub-transform 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.

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 the sub-transform 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.

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 the sub-transform failed.

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.

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

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 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 "PASSTHROUGH_MT".
See Also:
FormattableObject.toWKT(), FormattableObject.toString()
TODO:
The numTrailingOrdinates parameter is not part of OpenGIS specification. We should returns a more complex WKT when numTrailingOrdinates != 0, using an affine transform to change the coordinates order.


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