Search in sources :

Example 1 with ProjectedCRS

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

Example 2 with ProjectedCRS

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

the class DefaultProjectedCRSTest method testWKT1_WithExplicitAxisLength.

/**
 * Tests WKT 1 formatting of a pseudo-projection with explicit {@code "semi-major"} and {@code "semi-minor"}
 * parameter values. This was a way to define the Google pseudo-projection using standard projection method
 * name before EPSG introduced the <cite>"Popular Visualisation Pseudo Mercator"</cite> projection method.
 * The approach tested in this method is now deprecated at least for the Google projection (while it may
 * still be useful for other projections), but we still test it for compatibility reasons.
 *
 * @throws FactoryException if the CRS creation failed.
 */
@Test
@DependsOnMethod("testWKT1")
public void testWKT1_WithExplicitAxisLength() throws FactoryException {
    final ProjectedCRS crs = new GeodeticObjectBuilder().setConversionMethod("Mercator (variant A)").setConversionName("Popular Visualisation Pseudo-Mercator").setParameter("semi-major", 6378137, Units.METRE).setParameter("semi-minor", 6378137, Units.METRE).addName("WGS 84 / Pseudo-Mercator").createProjectedCRS(HardCodedCRS.WGS84, HardCodedCS.PROJECTED);
    assertWktEquals(Convention.WKT1, "PROJCS[“WGS 84 / Pseudo-Mercator”,\n" + "  GEOGCS[“WGS 84”,\n" + "    DATUM[“World Geodetic System 1984”,\n" + "      SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" + "      PRIMEM[“Greenwich”, 0.0],\n" + "    UNIT[“degree”, 0.017453292519943295],\n" + "    AXIS[“Longitude”, EAST],\n" + "    AXIS[“Latitude”, NORTH]],\n" + "  PROJECTION[“Mercator_1SP”, AUTHORITY[“EPSG”, “9804”]],\n" + // Non-standard: appears because its value is different than the ellipsoid value.
    "  PARAMETER[“semi_minor”, 6378137.0],\n" + "  PARAMETER[“latitude_of_origin”, 0.0],\n" + "  PARAMETER[“central_meridian”, 0.0],\n" + "  PARAMETER[“scale_factor”, 1.0],\n" + "  PARAMETER[“false_easting”, 0.0],\n" + "  PARAMETER[“false_northing”, 0.0],\n" + "  UNIT[“metre”, 1],\n" + "  AXIS[“Easting”, EAST],\n" + "  AXIS[“Northing”, NORTH]]", crs);
    loggings.assertNextLogContains("semi_minor", "WGS84");
    loggings.assertNoUnexpectedLog();
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) GeodeticObjectBuilder(org.apache.sis.internal.referencing.GeodeticObjectBuilder) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 3 with ProjectedCRS

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

the class DefaultProjectedCRSTest method testInternal.

/**
 * Tests WKT formatting in "internal" mode.
 * This mode is similar to WKT 2 but shall include the axes of the base CRS and more parameter identifiers.
 *
 * @throws FactoryException if the CRS creation failed.
 */
