use of org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory in project sis by apache.
the class GeographicOffsetsTest method testCreateWithContext.
/**
* Tests {@code VerticalOffset.createMathTransform(…)} indirectly, through a call to the math transform factory
* with the source and target coordinate systems specified. The intent of this test is to verify that the change
* of axis direction is properly handled, given source CRS axis direction up and target CRS axis direction down.
*
* @throws FactoryException if an error occurred while creating the transform.
* @throws TransformException should never happen.
*/
@Test
public void testCreateWithContext() throws FactoryException, TransformException {
final DefaultMathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class, DefaultMathTransformFactory.class);
final ParameterValueGroup pv = factory.getDefaultParameters("Vertical Offset");
pv.parameter("Vertical Offset").setValue(15.55, Units.FOOT);
/*
* Now create the MathTransform. But at the difference of the above testVerticalOffset() method,
* we supply information about axis directions. The operation parameter shall have the same sign
* than in the EPSG database (which is positive), and the source and target ordinates shall have
* the same sign than in the EPSG example (positive too). However we do not test unit conversion
* in this method (EPSG sample point uses feet units), only axis direction.
*/
final DefaultMathTransformFactory.Context context = new DefaultMathTransformFactory.Context();
// Direction up, in metres.
context.setSource(HardCodedCS.GRAVITY_RELATED_HEIGHT);
// Direction down, in metres.
context.setTarget(HardCodedCS.DEPTH);
transform = factory.createParameterizedTransform(pv, context);
tolerance = Formulas.LINEAR_TOLERANCE;
final double[] source = new double[transform.getSourceDimensions()];
final double[] target = new double[transform.getTargetDimensions()];
// 2.55 metres up, same sign than in EPSG example (positive).
source[0] = 2.55;
// 7.18 feet down.
target[0] = 7.18 * 0.3048;
verifyTransform(source, target);
}
Aggregations