Search in sources :

Example 6 with DefaultMathTransformFactory

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);
}
Also used : DefaultMathTransformFactory(org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test)

Aggregations

DefaultMathTransformFactory (org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory)6 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)4 DeferredCoordinateOperation (org.apache.sis.internal.referencing.DeferredCoordinateOperation)2 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 DatumShiftMethod (org.apache.sis.internal.referencing.provider.DatumShiftMethod)1 AbstractIdentifiedObject (org.apache.sis.referencing.AbstractIdentifiedObject)1 NamedIdentifier (org.apache.sis.referencing.NamedIdentifier)1 DefaultGeodeticDatum (org.apache.sis.referencing.datum.DefaultGeodeticDatum)1 InvalidGeodeticParameterException (org.apache.sis.referencing.factory.InvalidGeodeticParameterException)1 DefaultCoordinateOperationFactory (org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory)1 DefaultOperationMethod (org.apache.sis.referencing.operation.DefaultOperationMethod)1 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)1 Test (org.junit.Test)1 Identifier (org.opengis.metadata.Identifier)1 IdentifiedObject (org.opengis.referencing.IdentifiedObject)1 GeodeticCRS (org.opengis.referencing.crs.GeodeticCRS)1 EllipsoidalCS (org.opengis.referencing.cs.EllipsoidalCS)1