Class SpecializableTransform
java.lang.Object
org.apache.sis.io.wkt.FormattableObject
org.apache.sis.referencing.operation.transform.AbstractMathTransform
org.apache.sis.referencing.operation.transform.SpecializableTransform
- All Implemented Interfaces:
Serializable
,Parameterized
,LenientComparable
,org.opengis.referencing.operation.MathTransform
- Direct Known Subclasses:
SpecializableTransform2D
A transform having sub-areas where more accurate transforms can be used.
The global transform must be a reasonable approximation of the specialized transforms.
The lower and upper values of given envelopes are inclusive.
- Since:
- 1.0
- Version:
- 1.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
The inverse ofSpecializableTransform
.private static final class
The region where a transform is valid, together with the transform.private static interface
Call of aMathTransform.transform(…)
method with source and target arrays fixed atTransformCall
creation time. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RTreeNode
Domains where specialized transforms are valid.private final org.opengis.referencing.operation.MathTransform
The global transform to use if there is no suitable specialization.private org.opengis.referencing.operation.MathTransform
The inverse of this transform, computed when first needed.private static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
MAXIMUM_BUFFER_SIZE, MAXIMUM_FAILURES
-
Constructor Summary
ConstructorsConstructorDescriptionSpecializableTransform
(org.opengis.referencing.operation.MathTransform global, Map<org.opengis.geometry.Envelope, org.opengis.referencing.operation.MathTransform> specializations) Creates a new transform with the given global transform and some amount of specializations. -
Method Summary
Modifier and TypeMethodDescriptionprotected final int
Computes a hash value for this transform.(package private) SpecializableTransform.Inverse
Invoked at construction time for creating the inverse transform.final org.opengis.referencing.operation.Matrix
derivative
(org.opengis.geometry.DirectPosition point) Gets the derivative of this transform at a point.final boolean
equals
(Object object, ComparisonMode mode) Compares the specified object with this math transform for equality.private org.opengis.referencing.operation.MathTransform
forDomain
(org.opengis.geometry.DirectPosition pos) Returns the transform to use for the given position, orglobal
if none.protected final String
Formats the inner part of a Well Known Text version 1 (WKT 1) element.final int
Gets the dimension of input points.(package private) final org.opengis.referencing.operation.MathTransform
If this transform has no children, then returns the transform that we should use instead.final int
Gets the dimension of output points.org.opengis.referencing.operation.MathTransform
inverse()
Returns the inverse of this transform.private SpecializableTransform.SubArea
locate
(org.opengis.geometry.DirectPosition pos) Returns the node that contains the given position, ornull
if none.private List<SpecializableTransform.SubArea>
roots()
Returns theSpecializableTransform.SubArea
instances at the root of this class.final org.opengis.referencing.operation.Matrix
transform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate) Transforms a single coordinate tuple in an array, and optionally computes the transform derivative at that location.final void
transform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms a list of coordinate tuples.final void
transform
(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms a list of coordinate tuples.final void
transform
(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms a list of coordinate tuples.final void
transform
(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms a list of coordinate tuples.private void
transform
(SpecializableTransform.TransformCall transform, DirectPositionView src, int dstOff, int srcInc, int dstInc, int numPts) Transforms a list of coordinate tuples.final org.opengis.geometry.DirectPosition
transform
(org.opengis.geometry.DirectPosition ptSrc, org.opengis.geometry.DirectPosition ptDst) Transforms the specifiedptSrc
and stores the result inptDst
.Methods inherited from class org.apache.sis.referencing.operation.transform.AbstractMathTransform
beforeFormat, equals, getContextualParameters, getDomain, getParameterDescriptors, getParameterValues, hashCode, isIdentity, isInverseEquals, mismatchedDimension, tryConcatenate
Methods inherited from class org.apache.sis.io.wkt.FormattableObject
print, toString, toString, toWKT
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opengis.referencing.operation.MathTransform
toWKT
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
global
private final org.opengis.referencing.operation.MathTransform globalThe global transform to use if there is no suitable specialization. -
domains
Domains where specialized transforms are valid. This is the root of an R-Tree. May benull
if there is no R-Tree, in which caseglobal
should be used instead. -
inverse
private org.opengis.referencing.operation.MathTransform inverseThe inverse of this transform, computed when first needed. This object is included in serialization for avoiding rounding error issues.- See Also:
-
-
Constructor Details
-
SpecializableTransform
SpecializableTransform(org.opengis.referencing.operation.MathTransform global, Map<org.opengis.geometry.Envelope, org.opengis.referencing.operation.MathTransform> specializations) Creates a new transform with the given global transform and some amount of specializations.- Parameters:
global
- the transform to use globally where there is no suitable specialization.specializations
- more accurate transforms available in sub-areas.
-
-
Method Details
-
roots
Returns theSpecializableTransform.SubArea
instances at the root of this class. This is thedomains
node, unless that node is a synthetic node created byRTreeNode
when it needs to contain more than one children. -
getSubstitute
final org.opengis.referencing.operation.MathTransform getSubstitute()If this transform has no children, then returns the transform that we should use instead. Otherwise returnsnull
. -
getSourceDimensions
public final int getSourceDimensions()Gets the dimension of input points.- Specified by:
getSourceDimensions
in interfaceorg.opengis.referencing.operation.MathTransform
- Specified by:
getSourceDimensions
in classAbstractMathTransform
- Returns:
- the number of dimensions of input points.
- See Also:
-
getTargetDimensions
public final int getTargetDimensions()Gets the dimension of output points.- Specified by:
getTargetDimensions
in interfaceorg.opengis.referencing.operation.MathTransform
- Specified by:
getTargetDimensions
in classAbstractMathTransform
- Returns:
- the number of dimensions of output points.
- See Also:
-
locate
Returns the node that contains the given position, ornull
if none. This method searches from the root of the tree. It should be invoked only when we do not know what was the last search result. -
forDomain
private org.opengis.referencing.operation.MathTransform forDomain(org.opengis.geometry.DirectPosition pos) Returns the transform to use for the given position, orglobal
if none. -
transform
public final org.opengis.geometry.DirectPosition transform(org.opengis.geometry.DirectPosition ptSrc, org.opengis.geometry.DirectPosition ptDst) throws org.opengis.referencing.operation.TransformException Transforms the specifiedptSrc
and stores the result inptDst
. This method delegates to the most specialized transform.- Specified by:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
transform
in classAbstractMathTransform
- Parameters:
ptSrc
- the coordinate tuple to be transformed.ptDst
- the coordinate tuple that stores the result of transformingptSrc
, ornull
.- Returns:
- the coordinate tuple after transforming
ptSrc
and storing the result inptDst
, or a newly created point ifptDst
was null. - Throws:
org.opengis.referencing.operation.TransformException
- if the point cannot be transformed.
-
derivative
public final org.opengis.referencing.operation.Matrix derivative(org.opengis.geometry.DirectPosition point) throws org.opengis.referencing.operation.TransformException Gets the derivative of this transform at a point. This method delegates to the most specialized transform.- Specified by:
derivative
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
derivative
in classAbstractMathTransform
- Parameters:
point
- the coordinate tuple where to evaluate the derivative.- Returns:
- the derivative at the specified point (never
null
). - Throws:
org.opengis.referencing.operation.TransformException
- if the derivative cannot be evaluated at the specified point.
-
transform
public final org.opengis.referencing.operation.Matrix transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate) throws org.opengis.referencing.operation.TransformException Transforms a single coordinate tuple in an array, and optionally computes the transform derivative at that location. This method delegates to the most specialized transform.- Specified by:
transform
in classAbstractMathTransform
- Parameters:
srcPts
- the array containing the source coordinates (cannot benull
).srcOff
- the offset to the point to be transformed in the source array.dstPts
- the array into which the transformed coordinates is returned. May be the same thansrcPts
. May benull
if only the derivative matrix is desired.dstOff
- the offset to the location of the transformed point that is stored in the destination array.derivate
-true
for computing the derivative, orfalse
if not needed.- Returns:
- the matrix of the transform derivative at the given source position,
or
null
if thederivate
argument isfalse
. - Throws:
org.opengis.referencing.operation.TransformException
- if the point cannot be transformed or if a problem occurred while calculating the derivative.- See Also:
-
transform
private void transform(SpecializableTransform.TransformCall transform, DirectPositionView src, int dstOff, int srcInc, int dstInc, int numPts) throws org.opengis.referencing.operation.TransformException Transforms a list of coordinate tuples. This method delegates to the most specialized transform, with singletransform(…)
calls for coordinate sequences as long as possible.- Parameters:
transform
- caller for aMathTransform.transform(…)
method.src
- a window over the source points. May be backed by afloat[]
ordouble[]
array.dstOff
- where to write the first coordinate in the target array.srcInc
- the source dimension, negative if we must iterate backward.dstInc
- the target dimension, negative if we must iterate backward.numPts
- number of points to transform.- Throws:
org.opengis.referencing.operation.TransformException
-
transform
public final void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws org.opengis.referencing.operation.TransformException Transforms a list of coordinate tuples. This method delegates to the most specialized transform.- Specified by:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
transform
in classAbstractMathTransform
- 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:
org.opengis.referencing.operation.TransformException
- if a point cannot be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with Double.NaN values, continue and throw the exception only at end. Implementations that fall in the latter case should set the last completed transform tothis
.
-
transform
public final void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) throws org.opengis.referencing.operation.TransformException Transforms a list of coordinate tuples. This method delegates to the most specialized transform.- Specified by:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
transform
in classAbstractMathTransform
- 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:
org.opengis.referencing.operation.TransformException
- if a point cannot be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the un-transformable points withFloat.NaN
values, continue and throw the exception only at end. Implementations that fall in the latter case should set the last completed transform tothis
.
-
transform
public final void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) throws org.opengis.referencing.operation.TransformException Transforms a list of coordinate tuples. This method delegates to the most specialized transform, with singletransform(…)
calls for coordinate sequences as long as possible.- Specified by:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
transform
in classAbstractMathTransform
- 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.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:
org.opengis.referencing.operation.TransformException
- if a point cannot be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with Float.NaN values, continue and throw the exception only at end. Implementations that fall in the latter case should set the last completed transform tothis
.
-
transform
public final void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws org.opengis.referencing.operation.TransformException Transforms a list of coordinate tuples. This method delegates to the most specialized transform, with singletransform(…)
calls for coordinate sequences as long as possible.- Specified by:
transform
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
transform
in classAbstractMathTransform
- 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.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:
org.opengis.referencing.operation.TransformException
- if a point cannot be transformed. Some implementations will stop at the first failure, wile some other implementations will fill the untransformable points with Double.NaN values, continue and throw the exception only at end. Implementations that fall in the latter case should set the last completed transform tothis
.
-
computeHashCode
protected final int computeHashCode()Computes a hash value for this transform. This method is invoked byAbstractMathTransform.hashCode()
when first needed.- Overrides:
computeHashCode
in classAbstractMathTransform
- Returns:
- the hash code value. This value may change between different execution of the Apache SIS library.
-
equals
Compares the specified object with this math transform for equality.- Specified by:
equals
in interfaceLenientComparable
- Overrides:
equals
in classAbstractMathTransform
- Parameters:
object
- the object to compare with this transform.mode
- the strictness level of the comparison. Default toSTRICT
.- Returns:
true
if the given object is considered equals to this math transform.- See Also:
-
formatTo
Formats the inner part of a Well Known Text version 1 (WKT 1) element.Compatibility note: TheSPECIALIZABLE_MT
element formatted here is an Apache SIS-specific extension.- Overrides:
formatTo
in classAbstractMathTransform
- Parameters:
formatter
- the formatter to use.- Returns:
- the WKT element name, which is
"Specializable_MT"
. - See Also:
-
inverse
public org.opengis.referencing.operation.MathTransform inverse() throws org.opengis.referencing.operation.NoninvertibleTransformExceptionReturns the inverse of this transform.- Specified by:
inverse
in interfaceorg.opengis.referencing.operation.MathTransform
- Overrides:
inverse
in classAbstractMathTransform
- Throws:
org.opengis.referencing.operation.NoninvertibleTransformException
-
createInverse
SpecializableTransform.Inverse createInverse() throws org.opengis.referencing.operation.NoninvertibleTransformExceptionInvoked at construction time for creating the inverse transform. Overridden bySpecializableTransform2D
for the two-dimensional variant.- Throws:
org.opengis.referencing.operation.NoninvertibleTransformException
-