Search in sources :

Example 1 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class CoordinateOperationFinderTest method testGeographic3D_to_2D.

/**
 * Tests the conversion from a three-dimensional geographic CRS to a two-dimensional geographic CRS.
 * The vertical dimension is simply dropped.
 *
 * @throws FactoryException if the operation can not be created.
 * @throws TransformException if an error occurred while converting the test points.
 */
@Test
@DependsOnMethod("testIdentityTransform")
public void testGeographic3D_to_2D() throws FactoryException, TransformException {
    final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic3D();
    final GeographicCRS targetCRS = CommonCRS.WGS84.geographic();
    final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
    assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
    assertSame("targetCRS", targetCRS, operation.getTargetCRS());
    assertEquals("name", "Axis changes", operation.getName().getCode());
    assertInstanceOf("operation", Conversion.class, operation);
    final ParameterValueGroup parameters = ((SingleOperation) operation).getParameterValues();
    assertEquals("parameters.descriptor", "Geographic3D to 2D conversion", parameters.getDescriptor().getName().getCode());
    assertTrue("parameters.isEmpty", parameters.values().isEmpty());
    transform = operation.getMathTransform();
    assertInstanceOf("transform", LinearTransform.class, transform);
    assertEquals("sourceDimensions", 3, transform.getSourceDimensions());
    assertEquals("targetDimensions", 2, transform.getTargetDimensions());
    Assert.assertMatrixEquals("transform.matrix", Matrices.create(3, 4, new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), STRICT);
    isInverseTransformSupported = false;
    verifyTransform(new double[] { 30, 10, 20, 20, 30, -10 }, new double[] { 30, 10, 20, 30 });
    validate();
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) SingleOperation(org.opengis.referencing.operation.SingleOperation) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 2 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class CoordinateOperationRegistryTest method verifyNTF.

/**
 * Verifies a coordinate operation which is expected to be <cite>"NTF (Paris) to WGS 84 (1)"</cite> (EPSG:8094).
 *
 * @param  domain  either {@code "geog2D domain"} or either {@code "geog3D domain"}.
 * @param  isEPSG  {@code true} if the coordinate operation is expected to contain EPSG identifiers.
 */
