/** 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); } }
/** 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)); } } } }
final Citation authority = authorityFactory.getAuthority(); final Identifier sourceID = AbstractIdentifiedObject.getIdentifier(sourceCRS, authority); if (sourceID == null) { try { operations = authorityFactory.createFromCoordinateReferenceSystemCodes( sourceCode, targetCode); inverse = (operations == null || operations.isEmpty()); authorityFactory.createFromCoordinateReferenceSystemCodes( targetCode, sourceCode);
if (!(candidate instanceof CoordinateOperationFactoryUsingWKT) && candidate .getAuthority() .getTitle() .equals(this.getAuthority().getTitle())) {
@Override OperationMethod createFromAPI(AuthorityFactory factory, String code) throws FactoryException { return opFactory(factory).createOperationMethod(code); } };
/** * Finds the authority codes for the given coordinate reference system. * This method does not trust the code given by the user in its CRS - we verify it. * This method may return codes even if the axis order does not match; * it will be caller's responsibility to make necessary adjustments. */ private List<String> findCode(final CoordinateReferenceSystem crs) throws FactoryException { final List<String> codes = new ArrayList<>(); if (codeFinder != null) { for (final IdentifiedObject candidate : codeFinder.find(crs)) { final Identifier identifier = IdentifiedObjects.getIdentifier(candidate, registry.getAuthority()); if (identifier != null) { final String code = identifier.getCode(); if (Utilities.deepEquals(candidate, crs, ComparisonMode.APPROXIMATIVE)) { codes.add(0, code); // If axis order match, give precedence to that CRS. } else { codes.add(code); } } } } return codes; }
@Override OperationMethod createFromAPI(AuthorityFactory factory, String code) throws FactoryException { return opFactory(factory).createOperationMethod(code); } };
/** * Creates an operation from a single operation code. * * <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 code Coded value for operation. * @return The operation 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. */ public CoordinateOperation createCoordinateOperation(String code) throws NoSuchAuthorityCodeException, FactoryException { CoordinateOperation coordop = super.createCoordinateOperation(code); if (coordop == null) { CoordinateOperationAuthorityFactory fallback = getFallbackAuthorityFactory(); if (fallback != null) { coordop = fallback.createCoordinateOperation(code); } } return coordop; }
/** * 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; }
/** * Finds the authority codes for the given coordinate reference system. * This method does not trust the code given by the user in its CRS - we verify it. * This method may return codes even if the axis order does not match; * it will be caller's responsibility to make necessary adjustments. */ private List<String> findCode(final CoordinateReferenceSystem crs) throws FactoryException { final List<String> codes = new ArrayList<>(); if (codeFinder != null) { for (final IdentifiedObject candidate : codeFinder.find(crs)) { final Identifier identifier = IdentifiedObjects.getIdentifier(candidate, registry.getAuthority()); if (identifier != null) { final String code = identifier.getCode(); if (Utilities.deepEquals(candidate, crs, ComparisonMode.APPROXIMATIVE)) { codes.add(0, code); // If axis order match, give precedence to that CRS. } else { codes.add(code); } } } } return codes; }
code = entry.getKey(); geotkMethod = entry.getValue(); epsgMethod = factory.createOperationMethod(code); name = epsgMethod.getName().getCode(); message = "Name \"" + name + "\" for code " + code;
/** * Creates an operation from a single operation code. * * @throws FactoryException if the object creation failed. */ @Override public CoordinateOperation createCoordinateOperation(final String code) throws FactoryException { return replace( getCoordinateOperationAuthorityFactory(code) .createCoordinateOperation(toBackingFactoryCode(code))); }
return Collections.emptySet(); return factory.createFromCoordinateReferenceSystemCodes( toBackingFactoryCode(sourceCRS), toBackingFactoryCode(targetCRS));
codeFinder = ((GeodeticAuthorityFactory) registry).newIdentifiedObjectFinder(); } else try { codeFinder = IdentifiedObjects.newFinder(Citations.getIdentifier(registry.getAuthority(), false)); } catch (NoSuchAuthorityFactoryException e) { Logging.recoverableException(Logging.getLogger(Loggers.COORDINATE_OPERATION),
public CoordinateOperation createCoordinateOperation(String code) throws FactoryException { final String key = toKey(code); CoordinateOperation operation = (CoordinateOperation) cache.get(key); if (operation == null) { try { cache.writeLock(key); operation = (CoordinateOperation) cache.peek(key); if (operation == null) { operation = operationAuthority.createCoordinateOperation(code); cache.put(key, operation); } } finally { cache.writeUnLock(key); } } return operation; }
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; } //
codeFinder = ((GeodeticAuthorityFactory) registry).newIdentifiedObjectFinder(); } else try { codeFinder = IdentifiedObjects.newFinder(Citations.toCodeSpace(registry.getAuthority())); } catch (NoSuchAuthorityFactoryException e) { Logging.recoverableException(Logging.getLogger(Loggers.COORDINATE_OPERATION),
@Override CoordinateOperation createFromAPI(AuthorityFactory factory, String code) throws FactoryException { return opFactory(factory).createCoordinateOperation(code); } };
/** * 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); }
@Override CoordinateOperation createFromAPI(AuthorityFactory factory, String code) throws FactoryException { return opFactory(factory).createCoordinateOperation(code); } };