Interface MathTransformProvider

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface MathTransformProvider
An object capable to create Math­Transform instances from given parameter values. This interface is the Apache SIS mechanism by which formula are concretized as Java code. A math transform provider ignores the source and target CRS and works with coordinates in predefined axis order and units — typically (east, north, up) in degrees or meters — although some variations are allowed in the number of dimensions (typically the "up" dimension being optional). Adjustments for CRS axis order, units and exact number of dimensions are caller's responsibility.

This interface is generally not used directly. The recommended way to get a Math­Transform is to find the coordinate operation (generally from a pair of source and target CRS), then to invoke Coordinate­Operation​.get­Math­Transform(). Alternatively, one can also use a math transform factory.

Implementations of this interface usually extend Default­Operation­Method, but this is not mandatory. This interface can also be used alone since Math­Transform instances can be created for other purpose than coordinate operations.

How to add custom coordinate operations to Apache SIS

Default­Math­Transform­Factory can discover automatically new coordinate operations (including map projections) by scanning the module path. To define a custom coordinate operation, one needs to define a thread-safe class implementing both this Math­Transform­Provider interface and the Operation­Method one. While not mandatory, we suggest to extend Default­Operation­Method. Example:
public class MyOperationProvider extends DefaultOperationMethod implements MathTransformProvider {
    private static final ParameterDescriptor<Foo> FOO;
    private static final ParameterDescriptor<Bar> BAR;
    private static final ParameterDescriptorGroup PARAMETERS;
    static {
        final var builder = new ParameterBuilder();
        FOO = builder.addName("Foo").create(Foo.class, null);
        BAR = builder.addName("Bar").create(Bar.class, null);
        PARAMETERS = builder.addName("My operation").createGroup(FOO, BAR);
    }

    public MyOperationProvider() {
        super(Map.of(NAME_KEY, PARAMETERS.getName()), PARAMETERS);
    }

    @Override
    public MathTransform createMathTransform(Context context) {
        var pg  = Parameters.castOrWrap(context.getCompletedParameters();
        Foo foo = pg.getMandatoryValue(FOO);
        Bar bar = pg.getMandatoryValue(BAR);
        return new MyOperation(foo, bar);
    }
}
In the common case where the provider needs numerical parameter values in a specific units of measurement, the following pattern can be used:
    double semiMajor = values.parameter("semi_major").doubleValue(Units.METRE);
    double semiMinor = values.parameter("semi_minor").doubleValue(Units.METRE);
Then the class name of that implementation shall be declared in module-info​.java as a provider of the org​.opengis​.referencing​.operation​.Operation­Method service.
Since:
0.6
See Also: