Search in sources :

Example 1 with DefaultCompoundCRS

use of org.apache.sis.referencing.crs.DefaultCompoundCRS in project sis by apache.

the class CRSTest method testGetComponentAt.

/**
 * Tests {@link CRS#getComponentAt(CoordinateReferenceSystem, int, int)}.
 *
 * @since 0.5
 */
@Test
public void testGetComponentAt() {
    testGetComponentAt(// Null because our CRS has no component for the 'x' axis alone.
    null, // Null because our CRS has no component for the 'y' axis alone.
    null, HardCodedCRS.GRAVITY_RELATED_HEIGHT, HardCodedCRS.TIME, HardCodedCRS.WGS84, // Null because our CRS has no (x,y,z) component.
    null, HardCodedCRS.GEOID_4D);
    /*
         * The above tests was for the standard (x,y,z,t) flat view.
         * Now test again, but with a more hierarchical structure: ((x,y,z),t)
         */
    testGetComponentAt(// Null because our CRS has no component for the 'x' axis alone.
    null, // Null because our CRS has no component for the 'y' axis alone.
    null, HardCodedCRS.GRAVITY_RELATED_HEIGHT, HardCodedCRS.TIME, HardCodedCRS.WGS84, HardCodedCRS.GEOID_3D, new DefaultCompoundCRS(IdentifiedObjects.getProperties(HardCodedCRS.GEOID_4D), HardCodedCRS.GEOID_3D, HardCodedCRS.TIME));
}
Also used : DefaultCompoundCRS(org.apache.sis.referencing.crs.DefaultCompoundCRS) Test(org.junit.Test)

Example 2 with DefaultCompoundCRS

use of org.apache.sis.referencing.crs.DefaultCompoundCRS in project sis by apache.

the class EnvelopesTest method testTransform4to2D.

/**
 * Tests the transformation of an envelope from a 4D CRS to a 2D CRS
 * where the ordinates in one dimension are NaN.
 *
 * @throws TransformException if an error occurred while transforming the envelope.
 *
 * @since 0.8
 */
@Test
public void testTransform4to2D() throws TransformException {
    final CoordinateReferenceSystem targetCRS = HardCodedCRS.WGS84;
    final CoordinateReferenceSystem sourceCRS = new DefaultCompoundCRS(Collections.singletonMap(DefaultCompoundCRS.NAME_KEY, "4D CRS"), HardCodedCRS.WGS84, HardCodedCRS.GRAVITY_RELATED_HEIGHT, HardCodedCRS.TIME);
    final GeneralEnvelope env = new GeneralEnvelope(sourceCRS);
    env.setRange(0, -170, 170);
    env.setRange(1, -80, 80);
    env.setRange(2, -50, -50);
    env.setRange(3, Double.NaN, Double.NaN);
    // Opportunist test (not really the topic of this method).
    assertFalse("isAllNaN", env.isAllNaN());
    // Opportunist test (not really the topic of this method).
    assertTrue("isEmpty", env.isEmpty());
    /*
         * If the referencing framework has selected the CopyTransform implementation
         * as expected, then the envelope ordinates should not be NaN.
         */
    final Envelope env2D = Envelopes.transform(env, targetCRS);
    assertEquals(-170, env2D.getMinimum(0), 0);
    assertEquals(170, env2D.getMaximum(0), 0);
    assertEquals(-80, env2D.getMinimum(1), 0);
    assertEquals(80, env2D.getMaximum(1), 0);
}
Also used : DefaultCompoundCRS(org.apache.sis.referencing.crs.DefaultCompoundCRS) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Envelope(org.opengis.geometry.Envelope) Test(org.junit.Test)

Aggregations

DefaultCompoundCRS (org.apache.sis.referencing.crs.DefaultCompoundCRS)2 Test (org.junit.Test)2 Envelope (org.opengis.geometry.Envelope)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1