Search in sources :

Example 41 with CoordinateOperation

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();
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 42 with CoordinateOperation

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");
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test)

Example 43 with CoordinateOperation

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();
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 44 with CoordinateOperation

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();
}
Also used : CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test)

Example 45 with CoordinateOperation

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());
}
Also used : ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) CoordinateOperation(org.opengis.referencing.operation.CoordinateOperation) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) Test(org.junit.Test)

Aggregations

CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)45 Test (org.junit.Test)32 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)24 DependsOnMethod (org.apache.sis.test.DependsOnMethod)21 CompoundCRS (org.opengis.referencing.crs.CompoundCRS)6 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)6 SingleOperation (org.opengis.referencing.operation.SingleOperation)6 AbstractCoordinateOperation (org.apache.sis.referencing.operation.AbstractCoordinateOperation)5 DefaultCompoundCRS (org.apache.sis.referencing.crs.DefaultCompoundCRS)4 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)4 ConcatenatedOperation (org.opengis.referencing.operation.ConcatenatedOperation)4 MathTransform (org.opengis.referencing.operation.MathTransform)3 Extent (org.opengis.metadata.extent.Extent)2 ReferenceSystem (org.opengis.referencing.ReferenceSystem)2 OperationMethod (org.opengis.referencing.operation.OperationMethod)2 TransformException (org.opengis.referencing.operation.TransformException)2 Transformation (org.opengis.referencing.operation.Transformation)2 FactoryException (org.opengis.util.FactoryException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1