Search in sources :

Example 11 with CoordinateOperation

use of org.opengis.referencing.operation.CoordinateOperation in project sis by apache.

the class CoordinateOperationFinderTest method testGeocentricTranslationInGeocentricDomain.

/**
 * Tests a transformation using the <cite>"Geocentric translations (geocentric domain)"</cite> method,
 * together with a longitude rotation and unit conversion. The CRS and sample point are derived from
 * the GR3DF97A – <cite>Grille de paramètres de transformation de coordonnées</cite> document.
 *
 * @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("testLongitudeRotation")
public void testGeocentricTranslationInGeocentricDomain() throws ParseException, FactoryException, TransformException {
    final CoordinateReferenceSystem sourceCRS = parse("GeodeticCRS[“NTF (Paris)”, $NTF,\n" + // in degrees.
    "  PrimeMeridian[“Paris”, 2.33722917],\n" + "  CS[Cartesian, 3],\n" + "    Axis[“(X)”, geocentricX],\n" + "    Axis[“(Y)”, geocentricY],\n" + "    Axis[“(Z)”, geocentricZ],\n" + "    Unit[“kilometre”, 1000]]");
    final GeocentricCRS targetCRS = CommonCRS.WGS84.geocentric();
    final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
    assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
    assertSame("targetCRS", targetCRS, operation.getTargetCRS());
    assertFalse("isIdentity", operation.getMathTransform().isIdentity());
    assertEquals("name", "Datum shift", operation.getName().getCode());
    assertSetEquals(Arrays.asList(DATUM_SHIFT_APPLIED), operation.getCoordinateOperationAccuracy());
    assertInstanceOf("operation", Transformation.class, operation);
    assertEquals("method", "Geocentric translations (geocentric domain)", ((SingleOperation) operation).getMethod().getName().getCode());
    /*
         * Same test point than the one used in FranceGeocentricInterpolationTest:
         *
         * ┌────────────────────────────────────────────┬──────────────────────────────────────────────────────────┐
         * │         Geographic coordinates (°)         │                  Geocentric coordinates (m)              │
         * ├────────────────────────────────────────────┼──────────────────────────────────────────────────────────┤
         * │    NTF: 48°50′40.2441″N  2°25′32.4187″E    │    X = 4201905.725   Y = 177998.072   Z = 4778904.260    │
         * │    RGF: 48°50′39.9967″N  2°25′29.8273″E    │      ΔX = -168         ΔY = -60          ΔZ = 320        │
         * └────────────────────────────────────────────┴──────────────────────────────────────────────────────────┘
         *
         * The source coordinate below is different than in the above table because the prime meridian is set to the
         * Paris meridian, so there is a longitude rotation to take in account for X and Y axes.
         */
    transform = operation.getMathTransform();
    tolerance = LINEAR_TOLERANCE;
    verifyTransform(// Paris prime meridian
    new double[] { 4205.669137, 6.491944, 4778.904260 }, // Greenwich prime meridian
    new double[] { 4201737.725, 177938.072, 4779224.260 });
    validate();
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) GeocentricCRS(org.opengis.referencing.crs.GeocentricCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 12 with CoordinateOperation

use of org.opengis.referencing.operation.CoordinateOperation in project sis by apache.

the class CoordinateOperationFinderTest method testProjected4D_to_2D.

/**
 * Tests conversion from four-dimensional compound CRS to two-dimensional projected CRS.
 *
 * @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("testTemporalConversion")
public void testProjected4D_to_2D() throws ParseException, FactoryException, TransformException {
    final CoordinateReferenceSystem targetCRS = parse("ProjectedCRS[“WGS 84 / World Mercator”,\n" + "  BaseGeodCRS[“WGS 84”,\n" + "    Datum[“World Geodetic System 1984”,\n" + "      Ellipsoid[“WGS 84”, 6378137.0, 298.257223563]]],\n" + "  Conversion[“WGS 84 / World Mercator”,\n" + "    Method[“Mercator (1SP)”]],\n" + "  CS[Cartesian, 2],\n" + "    Axis[“Easting”, EAST],\n" + "    Axis[“Northing”, NORTH],\n" + "    Unit[“m”, 1],\n" + "  Id[“EPSG”, “3395”]]");
    CoordinateReferenceSystem sourceCRS = targetCRS;
    sourceCRS = compound("Mercator 3D", sourceCRS, CommonCRS.Vertical.MEAN_SEA_LEVEL.crs());
    sourceCRS = compound("Mercator 4D", sourceCRS, CommonCRS.Temporal.MODIFIED_JULIAN.crs());
    final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
    assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
    assertSame("targetCRS", targetCRS, operation.getTargetCRS());
    transform = operation.getMathTransform();
    assertFalse("transform.isIdentity", transform.isIdentity());
    assertInstanceOf("The somewhat complex MathTransform chain should have been simplified " + "to a single affine transform.", LinearTransform.class, transform);
    assertInstanceOf("The operation should be a simple axis change, not a complex" + "chain of ConcatenatedOperations.", Conversion.class, operation);
    assertEquals("sourceDimensions", 4, transform.getSourceDimensions());
    assertEquals("targetDimensions", 2, transform.getTargetDimensions());
    Assert.assertMatrixEquals("transform.matrix", Matrices.create(3, 5, new double[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), STRICT);
    isInverseTransformSupported = false;
    verifyTransform(new double[] { 0, 0, 0, 0, 1000, -2000, 20, 4000 }, new double[] { 0, 0, 1000, -2000 });
    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 13 with CoordinateOperation

use of org.opengis.referencing.operation.CoordinateOperation 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 14 with CoordinateOperation

use of org.opengis.referencing.operation.CoordinateOperation 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 15 with CoordinateOperation

use of org.opengis.referencing.operation.CoordinateOperation 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)

Aggregations

CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)45 Test (org.junit.Test)32 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)24 DependsOnMethod (org.apache.sis.test.DependsOnMethod)21 CompoundCRS (org.opengis.referencing.crs.CompoundCRS)6 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)6 SingleOperation (org.opengis.referencing.operation.SingleOperation)6 AbstractCoordinateOperation (org.apache.sis.referencing.operation.AbstractCoordinateOperation)5 DefaultCompoundCRS (org.apache.sis.referencing.crs.DefaultCompoundCRS)4 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)4 ConcatenatedOperation (org.opengis.referencing.operation.ConcatenatedOperation)4 MathTransform (org.opengis.referencing.operation.MathTransform)3 Extent (org.opengis.metadata.extent.Extent)2 ReferenceSystem (org.opengis.referencing.ReferenceSystem)2 OperationMethod (org.opengis.referencing.operation.OperationMethod)2 TransformException (org.opengis.referencing.operation.TransformException)2 Transformation (org.opengis.referencing.operation.Transformation)2 FactoryException (org.opengis.util.FactoryException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1