Search in sources :

Example 6 with TransferFunction

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

the class GCOM_C method transferFunction.

/**
 * Builds the function converting values from their packed formats in the variable to "real" values.
 * This method is invoked only if {@link #validRange(Variable)} returned a non-null value.
 *
 * @param  data  the variable from which to determine the transfer function.
 * @return a transfer function built from the attributes defined in the given variable.
 */
@Override
public TransferFunction transferFunction(final Variable data) {
    final TransferFunction tr = super.transferFunction(data);
    if (tr.isIdentity()) {
        final double slope = data.getAttributeAsNumber("Slope");
        final double offset = data.getAttributeAsNumber("Offset");
        if (Double.isFinite(slope))
            tr.setScale(slope);
        if (Double.isFinite(offset))
            tr.setOffset(offset);
    }
    return tr;
}
Also used : TransferFunction(org.apache.sis.referencing.operation.transform.TransferFunction)

Aggregations

TransferFunction (org.apache.sis.referencing.operation.transform.TransferFunction)6 Vector (org.apache.sis.math.Vector)1 DataStoreException (org.apache.sis.storage.DataStoreException)1 Test (org.junit.Test)1 MathTransform1D (org.opengis.referencing.operation.MathTransform1D)1