Class AbstractMathTransform2D
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.referencing.operation.transform.AbstractMathTransform
org.apache.sis.referencing.operation.transform.AbstractMathTransform2D
- All Implemented Interfaces:
Parameterized,LenientComparable,org.opengis.referencing.operation.MathTransform,org.opengis.referencing.operation.MathTransform2D
- Direct Known Subclasses:
LongitudeWraparound,NormalizedProjection,PoleRotation,ResamplingGrid,TransformAdapter2D,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 othertransform methods as well.
Immutability and thread safety
All Apache SIS implementations ofMathTransform2D 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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classBase class for implementation of inverse math transforms. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intNumber of input and output dimensions of allAbstractMathTransform2D, which is 2.Fields inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
MAXIMUM_BUFFER_SIZE, MAXIMUM_FAILURES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateTransformedShape(Shape shape) Transforms the specified shape.(package private) static ShapecreateTransformedShape(org.opengis.referencing.operation.MathTransform2D mt, Shape shape, AffineTransform preTransform, AffineTransform postTransform, boolean horizontal) Transforms a geometric shape.org.opengis.referencing.operation.Matrixderivative(Point2D point) Gets the derivative of this transform at a point.(package private) static org.opengis.referencing.operation.Matrixderivative(AbstractMathTransform tr, Point2D point) Implementation ofderivative(DirectPosition)shared by the inverse transform.final intReturns the dimension of input points, which is always 2.final intReturns the dimension of output points, which is always 2.org.opengis.referencing.operation.MathTransform2Dinverse()Returns the inverse transform of this object.Transforms the specifiedptSrcand stores the result inptDst.(package private) static Point2Dtransform(AbstractMathTransform tr, Point2D ptSrc, Point2D ptDst) Implementation oftransform(Point2D, Point2D)shared by the inverse transform.Methods inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
beforeFormat, computeHashCode, derivative, equals, equals, formatTo, getContextualParameters, getDomain, getParameterDescriptors, getParameterValues, hashCode, isIdentity, isInverseEquals, mismatchedDimension, transform, transform, transform, transform, transform, transform, tryConcatenateMethods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toString, toWKTMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opengis.referencing.operation.MathTransform
derivative, isIdentity, toWKT, transform, transform, transform, transform, transform
-
Field Details
-
DIMENSION
protected static final int DIMENSIONNumber of input and output dimensions of allAbstractMathTransform2D, 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:
getSourceDimensionsin interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
getSourceDimensionsin classAbstractMathTransform- 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:
getTargetDimensionsin interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
getTargetDimensionsin classAbstractMathTransform- 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 specifiedptSrcand stores the result inptDst. The default implementation invokesAbstractMathTransform.transform(double[], int, double[], int, boolean)using a temporary array of doubles.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform2D- Parameters:
ptSrc- the coordinate tuple to be transformed.ptDst- the coordinate tuple that stores the result of transformingptSrc, ornullif a new point shall be created.- Returns:
- the coordinate tuple after transforming
ptSrcand storing the result inptDst, or in a new point ifptDstwas null. - Throws:
org.opengis.referencing.operation.TransformException- if the point cannot be transformed.- See Also:
-
MathTransform2D.transform(Point2D, Point2D)
-
transform
static Point2D transform(AbstractMathTransform tr, Point2D ptSrc, Point2D ptDst) throws org.opengis.referencing.operation.TransformException Implementation oftransform(Point2D, Point2D)shared by the inverse transform.- Throws:
org.opengis.referencing.operation.TransformException
-
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 aPath2D, but may also be aLine2Dor aQuadCurve2Dif such simplification is possible.- Specified by:
createTransformedShapein interfaceorg.opengis.referencing.operation.MathTransform2D- Parameters:
shape- shape to transform.- Returns:
- transformed shape, or
shapeif this transform is the identity transform. - Throws:
org.opengis.referencing.operation.TransformException- if a transform failed.
-
createTransformedShape
static Shape createTransformedShape(org.opengis.referencing.operation.MathTransform2D mt, Shape shape, AffineTransform preTransform, AffineTransform postTransform, boolean horizontal) throws org.opengis.referencing.operation.TransformException Transforms a geometric shape. This method always copy transformed coordinates in a new object. The new object is often aPath2D, but may also be aLine2Dor aQuadCurve2Dif such simplification is possible.- Parameters:
mt- the math transform to use.shape- the geometric shape to transform.preTransform- an optional affine transform to apply before the transformation usingthis, ornullif none.postTransform- an optional affine transform to apply after the transformation usingthis, ornullif none.horizontal-truefor forcing parabolic equation.- Returns:
- the transformed geometric shape.
- Throws:
org.opengis.referencing.operation.TransformException- if a transformation 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:- Copy the coordinates in a temporary array and pass that array to the
AbstractMathTransform.transform(double[], int, double[], int, boolean)method, with thederivateboolean argument set totrue. - If the latter method returned a non-null matrix, returns that matrix.
Otherwise throws
TransformException.
- Specified by:
derivativein interfaceorg.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.
- Copy the coordinates in a temporary array and pass that array to the
-
derivative
static org.opengis.referencing.operation.Matrix derivative(AbstractMathTransform tr, Point2D point) throws org.opengis.referencing.operation.TransformException Implementation ofderivative(DirectPosition)shared by the inverse transform.- Throws:
org.opengis.referencing.operation.TransformException
-
inverse
public org.opengis.referencing.operation.MathTransform2D inverse() throws org.opengis.referencing.operation.NoninvertibleTransformExceptionReturns the inverse transform of this object. The default implementation returnsthisif this transform is an identity transform, or throws an exception otherwise. Subclasses should override this method.- Specified by:
inversein interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
inversein interfaceorg.opengis.referencing.operation.MathTransform2D- Overrides:
inversein classAbstractMathTransform- Throws:
org.opengis.referencing.operation.NoninvertibleTransformException
-