Package org.opengis.example.referencing
Class SimpleTransform
- Object
-
- SimpleIdentifiedObject
-
- SimpleTransform
-
- All Implemented Interfaces:
Serializable
,Identifier
,IdentifiedObject
,CoordinateOperation
,MathTransform
,ReferenceIdentifier
- Direct Known Subclasses:
ProjectiveTransform
,SimpleTransform2D
public abstract class SimpleTransform extends SimpleIdentifiedObject implements CoordinateOperation, MathTransform
ACoordinateOperation
abstract base class. This class does not make distinction between Coordinate Operation and Math Transform, so we implement the two interfaces by the same class.Subclasses must implement the
transform(DirectPosition, DirectPosition)
method. All other transform methods are defined in terms of the above-cited method. However the othertransform
methods may be overridden for performances reasons.- Since:
- 3.1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected CoordinateReferenceSystem
sourceCRS
The source CRS, which determine the number of source dimensions.protected CoordinateReferenceSystem
targetCRS
The target CRS, which determine the number of target dimensions.-
Fields inherited from class SimpleIdentifiedObject
authority, code
-
Fields inherited from interface CoordinateOperation
COORDINATE_OPERATION_ACCURACY_KEY, DOMAIN_OF_VALIDITY_KEY, OPERATION_VERSION_KEY, SCOPE_KEY
-
Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
-
Fields inherited from interface Identifier
AUTHORITY_KEY, CODE_KEY, CODESPACE_KEY, DESCRIPTION_KEY, VERSION_KEY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleTransform(Citation authority, String name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS)
Creates a new operation for the given name and CRS.
-
Method Summary
Modifier and Type Method Description Matrix
derivative(DirectPosition point)
Gets the derivative of this transform at a point.boolean
equals(Object object)
Compares this transform with the given object for equality.MathTransform
getMathTransform()
Gets the math transform, which is represented directly bythis
implementation class since it does not distinguish operation and transform.String
getOperationVersion()
Version of the coordinate transformation (i.e., instantiation due to the stochastic nature of the parameters).CoordinateReferenceSystem
getSourceCRS()
Returns the source CRS.int
getSourceDimensions()
Gets the dimension of input points.CoordinateReferenceSystem
getTargetCRS()
Returns the target CRS.int
getTargetDimensions()
Gets the dimension of target points.MathTransform
inverse()
Creates the inverse transform of this object.boolean
isIdentity()
Tests whether this transform does not move any points.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.abstract DirectPosition
transform(DirectPosition ptSrc, DirectPosition ptDst)
Transforms the specifiedptSrc
and stores the result inptDst
.-
Methods inherited from class SimpleIdentifiedObject
getAuthority, getCode, getCodeSpace, getDomainOfValidity, getName, getScope, hashCode, toString, toWKT
-
Methods inherited from interface CoordinateOperation
getCoordinateOperationAccuracy, getDomainOfValidity, getScope
-
Methods inherited from interface IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
-
Methods inherited from interface Identifier
getDescription, getVersion
-
Methods inherited from interface MathTransform
toWKT
-
-
-
-
Field Detail
-
sourceCRS
protected final CoordinateReferenceSystem sourceCRS
The source CRS, which determine the number of source dimensions.- See Also:
getSourceCRS()
,getSourceDimensions()
-
targetCRS
protected final CoordinateReferenceSystem targetCRS
The target CRS, which determine the number of target dimensions.- See Also:
getTargetCRS()
,getTargetDimensions()
-
-
Constructor Detail
-
SimpleTransform
protected SimpleTransform(Citation authority, String name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS)
Creates a new operation for the given name and CRS.- Parameters:
authority
- organization responsible for definition of the name, ornull
.name
- the name of the new operation.sourceCRS
- the source CRS to be returned bygetSourceCRS()
.targetCRS
- the target CRS to be returned bygetTargetCRS()
.
-
-
Method Detail
-
getSourceCRS
public CoordinateReferenceSystem getSourceCRS()
Returns the source CRS.- Specified by:
getSourceCRS
in interfaceCoordinateOperation
- Returns:
- the source CRS, or
null
if not available.
-
getTargetCRS
public CoordinateReferenceSystem getTargetCRS()
Returns the target CRS.- Specified by:
getTargetCRS
in interfaceCoordinateOperation
- Returns:
- the target CRS, or
null
if not available.
-
getSourceDimensions
public int getSourceDimensions()
Gets the dimension of input points. The default implementation returns the dimension of the source CRS.- Specified by:
getSourceDimensions
in interfaceMathTransform
- Returns:
- the dimension of input points.
-
getTargetDimensions
public int getTargetDimensions()
Gets the dimension of target points. The default implementation returns the dimension of the target CRS.- Specified by:
getTargetDimensions
in interfaceMathTransform
- Returns:
- the dimension of input points.
-
getMathTransform
public MathTransform getMathTransform()
Gets the math transform, which is represented directly bythis
implementation class since it does not distinguish operation and transform.- Specified by:
getMathTransform
in interfaceCoordinateOperation
- Returns:
- the transform from source to target CRS.
-
transform
public abstract DirectPosition transform(DirectPosition ptSrc, DirectPosition ptDst) throws MismatchedDimensionException, TransformException
Transforms the specifiedptSrc
and stores the result inptDst
. IfptDst
isnull
, a newDirectPosition
object is allocated and the result of the transformation is stored in this object. In either case,ptDst
, which contains the transformed point, is returned for convenience. IfptSrc
andptDst
are the same object, the input point is correctly overwritten with the transformed point.- Specified by:
transform
in interfaceMathTransform
- Parameters:
ptSrc
- the specified coordinate point to be transformed.ptDst
- the specified coordinate point that stores the result of transformingptSrc
, ornull
.- Returns:
- the coordinate point after transforming
ptSrc
and storing the result inptDst
, or a newly created point ifptDst
was null. - Throws:
MismatchedDimensionException
- ifptSrc
orptDst
does not have the expected dimension.TransformException
- if the point can not be transformed.
-
transform
public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException
Transforms a list of coordinate point ordinal values.- Specified by:
transform
in interfaceMathTransform
- Parameters:
srcPts
- 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 thansrcPts
.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.- Throws:
TransformException
- if a point can not be transformed.
-
transform
public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) throws TransformException
Transforms a list of coordinate point ordinal values.- Specified by:
transform
in interfaceMathTransform
- Parameters:
srcPts
- 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 thansrcPts
.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.- Throws:
TransformException
- if a point can not be transformed.
-
transform
public void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws TransformException
Transforms a list of coordinate point ordinal values.- Specified by:
transform
in interfaceMathTransform
- Parameters:
srcPts
- 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 thansrcPts
.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.- Throws:
TransformException
- if a point can not be transformed.
-
transform
public void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) throws TransformException
Transforms a list of coordinate point ordinal values.- Specified by:
transform
in interfaceMathTransform
- Parameters:
srcPts
- 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 thansrcPts
.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.- Throws:
TransformException
- if a point can not be transformed.
-
derivative
public Matrix derivative(DirectPosition point) throws TransformException
Gets the derivative of this transform at a point. The default implementation throws an exception in all cases.- Specified by:
derivative
in interfaceMathTransform
- Parameters:
point
- the coordinate point where to evaluate the derivative.- Returns:
- the derivative at the specified point (never
null
). - Throws:
TransformException
- if the derivative can not be evaluated at the specified point.
-
inverse
public MathTransform inverse() throws NoninvertibleTransformException
Creates the inverse transform of this object. The default implementation throws an exception in all cases.- Specified by:
inverse
in interfaceMathTransform
- Returns:
- the inverse transform.
- Throws:
NoninvertibleTransformException
- if the transform can not be inverted.
-
isIdentity
public boolean isIdentity()
Tests whether this transform does not move any points. The default implementation tests if the source and target CRS are equals.- Specified by:
isIdentity
in interfaceMathTransform
- Returns:
true
if thisMathTransform
is an identity transform;false
otherwise.
-
getOperationVersion
public String getOperationVersion()
Version of the coordinate transformation (i.e., instantiation due to the stochastic nature of the parameters). The default implementation returnsnull
.- Specified by:
getOperationVersion
in interfaceCoordinateOperation
- Returns:
- the coordinate operation version, or
null
in none.
-
equals
public boolean equals(Object object)
Compares this transform with the given object for equality.- Overrides:
equals
in classSimpleIdentifiedObject
- Parameters:
object
- the object to compare with thisSimpleTransform
.- Returns:
true
if the given object is equals to this object.
-
-