Class AbstractMathTransform

    • Constructor Detail

      • AbstractMathTransform

        protected AbstractMathTransform()
        Constructs a math transform.
    • Method Detail

      • getName

        public String getName()
        Returns a name for this math transform (never null). This convenience methods returns the name of the parameter descriptors if any, or the short class name otherwise.
        Returns:
        A name for this math transform (never null).
        Since:
        2.5
      • getSourceDimensions

        public abstract int getSourceDimensions()
        Gets the dimension of input points.
        Specified by:
        getSourceDimensions in interface MathTransform
        Returns:
        The dimension of input points.
      • getTargetDimensions

        public abstract int getTargetDimensions()
        Gets the dimension of output points.
        Specified by:
        getTargetDimensions in interface MathTransform
        Returns:
        The dimension of output points.
      • getParameterDescriptors

        public ParameterDescriptorGroup getParameterDescriptors()
        Returns the parameter descriptors for this math transform, or null if unknow. This method is similar to OperationMethod.getParameters(), except that MathTransform returns parameters in standard units (usually meters or decimal degrees).
        Returns:
        The parameter descriptors for this math transform, or null.
        See Also:
        OperationMethod.getParameters()
      • getParameterValues

        public ParameterValueGroup getParameterValues()
        Returns the parameter values for this math transform, or null if unknow. This method is similar to Operation.getParameterValues(), except that MathTransform returns parameters in standard units (usually meters or decimal degrees). Since this method returns a copy of the parameter values, any change to a value will have no effect on this math transform.
        Returns:
        A copy of the parameter values for this math transform, or null.
        See Also:
        Operation.getParameterValues()
      • isIdentity

        public boolean isIdentity()
        Tests whether this transform does not move any points. The default implementation always returns false.
        Specified by:
        isIdentity in interface MathTransform
        Returns:
        true if this MathTransform 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. The default implementation invokes MathTransform.transform(double[],int,double[],int,int) using a temporary array of doubles.
        Specified by:
        transform in interface MathTransform
        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 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 to this.
      • transform

        public void transform​(double[] srcPts,
                              int srcOff,
                              float[] dstPts,
                              int dstOff,
                              int numPts)
                       throws TransformException
        Transforms a list of coordinate point ordinal values. The default implementation invokes MathTransform.transform(double[],int,double[],int,int) using a temporary array of doubles.
        Specified by:
        transform in interface MathTransform
        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 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 to this.
        Since:
        2.5
      • transform

        public void transform​(float[] srcPts,
                              int srcOff,
                              double[] dstPts,
                              int dstOff,
                              int numPts)
                       throws TransformException
        Transforms a list of coordinate point ordinal values. The default implementation delegates to MathTransform.transform(double[],int,double[],int,int).
        Specified by:
        transform in interface MathTransform
        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 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 to this.
        Since:
        2.5
      • hashCode

        public int hashCode()
        Returns a hash value for this transform.
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(Object object)
        Compares the specified object with this math transform for equality. The default implementation checks if object is an instance of the same class than this and use the same parameter descriptor. Subclasses should override this method in order to compare internal fields.
        Overrides:
        equals in class Object
        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.
      • needCopy

        protected static boolean needCopy​(int srcOff,
                                          int dimSource,
                                          int dstOff,
                                          int dimTarget,
                                          int numPts)
        Checks if source coordinates need to be copied before to apply the transformation. This convenience method is provided for transform(...) method implementation. This method make the following assumptions:

        • Coordinates will be iterated from lower index to upper index.
        • Coordinates are read and writen in shrunk. For example (longitude,latitude,height) values for one coordinate are read together, and the transformed (x,y,z) values are written together only after.

        However, this method does not assumes that source and target dimension are the same (in the special case where source and target dimension are always the same, a simplier and more efficient check is possible). The following example prepares a transformation from 2 dimensional points to three dimensional points:

         public void transform(double[] srcPts, int srcOff,
                               double[] dstPts, int dstOff, int numPts)
         {
             if (srcPts==dstPts && needCopy(srcOff, 2, dstOff, 3, numPts) {
                 final double[] old = srcPts;
                 srcPts = new double[numPts*2];
                 System.arraycopy(old, srcOff, srcPts, 0, srcPts.length);
                 srcOff = 0;
             }
         }
        This method is for internal usage by the referencing module only. Do not use! It will be replaced by a different mechanism in a future GeoTools version.
        Parameters:
        srcOff - The offset in the source coordinate array.
        dimSource - The dimension of input points.
        dstOff - The offset in the destination coordinate array.
        dimTarget - The dimension of output points.
        numPts - The number of points to transform.
        Returns:
        true if the source coordinates should be copied before to apply the transformation in order to avoid an overlap with the destination array.
      • rollLongitude

        protected static double rollLongitude​(double x)
        Ensures that the specified longitude stay within ±π radians. This method is typically invoked after geographic coordinates are transformed. This method may add or substract some amount of 2π radians to x.
        Parameters:
        x - The longitude in radians.
        Returns:
        The longitude in the range ±π radians.
      • normalizeAngle

        protected static double normalizeAngle​(double x)
        Ensures that the specified longitude stay within 0 and {code}PI{code}.
        Parameters:
        x - An angle
        Returns:
        The normalized angle