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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations