Search in sources :

Example 36 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem in project sis by apache.

the class CoordinateOperationRegistryTest method testLongitudeRotationBetweenNormalizedGeographic3D.

/**
 * Tests <cite>"NTF (Paris) to WGS 84 (1)"</cite> operation with three-dimensional source and target CRS
 * having different axis order and units than the ones declared in the EPSG dataset.
 *
 * @throws ParseException if a CRS used in this test can not be parsed.
 * @throws FactoryException if the operation can not be created.
 * @throws TransformException if an error occurred while converting the test points.
 */
@Test
@DependsOnMethod({ "testLongitudeRotationBetweenNormalizedCRS", "testLongitudeRotationBetweenGeographic3D" })
public void testLongitudeRotationBetweenNormalizedGeographic3D() throws ParseException, FactoryException, TransformException {
    final CoordinateReferenceSystem sourceCRS = parse("GeodeticCRS[“NTF (Paris)”,\n" + "  $NTF,\n" + "    PrimeMeridian[“Paris”, 2.33722917],\n" + "  CS[ellipsoidal, 3],\n" + "    Axis[“Longitude (λ)”, EAST, Unit[“degree”, 0.017453292519943295]],\n" + "    Axis[“Latitude (φ)”, NORTH, Unit[“degree”, 0.017453292519943295]],\n" + "    Axis[“Height (h)”, UP, Unit[“m”, 1]]]");
    final CoordinateReferenceSystem targetCRS = DefaultGeographicCRS.castOrCopy(CommonCRS.WGS84.geographic3D()).forConvention(AxesConvention.NORMALIZED);
    final CoordinateOperation operation = createOperation(sourceCRS, targetCRS);
    verifyNTF(operation, "geog3D domain", false);
    transform = operation.getMathTransform();
    tolerance = Formulas.ANGULAR_TOLERANCE;
    zTolerance = Formulas.LINEAR_TOLERANCE;
    zDimension = new int[] { 2 };
    λDimension = new int[] { 1 };
    // Because GeoAPI 3.0 does not distinguish z axis from other axes (fixed in GeoAPI 3.1).
    tolerance = zTolerance;
    verifyTransform(// in degrees east of Paris
    new double[] { 0.088442691, 48.844512250, 20.00 }, // in degrees east of Greenwich
    new double[] { 2.424952028, 48.844443528, 63.15 });
    validate();
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 37 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem in project sis by apache.

the class CoordinateOperationRegistryTest method testLongitudeRotationBetweenGeographic3D.

/**
 * Tests <cite>"NTF (Paris) to WGS 84 (1)"</cite> operation with three-dimensional source and target CRS.
 * {@link CoordinateOperationRegistry} should be able to find the operation despite the difference in
 * number of dimensions.
 *
 * @throws ParseException if a CRS used in this test can not be parsed.
 * @throws FactoryException if the operation can not be created.
 * @throws TransformException if an error occurred while converting the test points.
 */
@Test
@DependsOnMethod("testLongitudeRotationBetweenConformCRS")
public void testLongitudeRotationBetweenGeographic3D() throws ParseException, FactoryException, TransformException {
    final CoordinateReferenceSystem sourceCRS = parse("GeodeticCRS[“NTF (Paris)”,\n" + "  $NTF,\n" + "    PrimeMeridian[“Paris”, 2.5969213],\n" + "  CS[ellipsoidal, 3],\n" + "    Axis[“Latitude (φ)”, NORTH, Unit[“grad”, 0.015707963267948967]],\n" + "    Axis[“Longitude (λ)”, EAST, Unit[“grad”, 0.015707963267948967]],\n" + "    Axis[“Height (h)”, UP, Unit[“m”, 1]]]");
    final CoordinateReferenceSystem targetCRS = CommonCRS.WGS84.geographic3D();
    final CoordinateOperation operation = createOperation(sourceCRS, targetCRS);
    verifyNTF(operation, "geog3D domain", false);
    transform = operation.getMathTransform();
    tolerance = Formulas.ANGULAR_TOLERANCE;
    zTolerance = Formulas.LINEAR_TOLERANCE;
    zDimension = new int[] { 2 };
    λDimension = new int[] { 1 };
    // Because GeoAPI 3.0 does not distinguish z axis from other axes (fixed in GeoAPI 3.1).
    tolerance = zTolerance;
    verifyTransform(// in grads east of Paris
    new double[] { 54.271680278, 0.098269657, 20.00 }, // in degrees east of Greenwich
    new double[] { 48.844443528, 2.424952028, 63.15 });
    validate();
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 38 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem in project sis by apache.

the class CoordinateOperationRegistryTest method testLongitudeRotationBetweenConformCRS.

/**
 * Tests <cite>"NTF (Paris) to WGS 84 (1)"</cite> operation with source and target CRS conform to EPSG definitions.
 *
 * @throws ParseException if a CRS used in this test can not be parsed.
 * @throws FactoryException if the operation can not be created.
 * @throws TransformException if an error occurred while converting the test points.
 */
@Test
public void testLongitudeRotationBetweenConformCRS() throws ParseException, FactoryException, TransformException {
    final CoordinateReferenceSystem sourceCRS = parse("GeodeticCRS[“NTF (Paris)”,\n" + "  $NTF,\n" + "    PrimeMeridian[“Paris”, 2.5969213],\n" + "  CS[ellipsoidal, 2],\n" + "    Axis[“Latitude (φ)”, NORTH],\n" + "    Axis[“Longitude (λ)”, EAST],\n" + "    Unit[“grad”, 0.015707963267948967]]");
    // Intentionally omit Id[“EPSG”, 4807] for testing capability to find it back.
    final CoordinateReferenceSystem targetCRS = CommonCRS.WGS84.geographic();
    final CoordinateOperation operation = createOperation(sourceCRS, targetCRS);
    verifyNTF(operation, "geog2D domain", true);
    /*
         * Same test point than the one used in FranceGeocentricInterpolationTest:
         *
         * NTF: 48°50′40.2441″N  2°25′32.4187″E
         * RGF: 48°50′39.9967″N  2°25′29.8273″E     (close to WGS84)
         */
    transform = operation.getMathTransform();
    tolerance = Formulas.ANGULAR_TOLERANCE;
    λDimension = new int[] { 1 };
    verifyTransform(// in grads east of Paris
    new double[] { 54.271680278, 0.098269657 }, // in degrees east of Greenwich
    new double[] { 48.844443528, 2.424952028 });
    validate();
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test)

Example 39 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem in project sis by apache.

the class CoordinateOperationRegistryTest method testInverse.

/**
 * Tests the inverse of <cite>"NTF (Paris) to WGS 84 (1)"</cite> operation, also with different axis order.
 *
 * @throws ParseException if a CRS used in this test can not be parsed.
 * @throws FactoryException if the operation can not be created.
 * @throws TransformException if an error occurred while converting the test points.
 */
@Test
@DependsOnMethod("testLongitudeRotationBetweenNormalizedCRS")
public void testInverse() throws ParseException, FactoryException, TransformException {
    final CoordinateReferenceSystem targetCRS = parse("GeodeticCRS[“NTF (Paris)”,\n" + "  $NTF,\n" + "    PrimeMeridian[“Paris”, 2.5969213],\n" + "  CS[ellipsoidal, 2],\n" + "    Axis[“Longitude (λ)”, EAST],\n" + "    Axis[“Latitude (φ)”, NORTH],\n" + "    Unit[“grad”, 0.015707963267948967]]");
    final CoordinateReferenceSystem sourceCRS = CommonCRS.WGS84.normalizedGeographic();
    final CoordinateOperation operation = createOperation(sourceCRS, targetCRS);
    transform = operation.getMathTransform();
    tolerance = Formulas.ANGULAR_TOLERANCE;
    λDimension = new int[] { 1 };
    verifyTransform(// in degrees east of Greenwich
    new double[] { 2.424952028, 48.844443528 }, // in grads east of Paris
    new double[] { 0.098269657, 54.271680278 });
    validate();
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 40 with CoordinateReferenceSystem

use of org.opengis.referencing.crs.CoordinateReferenceSystem 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)

Aggregations

CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)210 Test (org.junit.Test)80 MathTransform (org.opengis.referencing.operation.MathTransform)32 FactoryException (org.opengis.referencing.FactoryException)25 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)24 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)23 Geometry (com.vividsolutions.jts.geom.Geometry)21 TransformException (org.opengis.referencing.operation.TransformException)21 DependsOnMethod (org.apache.sis.test.DependsOnMethod)19 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)13 Geometry (org.locationtech.jts.geom.Geometry)11 FactoryException (org.opengis.util.FactoryException)11 SimpleFeature (org.opengis.feature.simple.SimpleFeature)9 DirectPosition (org.opengis.geometry.DirectPosition)9 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)9 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)9 CoordinateSystemAxis (org.opengis.referencing.cs.CoordinateSystemAxis)9 ArrayList (java.util.ArrayList)8 GeometryType (org.opengis.feature.type.GeometryType)8 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)7