private static void verifyNTF(final CoordinateOperation operation, final String domain, final boolean isEPSG) {
    assertInstanceOf("Operation should have two steps.", ConcatenatedOperation.class, operation);
    final List<? extends CoordinateOperation> steps = ((ConcatenatedOperation) operation).getOperations();
    assertEquals("Operation should have two steps.", 2, steps.size());
    final SingleOperation step1 = (SingleOperation) steps.get(0);
    final SingleOperation step2 = (SingleOperation) steps.get(1);
    if (isEPSG) {
        assertEpsgNameAndIdentifierEqual("NTF (Paris) to WGS 84 (1)", 8094, operation);
        assertEpsgNameAndIdentifierEqual("NTF (Paris)", 4807, operation.getSourceCRS());
        assertEpsgNameAndIdentifierEqual("WGS 84", 4326, operation.getTargetCRS());
        assertEpsgNameAndIdentifierEqual("NTF (Paris) to NTF (1)", 1763, step1);
        assertEpsgNameAndIdentifierEqual("NTF to WGS 84 (1)", 1193, step2);
    } else {
        assertEpsgNameWithoutIdentifierEqual("NTF (Paris) to WGS 84 (1)", operation);
        assertEpsgNameWithoutIdentifierEqual("NTF (Paris)", operation.getSourceCRS());
        assertEquals("name", "WGS 84", operation.getTargetCRS().getName().getCode());
        assertEpsgNameWithoutIdentifierEqual("NTF (Paris) to NTF (1)", step1);
        assertEpsgNameWithoutIdentifierEqual("NTF to WGS 84 (1)", step2);
    }
    assertSame("SourceCRS shall be the targetCRS of previous step.", step1.getTargetCRS(), step2.getSourceCRS());
    assertEquals("Method 1", "Longitude rotation", step1.getMethod().getName().getCode());
    assertEquals("Method 2", "Geocentric translations (" + domain + ')', step2.getMethod().getName().getCode());
    final ParameterValueGroup p1 = step1.getParameterValues();
    final ParameterValueGroup p2 = step2.getParameterValues();
    assertEquals("Longitude offset", 2.5969213, p1.parameter("Longitude offset").doubleValue(), STRICT);
    assertEquals("X-axis translation", -168, p2.parameter("X-axis translation").doubleValue(), STRICT);
    assertEquals("Y-axis translation", -60, p2.parameter("Y-axis translation").doubleValue(), STRICT);
    assertEquals("Z-axis translation", 320, p2.parameter("Z-axis translation").doubleValue(), STRICT);
    assertEquals("linearAccuracy", 2, CRS.getLinearAccuracy(operation), STRICT);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ConcatenatedOperation(org.opengis.referencing.operation.ConcatenatedOperation) SingleOperation(org.opengis.referencing.operation.SingleOperation)

Example 3 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class CoordinateOperationRegistryTest method testFindDespiteDifferentAxisOrder.

/**
 * Tests <cite>"Martinique 1938 to RGAF09 (1)"</cite> operation with a target CRS fixed to EPSG:7086
 * instead of EPSG:5489. Both are <cite>"RGAF09"</cite>, but the former use (longitude, latitude) axis
 * order instead than the usual (latitude, longitude) order. The source CRS stay fixed to EPSG:4625.
 *
 * @throws FactoryException if an error occurred while creating a CRS or operation.
 */
@Test
public void testFindDespiteDifferentAxisOrder() throws FactoryException {
    CoordinateReferenceSystem sourceCRS = crsFactory.createGeographicCRS("EPSG:4625");
    CoordinateReferenceSystem targetCRS = crsFactory.createGeographicCRS("EPSG:5489");
    CoordinateOperation operation = createOperation(sourceCRS, targetCRS);
    assertEpsgNameAndIdentifierEqual("Martinique 1938 to RGAF09 (1)", 5491, operation);
    /*
         * Above was only a verification using the source and target CRS expected by EPSG dataset.
         * Now the interesting test: use a target CRS with different axis order.
         */
    targetCRS = crsFactory.createGeographicCRS("EPSG:7086");
    operation = createOperation(sourceCRS, targetCRS);
    assertEpsgNameWithoutIdentifierEqual("Martinique 1938 to RGAF09 (1)", operation);
    final ParameterValueGroup p = ((SingleOperation) operation).getParameterValues();
    /*
         * Values below are copied from EPSG geodetic dataset 9.1. They may need
         * to be adjusted if a future version of EPSG dataset modify those values.
         */
    assertEquals("X-axis translation", 127.744, p.parameter("X-axis translation").doubleValue(), STRICT);
    assertEquals("Y-axis translation", 547.069, p.parameter("Y-axis translation").doubleValue(), STRICT);
    assertEquals("Z-axis translation", 118.359, p.parameter("Z-axis translation").doubleValue(), STRICT);
    assertEquals("X-axis rotation", -3.1116, p.parameter("X-axis rotation").doubleValue(), STRICT);
    assertEquals("Y-axis rotation", 4.9509, p.parameter("Y-axis rotation").doubleValue(), STRICT);
    assertEquals("Z-axis rotation", -0.8837, p.parameter("Z-axis rotation").doubleValue(), STRICT);
    assertEquals("Scale difference", 14.1012, p.parameter("Scale difference").doubleValue(), STRICT);
    assertEquals("linearAccuracy", 0.1, CRS.getLinearAccuracy(operation), STRICT);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) SingleOperation(org.opengis.referencing.operation.SingleOperation) Test(org.junit.Test)

Example 4 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class DefaultCoordinateOperationFactoryTest method verifyParametersNTF.

/**
 * Verifies the datum shift parameters in the <cite>"NTF to WGS 84 (1)"</cite> transformation.
 * Those parameters depends on whether an EPSG database have been used or not.
 *
 * @param  steps            the list returned by {@link DefaultConcatenatedOperation#getOperations()}.
 * @param  datumShiftIndex  index of the datum shift operations in the {@code steps} list.
 * @return the {@link #isUsingEpsgFactory()} value, returned for convenience.
 */
private static boolean verifyParametersNTF(final List<? extends CoordinateOperation> steps, final int datumShiftIndex) throws FactoryException {
    if (isUsingEpsgFactory()) {
        final SingleOperation step1 = (SingleOperation) steps.get(datumShiftIndex);
        final SingleOperation step2 = (SingleOperation) steps.get(datumShiftIndex + 1);
        assertEpsgNameAndIdentifierEqual("NTF (Paris) to NTF (1)", 1763, step1);
        assertEpsgNameAndIdentifierEqual("NTF to WGS 84 (1)", 1193, step2);
        final ParameterValueGroup p1 = step1.getParameterValues();
        final ParameterValueGroup p2 = step2.getParameterValues();
        assertEquals("Longitude offset", 2.5969213, p1.parameter("Longitude offset").doubleValue(), STRICT);
        assertEquals("X-axis translation", -168, p2.parameter("X-axis translation").doubleValue(), STRICT);
        assertEquals("Y-axis translation", -60, p2.parameter("Y-axis translation").doubleValue(), STRICT);
        assertEquals("Z-axis translation", 320, p2.parameter("Z-axis translation").doubleValue(), STRICT);
        return true;
    } else {
        assertSame(CoordinateOperationFinder.ELLIPSOID_CHANGE, steps.get(datumShiftIndex).getName());
        return false;
    }
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) SingleOperation(org.opengis.referencing.operation.SingleOperation)

Example 5 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class DefaultTransformationTest method verifyProperties.

/**
 * Asserts that at least some of the properties of the given {@code op} instance have the expected values
 * for an instance created by {@link #createGeocentricTranslation()}.
 */
@SuppressWarnings("SuspiciousToArrayCall")
private static void verifyProperties(final DefaultTransformation op) {
    assertEquals("name", "Tokyo to JGD2000 (GSI)", op.getName().getCode());
    assertEquals("sourceCRS", "Tokyo 1918", op.getSourceCRS().getName().getCode());
    assertEquals("targetCRS", "JGD2000", op.getTargetCRS().getName().getCode());
    assertEquals("method", "Geocentric translations", op.getMethod().getName().getCode());
    assertEquals("parameters", "Geocentric translations", op.getParameterDescriptors().getName().getCode());
    final ParameterValueGroup parameters = op.getParameterValues();
    final ParameterValue<?>[] values = parameters.values().toArray(new ParameterValue<?>[3]);
    assertEquals("parameters", "Geocentric translations", parameters.getDescriptor().getName().getCode());
    assertEquals("parameters[0]", "X-axis translation", values[0].getDescriptor().getName().getCode());
    assertEquals("parameters[1]", "Y-axis translation", values[1].getDescriptor().getName().getCode());
    assertEquals("parameters[2]", "Z-axis translation", values[2].getDescriptor().getName().getCode());
    assertEquals("parameters[0]", -146.414, values[0].doubleValue(), STRICT);
    assertEquals("parameters[1]", 507.337, values[1].doubleValue(), STRICT);
    assertEquals("parameters[2]", 680.507, values[2].doubleValue(), STRICT);
    assertEquals(3, values.length);
    final Matrix m = MathTransforms.getMatrix(op.getMathTransform());
    assertNotNull("transform", m);
    for (int j = m.getNumRow(); --j >= 0; ) {
        for (int i = m.getNumCol(); --i >= 0; ) {
            double expected = (i == j) ? 1 : 0;
            if (i == 2)
                switch(j) {
                    case 0:
                        expected = -146.414;
                        break;
                    case 1:
                        expected = 507.337;
                        break;
                    case 2:
                        expected = 680.507;
                        break;
                }
            assertEquals(expected, m.getElement(j, i), STRICT);
        }
    }
}
Also used : Matrix(org.opengis.referencing.operation.Matrix) ParameterValue(org.opengis.parameter.ParameterValue) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup)

Aggregations

ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)98 Test (org.junit.Test)54 DependsOnMethod (org.apache.sis.test.DependsOnMethod)27 GeneralParameterValue (org.opengis.parameter.GeneralParameterValue)12 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)11 OperationMethod (org.opengis.referencing.operation.OperationMethod)11 ParameterValue (org.opengis.parameter.ParameterValue)8 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7 ParameterNotFoundException (org.opengis.parameter.ParameterNotFoundException)7 SingleOperation (org.opengis.referencing.operation.SingleOperation)6 FactoryException (org.opengis.util.FactoryException)6 DefaultGeodeticDatum (org.apache.sis.referencing.datum.DefaultGeodeticDatum)5 IdentifiedObject (org.opengis.referencing.IdentifiedObject)5 Matrix (org.opengis.referencing.operation.Matrix)5 ArrayList (java.util.ArrayList)4 DefaultConversion (org.apache.sis.referencing.operation.DefaultConversion)4 ParameterDescriptorGroup (org.opengis.parameter.ParameterDescriptorGroup)4 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)4 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)4 URL (java.net.URL)3