|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectFormattableObject
AbstractMathTransform
@ThreadSafe public abstract class AbstractMathTransform
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 map two-dimensional coordinate systems.
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 method as well.
| referencing/geotk-referencing (download) | View source code for this class |
| Nested Class Summary | |
|---|---|
protected class |
AbstractMathTransform.Inverse
Default implementation for inverse math transform. |
| Field Summary |
|---|
| Fields inherited from class FormattableObject |
|---|
EPSG, GEOTIFF, INTERNAL, OGC, SINGLE_LINE |
| Constructor Summary | |
|---|---|
protected |
AbstractMathTransform()
Constructs a math transform. |
| Method Summary | |
|---|---|
protected int |
computeHashCode()
Computes a hash value for this transform. |
Shape |
createTransformedShape(Shape shape)
Transform the specified shape. |
Matrix |
derivative(DirectPosition point)
Gets the derivative of this transform at a point. |
Matrix |
derivative(Point2D 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. |
boolean |
equals(Object object)
Compares the specified object with this math transform for strict equality. |
boolean |
equals(Object object,
ComparisonMode mode)
Compares the specified object with this math transform for equality. |
String |
formatWKT(Formatter formatter)
Formats the inner part of a Well Known Text (WKT) element. |
String |
getName()
Returns a name for this math transform (never null). |
ParameterDescriptorGroup |
getParameterDescriptors()
Returns the parameter descriptors for this math transform, or null if unknown. |
ParameterValueGroup |
getParameterValues()
Returns a copy of the parameter values for this math transform, or null if unknown. |
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. |
MathTransform |
inverse()
Returns the inverse transform of this object. |
boolean |
isIdentity()
Tests whether this transform does not move any points. |
protected static double |
rollLongitude(double x,
double bound)
Ensures that the specified longitude stay within the [-bound … bound] range. |
DirectPosition |
transform(DirectPosition ptSrc,
DirectPosition ptDst)
Transforms the specified ptSrc and stores the result in ptDst. |
protected abstract void |
transform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff)
Transforms a single coordinate point in an array. |
void |
transform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms a list of coordinate point ordinal values. |
void |
transform(double[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
Transforms a list of coordinate point ordinal values. |
void |
transform(float[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms a list of coordinate point ordinal values. |
void |
transform(float[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
Transforms a list of coordinate point ordinal values. |
Point2D |
transform(Point2D ptSrc,
Point2D ptDst)
Transforms the specified ptSrc and stores the result in ptDst. |
| Methods inherited from class FormattableObject |
|---|
getDefaultIndentation, print, setDefaultIndentation, toString, toWKT, toWKT, toWKT |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface MathTransform |
|---|
toWKT |
| Constructor Detail |
|---|
protected AbstractMathTransform()
| Method Detail |
|---|
public String getName()
null). This convenience methods
returns the name of the parameter descriptors if
any, or the short class name otherwise.
null).public abstract int getSourceDimensions()
getSourceDimensions in interface MathTransformpublic abstract int getTargetDimensions()
getTargetDimensions in interface MathTransformpublic ParameterDescriptorGroup getParameterDescriptors()
null if unknown.
This method is similar to OperationMethod.getParameters(), except that typical
MathTransform implementations return parameters in standard units (usually
metres or decimal degrees).
getParameterDescriptors in interface Parameterizednull.OperationMethod.getParameters()public ParameterValueGroup getParameterValues()
null if unknown.
This method is similar to SingleOperation.getParameterValues(), except that typical
MathTransform implementations return parameters in standard units (usually
metres or decimal degrees).
getParameterValues in interface Parameterizednull.
Since this method returns a copy of the parameter values, any change to
a value will have no effect on this math transform.SingleOperation.getParameterValues()public boolean isIdentity()
false.
isIdentity in interface MathTransform
public Point2D transform(Point2D ptSrc,
Point2D ptDst)
throws TransformException
ptSrc and stores the result in ptDst.
The default implementation invokes transform(double[],int,double[],int)
using a temporary array of doubles.
ptSrc - The coordinate point to be transformed.ptDst - The coordinate point that stores the result of transforming ptSrc,
or null if a new point should be created.
ptSrc and storing the result in
ptDst, or in a new point if ptDst was null.
MismatchedDimensionException - If this transform doesn't map two-dimensional
coordinate systems.
TransformException - If the point can't be transformed.MathTransform2D.transform(Point2D,Point2D)
public DirectPosition transform(DirectPosition ptSrc,
DirectPosition ptDst)
throws TransformException
ptSrc and stores the result in ptDst. The default
implementation delegates to transform(double[],int,double[],int).
transform in interface MathTransformptSrc - the coordinate point to be transformed.ptDst - the coordinate point that stores the result of transforming ptSrc,
or null.
ptSrc and storing the result
in ptDst, or a newly created point if ptDst was null.
MismatchedDimensionException - if ptSrc or
ptDst doesn't have the expected dimension.
TransformException - if the point can't be transformed.
protected abstract void transform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff)
throws TransformException
transform(srcPts, srcOff, dstPts, dstOff, 1)
However this method is easier to implement for AbstractMathTransform subclasses.
The default transform(double[],int,double[],int,int) method implementation will
invoke this method in a loop, taking care of the iteration
strategy depending on the argument value.
The source and destination may overlap. Consequently, implementors must read all source ordinate values before to start writing the transformed ordinates in the destination array.
Note: This method has protected access rather than public in the hope to encourage users to invoke the bulk methods with a number of points greater than 1, which is usually faster than invoking repeatidly this method. In addition this method may skip some verifications that are performed by the public methods. This is the case of Geotk implementation of map projections.
srcPts - The array containing the source point coordinates.srcOff - The offset to the point to be transformed in the source array.dstPts - the array into which the transformed point coordinate are returned.
May be the same than srcPts.dstOff - The offset to the location of the transformed point that is
stored in the destination array.
TransformException - If the point can't be transformed.
public void transform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
throws TransformException
(x0,y0,z0, x1,y1,z1 ...).The default implementation invokes
transform(double[],int,double[],int) in a loop,
using an iteration strategy determined from the arguments for
iterating over the points.
transform in interface MathTransformsrcPts - 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.
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.
public void transform(float[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
throws TransformException
transform(double[],int,double[],int,int) using a temporary
array of doubles.
transform in interface MathTransformsrcPts - 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.
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.
public void transform(double[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
throws TransformException
transform(double[],int,double[],int,int) using a temporary
array of doubles.
transform in interface MathTransformsrcPts - 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.
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.
public void transform(float[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
throws TransformException
transform(double[],int,double[],int,int) using a temporary
array of doubles if necessary.
transform in interface MathTransformsrcPts - 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.
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.
public Shape createTransformedShape(Shape shape)
throws TransformException
Path2D, but may also be a Line2D or a QuadCurve2D if such
simplification is possible.
shape - Shape to transform.
shape if this transform is the identity transform.
IllegalStateException - if this transform doesn't map 2D coordinate systems.
TransformException - if a transform failed.MathTransform2D.createTransformedShape(Shape)
public Matrix derivative(Point2D point)
throws TransformException
MathTransform2D interface
should override this method. Other subclasses should override
derivative(DirectPosition) instead.
point - The coordinate point where to evaluate the derivative.
MismatchedDimensionException - if the input dimension is not 2.
TransformException - if the derivative can't be evaluated at the specified point.MathTransform2D.derivative(Point2D)
public Matrix derivative(DirectPosition point)
throws TransformException
point has a valid dimension. Next, if the input dimension is 2, then this method
delegates the work to derivative(Point2D). Otherwise a TransformException
is thrown.
derivative in interface MathTransformpoint - The coordinate point where to evaluate the derivative.
null).
NullPointerException - if the derivative dependents on coordinate
and point is null.
MismatchedDimensionException - if point doesn't have the expected dimension.
TransformException - if the derivative can't be evaluated at the specified point.
public MathTransform inverse()
throws NoninvertibleTransformException
this if this transform is an identity transform, and throws
a NoninvertibleTransformException otherwise. Subclasses should override
this method.
inverse in interface MathTransformNoninvertibleTransformExceptionpublic final int hashCode()
computeHashCode()
when first needed and caches the value for future invocations. Subclasses should override
computeHashCode() instead than this method.
hashCode in class Objectprotected int computeHashCode()
hashCode()
when first needed.
public final boolean equals(Object object)
return equals(other, ComparisonMode.STRICT);
equals in interface LenientComparableequals in class Objectobject - The object to compare with this transform.
true if the given object is a transform of the same class and using
the same parameter values.
public boolean equals(Object object,
ComparisonMode mode)
true if the following conditions are meet:
object is an instance of the same class than this. We require the
same class because there is no interface for the various kinds of transform.The parameter values are not compared because subclasses can typically compare those values more efficiently by accessing to their member fields.
equals in interface LenientComparableobject - The object to compare with this transform.mode - The strictness level of the comparison. Default to STRICT.
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.public String formatWKT(Formatter formatter)
getParameterValues(). The parameter group name is used as the math
transform name.
formatWKT in interface FormattableformatWKT in class FormattableObjectformatter - The formatter to use.
"PARAM_MT" in the default implementation.FormattableObject.toWKT(),
FormattableObject.toString()
protected static void ensureNonNull(String name,
Object object)
throws InvalidParameterValueException
name - Argument name.object - User argument.
InvalidParameterValueException - if object is null.
protected static double rollLongitude(double x,
double bound)
The bound value is typically 180 if the longitude is express in degrees,
or Math.PI it the longitude is express in radians. But it can also be some
other value if the longitude has already been multiplied by a scale factor before
this method is invoked.
x - The longitude.bound - The absolute value of the minimal and maximal allowed value, or
Double.POSITIVE_INFINITY if no rolling should be applied.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||