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 long
Serial number for inter-operability with different versions.private final int
The dimension of source coordinates.Fields inherited from class org.apache.sis.referencing.operation.transform.AbstractLinearTransform
inverse
Fields inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
MAXIMUM_BUFFER_SIZE, MAXIMUM_FAILURES
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Computes a hash value for this transform.(package private) static CopyTransform
create
(org.opengis.referencing.operation.Matrix matrix) If a transform can be created from the given matrix, returns it.(package private) final LinearTransform
Invoked byAbstractLinearTransform.inverse()
the first time that the inverse transform needs to be computed.org.opengis.referencing.operation.Matrix
derivative
(org.opengis.geometry.DirectPosition point) Gets the derivative of this transform at a point.protected boolean
equalsSameClass
(Object object) Compares this math transform with an object which is known to be an instance of the same class.double
getElement
(int row, int column) Returns the matrix element at the given row and column.int
Gets the dimension of input points.int
Gets the dimension of output points.boolean
isAffine()
Returnstrue
if this transform is affine.boolean
Tests whether this transform does not move any points.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.void
transform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.void
transform
(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.void
transform
(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms an array of floating point coordinates by this matrix.void
transform
(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, tryConcatenate
Methods inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
beforeFormat, equals, formatTo, getContextualParameters, getDomain, hashCode, isInverseEquals, mismatchedDimension, transform
Methods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toWKT
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:
getSourceDimensions
in interfaceorg.opengis.referencing.operation.MathTransform
- Specified by:
getSourceDimensions
in classAbstractMathTransform
- Returns:
- the number of dimensions of input points.
- See Also:
-
getTargetDimensions
public int getTargetDimensions()Gets the dimension of output points.- Specified by:
getTargetDimensions
in interfaceorg.opengis.referencing.operation.MathTransform
- Specified by:
getTargetDimensions
in classAbstractMathTransform
- Returns:
- the number of dimensions of output points.
- See Also:
-
isAffine
public boolean isAffine()Returnstrue
if this transform is affine.- Specified by:
isAffine
in interfaceLinearTransform
- Overrides:
isAffine
in classAbstractLinearTransform
- Returns:
true
if this transform is affine, orfalse
otherwise.- 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:
isIdentity
in interfaceorg.opengis.referencing.operation.MathTransform
- Specified by:
isIdentity
in interfaceorg.opengis.referencing.operation.Matrix
- Overrides:
isIdentity
in 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:
transform
in 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 benull
if only the derivative matrix is desired.dstOff
- the offset to the location of the transformed point that is stored in the destination array.derivate
-true
for computing the derivative, orfalse
if not needed.- Returns:
- the matrix of the transform derivative at the given source position,
or
null
if thederivate
argument 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:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- 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.
-
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:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- 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.
-
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:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- 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.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:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- 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.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
- ifrow
is 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:
derivative
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
derivative
in 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:
createInverse
in classAbstractLinearTransform
-
computeHashCode
protected int computeHashCode()Computes a hash value for this transform. This method is invoked byAbstractMathTransform.hashCode()
when first needed.- Overrides:
computeHashCode
in 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:
equalsSameClass
in classAbstractLinearTransform
- Parameters:
object
- the object to compare with this transform.- Returns:
true
if the given object is considered equals to this math transform.
-