/** * Constructs an instance using the specified hints. This constructor recognizes the {@link * Hints#CRS_FACTORY CRS}, {@link Hints#CS_FACTORY CS}, {@link Hints#DATUM_FACTORY DATUM} and * {@link Hints#MATH_TRANSFORM_FACTORY MATH_TRANSFORM} {@code FACTORY} hints. * * @param hints The hints, or {@code null} if none. * @param priority The priority for this factory, as a number between {@link #MINIMUM_PRIORITY * MINIMUM_PRIORITY} and {@link #MAXIMUM_PRIORITY MAXIMUM_PRIORITY} inclusive. */ protected DirectAuthorityFactory(final Hints hints, final int priority) { super(priority); factories = ReferencingFactoryContainer.instance(hints); // Do not copies the user-provided hints to this.hints, because // this is up to sub-classes to decide which hints are relevant. }
/** * Constructs an instance making use of the default cache. * * @param factory The factory to cache. Can not be {@code null}. */ protected AbstractCachedAuthorityFactory(int priority) { this(priority, ObjectCaches.create("weak", 50), ReferencingFactoryContainer.instance(null)); }
/** * Constructs an instance making use of the default cache. * * @param factory The factory to cache. Can not be {@code null}. */ protected AbstractAuthorityMediator(int priority) { this(priority, ObjectCaches.create("weak", 50), ReferencingFactoryContainer.instance(null)); }
/** * Constructs an instance making use of the default cache. * * @param factory The factory to cache. Can not be {@code null}. */ protected AbstractCachedAuthorityFactory(int priority, Hints hints) { this(priority, ObjectCaches.create(hints), ReferencingFactoryContainer.instance(hints)); }
/** * Constructs a coordinate operation factory using the specified hints and priority. This * constructor recognizes the {@link Hints#CRS_FACTORY CRS}, {@link Hints#CS_FACTORY CS}, {@link * Hints#DATUM_FACTORY DATUM} and {@link Hints#MATH_TRANSFORM_FACTORY MATH_TRANSFORM} {@code * FACTORY} hints. * * @param userHints The hints, or {@code null} if none. * @param priority The priority for this factory, as a number between {@link #MINIMUM_PRIORITY * MINIMUM_PRIORITY} and {@link #MAXIMUM_PRIORITY MAXIMUM_PRIORITY} inclusive. * @since 2.2 */ public AbstractCoordinateOperationFactory(final Hints userHints, final int priority) { super(priority); factories = ReferencingFactoryContainer.instance(userHints); mtFactory = factories.getMathTransformFactory(); }
/** * Suggests a low-level factory group. If {@code crs} is {@code true}, then this method will try * to fetch the factory group from the CRS authority factory. Otherwise it will try to fetch the * factory group from the CS authority factory. This is used by subclasses like {@link * TransformedAuthorityFactory} that need low-level access to factories. Do not change this * method into a public one; we would need a better API before to do such thing. */ final ReferencingFactoryContainer getFactoryContainer(final boolean crs) { final AuthorityFactory factory; if (crs) { factory = crsFactory; } else { factory = csFactory; } if (factory instanceof DirectAuthorityFactory) { return ((DirectAuthorityFactory) factory).factories; } // No predefined factory group. Create one. if (factories == null) { factories = ReferencingFactoryContainer.instance(hints()); } return factories; }
/** Constructs an authority factory using the specified hints and priority. */ public FactoryUsingWKT(final Hints userHints, final int priority) { super(userHints, priority); factories = ReferencingFactoryContainer.instance(userHints); Object hint = null; if (userHints != null) { hint = userHints.get(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY); } if (hint instanceof File) { directory = (File) hint; } else if (hint instanceof String) { directory = new File((String) hint); } else { directory = null; } hints.put(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY, directory); // Disposes the cached property file after at least 15 minutes of inactivity. setTimeout(15 * 60 * 1000L); }
/** * If the specified factory is an instance of {@code AbstractCoordinateOperationFactory}, fetch * the {@link FactoryGroup} from this instance instead of from the hints. This constructor is * strictly reserved for factory subclasses that are wrapper around an other factory, like * {@link BufferedCoordinateOperationFactory}. */ AbstractCoordinateOperationFactory( final CoordinateOperationFactory factory, final Hints hints, final int priority) { super(priority); if (factory instanceof AbstractCoordinateOperationFactory) { factories = ((AbstractCoordinateOperationFactory) factory).getFactoryContainer(); } else { factories = ReferencingFactoryContainer.instance(hints); } mtFactory = factories.getMathTransformFactory(); }
dynamicDataSource = false; factories = ReferencingFactoryContainer.instance(userHints); long timeout = 30 * 60 * 1000; String defaultTimeout =
/** Constructs an authority factory using the specified hints and priority. */ public CoordinateOperationFactoryUsingWKT(final Hints userHints, final int priority) { super(userHints, priority); factories = ReferencingFactoryContainer.instance(userHints); // Search for user CRS_AUTHORITY_EXTRA_DIRECTORY hint, or use system default value. Object directoryHint = null; if (userHints != null && userHints.get(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY) != null) { directoryHint = userHints.get(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY); } else if (Hints.getSystemDefault(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY) != null) { directoryHint = Hints.getSystemDefault(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY); } if (directoryHint != null) { directory = directoryHint.toString(); hints.put(Hints.CRS_AUTHORITY_EXTRA_DIRECTORY, directory); } else { directory = null; } }
/** * Reduces the specified CRS to a two-dimensional one. If the given CRS has more than two * dimensions, then a new one is created using only the axis at ({@link #axisDimensionX}, {@link * #axisDimensionY}) index. * * @param crs The coordinate reference system to reduce, or {@code null}. * @return A coordinate reference system with no more than 2 dimensions, or {@code null} if * {@code crs} was null. * @throws FactoryException if the given CRS can't be reduced to two dimensions. * @since 2.5 */ public CoordinateReferenceSystem reduce(final CoordinateReferenceSystem crs) throws FactoryException { // Reminder: is is garanteed that axisDimensionX < axisDimensionY if (crs == null || crs.getCoordinateSystem().getDimension() <= 2) { return crs; } if (FACTORIES == null) { FACTORIES = ReferencingFactoryContainer.instance(null); // No need to synchronize: this is not a big deal if // two ReferencingFactoryContainer instances are created. } final CoordinateReferenceSystem reducedCRS; reducedCRS = FACTORIES.separate(crs, new int[] {axisDimensionX, axisDimensionY}); assert reducedCRS.getCoordinateSystem().getDimension() == 2 : reducedCRS; return reducedCRS; }
/** * Constructs an instance making use of the default cache. * * @param factory The factory to cache. Can not be {@code null}. */ protected AbstractAuthorityMediator(int priority, Hints hints) { this(priority, ObjectCaches.create(hints), ReferencingFactoryContainer.instance(hints)); // configurable behaviour poolConfig.minIdle = Hints.AUTHORITY_MIN_IDLE.toValue(hints); poolConfig.maxIdle = Hints.AUTHORITY_MAX_IDLE.toValue(hints); poolConfig.maxActive = Hints.AUTHORITY_MAX_ACTIVE.toValue(hints); poolConfig.minEvictableIdleTimeMillis = Hints.AUTHORITY_MIN_EVICT_IDLETIME.toValue(hints); poolConfig.softMinEvictableIdleTimeMillis = Hints.AUTHORITY_SOFTMIN_EVICT_IDLETIME.toValue(hints); poolConfig.timeBetweenEvictionRunsMillis = Hints.AUTHORITY_TIME_BETWEEN_EVICTION_RUNS.toValue(hints); // static behaviour poolConfig.maxWait = -1; // block indefinitely until a worker is available poolConfig.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK; }
final ReferencingFactoryContainer fg = ReferencingFactoryContainer.instance(hints); ParameterValueGroup params; try {
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); } } }
/** * Reduces the specified CRS to a two-dimensional one. If the given CRS has more than two * dimensions, then a new one is created using only the axis at ({@link #axisDimensionX}, * {@link #axisDimensionY}) index. * * @param crs The coordinate reference system to reduce, or {@code null}. * @return A coordinate reference system with no more than 2 dimensions, * or {@code null} if {@code crs} was null. * @throws FactoryException if the given CRS can't be reduced to two dimensions. * * @since 2.5 */ public CoordinateReferenceSystem reduce(final CoordinateReferenceSystem crs) throws FactoryException { // Reminder: is is garanteed that axisDimensionX < axisDimensionY if (crs == null || crs.getCoordinateSystem().getDimension() <= 2) { return crs; } if (FACTORIES == null) { FACTORIES = ReferencingFactoryContainer.instance(null); // No need to synchronize: this is not a big deal if // two ReferencingFactoryContainer instances are created. } final CoordinateReferenceSystem reducedCRS; reducedCRS = FACTORIES.separate(crs, new int[] {axisDimensionX, axisDimensionY}); assert reducedCRS.getCoordinateSystem().getDimension() == 2 : reducedCRS; return reducedCRS; }
final ReferencingFactoryContainer fg = ReferencingFactoryContainer.instance(hints); ParameterValueGroup params; try {
/** * Creates a new instance of GeoTiffMetadata2CRSAdapter * * @param hints * a map of hints to locate the authority and object factories. * (can be null) */ public GeoTiffMetadata2CRSAdapter(Hints hints) { final Hints tempHints = hints != null ? new Hints(hints) : DEFAULT_HINTS; this.hints = (Hints) tempHints.clone(); allAuthoritiesFactory = hints != null ? new AllAuthoritiesFactory(this.hints): DEFAULT_ALLAUTHORITIES_FACTORY; // factory = new ThreadedEpsgFactory(hints); datumObjFactory = ReferencingFactoryFinder.getDatumFactory(this.hints); crsFactory = ReferencingFactoryFinder.getCRSFactory(this.hints); csFactory = ReferencingFactoryFinder.getCSFactory(this.hints); tempHints.put(Hints.DATUM_AUTHORITY_FACTORY, allAuthoritiesFactory); tempHints.put(Hints.CS_FACTORY, csFactory); tempHints.put(Hints.CRS_FACTORY, crsFactory); tempHints.put(Hints.MATH_TRANSFORM_FACTORY, mtFactory); factories = ReferencingFactoryContainer.instance(tempHints); }