Class EPSGFactory

    • Method Detail

      • getLocale

        public Locale getLocale()
        Returns the locale used by this factory for producing error messages. This locale does not change the way data are read from the EPSG database.
        Specified by:
        get­Locale in interface Localized
        Returns:
        the locale for error messages.
      • install

        public void install​(Connection connection)
                     throws UnavailableFactoryException
        Creates the EPSG schema in the database and populates the tables with geodetic definitions. This method is invoked automatically when new­Data­Access() detects that the EPSG dataset is not installed. Users can also invoke this method explicitly if they wish to force the dataset installation.

        This method uses the following properties from the map specified at construction time:

        • catalog:
          a String giving the name of the database catalog where to create the EPSG schema. If non-null, that catalog shall exist prior this method call (this method does not create any catalog). If no catalog is specified or if the catalog is an empty string, then the EPSG schema will be created without catalog. If the database does not support catalogs in table definitions or in data manipulation, then this property is ignored.
        • schema:
          a String giving the name of the database schema where to create the EPSG tables. That schema shall not exist prior this method call; the schema will be created by this install(…) method. If the schema is an empty string, then the tables will be created without schema. If no schema is specified, then the default schema is "EPSG". If the database does not support schemas in table definitions or in data manipulation, then this property is ignored.
        • script­Provider:
          an Installation­Script­Provider giving the SQL scripts to execute for creating the EPSG database. If no provider is specified, then this method will search on the classpath (with Service­Loader) for user-provided implementations of Installation­Script­Provider. If no user-specified provider is found, then this method will search for "EPSG_*Tables​.sql", "EPSG_*Data​.sql" and "EPSG_*FKeys​.sql" files in the $SIS_DATA/Databases/External­Sources directory where * stands for any characters provided that there is no ambiguity.

        Legal constraint: the EPSG dataset can not be distributed with Apache SIS at this time for licensing reasons. Users need to either install the dataset manually (for example with the help of this method), or add on the classpath to a separated bundle like org​.apache​.sis:non-free:sis-epsg​.jar. See How to use EPSG geodetic dataset for more information.

        Parameters:
        connection - connection to the database where to create the EPSG schema.
        Throws:
        Unavailable­Factory­Exception - if installation failed. The exception will have a File­Not­Found­Exception cause if a SQL script has not been found (typically because a required resource is not on the classpath), an IOException if an I/O error occurred while reading a SQL script, or a SQLException if an error occurred while writing to the database.
        See Also:
        Installation­Script­Provider
      • newDataAccess

        protected EPSGDataAccess newDataAccess()
                                        throws FactoryException
        Creates the factory which will perform the actual geodetic object creation work. This method is invoked automatically when a new worker is required, either because the previous one has been disposed after its timeout or because a new one is required for concurrency.

        The default implementation performs the following steps:

        1. Gets a new connection from the data­Source.
        2. If this method is invoked for the first time, verifies if the EPSG tables exists. If the tables are not found, invokes install(Connection).
        3. Delegates to new­Data­Access(Connection, SQLTranslator), which provides an easier overriding point for subclasses wanting to return a custom EPSGData­Access instance.
        Specified by:
        new­Data­Access in class Concurrent­Authority­Factory<EPSGData­Access>
        Returns:
        Data Access Object (DAO) to use in create­Foo(String) methods.
        Throws:
        Factory­Exception - if the constructor failed to connect to the EPSG database. This exception usually has a SQLException as its cause.
      • newDataAccess

        protected EPSGDataAccess newDataAccess​(Connection connection,
                                               SQLTranslator translator)
                                        throws SQLException
        Creates the factory which will perform the actual geodetic object creation from a given connection. This method is a convenience hook easier to override than new­Data­Access() for subclasses wanting to return instances of their own EPSGData­Access subclass. The default implementation is simply:
        return new EPSGDataAccess(this, connection, translator);
        Subclasses can override this method with a similar code but with new EPSGData­Access(…) replaced by new My­Data­Access­Subclass(…).
        Parameters:
        connection - a connection to the EPSG database.
        translator - the translator from the SQL statements using MS-Access dialect to SQL statements using the dialect of the actual database.
        Returns:
        Data Access Object (DAO) to use in create­Foo(String) methods.
        Throws:
        SQLException - if a problem with the database has been detected.
        See Also:
        EPSGData­Access(EPSGFactory, Connection, SQLTranslator)