@Override public IdentifiedObject create(final String code) throws FactoryException { return factory.createGeographicCRS(code); } }
/** * Returns a {@linkplain GeographicCRS geographic coordinate reference system} from a code. * * @throws FactoryException if the object creation failed. */ @Override public GeographicCRS createGeographicCRS(final String code) throws FactoryException { return (GeographicCRS) replace( getCRSAuthorityFactory(code) .createGeographicCRS(toBackingFactoryCode(code))); }
public GeographicCRS createGeographicCRS(String code) throws FactoryException { final String key = toKey(code); GeographicCRS crs = (GeographicCRS) cache.get(key); if (crs == null) { try { cache.writeLock(key); crs = (GeographicCRS) cache.peek(key); if (crs == null) { crs = crsAuthority.createGeographicCRS(code); cache.put(key, crs); } } finally { cache.writeUnLock(key); } } return crs; }
public GeographicCRS createGeographicCRS(String code) throws FactoryException { final String key = toKey(code); GeographicCRS crs = (GeographicCRS) cache.get(key); if (crs == null) { try { cache.writeLock(key); crs = (GeographicCRS) cache.peek(key); if (crs == null) { crs = crsAuthority.createGeographicCRS(code); cache.put(key, crs); } } finally { cache.writeUnLock(key); } } return crs; }
/** Tests the CRS factory. */ @Test public void testCRS() throws FactoryException { CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("URN:OGC:DEF", null); GeographicCRS crs; try { crs = factory.createGeographicCRS("CRS:84"); fail(); } catch (NoSuchAuthorityCodeException exception) { // This is the expected exception. assertEquals("CRS:84", exception.getAuthorityCode()); } crs = factory.createGeographicCRS("urn:ogc:def:crs:CRS:WMS1.3:84"); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:CRS:1.3:84")); assertSame(crs, factory.createGeographicCRS("URN:OGC:DEF:CRS:CRS:1.3:84")); assertSame(crs, factory.createGeographicCRS("URN:OGC:DEF:CRS:CRS:84")); assertSame(crs, factory.createGeographicCRS("urn:x-ogc:def:crs:CRS:1.3:84")); assertSame(crs, CRS.decode("urn:ogc:def:crs:CRS:1.3:84")); assertSame(crs, CRS.decode("CRS:84")); assertNotSame(crs, DefaultGeographicCRS.WGS84); assertFalse(DefaultGeographicCRS.WGS84.equals(crs)); assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); // Test CRS:83 crs = factory.createGeographicCRS("urn:ogc:def:crs:CRS:1.3:83"); assertSame(crs, CRS.decode("CRS:83")); assertFalse(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); }
/** Tests the HTTP URI CRS factory. */ @Test public void testCRS() throws FactoryException { CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("http://www.opengis.net/def", null); GeographicCRS crs; try { crs = factory.createGeographicCRS("CRS:84"); fail(); } catch (NoSuchAuthorityCodeException exception) { assertEquals("CRS:84", exception.getAuthorityCode()); } crs = factory.createGeographicCRS("http://www.opengis.net/def/crs/CRS/WMS1.3/84"); assertSame(crs, factory.createGeographicCRS("http://www.opengis.net/def/crs/CRS/1.3/84")); assertSame(crs, factory.createGeographicCRS("HTTP://WWW.OPENGIS.NET/DEF/CRS/CRS/1.3/84")); assertSame(crs, factory.createGeographicCRS("HTTP://WWW.OPENGIS.NET/DEF/CRS/CRS/0/84")); assertSame(crs, CRS.decode("http://www.opengis.net/def/crs/CRS/1.3/84")); assertSame(crs, CRS.decode("CRS:84")); assertNotSame(crs, DefaultGeographicCRS.WGS84); assertFalse(DefaultGeographicCRS.WGS84.equals(crs)); assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); crs = factory.createGeographicCRS("http://www.opengis.net/def/crs/CRS/1.3/83"); assertSame(crs, CRS.decode("CRS:83")); assertFalse(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); }
/** Tests the CRS factory. */ @Test public void testCRS() throws FactoryException { CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("http://www.opengis.net/gml", null); GeographicCRS crs; try { crs = factory.createGeographicCRS("CRS:84"); fail(); } catch (NoSuchAuthorityCodeException exception) { // This is the expected exception. assertEquals("CRS:84", exception.getAuthorityCode()); } crs = factory.createGeographicCRS("http://www.opengis.net/gml/srs/crs.xml#84"); assertSame(crs, CRS.decode("http://www.opengis.net/gml/srs/crs.xml#84")); assertSame(crs, CRS.decode("CRS:84")); assertNotSame(crs, DefaultGeographicCRS.WGS84); assertFalse(DefaultGeographicCRS.WGS84.equals(crs)); assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); // Test CRS:83 crs = factory.createGeographicCRS("http://www.opengis.net/gml/srs/crs.xml#83"); assertSame(crs, CRS.decode("CRS:83")); assertFalse(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); } }
@Override public GeographicCRS createGeographicCRS(String code) throws FactoryException { return factory().createGeographicCRS(code); }
@Override GeographicCRS createFromAPI(AuthorityFactory factory, String code) throws FactoryException { return crsFactory(factory).createGeographicCRS(code); } };
@Override GeographicCRS createFromAPI(AuthorityFactory factory, String code) throws FactoryException { return crsFactory(factory).createGeographicCRS(code); } };
@Override public GeographicCRS createGeographicCRS(String code) throws FactoryException { return factory().createGeographicCRS(code); }
/** * Creates a geographic CRS for the given code and verify its properties. * * @param crsCode the code of the CRS to create. * @param expectedDirections either {@link #GEOGRAPHIC_2D} or {@link #GEOGRAPHIC_3D}. * @throws FactoryException if an error occurred while creating the CRS instance. */ private void createAndVerifyGeographicCRS(final int crsCode, final AxisDirection[] expectedDirections) throws FactoryException { if (crsAuthorityFactory != null) { final GeographicCRS crs; try { crs = crsAuthorityFactory.createGeographicCRS(String.valueOf(crsCode)); } catch (NoSuchAuthorityCodeException e) { unsupportedCode(GeographicCRS.class, crsCode); throw e; } if (crs == null) { fail("CRSAuthorityFactory.createGeographicCRS(\"" + code + "\") shall not return null."); } validators.validate(crs); verifyGeodeticCRS(crsCode, crs, expectedDirections); } }
crsAuthorityFactory.createGeographicCRS("EPSG:4326");
/** * Tests creation of {@code CRS:84} from various codes. * * @throws FactoryException if a CRS:84 creation failed. */ @Test public void testCRS84() throws FactoryException { final CRSAuthorityFactory factory = AuthorityFactories.ALL; final GeographicCRS crs = factory.createGeographicCRS("CRS:84"); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:CRS::84")); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:CRS:1.3:84")); assertSame(crs, factory.createGeographicCRS("URN:OGC:DEF:CRS:CRS:1.3:84")); assertSame(crs, factory.createGeographicCRS("URN:OGC:DEF:CRS:CRS::84")); assertSame(crs, factory.createGeographicCRS("urn:x-ogc:def:crs:CRS:1.3:84")); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:OGC:1.3:CRS84")); // Following are just wrappers for above factory. assertSame(crs, CRS.forCode("urn:ogc:def:crs:CRS:1.3:84")); assertSame(crs, CRS.forCode("urn:ogc:def:crs:OGC:1.3:CRS84")); assertSame(crs, CRS.forCode("CRS:84")); assertSame(crs, CRS.forCode("OGC:CRS84")); assertNotDeepEquals(crs, CRS.forCode("CRS:83")); }
/** * Tests creation of {@code EPSG:4326} from codes for various versions of the EPSG database. * This test verifies the logged messages. * * @throws FactoryException if an EPSG:4326 creation failed. */ @Test public void testVersionedEPSG() throws FactoryException { final CRSAuthorityFactory factory = AuthorityFactories.ALL; final GeographicCRS crs = factory.createGeographicCRS("EPSG:4326"); loggings.assertNoUnexpectedLog(); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:6.11.2:4326")); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:6.11.2:4326")); loggings.assertNextLogContains("6.11.2"); loggings.assertNoUnexpectedLog(); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:7.04:4326")); loggings.assertNextLogContains("7.04"); loggings.assertNoUnexpectedLog(); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:7.10:4326")); loggings.assertNextLogContains("7.10"); loggings.assertNoUnexpectedLog(); assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG::4326")); loggings.assertNoUnexpectedLog(); }
/** Possibly sets {@link #coordinateSystem} to a predefined CS matching the axes defined in the netCDF file. */ @Override void candidate(final Decoder decoder) throws FactoryException { if (isPredefined(Units.DEGREE)) { if (!is3D()) { GeographicCRS crs = decoder.getCRSAuthorityFactory().createGeographicCRS(String.valueOf(Constants.EPSG_UNKNOWN_CRS)); coordinateSystem = crs.getCoordinateSystem(); datum = crs.getDatum(); referenceSystem = crs; } else if (!tryEPSG(decoder)) { coordinateSystem = DEFAULT.geographic3D().getCoordinateSystem(); } if (isLongitudeFirst) { coordinateSystem = DefaultEllipsoidalCS.castOrCopy(coordinateSystem).forConvention(AxesConvention.RIGHT_HANDED); referenceSystem = null; } } else { tryEPSG(decoder); } }
/** * Returns the system-wide EPSG factory, or interrupts the tests with {@link org.junit.Assume} * if the EPSG factory is not available. Note that this method breaks isolation between tests. * For more isolated tests, use {@link #createFactory()} and {@link #close()} instead. * * @return the system-wide EPSG factory. * @throws FactoryException if an error occurred while fetching the factory. */ public static synchronized EPSGFactory getSharedFactory() throws FactoryException { assumeFalse("No connection to EPSG dataset.", isUnavailable); final CRSAuthorityFactory factory = CRS.getAuthorityFactory(Constants.EPSG); assumeTrue("No connection to EPSG dataset.", factory instanceof EPSGFactory); try { assertNotNull(factory.createGeographicCRS("4326")); } catch (UnavailableFactoryException e) { isUnavailable = true; Logging.getLogger(Loggers.CRS_FACTORY).warning(e.toString()); assumeNoException("No connection to EPSG dataset.", e); } return (EPSGFactory) factory; }
public void testWGS84() throws NoSuchAuthorityCodeException, FactoryException { assumeNotNull(crsAuthorityFactory); final GeographicCRS crs = crsAuthorityFactory.createGeographicCRS("EPSG:4326"); assertNotNull("CRSAuthorityFactory.createGeographicCRS()", crs); object = crs;
CoordinateReferenceSystem sourceCRS = crsFactory.createGeographicCRS("EPSG:4625"); CoordinateReferenceSystem targetCRS = crsFactory.createGeographicCRS("EPSG:5489"); CoordinateOperation operation = createOperation(sourceCRS, targetCRS); assertEpsgNameAndIdentifierEqual("Martinique 1938 to RGAF09 (1)", 5491, operation); targetCRS = crsFactory.createGeographicCRS("EPSG:7086"); operation = createOperation(sourceCRS, targetCRS); assertEpsgNameWithoutIdentifierEqual("Martinique 1938 to RGAF09 (1)", operation);
public void testCRSAuthorityCreation() throws NoSuchAuthorityCodeException, FactoryException { assumeNotNull(factory); final GeographicCRS crs = factory.createGeographicCRS("EPSG:4326"); validate(crs); assertNotNull(crs);