Search in sources :

Example 6 with MathTransformFactory

use of org.opengis.referencing.operation.MathTransformFactory in project sis by apache.

the class EllipsoidToCentricTransformTest method createGeodeticConversion.

/**
 * Convenience method for creating an instance from an ellipsoid.
 */
private void createGeodeticConversion(final Ellipsoid ellipsoid, boolean is3D) throws FactoryException {
    final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class);
    transform = EllipsoidToCentricTransform.createGeodeticConversion(factory, ellipsoid, is3D);
    /*
         * If the ellipsoid is a sphere, then EllipsoidToCentricTransform.createGeodeticConversion(…) created a
         * SphericalToCartesian instance instead than an EllipsoidToCentricTransform instance.  Create manually
         * the EllipsoidToCentricTransform here and wrap the two transform in a comparator for making sure that
         * the two implementations are consistent.
         */
    if (ellipsoid.isSphere()) {
        EllipsoidToCentricTransform tr = new EllipsoidToCentricTransform(ellipsoid.getSemiMajorAxis(), ellipsoid.getSemiMinorAxis(), ellipsoid.getAxisUnit(), is3D, EllipsoidToCentricTransform.TargetType.CARTESIAN);
        transform = new TransformResultComparator(transform, tr.context.completeTransform(factory, tr), 1E-2);
    }
}
Also used : MathTransformFactory(org.opengis.referencing.operation.MathTransformFactory)

Example 7 with MathTransformFactory

use of org.opengis.referencing.operation.MathTransformFactory in project sis by apache.

the class MolodenskyTransformTest method testProvider.

/**
 * Tests the creation through the provider.
 *
 * @throws FactoryException if an error occurred while creating a transform step.
 * @throws TransformException if a transformation failed.
 */
@Test
@DependsOnMethod("testRandomPoints")
public void testProvider() throws FactoryException, TransformException {
    final MathTransformFactory factory = new MathTransformFactoryMock(new Molodensky());
    final ParameterValueGroup parameters = factory.getDefaultParameters("Molodenski");
    parameters.parameter("dim").setValue(3);
    parameters.parameter("dx").setValue(-3.0);
    parameters.parameter("dy").setValue(142.0);
    parameters.parameter("dz").setValue(183.0);
    parameters.parameter("src_semi_major").setValue(6378206.4);
    parameters.parameter("src_semi_minor").setValue(6356583.8);
    parameters.parameter("tgt_semi_major").setValue(6378137.0);
    parameters.parameter("tgt_semi_minor").setValue(6356752.31414036);
    transform = factory.createParameterizedTransform(parameters);
    assertEquals(3, transform.getSourceDimensions());
    assertEquals(3, transform.getTargetDimensions());
    tolerance = Formulas.ANGULAR_TOLERANCE * 5;
    zTolerance = Formulas.LINEAR_TOLERANCE * 5;
    verifyInDomain(CoordinateDomain.RANGE_10, ORDINATE_COUNT);
}
Also used : Molodensky(org.apache.sis.internal.referencing.provider.Molodensky) MathTransformFactory(org.opengis.referencing.operation.MathTransformFactory) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) GeocentricTranslationTest(org.apache.sis.internal.referencing.provider.GeocentricTranslationTest) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 8 with MathTransformFactory

use of org.opengis.referencing.operation.MathTransformFactory in project sis by apache.

the class TransformSeparatorTest method testConcatenatedTransform.

/**
 * Tests separation of a concatenated transform.
 *
 * @throws FactoryException if an error occurred while creating a new transform.
 */
