private void disposeAuthorityFactories(Set<? extends AuthorityFactory> factories) throws FactoryException { for (AuthorityFactory af : factories) { if (af instanceof AbstractAuthorityFactory) { LOGGER.info("Disposing referencing factory " + af); ((AbstractAuthorityFactory) af).dispose(); } } } }
/** * Hook to cleanup various stuff of some used libraries (org.geotools), which depend on the * external client to call them for cleaning-up. */ private void cleanupWebapp() { LOG.info("Web application shutdown: cleaning various stuff"); WeakCollectionCleaner.DEFAULT.exit(); DeferredAuthorityFactory.exit(); }
double utmZoneCenterLongitude = ... // Center lon of zone, example: zone 10 = -123 int zoneNumber = ... // zone number, example: 10 double latitude, longitude = ... // lat, lon in degrees MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null); ReferencingFactoryContainer factories = new ReferencingFactoryContainer(null); GeographicCRS geoCRS = org.geotools.referencing.crs.DefaultGeographicCRS.WGS84; CartesianCS cartCS = org.geotools.referencing.cs.DefaultCartesianCS.GENERIC_2D; ParameterValueGroup parameters = mtFactory.getDefaultParameters("Transverse_Mercator"); parameters.parameter("central_meridian").setValue(utmZoneCenterLongitude); parameters.parameter("latitude_of_origin").setValue(0.0); parameters.parameter("scale_factor").setValue(0.9996); parameters.parameter("false_easting").setValue(500000.0); parameters.parameter("false_northing").setValue(0.0); Map properties = Collections.singletonMap("name", "WGS 84 / UTM Zone " + zoneNumber); ProjectedCRS projCRS = factories.createProjectedCRS(properties, geoCRS, null, parameters, cartCS); MathTransform transform = CRS.findMathTransform(geoCRS, projCRS); double[] dest = new double[2]; transform.transform(new double[] {longitude, latitude}, 0, dest, 0, 1); int easting = (int)Math.round(dest[0]); int northing = (int)Math.round(dest[1]);
/** Makes sure that {@link #fallback} is initialized. */ private void ensureFallback() throws FactoryException { if (fallback == null) { fallback = FallbackAuthorityFactory.this.fallback.getIdentifiedObjectFinder( getProxy().getType()); } fallback.setFullScanAllowed(isFullScanAllowed()); }
/** * Returns a finder which can be used for looking up unidentified objects. The default * implementation delegates lookup to the underlying backing store and caches the result. */ @Override public synchronized IdentifiedObjectFinder getIdentifiedObjectFinder( final Class<? extends IdentifiedObject> type) throws FactoryException { return new Finder(getBackingStore().getIdentifiedObjectFinder(type)); }
/** * Returns a finder which can be used for looking up unidentified objects. The default * implementation delegates lookup to the underlying backing store and caches the result. * * @throws FactoryException if the finder can not be created. * @since 2.4 */ @Override public synchronized IdentifiedObjectFinder getIdentifiedObjectFinder( final Class<? extends IdentifiedObject> type) throws FactoryException { return new Finder(getBackingStore().getIdentifiedObjectFinder(type)); }
@Override public void dispose() throws FactoryException { super.dispose(); disposeAbstractAuthorityFactory(datumFactory); disposeAbstractAuthorityFactory(csFactory); disposeAbstractAuthorityFactory(crsFactory); disposeAbstractAuthorityFactory(operationFactory); }
/** * Returns a {@linkplain Extent extent} (usually an area of validity) from a code. * * @throws FactoryException if the object creation failed. */ @Override public Extent createExtent(final String code) throws FactoryException { return getGeotoolsFactory("createExtent", code).createExtent(toBackingFactoryCode(code)); }
/** * Creates an operation method from a code. * * @throws FactoryException if the object creation failed. */ @Override public OperationMethod createOperationMethod(final String code) throws FactoryException { return getGeotoolsFactory("createOperationMethod", code) .createOperationMethod(toBackingFactoryCode(code)); }
/** * Creates a finder using the specified factory. This constructor is protected because instances * of this class should not be created directly. Use {@link * AbstractAuthorityFactory#getIdentifiedObjectFinder} instead. * * @param factory The factory to scan for the identified objects. * @param type The type of objects to lookup. */ protected IdentifiedObjectFinder( final AuthorityFactory factory, final Class /*<? extends IdentifiedObject>*/ type) { setProxy(AuthorityFactoryProxy.getInstance(factory, type)); }
/** * Creates a parameter descriptor from a code. * * @throws FactoryException if the object creation failed. */ @Override public ParameterDescriptor createParameterDescriptor(final String code) throws FactoryException { return getGeotoolsFactory("createParameterDescriptor", code) .createParameterDescriptor(toBackingFactoryCode(code)); }
/** Lookups for the specified object. */ @Override public IdentifiedObject find(final IdentifiedObject object) throws FactoryException { IdentifiedObject candidate = finder.find(object); if (candidate != null) { return candidate; } ensureFallback(); candidate = fallback.find(object); return candidate; }
/** Returns the identifier of the specified object, or {@code null} if none. */ @Override public String findIdentifier(final IdentifiedObject object) throws FactoryException { String candidate = finder.findIdentifier(object); if (candidate != null) { return candidate; } ensureFallback(); candidate = fallback.findIdentifier(object); return candidate; } }
/** Returns the user-supplied factories. */ final Collection<AuthorityFactory> getFactories() { return ((ManyAuthoritiesFactory) getProxy().getAuthorityFactory()).getFactories(); }
/** * Returns a description of the underlying backing store, or {@code null} if unknow. * * @throws FactoryException if a failure occured while fetching the engine description. */ @Override public String getBackingStoreDescription() throws FactoryException { final AbstractAuthorityFactory factory = getGeotoolsFactory(null, null); return (factory != null) ? factory.getBackingStoreDescription() : null; }
/** * Gets a description of the object corresponding to a code. * * @param code Value allocated by authority. * @return A description of the object, or {@code null} if the object corresponding to the * specified {@code code} has no description. * @throws NoSuchAuthorityCodeException if the specified {@code code} was not found. * @throws FactoryException if the query failed for some other reason. */ public InternationalString getDescriptionText(final String code) throws FactoryException { return getBackingStore().getDescriptionText(code); }
/** * Returns a description of the underlying backing store, or {@code null} if unknow. This is for * example the database software used for storing the data. * * @throws FactoryException if a failure occured while fetching the engine description. */ @Override public String getBackingStoreDescription() throws FactoryException { return getBackingStore().getBackingStoreDescription(); }
/** * Returns a description of the underlying backing store, or {@code null} if unknow. This is for * example the database software used for storing the data. * * @throws FactoryException if a failure occured while fetching the engine description. */ @Override public String getBackingStoreDescription() throws FactoryException { return getBackingStore().getBackingStoreDescription(); }