/** * Makes sure that the specified geocentric CRS uses standard axis, prime meridian and the * specified datum. If {@code crs} already meets all those conditions, then it is returned * unchanged. Otherwise, a new normalized geocentric CRS is created and returned. * * @param crs The geocentric coordinate reference system to normalize. * @param datum The expected datum. * @return The normalized coordinate reference system. * @throws FactoryException if the construction of a new CRS was needed but failed. */ private GeocentricCRS normalize(final GeocentricCRS crs, final GeodeticDatum datum) throws FactoryException { final CartesianCS STANDARD = DefaultCartesianCS.GEOCENTRIC; final GeodeticDatum candidate = crs.getDatum(); if (equalsIgnorePrimeMeridian(candidate, datum)) { if (getGreenwichLongitude(candidate.getPrimeMeridian()) == getGreenwichLongitude(datum.getPrimeMeridian())) { if (hasStandardAxis(crs.getCoordinateSystem(), STANDARD)) { return crs; } } } final CRSFactory crsFactory = getFactoryContainer().getCRSFactory(); return crsFactory.createGeocentricCRS(getTemporaryName(crs), datum, STANDARD); }
/** * The standard three-dimensional Cartesian CS as defined by ISO 19111. * * @param unit the linear unit of the desired coordinate system, or {@code null} for metres. * @return the ISO 19111 coordinate system. */ public static CartesianCS standard(final Unit<?> unit) { return replaceUnit((CartesianCS) CommonCRS.WGS84.geocentric().getCoordinateSystem(), unit); }
/** * 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()); }
final Unit<Angle> angularUnit = createUnit(GeoKeys.AngularUnits, GeoKeys.AngularUnitSize, Angle.class, Units.DEGREE); final GeodeticDatum datum = createGeodeticDatum(names, angularUnit, linearUnit); CartesianCS cs = (CartesianCS) CommonCRS.WGS84.geocentric().getCoordinateSystem(); if (!Units.METRE.equals(linearUnit)) { cs = replaceLinearUnit(cs, linearUnit); lastName = crs.getName(); return crs;
/** * Verifies if the user-defined CRS created from GeoTIFF values * matches the given CRS created from the EPSG geodetic dataset. * This method does not verify the EPSG code of the given CRS. * * @param crs the CRS created from the EPSG geodetic dataset. */ private void verify(final GeocentricCRS crs) throws FactoryException { /* * Note: current createUnit(…) implementation does not allow us to distinguish whether METRE ou DEGREE units * were specified in the GeoTIFF file or if we got the default values. We do not compare units of that reason. */ final Unit<Length> linearUnit = createUnit(GeoKeys.GeogLinearUnits, GeoKeys.GeogLinearUnitSize, Length.class, Units.METRE); final Unit<Angle> angularUnit = createUnit(GeoKeys.AngularUnits, GeoKeys.AngularUnitSize, Angle.class, Units.DEGREE); final GeodeticDatum datum = crs.getDatum(); verifyIdentifier(crs, datum, GeoKeys.GeodeticDatum); verify(datum, angularUnit, linearUnit); }
/** * The standard three-dimensional Cartesian CS as defined by ISO 19111. * * @param unit the linear unit of the desired coordinate system, or {@code null} for metres. * @return the ISO 19111 coordinate system. */ public static CartesianCS standard(final Unit<?> unit) { return replaceUnit((CartesianCS) CommonCRS.WGS84.geocentric().getCoordinateSystem(), unit); }
/** * 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()); }
final GeodeticDatum sourceDatum = sourceCRS.getDatum(); final GeodeticDatum targetDatum = targetCRS.getDatum(); final CoordinateSystem sourceCS = sourceCRS.getCoordinateSystem(); final CoordinateSystem targetCS = targetCRS.getCoordinateSystem(); final double sourcePM, targetPM; sourcePM = getGreenwichLongitude(sourceDatum.getPrimeMeridian());
/** * Creates a geocentric CRS for the given properties and verify its properties after construction. * * @param crsCode the GIGS code of the CRS to create. * @param crsName the GIGS name of the CRS to create. * @param csCode the EPSG code of the coordinate system. * @throws FactoryException if an error occurred while creating the CRS instance. */ @SuppressWarnings("null") private void createAndVerifyGeocentricCRS(final int crsCode, final String crsName, final int csCode) throws FactoryException { if (crsFactory != null) { final GeocentricCRS crs = crsFactory.createGeocentricCRS(properties(crsCode, crsName), getIdentifiedObject(), epsgFactory.createCartesianCS(String.valueOf(csCode))); assertNotNull("CRSFactory.createGeocentricCRS(…) shall not return null.", crs); validators.validate(crs); verifyIdentification(crs, crsName, String.valueOf(crsCode)); verifyCoordinateSystem(crs.getCoordinateSystem(), CartesianCS.class, GIGS2004.GEOCENTRIC, units.metre()); } }
final CoordinateSystem cs = object.getCoordinateSystem(); mandatory("GeocentricCRS: must have a CoordinateSystem.", cs); if (cs instanceof CartesianCS) { fail("GeocentricCRS: unknown CoordinateSystem of type " + cs.getClass().getCanonicalName() + '.'); final GeodeticDatum datum = object.getDatum(); mandatory("GeocentricCRS: must have a Datum.", datum); container.datum.validate(datum);
/** Possibly sets {@link #coordinateSystem} to a predefined CS matching the axes defined in the netCDF file. */ @Override void candidate(final Decoder decoder) throws FactoryException { super.candidate(decoder); final Integer epsg = epsgCandidate(Units.DEGREE); if (epsg != null) try { coordinateSystem = decoder.getCSAuthorityFactory().createSphericalCS(epsg.toString()); return; } catch (NoSuchAuthorityCodeException e) { recoverableException(e); } if (isPredefined(Units.DEGREE)) { coordinateSystem = (SphericalCS) DEFAULT.spherical().getCoordinateSystem(); if (isLongitudeFirst) { coordinateSystem = DefaultSphericalCS.castOrCopy(coordinateSystem).forConvention(AxesConvention.RIGHT_HANDED); } } }
/** * Tests the "ITRF93" geocentric CRS (EPSG:4915). * * @throws FactoryException if an error occurred while querying the factory. */ @Test public void testGeocentric() throws FactoryException { final EPSGFactory factory = TestFactorySource.factory; assumeNotNull(factory); final GeocentricCRS crs = factory.createGeocentricCRS("epsg:4915"); assertEpsgNameAndIdentifierEqual("ITRF93", 4915, crs); assertEpsgNameAndIdentifierEqual("International Terrestrial Reference Frame 1993", 6652, crs.getDatum()); assertAxisDirectionsEqual("EPSG::6500", crs.getCoordinateSystem(), AxisDirection.GEOCENTRIC_X, AxisDirection.GEOCENTRIC_Y, AxisDirection.GEOCENTRIC_Z); assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("4915")); }
cs = (CartesianCS) StandardDefinitions.createCoordinateSystem((short) 6500); } else { cs = (CartesianCS) DEFAULT.geocentric().getCoordinateSystem();
final GeodeticDatum datum = crs.getDatum(); assertNameAndIdentifierEqual("World Geodetic System 1984", 6326, datum); assertNameAndIdentifierEqual("Greenwich", 8901, datum.getPrimeMeridian()); final CartesianCS cs = (CartesianCS) crs.getCoordinateSystem(); assertEquals("dimension", 3, cs.getDimension()); assertUnboundedAxisEquals(AxisNames.GEOCENTRIC_X, "X", AxisDirection.GEOCENTRIC_X, Units.METRE, cs.getAxis(0));
cs = (CartesianCS) StandardDefinitions.createCoordinateSystem((short) 6500); } else { cs = (CartesianCS) DEFAULT.geocentric().getCoordinateSystem();
cs = (SphericalCS) DEFAULT.spherical().getCoordinateSystem();
cs = (SphericalCS) DEFAULT.spherical().getCoordinateSystem();
/** * Tests the creation of a geocentric CRS. * * @throws FactoryException if a factory fails to create a referencing object. */ @Test public void testGeocentric() throws FactoryException { final CoordinateSystemAxis X, Y, Z; final CartesianCS cs; final GeocentricCRS crs; // The final product of this method. final GeodeticDatum datum; final PrimeMeridian greenwich; final Ellipsoid ellipsoid; final Unit<Length> metre = units.metre(); final Unit<Angle> degree = units.degree(); assumeNotNull(datumFactory); validators.validate(greenwich = datumFactory.createPrimeMeridian (name("Greenwich Meridian"), 0, degree)); validators.validate(ellipsoid = datumFactory.createFlattenedSphere(name("WGS84 Ellipsoid"), 6378137, 298.257223563, metre)); validators.validate(datum = datumFactory.createGeodeticDatum (name("WGS84 Datum"), ellipsoid, greenwich)); assumeNotNull(csFactory); validators.validate(X = csFactory.createCoordinateSystemAxis(name("Geocentric X"), "X", GEOCENTRIC_X, metre)); validators.validate(Y = csFactory.createCoordinateSystemAxis(name("Geocentric Y"), "Y", GEOCENTRIC_Y, metre)); validators.validate(Z = csFactory.createCoordinateSystemAxis(name("Geocentric Z"), "Z", GEOCENTRIC_Z, metre)); validators.validate(cs = csFactory.createCartesianCS(name("Geocentric CS"), X, Z, Y)); assumeNotNull(crsFactory); validators.validate(crs = crsFactory.createGeocentricCRS(name("Geocentric CRS"), datum, cs)); assertAxisDirectionsEqual("GeocentricCRS", crs.getCoordinateSystem(), GEOCENTRIC_X, GEOCENTRIC_Z, GEOCENTRIC_Y); }
parameters = Affine.identity(3); // Dimension of geocentric CRS. final CoordinateSystem normalized = CommonCRS.WGS84.geocentric().getCoordinateSystem(); before = mtFactory.createCoordinateSystemChange(sourceCS, normalized, sourceDatum.getEllipsoid()); after = mtFactory.createCoordinateSystemChange(normalized, targetCS, targetDatum.getEllipsoid());
parameters = Affine.identity(3); // Dimension of geocentric CRS. final CoordinateSystem normalized = CommonCRS.WGS84.geocentric().getCoordinateSystem(); before = mtFactory.createCoordinateSystemChange(sourceCS, normalized, sourceDatum.getEllipsoid()); after = mtFactory.createCoordinateSystemChange(normalized, targetCS, targetDatum.getEllipsoid());