use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CoordinateOperationFinderTest method testTemporalConversion.
/**
* Tests a conversion of the temporal axis. We convert 1899-12-31 from a CRS having its epoch at 1970-1-1
* to an other CRS having its epoch at 1858-11-17, so the new value shall be approximatively 41 years
* after the new epoch. This conversion also implies a change of units from seconds to days.
*
* @throws FactoryException if the operation can not be created.
* @throws TransformException if an error occurred while converting the test points.
*/
@Test
@DependsOnMethod("testIdentityTransform")
public void testTemporalConversion() throws FactoryException, TransformException {
final TemporalCRS sourceCRS = CommonCRS.Temporal.UNIX.crs();
final TemporalCRS targetCRS = CommonCRS.Temporal.MODIFIED_JULIAN.crs();
final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
assertSame("targetCRS", targetCRS, operation.getTargetCRS());
assertEquals("name", "Axis changes", operation.getName().getCode());
assertInstanceOf("operation", Conversion.class, operation);
transform = operation.getMathTransform();
tolerance = 1E-12;
verifyTransform(new double[] { // December 31, 1899 at 12:00 UTC in seconds.
CommonCRS.Temporal.DUBLIN_JULIAN.datum().getOrigin().getTime() / 1000 }, new double[] { 15019.5 });
validate();
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CoordinateOperationFinderTest method testGeographic4D_to_EllipsoidalHeight.
/**
* Tests extracting the vertical part of a spatio-temporal CRS.
*
* @throws FactoryException if the operation can not be created.
* @throws TransformException if an error occurred while converting the test points.
*/
@Test
@DependsOnMethod("testGeographic3D_to_EllipsoidalHeight")
public void testGeographic4D_to_EllipsoidalHeight() throws FactoryException, TransformException {
// NOTE: make sure that the 'sourceCRS' below is not equal to any other 'sourceCRS' created in this class.
final CompoundCRS sourceCRS = compound("Test4D", CommonCRS.WGS84.geographic3D(), CommonCRS.Temporal.JULIAN.crs());
final VerticalCRS targetCRS = CommonCRS.Vertical.ELLIPSOIDAL.crs();
final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
assertSame("targetCRS", targetCRS, operation.getTargetCRS());
assertEquals("name", "Axis changes", operation.getName().getCode());
assertInstanceOf("operation", Conversion.class, operation);
transform = operation.getMathTransform();
assertInstanceOf("transform", LinearTransform.class, transform);
assertEquals("sourceDimensions", 4, transform.getSourceDimensions());
assertEquals("targetDimensions", 1, transform.getTargetDimensions());
Assert.assertMatrixEquals("transform.matrix", Matrices.create(2, 5, new double[] { 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), STRICT);
isInverseTransformSupported = false;
verifyTransform(new double[] { 0, 0, 0, 0, 5, 8, 20, 10, -5, -8, 24, 30 }, new double[] { 0, 20, 24 });
validate();
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CoordinateOperationFinderTest method testGeographic3D_to_4D.
/**
* Tests conversion from three-dimensional geographic CRS to four-dimensional compound CRS
* where the last dimension is time.
*
* @throws FactoryException if the operation can not be created.
* @throws TransformException if an error occurred while converting the test points.
*/
@Test
@DependsOnMethod("testTemporalConversion")
public void testGeographic3D_to_4D() throws FactoryException, TransformException {
// NOTE: make sure that the 'sourceCRS' below is not equal to any other 'sourceCRS' created in this class.
final CompoundCRS sourceCRS = compound("Test3D", CommonCRS.WGS84.geographic(), CommonCRS.Temporal.UNIX.crs());
final CompoundCRS targetCRS = compound("Test4D", CommonCRS.WGS84.geographic3D(), CommonCRS.Temporal.MODIFIED_JULIAN.crs());
final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
assertSame("targetCRS", targetCRS, operation.getTargetCRS());
assertInstanceOf("operation", ConcatenatedOperation.class, operation);
assertEquals("name", "CompoundCRS[“Test3D”] ⟶ CompoundCRS[“Test4D”]", operation.getName().getCode());
transform = operation.getMathTransform();
assertInstanceOf("transform", LinearTransform.class, transform);
assertEquals("sourceDimensions", 3, transform.getSourceDimensions());
assertEquals("targetDimensions", 4, transform.getTargetDimensions());
Assert.assertMatrixEquals("transform.matrix", Matrices.create(5, 4, new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1. / (24 * 60 * 60), 40587, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), 1E-12);
tolerance = 1E-12;
verifyTransform(new double[] { -5, -8, CommonCRS.Temporal.DUBLIN_JULIAN.datum().getOrigin().getTime() / 1000 }, new double[] { // Same value than in testTemporalConversion().
-5, // Same value than in testTemporalConversion().
-8, // Same value than in testTemporalConversion().
0, // Same value than in testTemporalConversion().
15019.5 });
validate();
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CoordinateOperationFinderTest method testGeocentricTranslationInGeocentricDomain.
/**
* Tests a transformation using the <cite>"Geocentric translations (geocentric domain)"</cite> method,
* together with a longitude rotation and unit conversion. The CRS and sample point are derived from
* the GR3DF97A – <cite>Grille de paramètres de transformation de coordonnées</cite> document.
*
* @throws ParseException if a CRS used in this test can not be parsed.
* @throws FactoryException if the operation can not be created.
* @throws TransformException if an error occurred while converting the test points.
*/
@Test
@DependsOnMethod("testLongitudeRotation")
public void testGeocentricTranslationInGeocentricDomain() throws ParseException, FactoryException, TransformException {
final CoordinateReferenceSystem sourceCRS = parse("GeodeticCRS[“NTF (Paris)”, $NTF,\n" + // in degrees.
" PrimeMeridian[“Paris”, 2.33722917],\n" + " CS[Cartesian, 3],\n" + " Axis[“(X)”, geocentricX],\n" + " Axis[“(Y)”, geocentricY],\n" + " Axis[“(Z)”, geocentricZ],\n" + " Unit[“kilometre”, 1000]]");
final GeocentricCRS targetCRS = CommonCRS.WGS84.geocentric();
final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
assertSame("targetCRS", targetCRS, operation.getTargetCRS());
assertFalse("isIdentity", operation.getMathTransform().isIdentity());
assertEquals("name", "Datum shift", operation.getName().getCode());
assertSetEquals(Arrays.asList(DATUM_SHIFT_APPLIED), operation.getCoordinateOperationAccuracy());
assertInstanceOf("operation", Transformation.class, operation);
assertEquals("method", "Geocentric translations (geocentric domain)", ((SingleOperation) operation).getMethod().getName().getCode());
/*
* Same test point than the one used in FranceGeocentricInterpolationTest:
*
* ┌────────────────────────────────────────────┬──────────────────────────────────────────────────────────┐
* │ Geographic coordinates (°) │ Geocentric coordinates (m) │
* ├────────────────────────────────────────────┼──────────────────────────────────────────────────────────┤
* │ NTF: 48°50′40.2441″N 2°25′32.4187″E │ X = 4201905.725 Y = 177998.072 Z = 4778904.260 │
* │ RGF: 48°50′39.9967″N 2°25′29.8273″E │ ΔX = -168 ΔY = -60 ΔZ = 320 │
* └────────────────────────────────────────────┴──────────────────────────────────────────────────────────┘
*
* The source coordinate below is different than in the above table because the prime meridian is set to the
* Paris meridian, so there is a longitude rotation to take in account for X and Y axes.
*/
transform = operation.getMathTransform();
tolerance = LINEAR_TOLERANCE;
verifyTransform(// Paris prime meridian
new double[] { 4205.669137, 6.491944, 4778.904260 }, // Greenwich prime meridian
new double[] { 4201737.725, 177938.072, 4779224.260 });
validate();
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CoordinateOperationFinderTest method testProjected4D_to_2D.
/**
* Tests conversion from four-dimensional compound CRS to two-dimensional projected CRS.
*
* @throws ParseException if a CRS used in this test can not be parsed.
* @throws FactoryException if the operation can not be created.
* @throws TransformException if an error occurred while converting the test points.
*/
@Test
@DependsOnMethod("testTemporalConversion")
public void testProjected4D_to_2D() throws ParseException, FactoryException, TransformException {
final CoordinateReferenceSystem targetCRS = parse("ProjectedCRS[“WGS 84 / World Mercator”,\n" + " BaseGeodCRS[“WGS 84”,\n" + " Datum[“World Geodetic System 1984”,\n" + " Ellipsoid[“WGS 84”, 6378137.0, 298.257223563]]],\n" + " Conversion[“WGS 84 / World Mercator”,\n" + " Method[“Mercator (1SP)”]],\n" + " CS[Cartesian, 2],\n" + " Axis[“Easting”, EAST],\n" + " Axis[“Northing”, NORTH],\n" + " Unit[“m”, 1],\n" + " Id[“EPSG”, “3395”]]");
CoordinateReferenceSystem sourceCRS = targetCRS;
sourceCRS = compound("Mercator 3D", sourceCRS, CommonCRS.Vertical.MEAN_SEA_LEVEL.crs());
sourceCRS = compound("Mercator 4D", sourceCRS, CommonCRS.Temporal.MODIFIED_JULIAN.crs());
final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
assertSame("targetCRS", targetCRS, operation.getTargetCRS());
transform = operation.getMathTransform();
assertFalse("transform.isIdentity", transform.isIdentity());
assertInstanceOf("The somewhat complex MathTransform chain should have been simplified " + "to a single affine transform.", LinearTransform.class, transform);
assertInstanceOf("The operation should be a simple axis change, not a complex" + "chain of ConcatenatedOperations.", Conversion.class, operation);
assertEquals("sourceDimensions", 4, transform.getSourceDimensions());
assertEquals("targetDimensions", 2, transform.getTargetDimensions());
Assert.assertMatrixEquals("transform.matrix", Matrices.create(3, 5, new double[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), STRICT);
isInverseTransformSupported = false;
verifyTransform(new double[] { 0, 0, 0, 0, 1000, -2000, 20, 4000 }, new double[] { 0, 0, 1000, -2000 });
validate();
}
Aggregations