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();
}
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());
}
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());
}
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);
}
Aggregations