final List<SingleCRS> sourceCRS, final SingleCRS targetCRS) { final boolean targetGeodetic; final Datum targetDatum = targetCRS.getDatum(); if (targetDatum instanceof GeodeticDatum) { targetGeodetic = true; boolean shift = false; for (final SingleCRS crs : sourceCRS) { final Datum sourceDatum = crs.getDatum(); final boolean sourceGeodetic; if (sourceDatum instanceof GeodeticDatum) { && (shift || targetCRS.getCoordinateSystem().getDimension() >= 3);
/** * Returns the datum of the specified CRS, or {@code null} if none. * * @param crs The coordinate reference system for which to get the datum. May be {@code null}. * @return The datum in the given CRS, or {@code null} if none. */ public static Datum getDatum(final CoordinateReferenceSystem crs) { return (crs instanceof SingleCRS) ? ((SingleCRS) crs).getDatum() : null; }
if (horizontalCRS != null) { targetUnit = getFirstAxisUnit(horizontalCRS.getCoordinateSystem()); } else {
public SingleCRS toGeodetic3D(SingleCRS crs) throws FactoryException { if (crs instanceof GeographicCRS || crs instanceof ProjectedCRS) { switch (crs.getCoordinateSystem().getDimension()) { case 2: { CoordinateSystemAxis vertical = Axes.ELLIPSOIDAL_HEIGHT; final Unit<Length> units = ((GeodeticDatum) crs.getDatum()).getEllipsoid().getAxisUnit(); if (!Units.METRE.equals(units)) { vertical = getCSFactory().createCoordinateSystemAxis( throw new FactoryException(Errors.format(Errors.Keys.UnsupportedCrs_1, crs.getName()));
/** * Tests the construction of a {@link DefaultDerivedCRS}. */ @Test public void testConstruction() { final DefaultDerivedCRS crs = createLongitudeRotation(); // Validators.validate(crs); assertEquals("name", "Back to Greenwich", crs.getName().getCode()); assertEquals("baseCRS", "NTF (Paris)", crs.getBaseCRS().getName().getCode()); assertEquals("datum", "Nouvelle Triangulation Française", crs.getDatum().getName().getCode()); assertSame ("coordinateSystem", HardCodedCS.GEODETIC_φλ, crs.getCoordinateSystem()); final Conversion conversion = crs.getConversionFromBase(); assertSame("sourceCRS", crs.getBaseCRS(), conversion.getSourceCRS()); assertSame("targetCRS", crs, conversion.getTargetCRS()); assertMatrixEquals("Longitude rotation", new Matrix3( 0, 1, 0, 1, 0, 2.33722917, 0, 0, 1), MathTransforms.getMatrix(conversion.getMathTransform()), STRICT); }
/** * Constructs a new coordinate reference system with the same values than the specified one. * This copy constructor provides a way to wrap an arbitrary implementation into a Geotools one * or a user-defined one (as a subclass), usually in order to leverage some * implementation-specific API. This constructor performs a shallow copy, i.e. the properties * are not cloned. * * @param crs The coordinate reference system to copy. * @since 2.2 */ public AbstractSingleCRS(final SingleCRS crs) { super(crs); datum = crs.getDatum(); }
if (horizontal == null) { horizontal = candidate; if (horizontal.getCoordinateSystem().getDimension() == 2) { hi = i; continue;
/** * Work around for RFE #4093999 in Sun's bug database ("Relax constraint on placement of * this()/super() call in constructors"). * * @todo What to do if {@code base} is not an instance of {@link SingleCRS}? */ private static Datum getDatum(final CoordinateReferenceSystem base) { ensureNonNull("base", base); return (base instanceof SingleCRS) ? ((SingleCRS) base).getDatum() : null; }
if (!Utilities.equalsApproximatively(crsA.getCoordinateSystem(), crsG.getCoordinateSystem())) { return CS; final Datum datumA = crsA.getDatum(); final Datum datumG = crsG.getDatum(); if (!Utilities.equalsApproximatively(datumA, datumG)) { if ((datumA instanceof GeodeticDatum) && (datumG instanceof GeodeticDatum) &&
baseCRS.getCoordinateSystem().getClass(), CoordinateSystem.class))
where = "SOURCE_GEOGCRS_CODE"; } else if (object instanceof SingleCRS) { dependency = ((SingleCRS) object).getDatum(); where = "DATUM_CODE"; } else if (object instanceof GeodeticDatum) {
if (!Utilities.equalsApproximatively(crsA.getCoordinateSystem(), crsG.getCoordinateSystem())) { return CS; final Datum datumA = crsA.getDatum(); final Datum datumG = crsG.getDatum(); if (!Utilities.equalsApproximatively(datumA, datumG)) { if ((datumA instanceof GeodeticDatum) && (datumG instanceof GeodeticDatum) &&
baseCRS.getCoordinateSystem().getClass(), CoordinateSystem.class))
where = "SOURCE_GEOGCRS_CODE"; } else if (object instanceof SingleCRS) { dependency = ((SingleCRS) object).getDatum(); where = "DATUM_CODE"; } else if (object instanceof GeodeticDatum) {
} else { linearUnit = csUnit; angularUnit = AxisDirections.getAngularUnit(geoCRS.getCoordinateSystem(), Units.DEGREE); cs = parseCoordinateSystem(element, WKTKeywords.Cartesian, 2, isWKT1, csUnit, geoCRS.getDatum()); final Map<String,?> properties = parseMetadataAndClose(element, name, conversion); if (cs instanceof CartesianCS) {
int d = 0; for (SingleCRS crs2 : getSingleComponents(crs)) { final int dim = crs2.getCoordinateSystem().getDimension(); if (crs2 instanceof GeographicCRS || crs2 instanceof ProjectedCRS) { for (int i=0; i<dim; i++) { // May be 2 or 3 dimensional.
/** * Creates a new identifier with the same values than the given identifier, * and store the given horizontal component for information purpose. * * @param identifier The identifier to copy. * @param horizontalCRS The horizontal component of the 3D CRS. */ private Identifier3D(final Identifier identifier, final SingleCRS horizontalCRS) { super(identifier); this.horizontalCRS = horizontalCRS; assert horizontalCRS.getDatum() instanceof GeodeticDatum : horizontalCRS; }
} else { linearUnit = csUnit; angularUnit = AxisDirections.getAngularUnit(geoCRS.getCoordinateSystem(), Units.DEGREE); cs = parseCoordinateSystem(element, WKTKeywords.Cartesian, 2, isWKT1, csUnit, geoCRS.getDatum()); final Map<String,?> properties = parseMetadataAndClose(element, name, conversion); if (cs instanceof CartesianCS) {
final CoordinateSystem cs = horizontal.getCoordinateSystem(); axis[xyFirst ? 0 : 1] = cs.getAxis(0); axis[xyFirst ? 1 : 2] = cs.getAxis(1);
/** * Returns the datum, or {@code null} if none. * * This property does not exist in {@code CoordinateReferenceSystem} interface — it is defined in the * {@link SingleCRS} sub-interface instead. But Apache SIS does not define an {@code AbstractSingleCRS} class * in order to simplify our class hierarchy, so we provide a datum getter in this class has a hidden property. * Subclasses implementing {@code SingleCRS} (basically all SIS subclasses except {@link DefaultCompoundCRS}) * will override this method with public access and more specific return type. * * @return the datum, or {@code null} if none. */ Datum getDatum() { /* * User could provide his own CRS implementation outside this SIS package, so we have * to check for SingleCRS interface. But all SIS classes override this implementation. */ return (this instanceof SingleCRS) ? ((SingleCRS) this).getDatum() : null; }