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 classThe inverse ofSpecializableTransform.private static final classThe region where a transform is valid, together with the transform.private static interfaceCall of aMathTransform.transform(…)method with source and target arrays fixed atTransformCallcreation time. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RTreeNodeDomains where specialized transforms are valid.private final org.opengis.referencing.operation.MathTransformThe global transform to use if there is no suitable specialization.private org.opengis.referencing.operation.MathTransformThe inverse of this transform, computed when first needed.private static final longFor 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 intComputes a hash value for this transform.(package private) SpecializableTransform.InverseInvoked at construction time for creating the inverse transform.final org.opengis.referencing.operation.Matrixderivative(org.opengis.geometry.DirectPosition point) Gets the derivative of this transform at a point.final booleanequals(Object object, ComparisonMode mode) Compares the specified object with this math transform for equality.private org.opengis.referencing.operation.MathTransformforDomain(org.opengis.geometry.DirectPosition pos) Returns the transform to use for the given position, orglobalif none.protected final StringFormats the inner part of a Well Known Text version 1 (WKT 1) element.final intGets the dimension of input points.(package private) final org.opengis.referencing.operation.MathTransformIf this transform has no children, then returns the transform that we should use instead.final intGets the dimension of output points.org.opengis.referencing.operation.MathTransforminverse()Returns the inverse of this transform.private SpecializableTransform.SubArealocate(org.opengis.geometry.DirectPosition pos) Returns the node that contains the given position, ornullif none.private List<SpecializableTransform.SubArea>roots()Returns theSpecializableTransform.SubAreainstances at the root of this class.final org.opengis.referencing.operation.Matrixtransform(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 voidtransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms a list of coordinate tuples.final voidtransform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms a list of coordinate tuples.final voidtransform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transforms a list of coordinate tuples.final voidtransform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Transforms a list of coordinate tuples.private voidtransform(SpecializableTransform.TransformCall transform, DirectPositionView src, int dstOff, int srcInc, int dstInc, int numPts) Transforms a list of coordinate tuples.final org.opengis.geometry.DirectPositiontransform(org.opengis.geometry.DirectPosition ptSrc, org.opengis.geometry.DirectPosition ptDst) Transforms the specifiedptSrcand 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, 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
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 benullif there is no R-Tree, in which caseglobalshould 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.SubAreainstances at the root of this class. This is thedomainsnode, unless that node is a synthetic node created byRTreeNodewhen 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:
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()Gets the dimension of output points.- Specified by:
getTargetDimensionsin interfaceorg.opengis.referencing.operation.MathTransform- Specified by:
getTargetDimensionsin classAbstractMathTransform- Returns:
- the number of dimensions of output points.
- See Also:
-
locate
Returns the node that contains the given position, ornullif 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, orglobalif 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 specifiedptSrcand stores the result inptDst. This method delegates to the most specialized transform.- Specified by:
transformin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
transformin 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
ptSrcand storing the result inptDst, or a newly created point ifptDstwas 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:
derivativein interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
derivativein 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:
transformin 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 benullif only the derivative matrix is desired.dstOff- the offset to the location of the transformed point that is stored in the destination array.derivate-truefor computing the derivative, orfalseif not needed.- Returns:
- the matrix of the transform derivative at the given source position,
or
nullif thederivateargument 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:
transformin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
transformin 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:
transformin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
transformin 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.NaNvalues, 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:
transformin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
transformin 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:
transformin interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
transformin 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:
computeHashCodein 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:
equalsin interfaceLenientComparable- Overrides:
equalsin classAbstractMathTransform- Parameters:
object- the object to compare with this transform.mode- the strictness level of the comparison. Default toSTRICT.- Returns:
trueif 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_MTelement formatted here is an Apache SIS-specific extension.- Overrides:
formatToin 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:
inversein interfaceorg.opengis.referencing.operation.MathTransform- Overrides:
inversein 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 bySpecializableTransform2Dfor the two-dimensional variant.- Throws:
org.opengis.referencing.operation.NoninvertibleTransformException
-