Search in sources :

Example 1 with Matrix3

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);
}
Also used : ParameterValue(org.opengis.parameter.ParameterValue) GeneralParameterValue(org.opengis.parameter.GeneralParameterValue) MathTransform(org.opengis.referencing.operation.MathTransform) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) ParameterDescriptor(org.opengis.parameter.ParameterDescriptor) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) OperationMethod(org.opengis.referencing.operation.OperationMethod) Matrix3(org.apache.sis.referencing.operation.matrix.Matrix3) CC_OperationParameterGroupTest(org.apache.sis.internal.jaxb.referencing.CC_OperationParameterGroupTest) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 2 with Matrix3

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);
}
Also used : Matrix(org.opengis.referencing.operation.Matrix) Matrix3(org.apache.sis.referencing.operation.matrix.Matrix3) Test(org.junit.Test) DefaultParameterDescriptorGroupTest(org.apache.sis.parameter.DefaultParameterDescriptorGroupTest) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 3 with Matrix3

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);
}
Also used : Matrix(org.opengis.referencing.operation.Matrix) Matrix3(org.apache.sis.referencing.operation.matrix.Matrix3) Test(org.junit.Test)

Example 4 with Matrix3

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);
}
Also used : MathTransform(org.opengis.referencing.operation.MathTransform) Matrix2(org.apache.sis.referencing.operation.matrix.Matrix2) Matrix3(org.apache.sis.referencing.operation.matrix.Matrix3) Test(org.junit.Test)

Example 5 with Matrix3

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);
}
Also used : DefaultConversion(org.apache.sis.referencing.operation.DefaultConversion) Conversion(org.opengis.referencing.operation.Conversion) Matrix3(org.apache.sis.referencing.operation.matrix.Matrix3) DefaultConversionTest(org.apache.sis.referencing.operation.DefaultConversionTest) Test(org.junit.Test)

Aggregations

Matrix3 (org.apache.sis.referencing.operation.matrix.Matrix3)13 Test (org.junit.Test)10 MathTransform (org.opengis.referencing.operation.MathTransform)6 DependsOnMethod (org.apache.sis.test.DependsOnMethod)4 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)3 Matrix (org.opengis.referencing.operation.Matrix)3 Angle (javax.measure.quantity.Angle)2 Matrix2 (org.apache.sis.referencing.operation.matrix.Matrix2)2 Envelope (org.opengis.geometry.Envelope)2 ParameterValue (org.opengis.parameter.ParameterValue)2 CC_OperationParameterGroupTest (org.apache.sis.internal.jaxb.referencing.CC_OperationParameterGroupTest)1 DefaultParameterDescriptorGroupTest (org.apache.sis.parameter.DefaultParameterDescriptorGroupTest)1 DefaultConversion (org.apache.sis.referencing.operation.DefaultConversion)1 DefaultConversionTest (org.apache.sis.referencing.operation.DefaultConversionTest)1 Matrix4 (org.apache.sis.referencing.operation.matrix.Matrix4)1 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)1 GeneralParameterValue (org.opengis.parameter.GeneralParameterValue)1 ParameterDescriptor (org.opengis.parameter.ParameterDescriptor)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1 Conversion (org.opengis.referencing.operation.Conversion)1