Class AbstractMathTransform

  • Direct Known Subclasses:
    AbstractMathTransform.Inverse, VerticalTransform

    public abstract class AbstractMathTransform
    extends java.lang.Object
    Provides a default implementation for most methods required by the {MathTransform} interface. AbstractMathTransform provides a convenient base class from which other transform classes can be easily derived. In addition, AbstractMathTransform implements methods required by the {MathTransform2D} interface, but does not implements MathTransform2D. Subclasses must declare implements MathTransform2D themselves if they know to maps two-dimensional coordinate systems. For more information, please check out the tutorial.
    Since:
    3.9.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  AbstractMathTransform.Inverse
      Default implementation for inverse math transform.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractMathTransform()
      Constructs a math transform.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract int getSourceDimensions()
      Gets the dimension of input points.
      abstract int getTargetDimensions()
      Gets the dimension of output points.
      int hashCode()
      Returns a hash value for this transform.
      boolean isIdentity()
      Tests whether this transform does not move any points.
      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.
      protected static double rollLongitude​(double x)
      Ensures that the specified longitude stay within ±π radians.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractMathTransform

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

      • getSourceDimensions

        public abstract int getSourceDimensions()
        Gets the dimension of input points.
      • getTargetDimensions

        public abstract int getTargetDimensions()
        Gets the dimension of output points.
      • isIdentity

        public boolean isIdentity()
        Tests whether this transform does not move any points. The default implementation always returns false.
      • hashCode

        public int hashCode()
        Returns a hash value for this transform.
        Overrides:
        hashCode in class java.lang.Object
      • 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 subtract some amount of 2π radians to x.
        Parameters:
        x - The longitude in radians.
        Returns:
        The longitude in the range ±π radians.