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);
}
}
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);
}
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());
}
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;
}
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);
}
}
}
}
}
Aggregations