@Test
@DependsOnMethod("testLinearTransform")
public void testConcatenatedTransform() throws FactoryException {
    final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class);
    final TransformSeparator s = new TransformSeparator(EllipsoidToCentricTransform.createGeodeticConversion(factory, HardCodedDatum.WGS84.getEllipsoid(), false), factory);
    s.addSourceDimensions(0, 1);
    s.addTargetDimensions(0, 1);
    final Iterator<MathTransform> it = MathTransforms.getSteps(s.separate()).iterator();
    assertInstanceOf("normalize", LinearTransform.class, it.next());
    assertInstanceOf("transform", EllipsoidToCentricTransform.class, it.next());
    assertInstanceOf("denormalize", LinearTransform.class, it.next());
    assertFalse(it.hasNext());
}
Also used : MathTransform(org.opengis.referencing.operation.MathTransform) MathTransformFactory(org.opengis.referencing.operation.MathTransformFactory) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 9 with MathTransformFactory

use of org.opengis.referencing.operation.MathTransformFactory in project sis by apache.

the class DefaultMathTransformFactoryTest method factory.

/**
 * Returns the factory to use for the tests.
 *
 * @return the factory to use for the tests.
 */
static DefaultMathTransformFactory factory() {
    final MathTransformFactory factory = DefaultFactories.forClass(MathTransformFactory.class);
    assertNotNull("No Apache SIS implementation of MathTransformFactory found in “META-INF/services”.", factory);
    assertEquals("Expected the default implementation of MathTransformFactory to be first in “META-INF/services”.", DefaultMathTransformFactory.class, factory.getClass());
    return (DefaultMathTransformFactory) factory;
}
Also used : MathTransformFactory(org.opengis.referencing.operation.MathTransformFactory)

Example 10 with MathTransformFactory

use of org.opengis.referencing.operation.MathTransformFactory in project sis by apache.

the class GeoKeysTest method verifyParameterNames.

/**
 * Verifies that parameter names registered in the {@link org.apache.sis.internal.referencing.provider} package
 * match the name of fields listed in {@link GeoKeys}.
 */
@Test
@DependsOnMethod("testName")
public void verifyParameterNames() {
    final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class);
    for (final OperationMethod method : factory.getAvailableMethods(SingleOperation.class)) {
        for (final GeneralParameterDescriptor param : method.getParameters().descriptors()) {
            final Identifier identifier = IdentifiedObjects.getIdentifier(param, Citations.GEOTIFF);
            final Set<String> names = IdentifiedObjects.getNames(param, Citations.GEOTIFF);
            /*
                 * If there is no GeoTIFF identifiers, we should have no GeoTIFF name neither.
                 */
            assertEquals(param.getName().getCode(), identifier == null, names.isEmpty());
            if (identifier != null) {
                final int code = Short.parseShort(identifier.getCode());
                for (final String name : names) {
                    assertEquals(name, code(name), code);
                }
            }
        }
    }
}
Also used : Identifier(org.opengis.metadata.Identifier) MathTransformFactory(org.opengis.referencing.operation.MathTransformFactory) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) OperationMethod(org.opengis.referencing.operation.OperationMethod) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

MathTransformFactory (org.opengis.referencing.operation.MathTransformFactory)10 Test (org.junit.Test)7 DependsOnMethod (org.apache.sis.test.DependsOnMethod)5 OperationMethod (org.opengis.referencing.operation.OperationMethod)3 DefaultParameterDescriptorTest (org.apache.sis.parameter.DefaultParameterDescriptorTest)2 Identifier (org.opengis.metadata.Identifier)2 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)2 Conversion (org.opengis.referencing.operation.Conversion)2 MathTransform (org.opengis.referencing.operation.MathTransform)2 GeocentricTranslationTest (org.apache.sis.internal.referencing.provider.GeocentricTranslationTest)1 Molodensky (org.apache.sis.internal.referencing.provider.Molodensky)1 DefaultProjectedCRS (org.apache.sis.referencing.crs.DefaultProjectedCRS)1 InvalidGeodeticParameterException (org.apache.sis.referencing.factory.InvalidGeodeticParameterException)1 DefaultConversion (org.apache.sis.referencing.operation.DefaultConversion)1 Matrix4 (org.apache.sis.referencing.operation.matrix.Matrix4)1 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)1