Search in sources :

Example 31 with ProjectedCRS

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

the class DefaultProjectedCRSTest method testWKT1_WithMixedUnits.

/**
 * Tests WKT 1 formatting with a somewhat convolved case where the units of the prime meridian is not
 * the same than the unit of axes. Since the axis units is what we write in the {@code UNIT[…]} element,
 * the WKT formatter need to convert the unit of prime meridian and all parameter angular values.
 *
 * @throws FactoryException if the CRS creation failed.
 */
@Test
@DependsOnMethod("testWKT1_WithCommonUnits")
public void testWKT1_WithMixedUnits() throws FactoryException {
    final ProjectedCRS crs = create(HardCodedCRS.NTF_NORMALIZED_AXES);
    // Opportunist check.
    Validators.validate(crs);
    assertWktEquals(Convention.WKT1, "PROJCS[“NTF (Paris) / Lambert zone II”,\n" + "  GEOGCS[“NTF (Paris)”,\n" + "    DATUM[“Nouvelle Triangulation Francaise”,\n" + "      SPHEROID[“NTF”, 6378249.2, 293.4660212936269]],\n" + // Note the conversion from 2.5969213 grads.
    "      PRIMEM[“Paris”, 2.33722917],\n" + "    UNIT[“degree”, 0.017453292519943295],\n" + "    AXIS[“Longitude”, EAST],\n" + "    AXIS[“Latitude”, NORTH]],\n" + "  PROJECTION[“Lambert_Conformal_Conic_1SP”, AUTHORITY[“EPSG”, “9801”]],\n" + // Note the conversion from 52 grads.
    "  PARAMETER[“latitude_of_origin”, 46.8],\n" + "  PARAMETER[“central_meridian”, 0.0],\n" + "  PARAMETER[“scale_factor”, 0.99987742],\n" + "  PARAMETER[“false_easting”, 600000.0],\n" + "  PARAMETER[“false_northing”, 2200000.0],\n" + "  UNIT[“metre”, 1],\n" + "  AXIS[“Easting”, EAST],\n" + "  AXIS[“Northing”, NORTH],\n" + "  AUTHORITY[“EPSG”, “27572”]]", crs);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 32 with ProjectedCRS

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

the class DefaultProjectedCRSTest method testWKT1_WithCommonUnits.

/**
 * Tests WKT 1 formatting using {@link Convention#WKT1_COMMON_UNITS}.
 *
 * @throws FactoryException if the CRS creation failed.
 */
@Test
@DependsOnMethod("testWKT1")
public void testWKT1_WithCommonUnits() throws FactoryException {
    final ProjectedCRS crs = create(HardCodedCRS.NTF);
    assertWktEquals(Convention.WKT1_COMMON_UNITS, "PROJCS[“NTF (Paris) / Lambert zone II”,\n" + "  GEOGCS[“NTF (Paris)”,\n" + "    DATUM[“Nouvelle Triangulation Francaise”,\n" + "      SPHEROID[“NTF”, 6378249.2, 293.4660212936269]],\n" + // Note the conversion from 2.5969213 grads.
    "      PRIMEM[“Paris”, 2.33722917],\n" + "    UNIT[“grad”, 0.015707963267948967],\n" + "    AXIS[“Longitude”, EAST],\n" + "    AXIS[“Latitude”, NORTH]],\n" + "  PROJECTION[“Lambert_Conformal_Conic_1SP”, AUTHORITY[“EPSG”, “9801”]],\n" + // Note the conversion from 52 grads.
    "  PARAMETER[“latitude_of_origin”, 46.8],\n" + "  PARAMETER[“central_meridian”, 0.0],\n" + "  PARAMETER[“scale_factor”, 0.99987742],\n" + "  PARAMETER[“false_easting”, 600000.0],\n" + "  PARAMETER[“false_northing”, 2200000.0],\n" + "  UNIT[“meter”, 1],\n" + "  AXIS[“Easting”, EAST],\n" + "  AXIS[“Northing”, NORTH],\n" + "  AUTHORITY[“EPSG”, “27572”]]", crs);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 33 with ProjectedCRS

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

the class DefaultProjectedCRSTest method testWKT2_Simplified.

/**
 * Tests WKT 2 formatting in simplified mode.
 *
 * @throws FactoryException if the CRS creation failed.
 */
@Test
@DependsOnMethod("testWKT1")
public void testWKT2_Simplified() throws FactoryException {
    ProjectedCRS crs = create(HardCodedCRS.NTF);
    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],\n" + "    Unit[“grad”, 0.015707963267948967]],\n" + "  Conversion[“Lambert zone II”,\n" + "    Method[“Lambert Conic Conformal (1SP)”],\n" + "    Parameter[“Latitude of natural origin”, 52.0],\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);
    /*
         * Try again, but with mixed units. It should force the formatter to add explicit
         * unit declaration in PrimeMeridian[…] and some Parameter[…] elements.
         */
    crs = create(HardCodedCRS.NTF_NORMALIZED_AXES);
    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 34 with ProjectedCRS

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

the class DefaultProjectedCRSTest method testEquals.

/**
 * Tests {@link DefaultProjectedCRS#equals(Object, ComparisonMode)}.
 * In particular, we want to test the ability to ignore axis order of the base CRS in "ignore metadata" mode.
 *
 * @throws FactoryException if the CRS creation failed.
 *
 * @since 0.7
 */
@Test
public void testEquals() throws FactoryException {
    final ProjectedCRS standard = create(CommonCRS.WGS84.geographic());
    final ProjectedCRS normalized = create(CommonCRS.WGS84.normalizedGeographic());
    assertFalse("STRICT", ((LenientComparable) standard).equals(normalized, ComparisonMode.STRICT));
    assertFalse("BY_CONTRACT", ((LenientComparable) standard).equals(normalized, ComparisonMode.BY_CONTRACT));
    assertTrue("IGNORE_METADATA", ((LenientComparable) standard).equals(normalized, ComparisonMode.IGNORE_METADATA));
    assertTrue("APPROXIMATIVE", ((LenientComparable) standard).equals(normalized, ComparisonMode.APPROXIMATIVE));
    assertTrue("ALLOW_VARIANT", ((LenientComparable) standard).equals(normalized, ComparisonMode.ALLOW_VARIANT));
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) Test(org.junit.Test)

Example 35 with ProjectedCRS

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

the class DefaultProjectedCRSTest method testWKT2_ForEquirectangular.

/**
 * Tests formatting of “Equidistant Cylindrical (Spherical)” projected CRS. This one is a special case
 * because it is simplified to an affine transform. The referencing module should be able to find the
 * original projection parameters.
 *
 * @throws FactoryException if the CRS creation failed.
 */
@Test
@DependsOnMethod("testWKT2_Simplified")
public void testWKT2_ForEquirectangular() throws FactoryException {
    final ProjectedCRS crs = new GeodeticObjectBuilder().setConversionMethod("Equirectangular").setConversionName("Equidistant Cylindrical (Spherical)").setParameter("False easting", 1000, Units.METRE).setParameter("False northing", 2000, Units.METRE).addName("Equidistant Cylindrical (Spherical)").createProjectedCRS(HardCodedCRS.WGS84, HardCodedCS.PROJECTED);
    assertWktEquals(Convention.WKT2_SIMPLIFIED, "ProjectedCRS[“Equidistant Cylindrical (Spherical)”,\n" + "  BaseGeodCRS[“WGS 84”,\n" + "    Datum[“World Geodetic System 1984”,\n" + "      Ellipsoid[“WGS84”, 6378137.0, 298.257223563]],\n" + "    Unit[“degree”, 0.017453292519943295]],\n" + "  Conversion[“Equidistant Cylindrical (Spherical)”,\n" + "    Method[“Equidistant Cylindrical (Spherical)”],\n" + "    Parameter[“Latitude of 1st standard parallel”, 0.0],\n" + "    Parameter[“Longitude of natural origin”, 0.0],\n" + "    Parameter[“False easting”, 1000.0],\n" + "    Parameter[“False northing”, 2000.0]],\n" + "  CS[Cartesian, 2],\n" + "    Axis[“Easting (E)”, east],\n" + "    Axis[“Northing (N)”, north],\n" + "    Unit[“metre”, 1]]", crs);
}
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)

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