/** * Returns a simple authority code (like "EPSG:4236") that can be passed to the wrapped * factories. * * @param code The code given to this factory. * @return The code to give to the underlying factories. * @throws FactoryException if the code can't be converted. */ @Override protected String toBackingFactoryCode(final String code) throws FactoryException { return getParser(code).getAuthorityCode(); } }
/** * Returns the coordinate system factory to use for the specified URI. If the URI contains a * version string, then this method will try to fetch a factory for that particular version. The * {@link #createVersionedFactory} method may be invoked for that purpose. If no factory is * provided for that specific version, then the {@linkplain * AuthorityFactoryAdapter#getCSAuthorityFactory default one} is used. * * @param code The URI given to this class. * @return A factory for the specified URI (never {@code null}). * @throws FactoryException if no coordinate system factory is available. */ @Override protected CSAuthorityFactory getCSAuthorityFactory(final String code) throws FactoryException { if (code != null) { final URI_Parser parser = getParser(code); parser.logWarningIfTypeMismatch(this, CSAuthorityFactory.class); final AuthorityFactory factory = getVersionedFactory(parser); if (factory instanceof CSAuthorityFactory) { return (CSAuthorityFactory) factory; } } return super.getCSAuthorityFactory(code); }
/** Test that an unversioned HTTP URI can be parsed. */ @Test public void testParseUnversioned() throws NoSuchAuthorityCodeException { URI_Parser parser = HTTP_URI_Parser.buildParser("http://www.opengis.net/def/crs/EPSG/0/4326"); assertEquals("crs", parser.type.name); assertEquals("EPSG", parser.authority); assertNull(parser.version); assertEquals("4326", parser.code); assertEquals("EPSG:4326", parser.getAuthorityCode()); }
/** * Returns the coordinate reference system factory to use for the specified URI. If the URI * contains a version string, then this method will try to fetch a factory for that particular * version. The {@link #createVersionedFactory} method may be invoked for that purpose. If no * factory is provided for that specific version, then the {@linkplain * AuthorityFactoryAdapter#getCRSAuthorityFactory default one} is used. * * @param code The URI given to this class. * @return A factory for the specified URI (never {@code null}). * @throws FactoryException if no coordinate reference system factory is available. */ @Override protected CRSAuthorityFactory getCRSAuthorityFactory(final String code) throws FactoryException { if (code != null) { final URI_Parser parser = getParser(code); parser.logWarningIfTypeMismatch(this, CRSAuthorityFactory.class); final AuthorityFactory factory = getVersionedFactory(parser); if (factory instanceof CRSAuthorityFactory) { return (CRSAuthorityFactory) factory; } } return super.getCRSAuthorityFactory(code); }
/** Test that an versioned HTTP URI can be parsed. */ @Test public void testParseVersioned() throws NoSuchAuthorityCodeException { URI_Parser parser = HTTP_URI_Parser.buildParser("http://www.opengis.net/def/crs/EPSG/6.11.2/4326"); assertEquals("crs", parser.type.name); assertEquals("EPSG", parser.authority); assertEquals("6.11.2", parser.version.toString()); assertEquals("4326", parser.code); assertEquals("EPSG:4326", parser.getAuthorityCode()); }
/** * Returns the datum factory to use for the specified URI. If the URI contains a version string, * then this method will try to fetch a factory for that particular version. The {@link * #createVersionedFactory} method may be invoked for that purpose. If no factory is provided * for that specific version, then the {@linkplain * AuthorityFactoryAdapter#getDatumAuthorityFactory default one} is used. * * @param code The URI given to this class. * @return A factory for the specified URI (never {@code null}). * @throws FactoryException if no datum factory is available. */ @Override protected DatumAuthorityFactory getDatumAuthorityFactory(final String code) throws FactoryException { if (code != null) { final URI_Parser parser = getParser(code); parser.logWarningIfTypeMismatch(this, DatumAuthorityFactory.class); final AuthorityFactory factory = getVersionedFactory(parser); if (factory instanceof DatumAuthorityFactory) { return (DatumAuthorityFactory) factory; } } return super.getDatumAuthorityFactory(code); }
/** * Returns the coordinate operation factory to use for the specified URI. If the URI contains a * version string, then this method will try to fetch a factory for that particular version. The * {@link #createVersionedFactory} method may be invoked for that purpose. If no factory is * provided for that specific version, then the {@linkplain * AuthorityFactoryAdapter#getCoordinateOperationAuthorityFactory default one} is used. * * @param code The URI given to this class. * @return A factory for the specified URI (never {@code null}). * @throws FactoryException if no coordinate operation factory is available. */ @Override protected CoordinateOperationAuthorityFactory getCoordinateOperationAuthorityFactory( final String code) throws FactoryException { if (code != null) { final URI_Parser parser = getParser(code); parser.logWarningIfTypeMismatch(this, CoordinateOperationAuthorityFactory.class); final AuthorityFactory factory = getVersionedFactory(parser); if (factory instanceof CoordinateOperationAuthorityFactory) { return (CoordinateOperationAuthorityFactory) factory; } } return super.getCoordinateOperationAuthorityFactory(code); }