Class EPSGFactoryFallback

All Implemented Interfaces:
org.opengis.referencing.AuthorityFactory, org.opengis.referencing.crs.CRSAuthorityFactory, org.opengis.referencing.cs.CSAuthorityFactory, org.opengis.referencing.datum.DatumAuthorityFactory, org.opengis.util.Factory

final class EPSGFactoryFallback extends GeodeticAuthorityFactory implements org.opengis.referencing.crs.CRSAuthorityFactory, org.opengis.referencing.cs.CSAuthorityFactory, org.opengis.referencing.datum.DatumAuthorityFactory
The authority factory to use as a fallback when the real EPSG factory is not available. We use this factory in order to guarantee that the minimal set of CRS codes documented in the CRS.forCode(String) method javadoc is always available. This fallback uses data available in public sources, with all EPSG metadata omitted except the identifiers. The EPSG identifiers are provided as references where to find the complete definitions.
Since:
0.7
Version:
1.3
  • Field Details

    • FORCE_HARDCODED

      @Debug static final boolean FORCE_HARDCODED
      Whether to disallow CommonCRS to use EPSGFactory (in which case CommonCRS will fallback on hard-coded values). This field should always be false, except for debugging purposes.
      See Also:
    • INSTANCE

      static final EPSGFactoryFallback INSTANCE
      The singleton instance.
    • installationURL

      private String installationURL
      URL where users can get more information about the installation process. Fetched when first needed.
      See Also:
    • CRS

      private static final int CRS
      Kinds of object created by this factory, as bitmask. Note that objects created for CS and AXIS kinds are currently not cached.
      See Also:
    • DATUM

      private static final int DATUM
      Kinds of object created by this factory, as bitmask. Note that objects created for CS and AXIS kinds are currently not cached.
      See Also:
    • ELLIPSOID

      private static final int ELLIPSOID
      Kinds of object created by this factory, as bitmask. Note that objects created for CS and AXIS kinds are currently not cached.
      See Also:
    • PRIME_MERIDIAN

      private static final int PRIME_MERIDIAN
      Kinds of object created by this factory, as bitmask. Note that objects created for CS and AXIS kinds are currently not cached.
      See Also:
    • UNIT

      private static final int UNIT
      Kinds of object created by this factory, as bitmask. Note that objects created for CS and AXIS kinds are currently not cached.
      See Also:
    • AXIS

      private static final int AXIS
      Kinds of object created by this factory, as bitmask. Note that objects created for CS and AXIS kinds are currently not cached.
      See Also:
    • CS

      private static final int CS
      Kinds of object created by this factory, as bitmask. Note that objects created for CS and AXIS kinds are currently not cached.
      See Also:
  • Constructor Details

    • EPSGFactoryFallback

      private EPSGFactoryFallback()
      Constructor for the singleton instance.
  • Method Details

    • getAuthority

      public org.opengis.metadata.citation.Citation getAuthority()
      Returns an authority with "Subset of EPSG" title.
      Specified by:
      getAuthority in interface org.opengis.referencing.AuthorityFactory
      Specified by:
      getAuthority in class GeodeticAuthorityFactory
      Returns:
      the organization responsible for definition of the database, or null if unknown.
      See Also:
    • getAuthorityTitle

      private String getAuthorityTitle()
      Returns the title of the authority as a string in the default locale. This is used in exceptions.
    • getCodeSpaces

      public Set<String> getCodeSpaces()
      Returns the namespace of EPSG codes.
      Overrides:
      getCodeSpaces in class GeodeticAuthorityFactory
      Returns:
      the "EPSG" string in a singleton map.
    • getAuthorityCodes

      public Set<String> getAuthorityCodes(Class<? extends org.opengis.referencing.IdentifiedObject> type)
      Returns the list of EPSG codes available.
      Specified by:
      getAuthorityCodes in interface org.opengis.referencing.AuthorityFactory
    • add

      private static void add(Set<String> codes, short value)
      Adds the given value to the given set, provided that the value is different than zero. Zero is used as a sentinel value in CommonCRS meaning "no EPSG code".
    • createPrimeMeridian

      public org.opengis.referencing.datum.PrimeMeridian createPrimeMeridian(String code) throws org.opengis.referencing.NoSuchAuthorityCodeException
      Returns a prime meridian for the given EPSG code.
      Specified by:
      createPrimeMeridian in interface org.opengis.referencing.datum.DatumAuthorityFactory
      Overrides:
      createPrimeMeridian in class GeodeticAuthorityFactory
      Parameters:
      code - value allocated by authority.
      Returns:
      the prime meridian for the given code.
      Throws:
      org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
      See Also:
    • createEllipsoid

      public org.opengis.referencing.datum.Ellipsoid createEllipsoid(String code) throws org.opengis.referencing.NoSuchAuthorityCodeException
      Returns an ellipsoid for the given EPSG code.
      Specified by:
      createEllipsoid in interface org.opengis.referencing.datum.DatumAuthorityFactory
      Overrides:
      createEllipsoid in class GeodeticAuthorityFactory
      Parameters:
      code - value allocated by authority.
      Returns:
      the ellipsoid for the given code.
      Throws:
      org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
      See Also:
    • createDatum

      public org.opengis.referencing.datum.Datum createDatum(String code) throws org.opengis.referencing.NoSuchAuthorityCodeException
      Returns a datum for the given EPSG code.
      Specified by:
      createDatum in interface org.opengis.referencing.datum.DatumAuthorityFactory
      Overrides:
      createDatum in class GeodeticAuthorityFactory
      Parameters:
      code - value allocated by authority.
      Returns:
      the datum for the given code.
      Throws:
      org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
      See Also:
    • createCoordinateReferenceSystem

      public org.opengis.referencing.crs.CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws org.opengis.referencing.NoSuchAuthorityCodeException
      Returns a coordinate reference system for the given EPSG code. This method is invoked as a fallback when CRS.forCode(String) cannot create a CRS for a given code.
      Specified by:
      createCoordinateReferenceSystem in interface org.opengis.referencing.crs.CRSAuthorityFactory
      Overrides:
      createCoordinateReferenceSystem in class GeodeticAuthorityFactory
      Parameters:
      code - value allocated by authority.
      Returns:
      the coordinate reference system for the given code.
      Throws:
      org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
      See Also:
    • createCoordinateSystem

      public org.opengis.referencing.cs.CoordinateSystem createCoordinateSystem(String code) throws org.opengis.referencing.NoSuchAuthorityCodeException
      Returns a coordinate system for the given EPSG code. Contrarily to other kinds of objects, coordinate systems are not cached because we cannot use CommonCRS as a store for them (because all enumerated values use the same coordinate systems). The lack of caching should not be an issue since standalone CS objects (without CRS) are rarely be needed.
      Specified by:
      createCoordinateSystem in interface org.opengis.referencing.cs.CSAuthorityFactory
      Overrides:
      createCoordinateSystem in class GeodeticAuthorityFactory
      Parameters:
      code - value allocated by authority.
      Returns:
      the coordinate system for the given code.
      Throws:
      org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
      See Also:
    • createCoordinateSystemAxis

      public org.opengis.referencing.cs.CoordinateSystemAxis createCoordinateSystemAxis(String code) throws org.opengis.referencing.NoSuchAuthorityCodeException
      Returns a coordinate system axis for the given EPSG code. Axes are not cached for the same reasons than createCoordinateSystem(String).
      Specified by:
      createCoordinateSystemAxis in interface org.opengis.referencing.cs.CSAuthorityFactory
      Overrides:
      createCoordinateSystemAxis in class GeodeticAuthorityFactory
      Parameters:
      code - value allocated by authority.
      Returns:
      the axis for the given code.
      Throws:
      org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
      See Also:
    • createUnit

      public javax.measure.Unit<?> createUnit(String code) throws org.opengis.referencing.NoSuchAuthorityCodeException
      Returns a unit of measurement for the given code.
      Specified by:
      createUnit in interface org.opengis.referencing.cs.CSAuthorityFactory
      Overrides:
      createUnit in class GeodeticAuthorityFactory
      Parameters:
      code - value allocated by authority.
      Returns:
      the unit of measurement for the given code.
      Throws:
      org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
      See Also:
    • createObject

      public org.opengis.referencing.IdentifiedObject createObject(String code) throws org.opengis.referencing.NoSuchAuthorityCodeException
      Returns a coordinate reference system, datum or ellipsoid for the given EPSG code.
      Specified by:
      createObject in interface org.opengis.referencing.AuthorityFactory
      Specified by:
      createObject in class GeodeticAuthorityFactory
      Parameters:
      code - value allocated by authority.
      Returns:
      the object for the given code.
      Throws:
      org.opengis.referencing.NoSuchAuthorityCodeException - if the specified code was not found.
      See Also:
    • predefined

      private Object predefined(String code, int kind) throws org.opengis.referencing.NoSuchAuthorityCodeException
      Implementation of all createFoo(String) methods in this fallback class.
      Parameters:
      code - the EPSG code.
      kind - any combination of *_MASK bits.
      Returns:
      the requested object.
      Throws:
      org.opengis.referencing.NoSuchAuthorityCodeException - if no matching object has been found.
    • getInstallationURL

      private String getInstallationURL()
      Returns a URL where users can get more information about the installation process.
    • toClass

      private static Class<?> toClass(int kind)
      Returns the interface for the given *_MASK constant. This is used for formatting error message only.