Search in sources :

Example 11 with CompoundCRS

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

the class CoordinateOperationFinderTest method testGeographic4D_to_2D.

// ////////////////////////////////////////////////////////////////////////////////
// //////////                                                          ////////////
// //////////        Tests that change the number of dimensions        ////////////
// //////////                                                          ////////////
// ////////////////////////////////////////////////////////////////////////////////
/**
 * Tests the conversion from a four-dimensional geographic CRS to a two-dimensional geographic CRS.
 * The vertical and temporal dimensions are simply dropped.
 *
 * @throws FactoryException if the operation can not be created.
 * @throws TransformException if an error occurred while converting the test points.
 */
@Test
@DependsOnMethod("testGeographic3D_to_2D")
public void testGeographic4D_to_2D() throws FactoryException, TransformException {
    // NOTE: make sure that the 'sourceCRS' below is not equal to any other 'sourceCRS' created in this class.
    final CompoundCRS sourceCRS = compound("Test4D", CommonCRS.WGS84.geographic3D(), CommonCRS.Temporal.UNIX.crs());
    final GeographicCRS targetCRS = CommonCRS.WGS84.geographic();
    final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
    assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
    assertSame("targetCRS", targetCRS, operation.getTargetCRS());
    transform = operation.getMathTransform();
    assertInstanceOf("transform", LinearTransform.class, transform);
    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[] { 30, 10, 20, 1000, 20, 30, -10, 3000 }, new double[] { 30, 10, 20, 30 });
    validate();
}
Also used : CompoundCRS(org.opengis.referencing.crs.CompoundCRS) DefaultCompoundCRS(org.apache.sis.referencing.crs.DefaultCompoundCRS) CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

CompoundCRS (org.opengis.referencing.crs.CompoundCRS)11 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)6 DefaultCompoundCRS (org.apache.sis.referencing.crs.DefaultCompoundCRS)5 Test (org.junit.Test)5 DependsOnMethod (org.apache.sis.test.DependsOnMethod)4 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)3 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)3 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)3 IdentifiedObject (org.opengis.referencing.IdentifiedObject)2 DerivedCRS (org.opengis.referencing.crs.DerivedCRS)2 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)2 ConcatenatedOperation (org.opengis.referencing.operation.ConcatenatedOperation)2 HashMap (java.util.HashMap)1 DefaultDerivedCRS (org.apache.sis.referencing.crs.DefaultDerivedCRS)1 DefaultVerticalCRS (org.apache.sis.referencing.crs.DefaultVerticalCRS)1 DefaultVerticalCS (org.apache.sis.referencing.cs.DefaultVerticalCS)1 IdentifiedObjectFinder (org.apache.sis.referencing.factory.IdentifiedObjectFinder)1 NoSuchAuthorityFactoryException (org.apache.sis.referencing.factory.NoSuchAuthorityFactoryException)1 PassThroughTransform (org.apache.sis.referencing.operation.transform.PassThroughTransform)1 UnsupportedImplementationException (org.apache.sis.util.UnsupportedImplementationException)1