Search in sources :

Example 1 with GeodeticObjectFactory

use of org.apache.sis.referencing.factory.GeodeticObjectFactory in project sis by apache.

the class EllipsoidalHeightCombinerTest method testProjectedCRS.

/**
 * Tests {@link EllipsoidalHeightCombiner#createCompoundCRS EllipsoidalHeightCombiner.createCompoundCRS(…)}
 * with a projected CRS.
 *
 * @throws FactoryException if a CRS can not be created.
 */
@Test
@DependsOnMethod("testGeographicCRS")
public void testProjectedCRS() throws FactoryException {
    final EllipsoidalHeightCombiner services = create();
    final GeodeticObjectFactory factory = new GeodeticObjectFactory();
    final Map<String, String> properties = Collections.singletonMap(CoordinateReferenceSystem.NAME_KEY, "World Mercator (4D)");
    final ProjectedCRS horizontal = factory.createProjectedCRS(properties, HardCodedCRS.WGS84, HardCodedConversions.MERCATOR, HardCodedCS.PROJECTED);
    final ProjectedCRS volumetric = factory.createProjectedCRS(properties, HardCodedCRS.WGS84_3D, HardCodedConversions.MERCATOR, HardCodedCS.PROJECTED_3D);
    final VerticalCRS vertical = HardCodedCRS.ELLIPSOIDAL_HEIGHT;
    final TemporalCRS temporal = HardCodedCRS.TIME;
    final VerticalCRS geoidal = HardCodedCRS.GRAVITY_RELATED_HEIGHT;
    /*
         * createCompoundCRS(…) should not combine ProjectedCRS with non-ellipsoidal height.
         */
    CoordinateReferenceSystem compound = services.createCompoundCRS(properties, horizontal, geoidal, temporal);
    assertArrayEqualsIgnoreMetadata(new SingleCRS[] { horizontal, geoidal, temporal }, CRS.getSingleComponents(compound).toArray());
    /*
         * createCompoundCRS(…) should combine ProjectedCRS with ellipsoidal height.
         */
    compound = services.createCompoundCRS(properties, horizontal, vertical);
    assertArrayEqualsIgnoreMetadata(new SingleCRS[] { volumetric }, CRS.getSingleComponents(compound).toArray());
    /*
         * createCompoundCRS(…) should combine ProjectedCRS with ellipsoidal height and keep time.
         */
    compound = services.createCompoundCRS(properties, horizontal, vertical, temporal);
    assertArrayEqualsIgnoreMetadata(new SingleCRS[] { volumetric, temporal }, CRS.getSingleComponents(compound).toArray());
    /*
         * Non-standard feature: accept (VerticalCRS + ProjectedCRS) order.
         */
    compound = services.createCompoundCRS(properties, temporal, vertical, horizontal);
    final Object[] components = CRS.getSingleComponents(compound).toArray();
    assertEquals(2, components.length);
    assertEqualsIgnoreMetadata(temporal, components[0]);
    assertInstanceOf("Shall be a three-dimensional projected CRS.", ProjectedCRS.class, components[1]);
    assertAxisDirectionsEqual("Shall be a three-dimensional projected CRS.", ((CoordinateReferenceSystem) components[1]).getCoordinateSystem(), AxisDirection.UP, AxisDirection.EAST, AxisDirection.NORTH);
}
Also used : TemporalCRS(org.opengis.referencing.crs.TemporalCRS) ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) VerticalCRS(org.opengis.referencing.crs.VerticalCRS) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) GeodeticObjectFactory(org.apache.sis.referencing.factory.GeodeticObjectFactory) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

GeodeticObjectFactory (org.apache.sis.referencing.factory.GeodeticObjectFactory)1 DependsOnMethod (org.apache.sis.test.DependsOnMethod)1 Test (org.junit.Test)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)1 TemporalCRS (org.opengis.referencing.crs.TemporalCRS)1 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)1