use of org.apache.sis.referencing.operation.matrix.Matrix3 in project sis by apache.
the class SingleOperationMarshallingTest method testTransformationUnmarshalling.
/**
* Tests unmarshalling of a transformation.
*
* @throws JAXBException if an error occurred during marshalling or unmarshalling.
*/
@Test
@DependsOnMethod("testConversionUnmarshalling")
public void testTransformationUnmarshalling() throws JAXBException {
final DefaultTransformation c = unmarshalFile(DefaultTransformation.class, "Transformation.xml");
assertEquals("name", "NTF (Paris) to NTF (1)", c.getName().getCode());
assertEquals("identifier", "1763", getSingleton(c.getIdentifiers()).getCode());
assertEquals("scope", "Change of prime meridian.", String.valueOf(c.getScope()));
assertEquals("operationVersion", "IGN-Fra", c.getOperationVersion());
final OperationMethod method = c.getMethod();
assertNotNull("method", method);
assertEquals("method.name", "Longitude rotation", method.getName().getCode());
assertEquals("method.identifier", "9601", getSingleton(method.getIdentifiers()).getCode());
assertEquals("method.formula", "Target_longitude = Source_longitude + longitude_offset.", method.getFormula().getFormula().toString());
final ParameterDescriptor<?> descriptor = (ParameterDescriptor<?>) getSingleton(method.getParameters().descriptors());
assertEquals("descriptor.name", "Longitude offset", descriptor.getName().getCode());
assertEquals("descriptor.identifier", "8602", getSingleton(descriptor.getIdentifiers()).getCode());
assertEquals("descriptor.valueClass", Double.class, descriptor.getValueClass());
final ParameterValueGroup parameters = c.getParameterValues();
assertNotNull("parameters", parameters);
assertSame("parameters.descriptors", method.getParameters(), parameters.getDescriptor());
final ParameterValue<?> parameter = (ParameterValue<?>) getSingleton(parameters.values());
assertSame("parameters.descriptor", descriptor, parameter.getDescriptor());
assertEquals("parameters.unit", Units.GRAD, parameter.getUnit());
assertEquals("parameters.value", 2.5969213, parameter.getValue());
final CoordinateReferenceSystem sourceCRS = c.getSourceCRS();
assertInstanceOf("sourceCRS", GeodeticCRS.class, sourceCRS);
assertEquals("sourceCRS.name", "NTF (Paris)", sourceCRS.getName().getCode());
assertEquals("sourceCRS.scope", "Geodetic survey.", sourceCRS.getScope().toString());
assertEquals("sourceCRS.identifier", "4807", getSingleton(sourceCRS.getIdentifiers()).getCode());
final CoordinateReferenceSystem targetCRS = c.getTargetCRS();
assertInstanceOf("targetCRS", GeodeticCRS.class, targetCRS);
assertEquals("targetCRS.name", "NTF", targetCRS.getName().getCode());
assertEquals("targetCRS.scope", "Geodetic survey.", targetCRS.getScope().toString());
assertEquals("targetCRS.identifier", "4275", getSingleton(targetCRS.getIdentifiers()).getCode());
final MathTransform tr = c.getMathTransform();
assertInstanceOf("mathTransform", LinearTransform.class, tr);
assertMatrixEquals("mathTransform.matrix", new Matrix3(1, 0, 0, 0, 1, 2.33722917, 0, 0, 1), ((LinearTransform) tr).getMatrix(), STRICT);
Validators.validate(c);
}
use of org.apache.sis.referencing.operation.matrix.Matrix3 in project sis by apache.
the class ContextualParametersTest method testCompleteTransform.
/**
* Tests {@link ContextualParameters#completeTransform(MathTransformFactory, MathTransform)}
* with non-identity normalization transforms.
*
* @throws FactoryException should never happen.
*/
@Test
@DependsOnMethod("testSameTransform")
public void testCompleteTransform() throws FactoryException {
final ContextualParameters p = create(2, 2);
final Matrix normalize = p.normalizeGeographicInputs(12);
final Matrix denormalize = p.denormalizeGeographicOutputs(18);
final Matrix product = MathTransforms.getMatrix(p.completeTransform(DefaultMathTransformFactoryTest.factory(), MathTransforms.identity(2)));
assertMatrixEquals("normalize", new Matrix3(PI / 180, 0, toRadians(-12), 0, PI / 180, 0, 0, 0, 1), normalize, 1E-16);
assertMatrixEquals("denormalize", new Matrix3(180 / PI, 0, 18, 0, 180 / PI, 0, 0, 0, 1), denormalize, STRICT);
assertMatrixEquals("product", new Matrix3(1, 0, 6, 0, 1, 0, 0, 0, 1), product, STRICT);
}
use of org.apache.sis.referencing.operation.matrix.Matrix3 in project sis by apache.
the class PassThroughTransformTest method testIdentity.
/**
* Tests the pass through transform using an identity transform.
* The "pass-through" of such transform shall be itself the identity transform.
*
* @throws TransformException should never happen.
*/
@Test
public void testIdentity() throws TransformException {
final Matrix matrix = new Matrix3();
runTest(MathTransforms.linear(matrix), IdentityTransform.class);
}
use of org.apache.sis.referencing.operation.matrix.Matrix3 in project sis by apache.
the class MathTransformParserTest method testParamMT.
/**
* Tests parsing of a {@code PARAM_MT["Affine", …]} element.
*
* @throws ParseException if an error occurred during the parsing.
*/
@Test
public void testParamMT() throws ParseException {
MathTransform tr;
tr = parse("PARAM_MT[\"Affine\"," + "PARAMETER[\"num_row\",2]," + "PARAMETER[\"num_col\",2]," + "PARAMETER[\"elt_0_1\",7]]");
assertMatrixEquals("Affine", new Matrix2(1, 7, 0, 1), MathTransforms.getMatrix(tr), STRICT);
/*
* Larger matrix, mix quote and bracket styles and insert spaces.
*/
tr = parse("Param_MT(\"Affine\", " + "PARAMETER(“num_row”, 3), " + "Parameter(“num_col”, 3),\n" + "parameter[“elt_0_1”, 1], " + "parameter[“elt_0_2”, 2], " + "parameter[“elt_1_2”, 3] )");
assertMatrixEquals("Affine", new Matrix3(1, 1, 2, 0, 1, 3, 0, 0, 1), MathTransforms.getMatrix(tr), STRICT);
}
use of org.apache.sis.referencing.operation.matrix.Matrix3 in project sis by apache.
the class DefaultDerivedCRSTest method testConstruction.
/**
* Tests the construction of a {@link DefaultDerivedCRS}.
*/
@Test
public void testConstruction() {
final DefaultDerivedCRS crs = createLongitudeRotation();
// Validators.validate(crs);
assertEquals("name", "Back to Greenwich", crs.getName().getCode());
assertEquals("baseCRS", "NTF (Paris)", crs.getBaseCRS().getName().getCode());
assertEquals("datum", "Nouvelle Triangulation Française", crs.getDatum().getName().getCode());
assertSame("coordinateSystem", HardCodedCS.GEODETIC_φλ, crs.getCoordinateSystem());
final Conversion conversion = crs.getConversionFromBase();
assertSame("sourceCRS", crs.getBaseCRS(), conversion.getSourceCRS());
assertSame("targetCRS", crs, conversion.getTargetCRS());
assertMatrixEquals("Longitude rotation", new Matrix3(0, 1, 0, 1, 0, 2.33722917, 0, 0, 1), MathTransforms.getMatrix(conversion.getMathTransform()), STRICT);
}
Aggregations