Class CopyTransform

All Implemented Interfaces:
Serializable, Parameterized, LinearTransform, LenientComparable, org.opengis.referencing.operation.MathTransform, org.opengis.referencing.operation.Matrix

final class CopyTransform extends AbstractLinearTransform
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
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serial number for inter-operability with different versions.
      See Also:
    • srcDim

      private final int srcDim
      The dimension of source coordinates. Must be greater than the highest value in indices.
    • indices

      private final int[] indices
      The 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 in indices.
      indices - the indices of coordinates to copy in the source array. The length of this array is the target dimension.
  • Method Details

    • create

      static CopyTransform create(org.opengis.referencing.operation.Matrix matrix)
      If a transform can be created from the given matrix, returns it. Otherwise returns null.
    • getSourceDimensions

      public int getSourceDimensions()
      Gets the dimension of input points.
      Specified by:
      getSourceDimensions in interface org.opengis.referencing.operation.MathTransform
      Specified by:
      getSourceDimensions in class AbstractMathTransform
      Returns:
      the number of dimensions of input points.
      See Also:
    • getTargetDimensions

      public int getTargetDimensions()
      Gets the dimension of output points.
      Specified by:
      getTargetDimensions in interface org.opengis.referencing.operation.MathTransform
      Specified by:
      getTargetDimensions in class AbstractMathTransform
      Returns:
      the number of dimensions of output points.
      See Also:
    • isAffine

      public boolean isAffine()
      Returns true if this transform is affine.
      Specified by:
      isAffine in interface LinearTransform
      Overrides:
      isAffine in class AbstractLinearTransform
      Returns:
      true if this transform is affine, or false otherwise.
      See Also:
    • isIdentity

      public boolean isIdentity()
      Tests whether this transform does not move any points.
      Note: this method should always returns false, since MathTransforms.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 interface org.opengis.referencing.operation.MathTransform
      Specified by:
      isIdentity in interface org.opengis.referencing.operation.Matrix
      Overrides:
      isIdentity in class AbstractMathTransform
    • 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 class AbstractMathTransform
      Parameters:
      srcPts - the array containing the source coordinates (cannot be null).
      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 than srcPts. May be null 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, or false if not needed.
      Returns:
      the matrix of the transform derivative at the given source position, or null if the derivate argument is false.
      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 interface org.opengis.referencing.operation.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.
    • 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 interface org.opengis.referencing.operation.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.
    • 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 interface org.opengis.referencing.operation.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.
    • 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 interface org.opengis.referencing.operation.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.
    • getElement

      public double getElement(int row, int column)
      Returns the matrix element at the given row and column.
      Throws:
      IndexOutOfBoundsException - if row 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 interface org.opengis.referencing.operation.MathTransform
      Overrides:
      derivative in class AbstractMathTransform
      Parameters:
      point - ignored (can be null).
      Returns:
      the derivative at the specified point (never null).
    • createInverse

      final LinearTransform createInverse()
      Invoked by AbstractLinearTransform.inverse() the first time that the inverse transform needs to be computed.
      Overrides:
      createInverse in class AbstractLinearTransform
    • 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 Apache SIS library.
    • equalsSameClass

      protected boolean equalsSameClass(Object object)
      Compares this math transform with an object which is known to be an instance of the same class.
      Specified by:
      equalsSameClass in class AbstractLinearTransform
      Parameters:
      object - the object to compare with this transform.
      Returns:
      true if the given object is considered equals to this math transform.