/** * Creates the backing store authority factory. * * @return The backing store to uses in {@code createXXX(...)} methods. * @throws FactoryNotFoundException if the no {@code epsg.properties} file has been found. * @throws FactoryException if the constructor failed to find or read the file. This exception * usually has an {@link IOException} as its cause. */ protected AbstractAuthorityFactory createBackingStore() throws FactoryException { try { URL url = getDefinitionsURL(); if (url == null) { throw new FactoryNotFoundException( Errors.format(ErrorKeys.FILE_DOES_NOT_EXIST_$1, FILENAME)); } final Iterator<? extends Identifier> ids = getAuthority().getIdentifiers().iterator(); final String authority = ids.hasNext() ? ids.next().getCode() : "EPSG"; final LogRecord record = Loggings.format( Level.CONFIG, LoggingKeys.USING_FILE_AS_FACTORY_$2, url.getPath(), authority); record.setLoggerName(LOGGER.getName()); LOGGER.log(record); return new PropertyAuthorityFactory(factories, getAuthorities(), url); } catch (IOException exception) { throw new FactoryException(Errors.format(ErrorKeys.CANT_READ_$1, FILENAME), exception); } }
void registerAdditionalCRS() throws KlabException { URL epsg = null; File epp = new File(KLAB.CONFIG.getDataPath() + File.separator + "epsg.properties"); if (epp.exists()) { try { epsg = epp.toURI().toURL(); } catch (MalformedURLException e) { throw new KlabIOException(e); } } if (epsg != null) { Hints hints = new Hints(Hints.CRS_AUTHORITY_FACTORY, PropertyAuthorityFactory.class); ReferencingFactoryContainer referencingFactoryContainer = ReferencingFactoryContainer .instance(hints); PropertyAuthorityFactory factory; try { factory = new PropertyAuthorityFactory(referencingFactoryContainer, Citations .fromName("EPSG"), epsg); ReferencingFactoryFinder.addAuthorityFactory(factory); } catch (IOException e) { throw new KlabIOException(e); } } }