Search in sources :

Example 21 with ProjectedCRS

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

the class CommonCRSTest method testUTM.

/**
 * Tests {@link CommonCRS#universal(double, double)} with Universal Transverse Mercator (UTM) projections.
 *
 * @since 0.7
 */
@Test
@DependsOnMethod("testGeographic")
public void testUTM() {
    final ProjectedCRS crs = CommonCRS.WGS72.universal(-45, -122);
    assertEquals("name", "WGS 72 / UTM zone 10S", crs.getName().getCode());
    final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues();
    assertEquals(Constants.LATITUDE_OF_ORIGIN, 0, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
    assertEquals(Constants.CENTRAL_MERIDIAN, -123, pg.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.SCALE_FACTOR, 0.9996, pg.parameter(Constants.SCALE_FACTOR).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_EASTING, 500000, pg.parameter(Constants.FALSE_EASTING).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 10000000, pg.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
    assertSame("Expected a cached instance.", crs, CommonCRS.WGS72.universal(-45, -122));
    assertNotSame("Expected a new instance.", crs, CommonCRS.WGS72.universal(+45, -122));
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 22 with ProjectedCRS

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

the class CommonCRSTest method testUPS.

/**
 * Tests {@link CommonCRS#universal(double, double)} with Universal Polar Stereographic (UPS) projections.
 *
 * @since 0.8
 */
@Test
@DependsOnMethod("testGeographic")
public void testUPS() {
    final ProjectedCRS crs = CommonCRS.WGS72.universal(-85, -122);
    assertEquals("name", "WGS 72 / Universal Polar Stereographic South", crs.getName().getCode());
    final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues();
    assertEquals(Constants.LATITUDE_OF_ORIGIN, -90, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
    assertEquals(Constants.CENTRAL_MERIDIAN, 0, pg.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.SCALE_FACTOR, 0.994, pg.parameter(Constants.SCALE_FACTOR).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_EASTING, 2000000, pg.parameter(Constants.FALSE_EASTING).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 2000000, pg.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
    assertSame("Expected a cached instance.", crs, CommonCRS.WGS72.universal(-85, -122));
    assertNotSame("Expected a new instance.", crs, CommonCRS.WGS72.universal(+85, -122));
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 23 with ProjectedCRS

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

the class StandardDefinitionsTest method testCreateUPS.

/**
 * Tests {@link StandardDefinitions#createUniversal(int, GeographicCRS, boolean, double, double, CartesianCS)}
 * for a Universal Polar Stereographic (UPS) projection. This test cheats a little bit on the coordinate system
 * by laziness; we are more interested in the projection parameters.
 *
 * @since 0.8
 */
@Test
@DependsOnMethod("testCreateGeographicCRS")
public void testCreateUPS() {
    final ProjectedCRS crs = StandardDefinitions.createUniversal(5041, HardCodedCRS.WGS84, false, 90, -122, HardCodedCS.PROJECTED);
    assertEquals("name", "WGS 84 / Universal Polar Stereographic North", crs.getName().getCode());
    final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues();
    assertEquals(Constants.LATITUDE_OF_ORIGIN, 90, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
    assertEquals(Constants.CENTRAL_MERIDIAN, 0, pg.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.SCALE_FACTOR, 0.994, pg.parameter(Constants.SCALE_FACTOR).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_EASTING, 2000000, pg.parameter(Constants.FALSE_EASTING).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 2000000, pg.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 24 with ProjectedCRS

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

the class StandardDefinitionsTest method testCreateUTM.

/**
 * Tests {@link StandardDefinitions#createUniversal(int, GeographicCRS, boolean, double, double, CartesianCS)}
 * for a Universal Transverse Mercator (UTM) projection.
 *
 * @since 0.7
 */
@Test
@DependsOnMethod("testCreateGeographicCRS")
public void testCreateUTM() {
    final ProjectedCRS crs = StandardDefinitions.createUniversal(32610, HardCodedCRS.WGS84, true, 15, -122, HardCodedCS.PROJECTED);
    assertEquals("name", "WGS 84 / UTM zone 10N", crs.getName().getCode());
    final ParameterValueGroup pg = crs.getConversionFromBase().getParameterValues();
    assertEquals(Constants.LATITUDE_OF_ORIGIN, 0, pg.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
    assertEquals(Constants.CENTRAL_MERIDIAN, -123, pg.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.SCALE_FACTOR, 0.9996, pg.parameter(Constants.SCALE_FACTOR).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_EASTING, 500000, pg.parameter(Constants.FALSE_EASTING).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 0, pg.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 25 with ProjectedCRS

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

the class TransformTestCase method testTransformOverAntiMeridian.

/**
 * Tests transform of an envelope over the ±180° limit. The Mercator projection used in this test
 * is not expected to wrap the longitude around Earth when using only the {@code MathTransform}.
 * However when the target CRS is known, then "wrap around" should be applied.
 *
 * @throws TransformException if an error occurred while transforming the envelope.
 *
 * @since 0.8
 */
@Test
@DependsOnMethod("testTransform")
public final void testTransformOverAntiMeridian() throws TransformException {
    final ProjectedCRS sourceCRS = HardCodedConversions.mercator();
    final GeographicCRS targetCRS = sourceCRS.getBaseCRS();
    final Conversion conversion = inverse(sourceCRS.getConversionFromBase());
    final G expected = createFromExtremums(targetCRS, 179, 40, 181, 50);
    final G rectangle = createFromExtremums(sourceCRS, // Computed by SIS (not validated by external authority).
    19926188.852, // Computed by SIS (not validated by external authority).
    4838471.398, 20148827.834, 6413524.594);
    final G actual = transform(conversion, rectangle);
    assertGeometryEquals(expected, actual, ANGULAR_TOLERANCE, ANGULAR_TOLERANCE);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) DefaultConversion(org.apache.sis.referencing.operation.DefaultConversion) Conversion(org.opengis.referencing.operation.Conversion) 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