@Test
@DependsOnMethod("testWKT1")
public void testInternal() throws FactoryException {
    ProjectedCRS crs = create(HardCodedCRS.NTF);
    assertWktEquals(Convention.INTERNAL, "ProjectedCRS[“NTF (Paris) / Lambert zone II”,\n" + "  BaseGeodCRS[“NTF (Paris)”,\n" + "    Datum[“Nouvelle Triangulation Française”,\n" + "      Ellipsoid[“NTF”, 6378249.2, 293.4660212936269],\n" + "      Scope[“Topographic mapping.”],\n" + "      Id[“EPSG”, 6807]],\n" + "      PrimeMeridian[“Paris”, 2.5969213, Id[“EPSG”, 8903]],\n" + "    CS[ellipsoidal, 2],\n" + "      Axis[“Longitude (λ)”, east],\n" + "      Axis[“Latitude (φ)”, north],\n" + "      Unit[“grad”, 0.015707963267948967, Id[“EPSG”, 9105]]],\n" + "  Conversion[“Lambert zone II”,\n" + "    Method[“Lambert Conic Conformal (1SP)”, Id[“EPSG”, 9801], Id[“GeoTIFF”, 9]],\n" + "    Parameter[“Latitude of natural origin”, 52.0, Id[“EPSG”, 8801], Id[“GeoTIFF”, 3081]],\n" + "    Parameter[“Longitude of natural origin”, 0.0, Id[“EPSG”, 8802], Id[“GeoTIFF”, 3080]],\n" + "    Parameter[“Scale factor at natural origin”, 0.99987742, Id[“EPSG”, 8805], Id[“GeoTIFF”, 3092]],\n" + "    Parameter[“False easting”, 600000.0, Id[“EPSG”, 8806], Id[“GeoTIFF”, 3082]],\n" + "    Parameter[“False northing”, 2200000.0, Id[“EPSG”, 8807], Id[“GeoTIFF”, 3083]]],\n" + "  CS[Cartesian, 2],\n" + "    Axis[“Easting (E)”, east],\n" + "    Axis[“Northing (N)”, north],\n" + "    Unit[“metre”, 1, Id[“EPSG”, 9001]],\n" + "  Id[“EPSG”, 27572]]", crs);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 4 with ProjectedCRS

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

the class DefaultProjectedCRSTest method testWKT2_WithMixedUnits.

/**
 * Tests WKT 2 formatting. Contrarily to the WKT 1 formatting, in this case it does not matter
 * if we mix the units of measurement because the unit is declared for each parameter and axis.
 *
 * @throws FactoryException if the CRS creation failed.
 */
@Test
@DependsOnMethod("testWKT1")
public void testWKT2_WithMixedUnits() throws FactoryException {
    final ProjectedCRS crs = create(HardCodedCRS.NTF_NORMALIZED_AXES);
    assertWktEquals(Convention.WKT2, "PROJCRS[“NTF (Paris) / Lambert zone II”,\n" + "  BASEGEODCRS[“NTF (Paris)”,\n" + "    DATUM[“Nouvelle Triangulation Francaise”,\n" + "      ELLIPSOID[“NTF”, 6378249.2, 293.4660212936269, LENGTHUNIT[“metre”, 1]]],\n" + "      PRIMEM[“Paris”, 2.5969213, ANGLEUNIT[“grad”, 0.015707963267948967]]],\n" + "  CONVERSION[“Lambert zone II”,\n" + "    METHOD[“Lambert Conic Conformal (1SP)”, ID[“EPSG”, 9801]],\n" + "    PARAMETER[“Latitude of natural origin”, 52.0, ANGLEUNIT[“grad”, 0.015707963267948967], ID[“EPSG”, 8801]],\n" + "    PARAMETER[“Longitude of natural origin”, 0.0, ANGLEUNIT[“degree”, 0.017453292519943295], ID[“EPSG”, 8802]],\n" + "    PARAMETER[“Scale factor at natural origin”, 0.99987742, SCALEUNIT[“unity”, 1], ID[“EPSG”, 8805]],\n" + "    PARAMETER[“False easting”, 600000.0, LENGTHUNIT[“metre”, 1], ID[“EPSG”, 8806]],\n" + "    PARAMETER[“False northing”, 2200000.0, LENGTHUNIT[“metre”, 1], ID[“EPSG”, 8807]]],\n" + "  CS[Cartesian, 2],\n" + "    AXIS[“Easting (E)”, east, ORDER[1]],\n" + "    AXIS[“Northing (N)”, north, ORDER[2]],\n" + "    LENGTHUNIT[“metre”, 1],\n" + "  ID[“EPSG”, 27572, URI[“urn:ogc:def:crs:EPSG::27572”]]]", crs);
    assertWktEquals(Convention.WKT2_SIMPLIFIED, "ProjectedCRS[“NTF (Paris) / Lambert zone II”,\n" + "  BaseGeodCRS[“NTF (Paris)”,\n" + "    Datum[“Nouvelle Triangulation Francaise”,\n" + "      Ellipsoid[“NTF”, 6378249.2, 293.4660212936269]],\n" + "      PrimeMeridian[“Paris”, 2.5969213, Unit[“grad”, 0.015707963267948967]],\n" + "    Unit[“degree”, 0.017453292519943295]],\n" + "  Conversion[“Lambert zone II”,\n" + "    Method[“Lambert Conic Conformal (1SP)”],\n" + "    Parameter[“Latitude of natural origin”, 52.0, Unit[“grad”, 0.015707963267948967]],\n" + "    Parameter[“Longitude of natural origin”, 0.0],\n" + "    Parameter[“Scale factor at natural origin”, 0.99987742],\n" + "    Parameter[“False easting”, 600000.0],\n" + "    Parameter[“False northing”, 2200000.0]],\n" + "  CS[Cartesian, 2],\n" + "    Axis[“Easting (E)”, east],\n" + "    Axis[“Northing (N)”, north],\n" + "    Unit[“metre”, 1],\n" + "  Id[“EPSG”, 27572, URI[“urn:ogc:def:crs:EPSG::27572”]]]", crs);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 5 with ProjectedCRS

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

the class Proj4FactoryTest method test3395.

/**
 * Tests the creation of the {@code "+init=epsg:3395"} projected CRS.
 *
 * @throws FactoryException if an error occurred while creating the CRS objects.
 */
@Test
public void test3395() throws FactoryException {
    final Proj4Factory factory = Proj4Factory.INSTANCE;
    final ProjectedCRS crs = factory.createProjectedCRS("+init=epsg:3395");
    final PJ pj = (PJ) TestUtilities.getSingleton(crs.getIdentifiers());
    assertEquals(PJ.Type.PROJECTED, pj.getType());
    final String definition = pj.getCode();
    assertTrue(definition, definition.contains("+proj=merc"));
    assertTrue(definition, definition.contains("+datum=WGS84"));
    assertAxisDirectionsEqual(definition, crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) Test(org.junit.Test)

Aggregations

ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)40 Test (org.junit.Test)31 DependsOnMethod (org.apache.sis.test.DependsOnMethod)23 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)11 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)10 GeodeticCRS (org.opengis.referencing.crs.GeodeticCRS)5 CartesianCS (org.opengis.referencing.cs.CartesianCS)5 Conversion (org.opengis.referencing.operation.Conversion)5 DefaultConversion (org.apache.sis.referencing.operation.DefaultConversion)4 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)4 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)4 EllipsoidalCS (org.opengis.referencing.cs.EllipsoidalCS)4 GeodeticObjectBuilder (org.apache.sis.internal.referencing.GeodeticObjectBuilder)3 DefaultProjectedCRS (org.apache.sis.referencing.crs.DefaultProjectedCRS)3 HashMap (java.util.HashMap)2 Ignore (org.junit.Ignore)2 DirectPosition (org.opengis.geometry.DirectPosition)2 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)2 EngineeringCRS (org.opengis.referencing.crs.EngineeringCRS)2 CoordinateSystemAxis (org.opengis.referencing.cs.CoordinateSystemAxis)2