Class CopyTransform
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.referencing.operation.transform.AbstractMathTransform
org.apache.sis.referencing.operation.transform.AbstractLinearTransform
org.apache.sis.referencing.operation.transform.CopyTransform
- All Implemented Interfaces:
Serializable,Parameterized,LinearTransform,LenientComparable,org.opengis.referencing.operation.MathTransform,org.opengis.referencing.operation.Matrix
A transform which copy the coordinates in the source array to different locations in the target array.
This is a special case of
ProjectiveTransform where the matrix coefficients are zero everywhere,
except one value by row which is set to 1 and is not the translation term. Those transforms are used for
swapping axis order, or selecting the dimension to retain when converting from a large dimension to a smaller one.
This transform has the particularity to involve no floating point operation - just copy of values with no change -
and consequently works well with NaN coordinate values.
We do not provide a subclass for the 2D case because our policy is to use
an AffineTransform for every 2D affine conversions.
- Since:
- 0.5
- Version:
- 1.1
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
AbstractMathTransform.Inverse -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int[]The indices of coordinates to copy in the source array.private static final longSerial number for inter-operability with different versions.private final intThe dimension of source coordinates.Fields inherited from class org.apache.sis.referencing.operation.transform.AbstractLinearTransform
inverseFields inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
MAXIMUM_BUFFER_SIZE, MAXIMUM_FAILURES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intComputes a hash value for this transform.(package private) static CopyTransformcreate(org.opengis.referencing.operation.Matrix matrix) If a transform can be created from the given matrix, returns it.(package private) final LinearTransformInvoked byAbstractLinearTransform.inverse()the first time that the inverse transform needs to be computed.org.opengis.referencing.operation.Matrixderivative(org.opengis.geometry.DirectPosition point) Gets the derivative of this transform at a point.protected booleanequalsSameClass(Object object) Compares this math transform with an object which is known to be an instance of the same class.doublegetElement(int row, int column) Returns the matrix element at the given row and column.intGets the dimension of input points.intGets the dimension of output points.booleanisAffine()Returnstrueif this transform is affine.booleanTests whether this transform does not move any points.org.opengis.referencing.operation.Matrixtransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate) Transforms a single position in a list of coordinate values, and optionally returns the derivative at that location.voidtransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.voidtransform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.voidtransform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.voidtransform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.Methods inherited from class org.apache.sis.referencing.operation.transform.AbstractLinearTransform
clone, deltaTransform, equals, getMatrix, getNumCol, getNumRow, getParameterDescriptors, getParameterValues, inverse, setElement, toString, tryConcatenateMethods inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
beforeFormat, equals, formatTo, getContextualParameters, getDomain, hashCode, isInverseEquals, mismatchedDimension, transformMethods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toWKTMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opengis.referencing.operation.MathTransform
toWKT, transform
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
srcDim
private final int srcDimThe dimension of source coordinates. Must be greater than the highest value inindices. -
indices
private final int[] indicesThe indices of coordinates to copy in the source array. The length of this array is the target dimension.
-
-
Constructor Details
-
CopyTransform
CopyTransform(int srcDim, int[] indices) Creates a new transform.- Parameters:
srcDim- the dimension of source coordinates. Must be greater than the highest value inindices.indices- the indices of coordinates to copy in the source array. The length of this array is the target dimension.
-
-
Method Details
-
create
If a transform can be created from the given matrix, returns it. Otherwise returnsnull. -
getSourceDimensions
public int getSourceDimensions()Gets the dimension of input points.- Specified by:
getSourceDimensionsin interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
getSourceDimensionsin classAbstractMathTransform- Returns:
- the number of dimensions of input points.
- See Also:
-
getTargetDimensions
public int getTargetDimensions()Gets the dimension of output points.- Specified by:
getTargetDimensionsin interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
getTargetDimensionsin classAbstractMathTransform- Returns:
- the number of dimensions of output points.
- See Also:
-
isAffine
public boolean isAffine()Returnstrueif this transform is affine.- Specified by:
isAffinein interfaceLinearTransform- Overrides:
isAffinein classAbstractLinearTransform- Returns:
trueif this transform is affine, orfalseotherwise.- See Also:
-
isIdentity
public boolean isIdentity()Tests whether this transform does not move any points.Note: this method should always returnsfalse, sinceMathTransforms.linear(…)should have created specialized implementations for identity cases. Nevertheless we perform the full check as a safety, in case someone instantiated this class directly instead of using a factory method.- Specified by:
isIdentityin interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
isIdentityin interfaceorg.opengis.referencing.operation.Matrix- Overrides:
isIdentityin classAbstractMathTransform
-
transform
public org.opengis.referencing.operation.Matrix transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate) Transforms a single position in a list of coordinate values, and optionally returns the derivative at that location.- Specified by:
transformin classAbstractMathTransform- Parameters:
srcPts- the array containing the source coordinates (cannot benull).srcOff- the offset to the point to be transformed in the source array.dstPts- the array into which the transformed coordinates is returned. May be the same thansrcPts. May benullif only the derivative matrix is desired.dstOff- the offset to the location of the transformed point that is stored in the destination array.derivate-truefor computing the derivative, orfalseif not needed.- Returns:
- the matrix of the transform derivative at the given source position,
or
nullif thederivateargument isfalse. - See Also:
-
transform
public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
transformin 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.
-
transform
public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
transformin 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.
-
transform
public void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
transformin 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.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 an array of floating point coordinates by this matrix.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
transformin 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.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.
-
getElement
public double getElement(int row, int column) Returns the matrix element at the given row and column.- Throws:
IndexOutOfBoundsException- ifrowis out of bounds.
-
derivative
public org.opengis.referencing.operation.Matrix derivative(org.opengis.geometry.DirectPosition point) Gets the derivative of this transform at a point. For a matrix transform, the derivative is the same everywhere.- Specified by:
derivativein interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
derivativein classAbstractMathTransform- Parameters:
point- ignored (can benull).- Returns:
- the derivative at the specified point (never
null).
-
createInverse
Invoked byAbstractLinearTransform.inverse()the first time that the inverse transform needs to be computed.- Overrides:
createInversein classAbstractLinearTransform
-
computeHashCode
protected int computeHashCode()Computes a hash value for this transform. This method is invoked byAbstractMathTransform.hashCode()when first needed.- Overrides:
computeHashCodein classAbstractMathTransform- Returns:
- the hash code value. This value may change between different execution of the Apache SIS library.
-
equalsSameClass
Compares this math transform with an object which is known to be an instance of the same class.- Specified by:
equalsSameClassin classAbstractLinearTransform- Parameters:
object- the object to compare with this transform.- Returns:
trueif the given object is considered equals to this math transform.
-