Class ReferencingFactoryContainer

java.lang.Object
org.apache.sis.internal.referencing.ReferencingFactoryContainer
Direct Known Subclasses:
CRSBuilder

public class ReferencingFactoryContainer extends Object
A container of factories frequently used together. Provides also some utility methods working with factories. This class may be temporary until we choose a dependency injection framework See SIS-102.

This class is not thread safe. Synchronization, if needed, is caller's responsibility.

Since:
1.0
Version:
1.0
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The key for specifying a CRSFactory instance to use for geodetic object constructions.
    private org.opengis.referencing.crs.CRSAuthorityFactory
    The factory for creating coordinate reference systems from authority codes.
    private org.opengis.referencing.crs.CRSFactory
    The coordinate reference system factory.
    static final String
    The key for specifying a CSFactory instance to use for geodetic object constructions.
    private org.opengis.referencing.cs.CSFactory
    The coordinate system factory.
    static final String
    The key for specifying a DatumFactory instance to use for geodetic object constructions.
    private org.opengis.referencing.datum.DatumFactory
    The datum factory.
    private Map<String,?>
    The default properties, or an empty map if none.
    static final String
    The key for specifying a MathTransformFactory instance to use for geodetic object constructions.
    private org.opengis.referencing.operation.MathTransformFactory
    The math transform factory.
    Factory for fetching operation methods and creating defining conversions.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance for the default factories.
    ReferencingFactoryContainer(Map<String,?> defaultProperties, org.opengis.referencing.crs.CRSFactory crsFactory, org.opengis.referencing.cs.CSFactory csFactory, org.opengis.referencing.datum.DatumFactory datumFactory, org.opengis.referencing.operation.CoordinateOperationFactory operationFactory, org.opengis.referencing.operation.MathTransformFactory mtFactory)
    Creates a new instance which will use the given factories.
  • Method Summary

    Modifier and Type
    Method
    Description
    final org.opengis.referencing.operation.CoordinateOperationAuthorityFactory
    Returns the factory for creating coordinate operations from authority codes.
    Returns the factory for fetching operation methods and creating defining conversions.
    final org.opengis.referencing.crs.CRSAuthorityFactory
    Returns the factory for creating coordinate reference systems from authority codes.
    final org.opengis.referencing.crs.CRSFactory
    Returns the factory for creating coordinate reference systems.
    final org.opengis.referencing.cs.CSAuthorityFactory
    Returns the factory for creating coordinate systems from authority codes.
    final org.opengis.referencing.cs.CSFactory
    Returns the factory for creating coordinate systems and their axes.
    final org.opengis.referencing.datum.DatumAuthorityFactory
    Returns the factory for creating datum from authority codes.
    final org.opengis.referencing.datum.DatumFactory
    Returns the factory for creating datum, prime meridians and ellipsoids.
    final <T extends org.opengis.util.Factory>
    T
    getFactory(Class<T> type)
    Returns one of the factories managed by this container.
    final org.opengis.referencing.operation.MathTransformFactory
    Returns the factory for creating parameterized transforms.
    final org.opengis.referencing.cs.CartesianCS
    Returns the a coordinate system for map projections with (easting, northing) axes in metres.
    final <T extends org.opengis.util.Factory>
    boolean
    setFactory(Class<T> type, T factory)
    Sets one of the factories managed by this container.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MT_FACTORY

      public static final String MT_FACTORY
      The key for specifying a MathTransformFactory instance to use for geodetic object constructions. This is usually not needed for CRS construction, except in the special case of a derived CRS created from a defining conversion.
      See Also:
    • CRS_FACTORY

      public static final String CRS_FACTORY
      The key for specifying a CRSFactory instance to use for geodetic object constructions.
      See Also:
    • CS_FACTORY

      public static final String CS_FACTORY
      The key for specifying a CSFactory instance to use for geodetic object constructions.
      See Also:
    • DATUM_FACTORY

      public static final String DATUM_FACTORY
      The key for specifying a DatumFactory instance to use for geodetic object constructions.
      See Also:
    • crsAuthorityFactory

      private org.opengis.referencing.crs.CRSAuthorityFactory crsAuthorityFactory
      The factory for creating coordinate reference systems from authority codes. If null, then a default factory will be created only when first needed.
    • datumFactory

      private org.opengis.referencing.datum.DatumFactory datumFactory
      The datum factory. If null, then a default factory will be created only when first needed.
    • csFactory

      private org.opengis.referencing.cs.CSFactory csFactory
      The coordinate system factory. If null, then a default factory will be created only when first needed.
    • crsFactory

      private org.opengis.referencing.crs.CRSFactory crsFactory
      The coordinate reference system factory. If null, then a default factory will be created only when first needed.
    • operationFactory

      private DefaultCoordinateOperationFactory operationFactory
      Factory for fetching operation methods and creating defining conversions. This is needed only for user-defined projected coordinate reference system.
    • mtFactory

      private org.opengis.referencing.operation.MathTransformFactory mtFactory
      The math transform factory. If null, then a default factory will be created only when first needed.
    • defaultProperties

      private Map<String,?> defaultProperties
      The default properties, or an empty map if none. This map shall not be modified since its reference may be shared without cloning. This field will be cleared when no longer needed.
  • Constructor Details

    • ReferencingFactoryContainer

      public ReferencingFactoryContainer()
      Creates a new instance for the default factories.
    • ReferencingFactoryContainer

      public ReferencingFactoryContainer(Map<String,?> defaultProperties, org.opengis.referencing.crs.CRSFactory crsFactory, org.opengis.referencing.cs.CSFactory csFactory, org.opengis.referencing.datum.DatumFactory datumFactory, org.opengis.referencing.operation.CoordinateOperationFactory operationFactory, org.opengis.referencing.operation.MathTransformFactory mtFactory)
      Creates a new instance which will use the given factories. Any factory given in argument may be null if lazy instantiation is desired.
      Parameters:
      defaultProperties - default properties to give to the objects to create (will not be cloned).
      crsFactory - the factory to use for creating coordinate reference systems.
      csFactory - the factory to use for creating coordinate systems.
      datumFactory - the factory to use for creating datum.
      operationFactory - the factory to use for creating (defining) conversions.
      mtFactory - the factory to use for creating transform objects.
  • Method Details

    • setFactory

      public final <T extends org.opengis.util.Factory> boolean setFactory(Class<T> type, T factory)
      Sets one of the factories managed by this container. The given type argument can be one of the following values:
      • CRSFactory.class
      • CSFactory.class
      • DatumFactory.class
      • CoordinateOperationFactory.class
      • MathTransformFactory.class
      Note that authority factories are not yet handled by this method for consistency with getFactory(Class).
      Type Parameters:
      T - the compile-time type of the type argument.
      Parameters:
      type - the factory type.
      factory - the factory to use for the given type, or null for the default.
      Returns:
      true if the factory changed as a result of this method call.
      Throws:
      IllegalArgumentException - if the type argument is not one of the valid values.
    • getFactory

      public final <T extends org.opengis.util.Factory> T getFactory(Class<T> type)
      Returns one of the factories managed by this container. The given type argument can be one of the following values:
      • CRSFactory.class
      • CSFactory.class
      • DatumFactory.class
      • CoordinateOperationFactory.class
      • MathTransformFactory.class
      Note that authority factories are not yet handled by this method, since we would have to expose the current restriction to EPSG geodetic dataset and to handle FactoryException.
      Type Parameters:
      T - the compile-time type of the type argument.
      Parameters:
      type - the factory type.
      Returns:
      the factory for the given type.
      Throws:
      IllegalArgumentException - if the type argument is not one of the valid values.
    • getCRSAuthorityFactory

      public final org.opengis.referencing.crs.CRSAuthorityFactory getCRSAuthorityFactory() throws org.opengis.util.FactoryException
      Returns the factory for creating coordinate reference systems from authority codes. Currently only EPSG codes are supported.
      Returns:
      the Coordinate Reference System authority factory (never null).
      Throws:
      org.opengis.util.FactoryException - if the authority factory cannot be obtained.
    • getCSAuthorityFactory

      public final org.opengis.referencing.cs.CSAuthorityFactory getCSAuthorityFactory() throws org.opengis.util.FactoryException
      Returns the factory for creating coordinate systems from authority codes. Currently only EPSG codes are supported.
      Returns:
      the Coordinate System authority factory (never null).
      Throws:
      org.opengis.util.FactoryException - if the authority factory cannot be obtained.
    • getDatumAuthorityFactory

      public final org.opengis.referencing.datum.DatumAuthorityFactory getDatumAuthorityFactory() throws org.opengis.util.FactoryException
      Returns the factory for creating datum from authority codes. Currently only EPSG codes are supported.
      Returns:
      the Datum authority factory (never null).
      Throws:
      org.opengis.util.FactoryException - if the authority factory cannot be obtained.
    • getCoordinateOperationAuthorityFactory

      public final org.opengis.referencing.operation.CoordinateOperationAuthorityFactory getCoordinateOperationAuthorityFactory() throws org.opengis.util.FactoryException
      Returns the factory for creating coordinate operations from authority codes. Currently only EPSG codes are supported.
      Returns:
      the Coordinate Operation authority factory (never null).
      Throws:
      org.opengis.util.FactoryException - if the authority factory cannot be obtained.
    • getCRSFactory

      public final org.opengis.referencing.crs.CRSFactory getCRSFactory()
      Returns the factory for creating coordinate reference systems.
      Returns:
      the Coordinate Reference System factory (never null).
    • getCSFactory

      public final org.opengis.referencing.cs.CSFactory getCSFactory()
      Returns the factory for creating coordinate systems and their axes.
      Returns:
      the Coordinate System factory (never null).
    • getDatumFactory

      public final org.opengis.referencing.datum.DatumFactory getDatumFactory()
      Returns the factory for creating datum, prime meridians and ellipsoids.
      Returns:
      the Datum factory (never null).
    • getCoordinateOperationFactory

      public final DefaultCoordinateOperationFactory getCoordinateOperationFactory()
      Returns the factory for fetching operation methods and creating defining conversions. This is needed only for user-defined projected coordinate reference system. The factory is fetched when first needed.
      Returns:
      the Coordinate Operation factory (never null).
    • getMathTransformFactory

      public final org.opengis.referencing.operation.MathTransformFactory getMathTransformFactory()
      Returns the factory for creating parameterized transforms.
      Returns:
      the Math Transform factory (never null).
    • getStandardProjectedCS

      public final org.opengis.referencing.cs.CartesianCS getStandardProjectedCS() throws org.opengis.util.FactoryException
      Returns the a coordinate system for map projections with (easting, northing) axes in metres. EPSG::4400 — Cartesian 2D CS. Axes: easting, northing (E,N). Orientations: east, north. UoM: m.
      Returns:
      a coordinate system with (easting, northing) axes in metres.
      Throws:
      org.opengis.util.FactoryException - if an error occurred while creating the coordinate system.