Search in sources :

Example 1 with AbstractMathTransform

use of org.apache.sis.referencing.operation.transform.AbstractMathTransform in project sis by apache.

the class Envelopes method derivativeAndTransform.

/**
 * A buckle method for calculating derivative and coordinate transformation in a single step,
 * if the given {@code derivative} argument is {@code true}.
 *
 * @param  transform  the transform to use.
 * @param  srcPts     the array containing the source coordinate at offset 0.
 * @param  dstPts     the array into which the transformed coordinate is returned.
 * @param  dstOff     the offset to the location of the transformed point that is stored in the destination array.
 * @param  derivate   {@code true} for computing the derivative, or {@code false} if not needed.
 * @return the matrix of the transform derivative at the given source position,
 *         or {@code null} if the {@code derivate} argument is {@code false}.
 * @throws TransformException if the point can not be transformed
 *         or if a problem occurred while calculating the derivative.
 */
static Matrix derivativeAndTransform(final MathTransform transform, final double[] srcPts, final double[] dstPts, final int dstOff, final boolean derivate) throws TransformException {
    if (transform instanceof AbstractMathTransform) {
        return ((AbstractMathTransform) transform).transform(srcPts, 0, dstPts, dstOff, derivate);
    }
    // Derivative must be calculated before to transform the coordinate.
    final Matrix derivative = derivate ? transform.derivative(new DirectPositionView.Double(srcPts, 0, transform.getSourceDimensions())) : null;
    transform.transform(srcPts, 0, dstPts, dstOff, 1);
    return derivative;
}
Also used : AbstractMathTransform(org.apache.sis.referencing.operation.transform.AbstractMathTransform) Matrix(org.opengis.referencing.operation.Matrix)

Aggregations

AbstractMathTransform (org.apache.sis.referencing.operation.transform.AbstractMathTransform)1 Matrix (org.opengis.referencing.operation.Matrix)1