Class AbstractMathTransform2D

All Implemented Interfaces:
Parameterized, LenientComparable, org.opengis.referencing.operation.MathTransform, org.opengis.referencing.operation.MathTransform2D
Direct Known Subclasses:
NormalizedProjection, PoleRotation, ZonedGridSystem

public abstract class AbstractMathTransform2D extends AbstractMathTransform implements org.opengis.referencing.operation.MathTransform2D
Base class for math transforms that are known to be two-dimensional in all cases. Two-dimensional math transforms are not required to extend this class, however doing so may simplify their implementation.

The simplest way to implement this abstract class is to provide an implementation for the following methods only:

However, more performance may be gained by overriding the other transform methods as well.

Immutability and thread safety

All Apache SIS implementations of MathTransform2D are immutable and thread-safe. It is highly recommended that third-party implementations be immutable and thread-safe too. This means that unless otherwise noted in the javadoc, MathTransform2D instances can be shared by many objects and passed between threads without synchronization.

Serialization

MathTransform2D may or may not be serializable, at implementation choices. Most Apache SIS implementations are serializable, but the serialized objects are not guaranteed to be compatible with future SIS versions. Serialization should be used only for short term storage or RMI between applications running the same SIS version.
Since:
0.5
Version:
1.2
Author:
Martin Desruisseaux (Geomatys)
  • Field Details

    • DIMENSION

      protected static final int DIMENSION
      Number of input and output dimensions of all AbstractMathTransform2D, which is 2. We define this constant for clarity only; its value shall not be modified.
      Purpose: this is used for making clearer in the code when the literal 2 stands for the number of dimensions. It reduces confusion in contexts where the literal 2 also appear for other meanings than the number of dimensions.
      Since:
      1.2
      See Also:
  • Constructor Details

    • AbstractMathTransform2D

      protected AbstractMathTransform2D()
      Constructor for subclasses.
  • Method Details

    • getSourceDimensions

      public final int getSourceDimensions()
      Returns the dimension of input points, which is always 2.
      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 final int getTargetDimensions()
      Returns the dimension of output points, which is always 2.
      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:
    • transform

      public Point2D transform(Point2D ptSrc, Point2D ptDst) throws org.opengis.referencing.operation.TransformException
      Transforms the specified ptSrc and stores the result in ptDst. The default implementation invokes AbstractMathTransform.transform(double[], int, double[], int, boolean) using a temporary array of doubles.
      Specified by:
      transform in interface org.opengis.referencing.operation.MathTransform2D
      Parameters:
      ptSrc - the coordinate tuple to be transformed.
      ptDst - the coordinate tuple that stores the result of transforming ptSrc, or null if a new point shall be created.
      Returns:
      the coordinate tuple after transforming ptSrc and storing the result in ptDst, or in a new point if ptDst was null.
      Throws:
      org.opengis.referencing.operation.TransformException - if the point cannot be transformed.
      See Also:
      • MathTransform2D.transform(Point2D, Point2D)
    • createTransformedShape

      public Shape createTransformedShape(Shape shape) throws org.opengis.referencing.operation.TransformException
      Transforms the specified shape. The default implementation computes quadratic curves using three points for each line segment in the shape. The returned object is often a Path2D, but may also be a Line2D or a QuadCurve2D if such simplification is possible.
      Specified by:
      createTransformedShape in interface org.opengis.referencing.operation.MathTransform2D
      Parameters:
      shape - shape to transform.
      Returns:
      transformed shape, or shape if this transform is the identity transform.
      Throws:
      org.opengis.referencing.operation.TransformException - if a transform failed.
    • derivative

      public org.opengis.referencing.operation.Matrix derivative(Point2D point) throws org.opengis.referencing.operation.TransformException
      Gets the derivative of this transform at a point. The default implementation performs the following steps:
      Specified by:
      derivative in interface org.opengis.referencing.operation.MathTransform2D
      Parameters:
      point - the coordinate tuple where to evaluate the derivative.
      Returns:
      the derivative at the specified point as a 2×2 matrix.
      Throws:
      org.opengis.referencing.operation.TransformException - if the derivative cannot be evaluated at the specified point.
    • inverse

      public org.opengis.referencing.operation.MathTransform2D inverse() throws org.opengis.referencing.operation.NoninvertibleTransformException
      Returns the inverse transform of this object. The default implementation returns this if this transform is an identity transform, or throws an exception otherwise. Subclasses should override this method.
      Specified by:
      inverse in interface org.opengis.referencing.operation.MathTransform
      Specified by:
      inverse in interface org.opengis.referencing.operation.MathTransform2D
      Overrides:
      inverse in class AbstractMathTransform
      Throws:
      org.opengis.referencing.operation.NoninvertibleTransformException