/** Prints the operations between every pairs of the specified authority code. */ private void operations(final PrintWriter out, final String[] args) throws FactoryException { if (!(factory instanceof CoordinateOperationAuthorityFactory)) { return; } final CoordinateOperationAuthorityFactory factory = (CoordinateOperationAuthorityFactory) this.factory; char[] separator = null; for (int i = 0; i < args.length; i++) { for (int j = i + 1; j < args.length; j++) { final Set<CoordinateOperation> op; op = factory.createFromCoordinateReferenceSystemCodes(args[i], args[j]); for (final CoordinateOperation operation : op) { if (separator == null) { separator = getSeparator(); } else { out.println(separator); } out.println(formatter.format(operation)); } } } }
/** * Creates operations from {@linkplain CoordinateReferenceSystem coordinate reference system} * codes. * * <p>This method searches in the {@linkplain #FILENAME properties file} for operations. * * <p>If not found there, it will create operations from a fallback factory (see {@link * #getFallbackAuthorityFactory}). * * @param sourceCRS Coded value of source coordinate reference system. * @param targetCRS Coded value of target coordinate reference system. * @return The operations from {@code sourceCRS} to {@code targetCRS}. * @throws NoSuchAuthorityCodeException if a specified code was not found. * @throws FactoryException if the object creation failed for some other reason. */ @Override public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes( String sourceCRS, String targetCRS) throws NoSuchAuthorityCodeException, FactoryException { Set<CoordinateOperation> coordops = super.createFromCoordinateReferenceSystemCodes(sourceCRS, targetCRS); if (coordops.isEmpty()) { // If not found, delegate to the fallback factory. CoordinateOperationAuthorityFactory fallback = getFallbackAuthorityFactory(); if (fallback != null) { coordops = fallback.createFromCoordinateReferenceSystemCodes(sourceCRS, targetCRS); } } return coordops; }
return Collections.emptySet(); return factory.createFromCoordinateReferenceSystemCodes( toBackingFactoryCode(sourceCRS), toBackingFactoryCode(targetCRS));
try { operations = authorityFactory.createFromCoordinateReferenceSystemCodes( sourceCode, targetCode); inverse = (operations == null || operations.isEmpty()); authorityFactory.createFromCoordinateReferenceSystemCodes( targetCode, sourceCode);
public synchronized Set /*<CoordinateOperation>*/ createFromCoordinateReferenceSystemCodes( final String sourceCode, final String targetCode) throws FactoryException { final Object key = ObjectCaches.toKey(getAuthority(), sourceCode, targetCode); Set operations = (Set) cache.get(key); if (operations == null) { try { cache.writeLock(key); operations = (Set) cache.peek(key); if (operations == null) { operations = operationAuthority.createFromCoordinateReferenceSystemCodes( sourceCode, targetCode); // can we not trust operationAuthority to return us an unmodifiableSet ? // operations = Collections.unmodifiableSet( operations ); cache.put(key, operations); } } finally { cache.writeUnLock(key); } } return operations; } //
Collection<CoordinateOperation> authoritatives; try { authoritatives = registry.createFromCoordinateReferenceSystemCodes(sourceID, targetID); final boolean inverse = Containers.isNullOrEmpty(authoritatives); if (inverse) { continue; // Ignore inverse operations if we already have direct ones. authoritatives = registry.createFromCoordinateReferenceSystemCodes(targetID, sourceID); if (Containers.isNullOrEmpty(authoritatives)) { continue;
/** * Creates operations from source and target coordinate reference system codes. * If the authority for the two given CRS is handled by the same factory, then * this method delegates to that factory. Otherwise this method returns an empty set. * * @throws FactoryException if the object creation failed. */ @Override public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes( final String sourceCRS, final String targetCRS) throws FactoryException { final Deferred deferred = new Deferred(); final CoordinateOperationAuthorityFactory factory = create(deferred, sourceCRS); final String source = deferred.code; if (create(deferred, targetCRS) == factory) { return factory.createFromCoordinateReferenceSystemCodes(source, deferred.code); } /* * No coordinate operation because of mismatched factories. This is not illegal (the result is an empty set) * but it is worth to notify the user because this case has some chances to be an user error. */ final LogRecord record = Resources.forLocale(null).getLogRecord(Level.WARNING, Resources.Keys.MismatchedOperationFactories_2, sourceCRS, targetCRS); record.setLoggerName(Loggers.CRS_FACTORY); Logging.log(MultiAuthoritiesFactory.class, "createFromCoordinateReferenceSystemCodes", record); return super.createFromCoordinateReferenceSystemCodes(sourceCRS, targetCRS); }
/** * Creates operations from source and target coordinate reference system codes. * If the authority for the two given CRS is handled by the same factory, then * this method delegates to that factory. Otherwise this method returns an empty set. * * @throws FactoryException if the object creation failed. */ @Override public Set<CoordinateOperation> createFromCoordinateReferenceSystemCodes( final String sourceCRS, final String targetCRS) throws FactoryException { final Deferred deferred = new Deferred(); final CoordinateOperationAuthorityFactory factory = create(deferred, sourceCRS); final String source = deferred.code; if (create(deferred, targetCRS) == factory) { return factory.createFromCoordinateReferenceSystemCodes(source, deferred.code); } /* * No coordinate operation because of mismatched factories. This is not illegal (the result is an empty set) * but it is worth to notify the user because this case has some chances to be an user error. */ final LogRecord record = Resources.forLocale(null).getLogRecord(Level.WARNING, Resources.Keys.MismatchedOperationFactories_2, sourceCRS, targetCRS); record.setLoggerName(Loggers.CRS_FACTORY); Logging.log(MultiAuthoritiesFactory.class, "createFromCoordinateReferenceSystemCodes", record); return super.createFromCoordinateReferenceSystemCodes(sourceCRS, targetCRS); }
try { try { operations = registry.createFromCoordinateReferenceSystemCodes(sourceID, targetID); inverse = Containers.isNullOrEmpty(operations); if (inverse) { operations = registry.createFromCoordinateReferenceSystemCodes(targetID, sourceID); if (Containers.isNullOrEmpty(operations)) { continue;