use of org.opengis.referencing.operation.CoordinateOperation in project sis by apache.
the class CoordinateOperationFinderTest method testGeographic3D_to_2D.
/**
* Tests the conversion from a three-dimensional geographic CRS to a two-dimensional geographic CRS.
* The vertical dimension is simply dropped.
*
* @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 testGeographic3D_to_2D() throws FactoryException, TransformException {
final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic3D();
final GeographicCRS targetCRS = CommonCRS.WGS84.geographic();
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);
final ParameterValueGroup parameters = ((SingleOperation) operation).getParameterValues();
assertEquals("parameters.descriptor", "Geographic3D to 2D conversion", parameters.getDescriptor().getName().getCode());
assertTrue("parameters.isEmpty", parameters.values().isEmpty());
transform = operation.getMathTransform();
assertInstanceOf("transform", LinearTransform.class, transform);
assertEquals("sourceDimensions", 3, transform.getSourceDimensions());
assertEquals("targetDimensions", 2, transform.getTargetDimensions());
Assert.assertMatrixEquals("transform.matrix", Matrices.create(3, 4, new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), STRICT);
isInverseTransformSupported = false;
verifyTransform(new double[] { 30, 10, 20, 20, 30, -10 }, new double[] { 30, 10, 20, 30 });
validate();
}
use of org.opengis.referencing.operation.CoordinateOperation in project sis by apache.
the class CoordinateOperationFinderTest method testPositionVectorTransformation.
/**
* Tests a datum shift applied as a position vector transformation in geocentric domain.
* This test does not use the the EPSG geodetic dataset.
*
* @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.
*
* @see DefaultCoordinateOperationFactoryTest#testPositionVectorTransformation()
* @see <a href="https://issues.apache.org/jira/browse/SIS-364">SIS-364</a>
*
* @since 0.8
*/
@Test
@DependsOnMethod("testGeographicToProjected")
public void testPositionVectorTransformation() throws ParseException, FactoryException, TransformException {
final CoordinateReferenceSystem sourceCRS = CommonCRS.WGS84.geographic();
final CoordinateReferenceSystem targetCRS = parse(AGD66());
final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
transform = operation.getMathTransform();
tolerance = LINEAR_TOLERANCE;
λDimension = new int[] { 0 };
verifyTransform(expectedAGD66(true), expectedAGD66(false));
validate();
}
use of org.opengis.referencing.operation.CoordinateOperation 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.opengis.referencing.operation.CoordinateOperation 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.opengis.referencing.operation.CoordinateOperation 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();
}
Aggregations