Search in sources :

Example 1 with GeocentricCRS

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

Example 2 with GeocentricCRS

use of org.opengis.referencing.crs.GeocentricCRS in project sis by apache.

the class CommonCRSTest method testSpherical.

/**
 * Tests the {@link CommonCRS#spherical()} method.
 */
@Test
@DependsOnMethod("testGeographic3D")
public void testSpherical() {
    final GeocentricCRS crs = CommonCRS.ETRS89.spherical();
    Validators.validate(crs);
    assertEquals("ETRS89", crs.getName().getCode());
    assertSame(CommonCRS.ETRS89.geographic().getDatum(), crs.getDatum());
    assertNotSame(CommonCRS.WGS84.geographic().getDatum(), crs.getDatum());
    final CoordinateSystem cs = crs.getCoordinateSystem();
    final String name = cs.getName().getCode();
    assertTrue(name, name.startsWith("Spherical"));
    assertEquals("dimension", 3, cs.getDimension());
    assertAxisDirectionsEqual(name, cs, AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
    assertSame("Cached value", crs, CommonCRS.ETRS89.spherical());
}
Also used : CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) GeocentricCRS(org.opengis.referencing.crs.GeocentricCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 3 with GeocentricCRS

use of org.opengis.referencing.crs.GeocentricCRS in project sis by apache.

the class CommonCRSTest method testGeocentric.

/**
 * Tests the {@link CommonCRS#geocentric()} method.
 */
@Test
@DependsOnMethod("testGeographic3D")
public void testGeocentric() {
    final GeocentricCRS crs = CommonCRS.WGS72.geocentric();
    Validators.validate(crs);
    assertEquals("WGS 72", crs.getName().getCode());
    assertSame(CommonCRS.WGS72.geographic().getDatum(), crs.getDatum());
    assertNotSame(CommonCRS.WGS84.geographic().getDatum(), crs.getDatum());
    final CoordinateSystem cs = crs.getCoordinateSystem();
    final String name = cs.getName().getCode();
    assertTrue(name, name.startsWith("Earth centred"));
    assertEquals("dimension", 3, cs.getDimension());
    assertAxisDirectionsEqual(name, cs, AxisDirection.GEOCENTRIC_X, AxisDirection.GEOCENTRIC_Y, AxisDirection.GEOCENTRIC_Z);
    assertSame("Cached value", crs, CommonCRS.WGS72.geocentric());
}
Also used : CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) GeocentricCRS(org.opengis.referencing.crs.GeocentricCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 4 with GeocentricCRS

use of org.opengis.referencing.crs.GeocentricCRS in project sis by apache.

the class SubTypes method castOrCopy.

/**
 * Returns a SIS implementation for the given coordinate reference system.
 *
 * @see AbstractCRS#castOrCopy(CoordinateReferenceSystem)
 */
static AbstractCRS castOrCopy(final CoordinateReferenceSystem object) {
    if (object instanceof DerivedCRS) {
        return DefaultDerivedCRS.castOrCopy((DerivedCRS) object);
    }
    if (object instanceof ProjectedCRS) {
        return DefaultProjectedCRS.castOrCopy((ProjectedCRS) object);
    }
    if (object instanceof GeodeticCRS) {
        if (object instanceof GeographicCRS) {
            return DefaultGeographicCRS.castOrCopy((GeographicCRS) object);
        }
        if (object instanceof GeocentricCRS) {
            return DefaultGeocentricCRS.castOrCopy((GeocentricCRS) object);
        }
        /*
             * The GeographicCRS and GeocentricCRS types are not part of ISO 19111.
             * ISO uses a single type, GeodeticCRS, for both of them and infer the
             * geographic or geocentric type from the coordinate system. We do this
             * check here for instantiating the most appropriate SIS type, but only
             * if we need to create a new object anyway (see below for rational).
             */
        if (object instanceof DefaultGeodeticCRS) {
            /*
                 * Result of XML unmarshalling — keep as-is. We avoid creating a new object because it
                 * would break object identities specified in GML document by the xlink:href attribute.
                 * However we may revisit this policy in the future. See SC_CRS.setElement(AbstractCRS).
                 */
            return (DefaultGeodeticCRS) object;
        }
        final Map<String, ?> properties = IdentifiedObjects.getProperties(object);
        final GeodeticDatum datum = ((GeodeticCRS) object).getDatum();
        final CoordinateSystem cs = object.getCoordinateSystem();
        if (cs instanceof EllipsoidalCS) {
            return new DefaultGeographicCRS(properties, datum, (EllipsoidalCS) cs);
        }
        if (cs instanceof SphericalCS) {
            return new DefaultGeocentricCRS(properties, datum, (SphericalCS) cs);
        }
        if (cs instanceof CartesianCS) {
            return new DefaultGeocentricCRS(properties, datum, (CartesianCS) cs);
        }
    }
    if (object instanceof VerticalCRS) {
        return DefaultVerticalCRS.castOrCopy((VerticalCRS) object);
    }
    if (object instanceof TemporalCRS) {
        return DefaultTemporalCRS.castOrCopy((TemporalCRS) object);
    }
    if (object instanceof EngineeringCRS) {
        return DefaultEngineeringCRS.castOrCopy((EngineeringCRS) object);
    }
    if (object instanceof ImageCRS) {
        return DefaultImageCRS.castOrCopy((ImageCRS) object);
    }
    if (object instanceof CompoundCRS) {
        return DefaultCompoundCRS.castOrCopy((CompoundCRS) object);
    }
    /*
         * Intentionally check for AbstractCRS after the interfaces because user may have defined his own
         * subclass implementing the interface. If we were checking for AbstractCRS before the interfaces,
         * the returned instance could have been a user subclass without the JAXB annotations required
         * for XML marshalling.
         */
    if (object == null || object instanceof AbstractCRS) {
        return (AbstractCRS) object;
    }
    return new AbstractCRS(object);
}
Also used : CartesianCS(org.opengis.referencing.cs.CartesianCS) EngineeringCRS(org.opengis.referencing.crs.EngineeringCRS) CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) DerivedCRS(org.opengis.referencing.crs.DerivedCRS) CompoundCRS(org.opengis.referencing.crs.CompoundCRS) GeodeticDatum(org.opengis.referencing.datum.GeodeticDatum) GeodeticCRS(org.opengis.referencing.crs.GeodeticCRS) SphericalCS(org.opengis.referencing.cs.SphericalCS) TemporalCRS(org.opengis.referencing.crs.TemporalCRS) ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ImageCRS(org.opengis.referencing.crs.ImageCRS) VerticalCRS(org.opengis.referencing.crs.VerticalCRS) EllipsoidalCS(org.opengis.referencing.cs.EllipsoidalCS) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) GeocentricCRS(org.opengis.referencing.crs.GeocentricCRS)

Aggregations

GeocentricCRS (org.opengis.referencing.crs.GeocentricCRS)4 DependsOnMethod (org.apache.sis.test.DependsOnMethod)3 Test (org.junit.Test)3 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)3 CompoundCRS (org.opengis.referencing.crs.CompoundCRS)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1 DerivedCRS (org.opengis.referencing.crs.DerivedCRS)1 EngineeringCRS (org.opengis.referencing.crs.EngineeringCRS)1 GeodeticCRS (org.opengis.referencing.crs.GeodeticCRS)1 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)1 ImageCRS (org.opengis.referencing.crs.ImageCRS)1 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)1 TemporalCRS (org.opengis.referencing.crs.TemporalCRS)1 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)1 CartesianCS (org.opengis.referencing.cs.CartesianCS)1 EllipsoidalCS (org.opengis.referencing.cs.EllipsoidalCS)1 SphericalCS (org.opengis.referencing.cs.SphericalCS)1 GeodeticDatum (org.opengis.referencing.datum.GeodeticDatum)1 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)1