use of org.opengis.referencing.operation.CoordinateOperation in project sis by apache.
the class CoordinateOperationRegistryTest method testLongitudeRotationBetweenNormalizedCRS.
/**
* Tests <cite>"NTF (Paris) to WGS 84 (1)"</cite> operation with normalized source and target CRS.
* {@link CoordinateOperationRegistry} should be able to find the operation despite the difference
* in axis order an units.
*
* @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("testLongitudeRotationBetweenConformCRS")
public void testLongitudeRotationBetweenNormalizedCRS() throws ParseException, FactoryException, TransformException {
final CoordinateReferenceSystem sourceCRS = parse("GeodeticCRS[“NTF (Paris)”,\n" + " $NTF,\n" + " PrimeMeridian[“Paris”, 2.33722917],\n" + " CS[ellipsoidal, 2],\n" + " Axis[“Longitude (λ)”, EAST],\n" + " Axis[“Latitude (φ)”, NORTH],\n" + " Unit[“degree”, 0.017453292519943295]]");
final CoordinateReferenceSystem targetCRS = CommonCRS.WGS84.normalizedGeographic();
final CoordinateOperation operation = createOperation(sourceCRS, targetCRS);
verifyNTF(operation, "geog2D domain", false);
transform = operation.getMathTransform();
tolerance = Formulas.ANGULAR_TOLERANCE;
λDimension = new int[] { 1 };
verifyTransform(// in degrees east of Paris
new double[] { 0.088442691, 48.844512250 }, // in degrees east of Greenwich
new double[] { 2.424952028, 48.844443528 });
validate();
}
use of org.opengis.referencing.operation.CoordinateOperation in project sis by apache.
the class DefaultConcatenatedOperationTest method testXML.
/**
* Tests (un)marshalling of a concatenated operation.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*/
@Test
public void testXML() throws JAXBException {
final DefaultConcatenatedOperation op = unmarshalFile(DefaultConcatenatedOperation.class, XML_FILE);
Validators.validate(op);
assertEquals("operations.size()", 2, op.getOperations().size());
final CoordinateOperation step1 = op.getOperations().get(0);
final CoordinateOperation step2 = op.getOperations().get(1);
final CoordinateReferenceSystem sourceCRS = op.getSourceCRS();
final CoordinateReferenceSystem targetCRS = op.getTargetCRS();
assertIdentifierEquals("identifier", "test", "test", null, "concatenated", getSingleton(op.getIdentifiers()));
assertIdentifierEquals("sourceCRS.identifier", "test", "test", null, "source", getSingleton(sourceCRS.getIdentifiers()));
assertIdentifierEquals("targetCRS.identifier", "test", "test", null, "target", getSingleton(targetCRS.getIdentifiers()));
assertIdentifierEquals("step1.identifier", "test", "test", null, "step-1", getSingleton(step1.getIdentifiers()));
assertIdentifierEquals("step2.identifier", "test", "test", null, "step-2", getSingleton(step2.getIdentifiers()));
assertInstanceOf("sourceCRS", GeodeticCRS.class, sourceCRS);
assertInstanceOf("targetCRS", GeodeticCRS.class, targetCRS);
assertSame("sourceCRS", step1.getSourceCRS(), sourceCRS);
assertSame("targetCRS", step2.getTargetCRS(), targetCRS);
assertSame("tmp CRS", step1.getTargetCRS(), step2.getSourceCRS());
/*
* Test marshalling and compare with the original file.
*/
assertMarshalEqualsFile(XML_FILE, op, "xmlns:*", "xsi:schemaLocation");
}
use of org.opengis.referencing.operation.CoordinateOperation in project sis by apache.
the class DefaultCoordinateOperationFactoryTest method testCompoundAndLongitudeRotation.
/**
* Tests a transformation from a 4D projection to a 2D projection which imply a change of
* prime meridian. This is the same test than {@link #testProjectionAndLongitudeRotation()},
* with extra dimension which should be just dropped.
*
* <p>This tests requires the EPSG database, because it requires the coordinate operation
* path which is defined there.</p>
*
* @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("testProjectionAndLongitudeRotation")
public void testCompoundAndLongitudeRotation() throws ParseException, FactoryException, TransformException {
final CoordinateReferenceSystem sourceCRS = parse("CompoundCRS[“NTF 4D”," + " $NTF,\n" + " VerticalCRS[“Geoidal height”,\n" + " VerticalDatum[“Geoid”],\n" + " CS[vertical, 1],\n" + " Axis[“Geoidal height (H)”, up],\n" + " Unit[“metre”, 1]],\n" + " TimeCRS[“Modified Julian”,\n" + " TimeDatum[“Modified Julian”, TimeOrigin[1858-11-17T00:00:00.0Z]],\n" + " CS[temporal, 1],\n" + " Axis[“Time (t)”, future],\n" + " TimeUnit[“day”, 86400]]]");
final CoordinateReferenceSystem targetCRS = parse("$Mercator");
final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
assertSame("targetCRS", targetCRS, operation.getTargetCRS());
assertInstanceOf("operation", ConcatenatedOperation.class, operation);
/*
* The accuracy of the coordinate operation depends on whether a path has been found with the help
* of the EPSG database. See testProjectionAndLongitudeRotation() for more information.
*/
final boolean isUsingEpsgFactory = verifyParametersNTF(((ConcatenatedOperation) operation).getOperations(), 2);
assertEquals("linearAccuracy", isUsingEpsgFactory ? 2 : PositionalAccuracyConstant.UNKNOWN_ACCURACY, CRS.getLinearAccuracy(operation), STRICT);
tolerance = isUsingEpsgFactory ? Formulas.LINEAR_TOLERANCE : 600;
transform = operation.getMathTransform();
isInverseTransformSupported = false;
/*
* Same coordinates than testProjectionAndLongitudeRotation(),
* but with random elevation and time which should be dropped.
*/
verifyTransform(new double[] { 601124.99, 2428693.45, 400, 1000, 600000.00, 2420000.00, 400, 1000 }, new double[] { 261804.30, 6218365.73, 260098.74, 6205194.95 });
validate();
}
use of org.opengis.referencing.operation.CoordinateOperation in project sis by apache.
the class DefaultCoordinateOperationFactoryTest method testPositionVectorTransformation.
/**
* Tests a datum shift applied as a position vector transformation in geocentric domain. This method performs
* the same test than {@link CoordinateOperationFinderTest#testPositionVectorTransformation()} except that the
* EPSG geodetic dataset may be used. The result however should be the same because of the {@code TOWGS84}
* parameter in the WKT used for the test.
*
* @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 CoordinateOperationFinderTest#testPositionVectorTransformation()
* @see <a href="https://issues.apache.org/jira/browse/SIS-364">SIS-364</a>
*
* @since 0.8
*/
@Test
public void testPositionVectorTransformation() throws ParseException, FactoryException, TransformException {
final CoordinateReferenceSystem sourceCRS = CommonCRS.WGS84.geographic();
final CoordinateReferenceSystem targetCRS = parse(CoordinateOperationFinderTest.AGD66());
final CoordinateOperation operation = factory.createOperation(sourceCRS, targetCRS);
transform = operation.getMathTransform();
tolerance = Formulas.LINEAR_TOLERANCE;
λDimension = new int[] { 0 };
verifyTransform(CoordinateOperationFinderTest.expectedAGD66(true), CoordinateOperationFinderTest.expectedAGD66(false));
validate();
}
use of org.opengis.referencing.operation.CoordinateOperation in project sis by apache.
the class Proj4FactoryTest method testTransform.
/**
* Tests the transformation from {@code "+init=epsg:4326"} to {@code "+init=epsg:3395"}.
*
* @throws FactoryException if an error occurred while creating the CRS objects.
* @throws TransformException if an error occurred while projecting a test point.
*/
@Test
public void testTransform() throws FactoryException, TransformException {
final Proj4Factory factory = Proj4Factory.INSTANCE;
final GeographicCRS sourceCRS = factory.createGeographicCRS("+init=epsg:4326");
final ProjectedCRS targetCRS = factory.createProjectedCRS("+init=epsg:3395");
final CoordinateOperation op = factory.createOperation(sourceCRS, targetCRS, true);
assertInstanceOf("createOperation", Conversion.class, op);
testMercatorProjection(op.getMathTransform());
}
Aggregations