Search in sources :

Example 26 with ProjectedCRS

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

the class TransformTestCase method testTransform.

/**
 * Tests the transformation of an envelope or rectangle. This is a relatively simple test case
 * working in the two-dimensional space only, with a coordinate operation of type "conversion"
 * (not a "transformation") and with no need to adjust for poles.
 *
 * @throws FactoryException if an error occurred while creating the operation.
 * @throws TransformException if an error occurred while transforming the envelope.
 */
@Test
public final void testTransform() throws FactoryException, TransformException {
    final ProjectedCRS targetCRS = CommonCRS.WGS84.universal(10, -123.5);
    final GeographicCRS sourceCRS = targetCRS.getBaseCRS();
    final Conversion conversion = targetCRS.getConversionFromBase();
    final MathTransform2D transform = (MathTransform2D) conversion.getMathTransform();
    /*
         * Transforms envelopes using MathTransform. Geographic coordinates are in (latitude, longitude) order.
         * Opportunistically check that the transform using a CoordinateOperation object produces the same result.
         */
    final G rectλφ = createFromExtremums(sourceCRS, -20, -126, 40, -120);
    final G rectXY = transform(targetCRS, transform, rectλφ);
    assertEquals("Conversion should produce the same result.", rectXY, transform(conversion, rectλφ));
    /*
         * Expected values are determined empirically by projecting many points.
         * Those values are the same than in EnvelopesTest.testTransform().
         */
    final G expected = createFromExtremums(targetCRS, 166021.56, -2214294.03, 833978.44, 4432069.06);
    assertGeometryEquals(expected, rectXY, LINEAR_TOLERANCE, LINEAR_TOLERANCE);
    /*
         * Test the inverse conversion.
         * Final envelope should be slightly bigger than the original.
         */
    final G rectBack = transform(sourceCRS, transform.inverse(), rectXY);
    assertTrue("Transformed envelope should not be smaller than the original one.", contains(rectBack, rectλφ));
    assertGeometryEquals(rectλφ, rectBack, 0.05, 1.0);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) MathTransform2D(org.opengis.referencing.operation.MathTransform2D) DefaultConversion(org.apache.sis.referencing.operation.DefaultConversion) Conversion(org.opengis.referencing.operation.Conversion) Test(org.junit.Test)

Example 27 with ProjectedCRS

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

the class CommonAuthorityFactoryTest method testAuto42001_foot.

/**
 * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the same {@code "AUTO:42001"} code
 * than {@link #testAuto42001()} except that axes are feet.
 *
 * @throws FactoryException if an error occurred while creating a CRS.
 */
@Test
@DependsOnMethod("testAuto42001")
public void testAuto42001_foot() throws FactoryException {
    final ProjectedCRS crs = factory.createProjectedCRS("AUTO2:42001, 0.3048, -123, 0");
    assertSame("Legacy namespace.", crs, factory.createProjectedCRS("AUTO:42001,9002,-123,0"));
    assertEquals("name", "WGS 84 / UTM zone 10N", crs.getName().getCode());
    assertTrue("Expected no EPSG identifier because the axes are not in metres.", crs.getIdentifiers().isEmpty());
    assertEquals("axis[0].unit", Units.FOOT, crs.getCoordinateSystem().getAxis(0).getUnit());
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 28 with ProjectedCRS

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

the class CommonAuthorityFactoryTest method testAuto42005.

/**
 * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42005"} code.
 *
 * @throws FactoryException if an error occurred while creating a CRS.
 */
@Test
@DependsOnMethod("testAuto42001")
@Ignore("Pending implementation of Mollweide projection.")
public void testAuto42005() throws FactoryException {
    final ProjectedCRS crs = factory.createProjectedCRS("AUTO:42005,9001,10,45");
    final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues();
    assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
    assertEquals(Constants.CENTRAL_MERIDIAN, 10, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Ignore(org.junit.Ignore) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 29 with ProjectedCRS

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

the class CommonAuthorityFactoryTest method testAuto42002.

/**
 * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42002"} code.
 *
 * @throws FactoryException if an error occurred while creating a CRS.
 */
@Test
@DependsOnMethod("testAuto42001")
public void testAuto42002() throws FactoryException {
    final ProjectedCRS crs = factory.createProjectedCRS("AUTO:42002,-122,10");
    assertSame("Omitting namespace.", crs, factory.createProjectedCRS(" 42002, -122 , 10 "));
    assertSame("With explicit unit.", crs, factory.createProjectedCRS("AUTO2 :  42002, 1, -122 , 10 "));
    assertEquals("name", "Transverse Mercator", crs.getName().getCode());
    assertTrue("Expected no EPSG identifier.", crs.getIdentifiers().isEmpty());
    final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues();
    assertEquals(TransverseMercator.NAME, crs.getConversionFromBase().getMethod().getName().getCode());
    assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
    assertEquals(Constants.CENTRAL_MERIDIAN, -122, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.LATITUDE_OF_ORIGIN, 10, p.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
    assertEquals(Constants.FALSE_NORTHING, 0, p.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 30 with ProjectedCRS

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

the class CommonAuthorityFactoryTest method testAuto42003.

/**
 * Tests {@link CommonAuthorityFactory#createProjectedCRS(String)} with the {@code "AUTO:42003"} code.
 *
 * @throws FactoryException if an error occurred while creating a CRS.
 */
@Test
@DependsOnMethod("testAuto42001")
@Ignore("Pending the port of Orthographic projection.")
public void testAuto42003() throws FactoryException {
    final ProjectedCRS crs = factory.createProjectedCRS("AUTO:42003,9001,10,45");
    final ParameterValueGroup p = crs.getConversionFromBase().getParameterValues();
    assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.NORTH);
    assertEquals(Constants.CENTRAL_MERIDIAN, 10, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
    assertEquals(Constants.LATITUDE_OF_ORIGIN, 45, p.parameter(Constants.LATITUDE_OF_ORIGIN).doubleValue(), STRICT);
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Ignore(org.junit.Ignore) 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