Class PassThroughTransform
- Object
-
- Formattable
-
- AbstractMathTransform
-
- PassThroughTransform
-
- All Implemented Interfaces:
Serializable
,MathTransform
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, if you have (latitude,longitude,height) coordinates, then you may wish to convert the height values from feet to meters without affecting the latitude and longitude values.- Since:
- 2.0
- Author:
- Martin Desruisseaux (IRD)
- See Also:
DimensionFilter
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class AbstractMathTransform
AbstractMathTransform.Inverse
-
-
Field Summary
Fields Modifier and Type Field Description 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 Formattable
SINGLE_LINE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PassThroughTransform(int firstAffectedOrdinate, MathTransform subTransform, int numTrailingOrdinates)
Create a pass through transform.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MathTransform
create(int firstAffectedOrdinate, MathTransform subTransform, int numTrailingOrdinates)
Creates a transform which passes through a subset of ordinates to another transform.Matrix
derivative(Position point)
Gets the derivative of this transform at a point.boolean
equals(Object object)
Compares the specified object with this math transform for equality.protected String
formatWKT(Formatter formatter)
Format 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.int
hashCode()
Returns a hash value for this transform.MathTransform
inverse()
Creates the inverse transform of this object.boolean
isIdentity()
Tests whether this transform does not move any points.void
transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
Transforms a list of coordinate point ordinal values.void
transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
Transforms a list of coordinate point ordinal values.-
Methods inherited from class AbstractMathTransform
createTransformedShape, derivative, ensureNonNull, getName, getParameterDescriptors, getParameterValues, needCopy, normalizeAngle, rollLongitude, transform, transform, transform, transform
-
Methods inherited from class Formattable
cleanupThreadLocals, toString, toWKT, toWKT, toWKT, toWKT
-
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)
Create a pass through transform.- Parameters:
firstAffectedOrdinate
- Index of the first affected ordinate.subTransform
- The sub transform.numTrailingOrdinates
- Number of trailing ordinates to pass through. Affected ordinates will range fromfirstAffectedOrdinate
inclusive todimTarget-numTrailingOrdinates
exclusive.
-
-
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 allows transforms to operate on a subset of ordinates. For example, if you have (latitidue,longitude,height) coordinates, then you may wish to convert the height values from feet to meters without affecting the latitude and longitude values.- Parameters:
firstAffectedOrdinate
- Index of the first affected ordinate.subTransform
- The sub transform.numTrailingOrdinates
- Number of trailing ordinates to pass through. Affected ordinates will range fromfirstAffectedOrdinate
inclusive todimTarget-numTrailingOrdinates
exclusive.- Returns:
- A pass through transform with the following dimensions:
Source: firstAffectedOrdinate + subTransform.getSourceDimensions() + numTrailingOrdinates Target: firstAffectedOrdinate + subTransform.getTargetDimensions() + numTrailingOrdinates
-
getSubTransform
public MathTransform getSubTransform()
Returns the sub transform.- Returns:
- The sub transform.
- Since:
- 2.2
-
getModifiedCoordinates
public 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 int getSourceDimensions()
Gets the dimension of input points.- Specified by:
getSourceDimensions
in interfaceMathTransform
- Specified by:
getSourceDimensions
in classAbstractMathTransform
- Returns:
- The dimension of input points.
-
getTargetDimensions
public int getTargetDimensions()
Gets the dimension of output points.- Specified by:
getTargetDimensions
in interfaceMathTransform
- Specified by:
getTargetDimensions
in classAbstractMathTransform
- Returns:
- The dimension of output points.
-
isIdentity
public boolean isIdentity()
Tests whether this transform does not move any points.- Specified by:
isIdentity
in interfaceMathTransform
- Overrides:
isIdentity
in classAbstractMathTransform
- Returns:
true
if thisMathTransform
is an identity transform;false
otherwise.
-
transform
public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) throws TransformException
Transforms a list of coordinate point ordinal values.- Specified by:
transform
in interfaceMathTransform
- Overrides:
transform
in classAbstractMathTransform
- 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 thansrcPts
.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 a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform tothis
.
-
transform
public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException
Transforms a list of coordinate point ordinal values.- Specified by:
transform
in interfaceMathTransform
- 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 thansrcPts
.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 a point can't be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with NaN values, continue and throw the exception only at end. Implementations that fall in the later case should set the last completed transform tothis
.
-
derivative
public Matrix derivative(Position point) throws TransformException
Gets the derivative of this transform at a point.- Specified by:
derivative
in interfaceMathTransform
- Overrides:
derivative
in classAbstractMathTransform
- 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 interfaceMathTransform
- Overrides:
inverse
in classAbstractMathTransform
- Returns:
- The inverse transform.
- Throws:
NoninvertibleTransformException
- if the transform can't be inversed.
-
hashCode
public int hashCode()
Returns a hash value for this transform. This value need not remain consistent between different implementations of the same class.- Overrides:
hashCode
in classAbstractMathTransform
-
equals
public boolean equals(Object object)
Compares the specified object with this math transform for equality.- Overrides:
equals
in classAbstractMathTransform
- Parameters:
object
- The object to compare with this transform.- 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
protected String formatWKT(Formatter formatter)
Format the inner part of a Well Known Text (WKT) element.- Overrides:
formatWKT
in classAbstractMathTransform
- Parameters:
formatter
- The formatter to use.- Returns:
- The WKT element name.
- See Also:
Formattable.toWKT()
,Formattable.toString()
-
-