| java.lang.Object org.geotools.referencing.wkt.Formattable org.geotools.referencing.operation.transform.AbstractMathTransform
All known Subclasses: org.geotools.referencing.operation.transform.MolodenskiTransform, org.geotools.referencing.operation.transform.LogarithmicTransform1D, org.geotools.referencing.operation.projection.MapProjection, org.geotools.referencing.operation.transform.ExponentialTransform1D, org.geotools.referencing.operation.transform.LinearTransform1D, org.geotools.referencing.operation.transform.IdentityTransform, org.geotools.referencing.operation.transform.NADCONTransform, org.geotools.referencing.operation.transform.ProjectiveTransform, org.geotools.referencing.operation.builder.LocalizationGridTransform2D, org.geotools.referencing.operation.transform.GeocentricTransform, org.geotools.referencing.operation.transform.PassThroughTransform, org.geotools.referencing.operation.transform.WarpTransform2D, org.geotools.referencing.operation.transform.ConcatenatedTransform, org.geotools.referencing.operation.builder.RubberSheetTransform, org.geotools.referencing.operation.transform.VerticalTransform,
AbstractMathTransform | abstract public class AbstractMathTransform extends Formattable implements MathTransform(Code) | | 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
themself if they know to maps two-dimensional coordinate systems.
since: 2.0 version: $Id: AbstractMathTransform.java 24925 2007-03-27 20:12:08Z jgarnett $ author: Martin Desruisseaux |
Method Summary | |
MathTransform | concatenate(MathTransform other, boolean applyOtherFirst) Concatenates in an optimized way a
MathTransform
other to this
MathTransform . | public Shape | createTransformedShape(Shape shape) Transform the specified shape. | final Shape | createTransformedShape(Shape shape, AffineTransform preTransform, AffineTransform postTransform, int orientation) Transforms a geometric shape. | public Matrix | derivative(Point2D point) Gets the derivative of this transform at a point. | public Matrix | derivative(DirectPosition point) Gets the derivative of this transform at a point. | protected static void | ensureNonNull(String name, Object object) Makes sure that an argument is non-null. | public boolean | equals(Object object) Compares the specified object with this math transform for equality. | protected String | formatWKT(Formatter formatter) Format the inner part of a
Well
Known Text (WKT) element. | public ParameterDescriptorGroup | getParameterDescriptors() Returns the parameter descriptors for this math transform, or
null if unknow. | public ParameterValueGroup | getParameterValues() Returns the parameter values for this math transform, or
null if unknow. | abstract public int | getSourceDimensions() Gets the dimension of input points. | abstract public int | getTargetDimensions() Gets the dimension of output points. | public int | hashCode() Returns a hash value for this transform. | public MathTransform | inverse() Creates the inverse transform of this object.
The default implementation returns
this if this transform is an identity
transform, and throws a
NoninvertibleTransformException otherwise. | static Matrix | invert(Matrix matrix) Inverts the specified matrix in place. | public 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.
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.
| protected static double | rollLongitude(double x) Ensures that the specified longitude stay within ±π radians. | static GeneralMatrix | toGMatrix(Matrix matrix) Wraps the specified matrix in a Geotools implementation of
Matrix . | static XMatrix | toXMatrix(Matrix matrix) Wraps the specified matrix in a Geotools implementation of
Matrix . | public Point2D | transform(Point2D ptSrc, Point2D ptDst) Transforms the specified
ptSrc and stores the result in
ptDst .
The default implementation invokes
AbstractMathTransform.transform(double[],int,double[],int,int) using a temporary array of doubles.
Parameters: ptSrc - the specified coordinate point to be transformed. Parameters: ptDst - the specified coordinate point that stores the result of transforming ptSrc , or null . | public DirectPosition | transform(DirectPosition ptSrc, DirectPosition ptDst) Transforms the specified
ptSrc and stores the result
in
ptDst . | public void | transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms a list of coordinate point ordinal values. |
AbstractMathTransform | protected AbstractMathTransform()(Code) | | Constructs a math transform.
|
concatenate | MathTransform concatenate(MathTransform other, boolean applyOtherFirst)(Code) | | Concatenates in an optimized way a
MathTransform
other to this
MathTransform . A new math transform is created to perform the combined
transformation. The
applyOtherFirst value determine the transformation
order as bellow:
- If
applyOtherFirst is
true , then transforming a point
p by the combined transform is equivalent to first transforming
p by
other and then transforming the result by the
original transform
this .
- If
applyOtherFirst is
false , then transforming a point
p by the combined transform is equivalent to first transforming
p by the original transform
this and then transforming
the result by
other .
If no special optimization is available for the combined transform, then this method
returns
null . In the later case, the concatenation will be prepared by
DefaultMathTransformFactory using a generic
ConcatenatedTransform .
The default implementation always returns
null . This method is ought to be
overridden by subclasses capable of concatenating some combinaison of transforms in a
special way. Examples are
ExponentialTransform1D and
LogarithmicTransform1D .
Parameters: other - The math transform to apply. Parameters: applyOtherFirst - true if the transformation order is other followed by this , or false if the transformation order is this followed by other . The combined math transform, or null if no optimized combinedtransform is available. |
createTransformedShape | public Shape createTransformedShape(Shape shape) throws TransformException(Code) | | Transform the specified shape. The default implementation computes
quadratic curves using three points for each shape segments.
Parameters: shape - Shape to transform. Transformed shape, or shape if this transform is the identity transform. throws: IllegalStateException - if this transform doesn't map 2D coordinate systems. throws: TransformException - if a transform failed. See Also: MathTransform2D.createTransformedShape(Shape) |
createTransformedShape | final Shape createTransformedShape(Shape shape, AffineTransform preTransform, AffineTransform postTransform, int orientation) throws TransformException(Code) | | Transforms a geometric shape. This method always copy transformed coordinates in a new
object. The new object is usually a
GeneralPath , but may also be a
Line2D or a
QuadCurve2D if such simplification is possible.
Parameters: shape - The geometric shape to transform. Parameters: preTransform - An optional affine transform to apply before thetransformation using this , or null if none. Parameters: postTransform - An optional affine transform to apply after the transformationusing this , or null if none. Parameters: orientation - Base line of quadratic curves. Must beShapeUtilities.HORIZONTAL or ShapeUtilities.PARALLEL). The transformed geometric shape. throws: MismatchedDimensionException - if this transform doesn't is not two-dimensional. throws: TransformException - If a transformation failed. |
derivative | public Matrix derivative(Point2D point) throws TransformException(Code) | | Gets the derivative of this transform at a point. The default implementation always
throw an exception. Subclasses that implement the
MathTransform2D interface
should override this method. Other subclasses should override
AbstractMathTransform.derivative(DirectPosition) instead.
Parameters: point - The coordinate point where to evaluate the derivative. The derivative at the specified point as a 2×2 matrix. throws: MismatchedDimensionException - if the input dimension is not 2. throws: TransformException - if the derivative can't be evaluated at the specified point. See Also: MathTransform2D.derivative(Point2D) |
derivative | public Matrix derivative(DirectPosition point) throws TransformException(Code) | | Gets the derivative of this transform at a point. The default implementation
ensure that
point has a valid dimension. Next, it try to delegate
the work to an other method:
- If the input dimension is 2, then this method delegates the work to
AbstractMathTransform.derivative(Point2D) .
- If this object is an instance of
MathTransform1D , then this
method delegates the work to
MathTransform1D.derivative(double)derivative(double) .
Otherwise, a
TransformException is thrown.
Parameters: point - The coordinate point where to evaluate the derivative. The derivative at the specified point (never null ). throws: NullPointerException - if the derivative dependents on coordinateand point is null . throws: MismatchedDimensionException - if point doesn't havethe expected dimension. throws: TransformException - if the derivative can't be evaluated at thespecified point. |
ensureNonNull | protected static void ensureNonNull(String name, Object object) throws IllegalArgumentException(Code) | | Makes sure that an argument is non-null. This is a
convenience method for subclass constructors.
Parameters: name - Argument name. Parameters: object - User argument. throws: InvalidParameterValueException - if object is null. |
equals | public boolean equals(Object object)(Code) | | 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.
|
formatWKT | protected String formatWKT(Formatter formatter)(Code) | | Format the inner part of a
Well
Known Text (WKT) element. The default implementation formats all parameter values
returned by
AbstractMathTransform.getParameterValues . The parameter group name is used as the math
transform name.
Parameters: formatter - The formatter to use. The WKT element name, which is "PARAM_MT" in the default implementation. |
getParameterDescriptors | public ParameterDescriptorGroup getParameterDescriptors()(Code) | | 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
or
).
The parameter descriptors for this math transform, or null . See Also: OperationMethod.getParameters |
getParameterValues | public ParameterValueGroup getParameterValues()(Code) | | 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
or
).
Since this method returns a copy of the parameter values, any change to a value
will have no effect on this math transform.
A copy of the parameter values for this math transform, or null . See Also: Operation.getParameterValues |
getSourceDimensions | abstract public int getSourceDimensions()(Code) | | Gets the dimension of input points.
|
getTargetDimensions | abstract public int getTargetDimensions()(Code) | | Gets the dimension of output points.
|
hashCode | public int hashCode()(Code) | | Returns a hash value for this transform.
|
inverse | public MathTransform inverse() throws NoninvertibleTransformException(Code) | | Creates the inverse transform of this object.
The default implementation returns
this if this transform is an identity
transform, and throws a
NoninvertibleTransformException otherwise. Subclasses
should override this method.
|
invert | static Matrix invert(Matrix matrix) throws NoninvertibleTransformException(Code) | | Inverts the specified matrix in place. If the matrix can't be inverted (for example
because of a
SingularMatrixException ), then the exception is wrapped into a
NoninvertibleTransformException .
|
isIdentity | public boolean isIdentity()(Code) | | Tests whether this transform does not move any points.
The default implementation always returns
false .
|
needCopy | protected static boolean needCopy(int srcOff, int dimSource, int dstOff, int dimTarget, int numPts)(Code) | | 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;
}
}
|
rollLongitude | protected static double rollLongitude(double x)(Code) | | 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. The longitude in the range ±π radians. |
toGMatrix | static GeneralMatrix toGMatrix(Matrix matrix)(Code) | | Wraps the specified matrix in a Geotools implementation of
Matrix . If
matrix is already an instance of
GeneralMatrix , then it is returned unchanged. Otherwise,
all elements are copied in a new
GeneralMatrix object.
Before to use this method, check if a
XMatrix (to be obtained with
AbstractMathTransform.toXMatrix )
would be suffisient. Use this method only if a
GeneralMatrix is really necessary.
|
toXMatrix | static XMatrix toXMatrix(Matrix matrix)(Code) | | Wraps the specified matrix in a Geotools implementation of
Matrix . If
matrix is already an instance of
XMatrix , then it is returned unchanged. Otherwise, all
elements are copied in a new
XMatrix object.
|
transform | public Point2D transform(Point2D ptSrc, Point2D ptDst) throws TransformException(Code) | | Transforms the specified
ptSrc and stores the result in
ptDst .
The default implementation invokes
AbstractMathTransform.transform(double[],int,double[],int,int) using a temporary array of doubles.
Parameters: ptSrc - the specified coordinate point to be transformed. Parameters: ptDst - the specified coordinate point that stores the result of transforming ptSrc , or null . the coordinate point after transforming ptSrc and storing the result in ptDst . throws: MismatchedDimensionException - if this transform doesn't map two-dimensionalcoordinate systems. throws: TransformException - if the point can't be transformed. See Also: MathTransform2D.transform(Point2DPoint2D) |
|
|