Class BufferedCoordinateOperationFactory

All Implemented Interfaces:
Factory, ObjectFactory, CoordinateOperationFactory, BufferedFactory, Factory, RegistrableFactory

public class BufferedCoordinateOperationFactory extends AbstractCoordinateOperationFactory implements BufferedFactory
Caches the coordinate operations created by an other factory. Those coordinate operations may be expensive to create. During rendering and during data I/O, some implementations make use a lof of coordinate transformations, hence caching them might help.

In most cases, users should not need to create an instance of this class explicitly. An instance of BufferedCoordinateOperationFactory should be automatically registered and returned by ReferencingFactoryFinder in default Geotools configuration.

Since:
2.3
Author:
Simone Giannecchini, Martin Desruisseaux
  • Constructor Details

    • BufferedCoordinateOperationFactory

      public BufferedCoordinateOperationFactory()
      Creates a buffered factory wrapping the default one.
    • BufferedCoordinateOperationFactory

      public BufferedCoordinateOperationFactory(Hints userHints)
      Creates a buffered factory wrapping an other factory selected according the specified hints.
      Parameters:
      userHints - The hints to use for choosing a backing factory.
    • BufferedCoordinateOperationFactory

      public BufferedCoordinateOperationFactory(ManyCoordinateOperationFactory many, Hints hints)
      Creates a buffered factory wrapping the specified factory.
    • BufferedCoordinateOperationFactory

      public BufferedCoordinateOperationFactory(Hints userHints, int priority)
      Creates a buffered factory wrapping an other factory selected according the specified hints.
      Parameters:
      userHints - The hints to use for choosing a backing factory.
      priority - The priority for this factory, as a number between MINIMUM_PRIORITY and MAXIMUM_PRIORITY inclusive.
    • BufferedCoordinateOperationFactory

      public BufferedCoordinateOperationFactory(CoordinateOperationFactory factory, int priority)
      Wraps the specified factory.
      Parameters:
      factory - The factory to wrap.
      priority - The priority for this factory, as a number between MINIMUM_PRIORITY and MAXIMUM_PRIORITY inclusive.
    • BufferedCoordinateOperationFactory

      public BufferedCoordinateOperationFactory(CoordinateOperationFactory factory, Hints userHints, int priority)
      Work around for RFE #4093999 in Sun's bug database ("Relax constraint on placement of this()/super() call in constructors").
  • Method Details

    • getBackingFactory

      public final CoordinateOperationFactory getBackingFactory()
      Returns the backing factory. Coordinate operation creation will be delegated to this factory when not available in the cache.
    • createOperation

      Returns an operation for conversion or transformation between two coordinate reference systems. If an operation was already created and still in the cache, the cached operation is returned. Otherwise the operation creation is delegated to the coordinate operation factory specified at construction time and the result is cached.
      Specified by:
      createOperation in interface CoordinateOperationFactory
      Parameters:
      sourceCRS - Input coordinate reference system.
      targetCRS - Output coordinate reference system.
      Returns:
      A coordinate operation from sourceCRS to targetCRS.
      Throws:
      OperationNotFoundException - if no operation path was found from sourceCRS to targetCRS.
      FactoryException - if the operation creation failed for some other reason.
    • findOperations

      public Set<CoordinateOperation> findOperations(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS) throws FactoryException
      Returns all available operations for conversion or transformation between two coordinate reference systems. The operation creation is delegated to the coordinate operation factory specified at construction time and the result is not cached.
      Specified by:
      findOperations in interface CoordinateOperationFactory
      Parameters:
      sourceCRS - Input coordinate reference system.
      targetCRS - Output coordinate reference system.
      Returns:
      A Set of coordinate operations from sourceCRS to targetCRS.
      Throws:
      FactoryException - if there was a failure retrieving or creating the operations.
    • createOperation

      Returns an operation for conversion or transformation between two coordinate reference systems using the specified method. The current implementation delegates to the coordinate operation factory specified at construction time with no caching.
      Specified by:
      createOperation in interface CoordinateOperationFactory
      Parameters:
      sourceCRS - Input coordinate reference system.
      targetCRS - Output coordinate reference system.
      method - The algorithmic method for conversion or transformation.
      Returns:
      A coordinate operation from sourceCRS to targetCRS.
      Throws:
      OperationNotFoundException - if no operation path was found from sourceCRS to targetCRS.
      FactoryException - if the operation creation failed for some other reason.
    • findFromDatabase

      public Set<CoordinateOperation> findFromDatabase(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, int limit)
      Description copied from interface: CoordinateOperationFactory
      Returns a list of available coordinate operations explicitly defined in some database (typically EPSG), for the provided CRS pair. Otherwise (if there is no database, or if the database doesn't contains any explicit operation from sourceCRS to targetCRS, or if this method failed to create the operations from the database), returns an empty Set.

      The default implementation always returns an empty Set. Subclasses should override this method if they can fetch a more accurate operation from some database.

      This method is normally invoked by findOperations(sourceCRS, targetCRS) before to try to figure out a transformation path by itself.

      The default implementation returns an empty set, subclasses working with an actual transformation database can override

      Specified by:
      findFromDatabase in interface CoordinateOperationFactory
      Parameters:
      sourceCRS - Input coordinate reference system.
      targetCRS - Output coordinate reference system.
      limit - The maximum number of operations to be returned. Use -1 to return all the available operations. Use 1 to return just one operation. Currently, the behavior for other values of limit is undefined.
      Returns:
      A set of coordinate operations from sourceCRS to targetCRS if and only if one is explicitly defined in some underlying database, or an empty Set otherwise.