public class EPSGFactory extends ConcurrentAuthorityFactory<EPSGDataAccess> implements CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Localized
DataSource
specified at construction time. The geodetic objects are cached
for reuse and the idle connections are closed after a timeout.
If no data source has been specified to the constructor, then EPSGFactory
searches for a
default data source in JNDI, or in the directory given by the SIS_DATA
environment variable,
or in the directory given by the "derby.system.home"
property, in that order.
See the package documentation for more information.
SQLTranslator
for examples of tables to look for). If the tables are not found,
then the install(Connection)
method will be invoked for creating the EPSG schema.
The install(…)
method can perform its work only if the definition files are reachable
on the classpath, or if the directory containing the files have been specified.
EPSGFactory
creates an EPSGDataAccess
instance
for performing the actual creation work. Developers who need to customize the geodetic object creation can override
the newDataAccess(Connection, SQLTranslator)
method in order to return their own EPSGDataAccess
subclass.EPSGDataAccess
,
SQLTranslator
,
List of authority codesDefined in the sis-referencing
module
Modifier and Type | Field and Description |
---|---|
protected CoordinateOperationFactory |
copFactory
The factory to use for creating
CoordinateOperation instances
from the properties read in the database. |
protected CRSFactory |
crsFactory
The factory to use for creating
CoordinateReferenceSystem instances
from the properties read in the database. |
protected CSFactory |
csFactory
The factory to use for creating
CoordinateSystem instances
from the properties read in the database. |
protected DataSource |
dataSource
The factory to use for creating
Connection s to the EPSG database. |
protected DatumFactory |
datumFactory
The factory to use for creating
Datum instances
from the properties read in the database. |
protected MathTransformFactory |
mtFactory
The factory to use for creating
MathTransform instances. |
protected NameFactory |
nameFactory
The factory to use for creating
GenericName instances. |
Constructor and Description |
---|
EPSGFactory(Map<String,?> properties)
Creates a factory using the given configuration.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
canClose(EPSGDataAccess factory)
Returns
true if the given Data Access Object (DAO) can be closed. |
Set<String> |
getCodeSpaces()
Returns the namespace of EPSG codes.
|
Locale |
getLocale()
Returns the locale used by this factory for producing error messages.
|
void |
install(Connection connection)
Creates the EPSG schema in the database and populates the tables with geodetic definitions.
|
protected boolean |
isCacheable(String code,
Object object)
Returns whether the given object can be cached.
|
protected EPSGDataAccess |
newDataAccess()
Creates the factory which will perform the actual geodetic object creation work.
|
protected EPSGDataAccess |
newDataAccess(Connection connection,
SQLTranslator translator)
Creates the factory which will perform the actual geodetic object creation from a given connection.
|
close, createCartesianCS, createCompoundCRS, createCoordinateOperation, createCoordinateReferenceSystem, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createDatum, createDerivedCRS, createEllipsoid, createEllipsoidalCS, createEngineeringCRS, createEngineeringDatum, createExtent, createFromCoordinateReferenceSystemCodes, createGeocentricCRS, createGeodeticDatum, createGeographicCRS, createImageCRS, createImageDatum, createObject, createOperationMethod, createParameterDescriptor, createPolarCS, createPrimeMeridian, createProjectedCRS, createSphericalCS, createTemporalCRS, createTemporalDatum, createTimeCS, createUnit, createVerticalCRS, createVerticalCS, createVerticalDatum, getAuthority, getAuthorityCodes, getDescriptionText, getTimeout, newIdentifiedObjectFinder, normalizeCode, printCacheContent, setTimeout, toString
createParametricCRS, createParametricCS, createParametricDatum, trimNamespace
getVendor
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createCompoundCRS, createCoordinateReferenceSystem, createDerivedCRS, createEngineeringCRS, createGeocentricCRS, createGeographicCRS, createImageCRS, createProjectedCRS, createTemporalCRS, createVerticalCRS
createCartesianCS, createCoordinateSystem, createCoordinateSystemAxis, createCylindricalCS, createEllipsoidalCS, createPolarCS, createSphericalCS, createTimeCS, createUnit, createVerticalCS
createDatum, createEllipsoid, createEngineeringDatum, createGeodeticDatum, createImageDatum, createPrimeMeridian, createTemporalDatum, createVerticalDatum
createCoordinateOperation, createFromCoordinateReferenceSystemCodes, createOperationMethod
createObject, getAuthority, getAuthorityCodes, getDescriptionText
getVendor
protected final DataSource dataSource
Connection
s to the EPSG database.protected final NameFactory nameFactory
GenericName
instances.protected final DatumFactory datumFactory
Datum
instances
from the properties read in the database.protected final CSFactory csFactory
CoordinateSystem
instances
from the properties read in the database.protected final CRSFactory crsFactory
CoordinateReferenceSystem
instances
from the properties read in the database.protected final CoordinateOperationFactory copFactory
CoordinateOperation
instances
from the properties read in the database.protected final MathTransformFactory mtFactory
MathTransform
instances.
The math transforms are created as part of CoordinateOperation
creation process.public EPSGFactory(Map<String,?> properties) throws FactoryException
null
or omitted, in which case default values are used.
Those default values are implementation-specific and may change in any future SIS version.
Key | Value class | Description |
---|---|---|
dataSource |
DataSource |
The factory to use for creating Connection s to the EPSG database. |
nameFactory |
NameFactory |
The factory to use for creating GenericName instances. |
datumFactory |
DatumAuthorityFactory |
The factory to use for creating Datum instances. |
csFactory |
CSAuthorityFactory |
The factory to use for creating CoordinateSystem instances. |
crsFactory |
CRSAuthorityFactory |
The factory to use for creating CoordinateReferenceSystem instances. |
copFactory |
CoordinateOperationAuthorityFactory |
The factory to use for creating CoordinateOperation instances. |
mtFactory |
MathTransformFactory |
The factory to use for creating MathTransform instances. |
catalog |
String |
The database catalog that contains the EPSG schema (see install). |
schema |
String |
The database schema that contains the EPSG tables (see install). |
scriptProvider |
InstallationScriptProvider |
A provider of SQL scripts to use if EPSGFactory needs to create the database. |
locale |
Locale |
The locale for producing error messages on a best effort basis. |
Default values
dataSource
is specified, this constructor defaults to the search algorithm described
in the package documentation.catalog
or schema
is specified, SQLTranslator
will try to auto-detect
the schema that contains the EPSG tables.locale
is specified, this constructor defaults to the
display locale.properties
- the data source, authority factories and other configuration properties,
or null
for the default values.ClassCastException
- if a property value is not of the expected class.IllegalArgumentException
- if a property value is invalid.FactoryException
- if an error occurred while creating the EPSG factory.public Set<String> getCodeSpaces()
getCodeSpaces
in class GeodeticAuthorityFactory
"EPSG"
string in a singleton map.public Locale getLocale()
getLocale
in interface Localized
public void install(Connection connection) throws UnavailableFactoryException
newDataAccess()
detects that the EPSG dataset is not installed.
Users can also invoke this method explicitely if they wish to force the dataset installation.
This method uses the following properties from the map specified at construction time:
catalog
: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
: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.scriptProvider
:InstallationScriptProvider
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 ServiceLoader
)
for user-provided implementations of InstallationScriptProvider
.
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/ExternalSources
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 a non-Apache bundle like geotk-epsg.jar
.
See LEGAL-183 for more information.
connection
- connection to the database where to create the EPSG schema.UnavailableFactoryException
- if installation failed. The exception will have a
FileNotFoundException
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.InstallationScriptProvider
protected EPSGDataAccess newDataAccess() throws FactoryException
The default implementation performs the following steps:
dataSource
.install(Connection)
.newDataAccess(Connection, SQLTranslator)
, which provides an easier
overriding point for subclasses wanting to return a custom EPSGDataAccess
instance.newDataAccess
in class ConcurrentAuthorityFactory<EPSGDataAccess>
createFoo(String)
methods.FactoryException
- if the constructor failed to connect to the EPSG database.
This exception usually has a SQLException
as its cause.protected EPSGDataAccess newDataAccess(Connection connection, SQLTranslator translator) throws SQLException
newDataAccess()
for subclasses
wanting to return instances of their own EPSGDataAccess
subclass.
The default implementation is simply:
return new EPSGDataAccess(this, connection, translator);Subclasses can override this method with a similar code but with
new EPSGDataAccess(…)
replaced
by new MyDataAccessSubclass(…)
.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.createFoo(String)
methods.SQLException
- if a problem with the database has been detected.EPSGDataAccess.EPSGDataAccess(EPSGFactory, Connection, SQLTranslator)
protected boolean canClose(EPSGDataAccess factory)
true
if the given Data Access Object (DAO) can be closed. This method is invoked automatically
after the timeout if the given DAO has been idle during all that time. The default
implementation always returns false
if a set returned by EPSGDataAccess.getAuthorityCodes(Class)
is still in use.canClose
in class ConcurrentAuthorityFactory<EPSGDataAccess>
factory
- the Data Access Object which is about to be closed.true
if the given Data Access Object can be closed.ConcurrentAuthorityFactory.close()
protected boolean isCacheable(String code, Object object)
EPSGDataAccess
created a new object not previously in the cache.isCacheable
in class ConcurrentAuthorityFactory<EPSGDataAccess>
code
- the authority code specified by the caller for creating an object.object
- the object created for the given authority code.ConcurrentAuthorityFactory.printCacheContent(PrintWriter)
Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.