/** * 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; }
@Override public IdentifiedObject create(final String code) throws FactoryException { return factory.createGeographicCRS(code); } }
@Override public IdentifiedObject create(final String code) throws FactoryException { return factory.createProjectedCRS(code); } }
/** * 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 AbstractCRS(final CoordinateReferenceSystem crs) { super(crs); coordinateSystem = crs.getCoordinateSystem(); }
if (horizontalCRS != null) { targetUnit = getFirstAxisUnit(horizontalCRS.getCoordinateSystem()); } else { targetUnit = getFirstAxisUnit(crs.getCoordinateSystem());
@Test public void testCRSConverter() throws Exception { CoordinateReferenceSystem crs = CRS.decode("EPSG:4326"); CRSConverter c = new CRSConverter(); assertEquals(crs.toWKT(), c.toString(crs)); assertEquals(DefaultGeographicCRS.WGS84.toWKT(), c.toString(DefaultGeographicCRS.WGS84)); CoordinateReferenceSystem crs2 = (CoordinateReferenceSystem) c.fromString(crs.toWKT()); assertTrue(CRS.equalsIgnoreMetadata(crs, crs2)); crs2 = (CoordinateReferenceSystem) c.fromString("EPSG:4326"); assertTrue(CRS.equalsIgnoreMetadata(crs, crs2)); }
if ((nativeCRS.getIdentifiers() != null) && !nativeCRS.getIdentifiers().isEmpty()) { cinfo.getRequestSRS() .add(((Identifier) nativeCRS.getIdentifiers().toArray()[0]).toString()); cinfo.getResponseSRS() .add(((Identifier) nativeCRS.getIdentifiers().toArray()[0]).toString());
/** Creates an object for the specified code. */ protected IdentifiedObject createObject(final String code) throws FactoryException { if (projections != null) { final String crs = (String) projections.get(code); if (crs != null) { return ((CRSAuthorityFactory) factory) .createProjectedCRS(crs) .getConversionFromBase(); } } return ((CoordinateOperationAuthorityFactory) factory).createCoordinateOperation(code); } }
public IdentifiedObject create(final String code) throws FactoryException { return factory.createCoordinateReferenceSystem(code); } }
public Set getAuthorityCodes(Class type) throws FactoryException { return crsAuthority.getAuthorityCodes(type); }
public InternationalString getDescriptionText(String code) throws FactoryException { return crsAuthority.getDescriptionText(code); }
public Citation getAuthority() { return crsAuthority.getAuthority(); }
/** * Constructs a new derived CRS 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 */ protected AbstractDerivedCRS(final GeneralDerivedCRS crs) { super(crs); baseCRS = crs.getBaseCRS(); conversionFromBase = crs.getConversionFromBase(); }
@Test public void testOverride() throws Exception { CoordinateReferenceSystem epsg3003 = CRS.decode("EPSG:3003"); DefaultGeodeticDatum datum3003 = (DefaultGeodeticDatum) (((ProjectedCRS) epsg3003).getDatum()); BursaWolfParameters[] bwParamArray3003 = datum3003.getBursaWolfParameters(); assertEquals(1, bwParamArray3003.length); BursaWolfParameters bw3003 = bwParamArray3003[0]; double tol = 1E-7; assertEquals(-104.1, bw3003.dx, tol); assertEquals(-49.1, bw3003.dy, tol); assertEquals(-9.9, bw3003.dz, tol); assertEquals(0.971, bw3003.ex, tol); assertEquals(-2.917, bw3003.ey, tol); assertEquals(0.714, bw3003.ez, tol); assertEquals(-11.68, bw3003.ppm, tol); // without an override they should be the same as 3002 CoordinateReferenceSystem epsg3002 = CRS.decode("EPSG:3002"); DefaultGeodeticDatum datum3002 = (DefaultGeodeticDatum) (((ProjectedCRS) epsg3002).getDatum()); BursaWolfParameters[] bwParamArray3002 = datum3002.getBursaWolfParameters(); assertEquals(1, bwParamArray3002.length); BursaWolfParameters bw3002 = bwParamArray3002[0]; assertFalse(bw3002.equals(bw3003)); } }
/** * Returns a {@linkplain GeocentricCRS geocentric coordinate reference system} from a code. * * @throws FactoryException if the object creation failed. */ @Override public GeocentricCRS createGeocentricCRS(final String code) throws FactoryException { return (GeocentricCRS) replace( getCRSAuthorityFactory(code) .createGeocentricCRS(toBackingFactoryCode(code))); }
writer.write("<low>" + lower + "</low>\n"); writer.write("<high>" + upper + "</high>\n"); final CoordinateSystem cs = crs.getCoordinateSystem(); for (int i = 0; i < cs.getDimension(); i++) { writer.write("<axisName>" + cs.getAxis(i).getName().getCode() + "</axisName>\n");
if (nativeCRS != null && !nativeCRS.getIdentifiers().isEmpty()) { cinfo.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED);
hints); CoordinateReferenceSystem worldCRS = factory .createCoordinateReferenceSystem("EPSG:4326");
/** * 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(); }
/** * 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; }