org.geotools.cs
Class CoordinateSystemEPSGFactory

java.lang.Object
  extended byorg.geotools.cs.CoordinateSystemAuthorityFactory
      extended byorg.geotools.cs.CoordinateSystemEPSGFactory
Direct Known Subclasses:
CoordinateSystemModifiedEPSGFactory

Deprecated. Replaced by FactoryUsingSQL.

public class CoordinateSystemEPSGFactory
extends CoordinateSystemAuthorityFactory

Default implementation for a coordinate system factory backed by the EPSG database. The EPSG database is freely available at http://www.epsg.org. Current version of this class requires EPSG database version 6.

EPSG database installation

The EPSG database is available in MS Access format only (not our fault! We take it as EPSG publish it). The EPSG_v6.mdb file can be stored anywhere on your system under any name, at your convenience. The database must be declared as an ODBC data source. Steps to follow:

Note about multi-radix units

The EPSG database express many angles in some multi-radix units. For example, a lot of EPSG's angles are coded in the following format: sign - degrees - decimal point - minutes (two digits) - integer seconds (two digits) - fraction of seconds (any precision). According this convention, the angle 40?30'N would be coded as 40.30 (sexagesimal degree) instead of 40.5 (fractional degree). Unfortunatly, sexagesimal degrees have the following inconvenients: Consequently, the default implementation of CoordinateSystemEPSGFactory will not use sexagesimal degrees for coordinate systems. All axis will use fractional degrees instead, which are way more convenient for computation purpose (radians would be as good). If sexagesimal degrees are really wanted, subclasses should overrides the replaceAxisUnit(org.geotools.units.Unit) method.

Version:
$Id: CoordinateSystemEPSGFactory.java 13813 2005-05-26 01:01:13Z desruisseaux $
Author:
Yann C?zard, Martin Desruisseaux, Rueben Schulz

Field Summary
protected  java.sql.Connection connection
          Deprecated. The connection to the EPSG database.
 
Fields inherited from class org.geotools.cs.CoordinateSystemAuthorityFactory
factory
 
Constructor Summary
CoordinateSystemEPSGFactory(CoordinateSystemFactory factory, java.sql.Connection connection)
          Deprecated. Construct an authority factory using the specified connection.
CoordinateSystemEPSGFactory(CoordinateSystemFactory factory, java.lang.String url, java.lang.String driver)
          Deprecated. Construct an authority factory using the specified URL to an EPSG database.
 
Method Summary
protected  java.lang.String adaptSQL(java.lang.String statement)
          Deprecated. Invoked when a new PreparedStatement is about to be created from a SQL string.
 CompoundCoordinateSystem createCompoundCoordinateSystem(java.lang.String code)
          Deprecated. Create a compound coordinate system from the EPSG code.
 CoordinateSystem createCoordinateSystem(java.lang.String code)
          Deprecated. Returns a coordinate system from a code.
 Datum createDatum(java.lang.String code)
          Deprecated. Returns a datum from a code.
 Ellipsoid createEllipsoid(java.lang.String code)
          Deprecated. Returns an Ellipsoid object from a code.
 GeographicCoordinateSystem createGeographicCoordinateSystem(java.lang.String code)
          Deprecated. Returns a geographic coordinate system from an EPSG code.
 java.lang.Object createObject(java.lang.String code)
          Deprecated. Returns an arbitrary object from a code.
 PrimeMeridian createPrimeMeridian(java.lang.String code)
          Deprecated. Returns a prime meridian, relative to Greenwich.
 ProjectedCoordinateSystem createProjectedCoordinateSystem(java.lang.String code)
          Deprecated. Returns a projected coordinate system from an EPSG code.
 Unit createUnit(java.lang.String code)
          Deprecated. Returns a Unit object from a code.
 VerticalCoordinateSystem createVerticalCoordinateSystem(java.lang.String code)
          Deprecated. Returns a vertical coordinate system from an EPSG code.
 void dispose()
          Deprecated. Dispose any resources hold by this object.
 java.lang.String getAuthority()
          Deprecated. Returns the authority name, which is "EPSG".
static CoordinateSystemAuthorityFactory getDefault()
          Deprecated. Returns a default coordinate system factory backed by the EPSG database.
static void main(java.lang.String[] args)
          Deprecated. Construct an object from the EPSG database and print its WKT (Well Know Text) to the standard output.
protected  Unit replaceAxisUnit(Unit unit)
          Deprecated. Replace the axis's unit for a coordinate system.
 
Methods inherited from class org.geotools.cs.CoordinateSystemAuthorityFactory
createHorizontalCoordinateSystem, createHorizontalDatum, createVerticalDatum
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

protected final java.sql.Connection connection
Deprecated. 
The connection to the EPSG database.

Constructor Detail

CoordinateSystemEPSGFactory

public CoordinateSystemEPSGFactory(CoordinateSystemFactory factory,
                                   java.sql.Connection connection)
Deprecated. 
Construct an authority factory using the specified connection.

Parameters:
factory - The underlying factory used for objects creation.
connection - The connection to the underlying EPSG database.

CoordinateSystemEPSGFactory

public CoordinateSystemEPSGFactory(CoordinateSystemFactory factory,
                                   java.lang.String url,
                                   java.lang.String driver)
                            throws java.sql.SQLException
Deprecated. 
Construct an authority factory using the specified URL to an EPSG database.

Parameters:
factory - The underlying factory used for objects creation.
url - The url to the EPSG database. For example, a connection using the ODBC-JDBC bridge may have an URL likes "jdbc:odbc:EPSG".
driver - An optional driver to load, or null if none. This is a convenience argument for the following pseudo-code:
Class.forName(driver).newInstance();
A message is logged to "org.geotools.cts" wether the loading sucseeds of fails. For JDBC-ODBC bridge, a typical value for this argument is "sun.jdbc.odbc.JdbcOdbcDriver". This argument needs to be non-null only once for a specific driver.
Throws:
java.sql.SQLException - if the constructor failed to connect to the EPSG database.
Method Detail

getDefault

public static CoordinateSystemAuthorityFactory getDefault()
                                                   throws java.sql.SQLException
Deprecated. 
Returns a default coordinate system factory backed by the EPSG database. Invoking dispose() on this special factory will not close the database connection, since it may be shared by many users. However, it is safe to invoke dispose() anyway in order to release some resources used by this instance.

By default, this method loads the "sun.jdbc.odbc.JdbcOdbcDriver" and ask for a connection to the "jdbc:odbc:EPSG" database. This default behavior can be changed by invoking the main(java.lang.String[]) method from the command line. For example:
 java org.geotools.cs.CoordinateSystemEPSGFactory -driver=[my driver] -connection=[my url]
 

Returns:
The default factory.
Throws:
java.sql.SQLException - if the connection to the database can't be etablished.

adaptSQL

protected java.lang.String adaptSQL(java.lang.String statement)
Deprecated. 
Invoked when a new PreparedStatement is about to be created from a SQL string. Since the EPSG database is available only in MS-Access format, SQL statements are formatted using some syntax specific to this particular database software (for example "SELECT * FROM [Coordinate Reference System]"). If a port of EPSG database is to be used with an other software, then this method should be overriden in order to adapt the SQL syntax. For example a subclass connecting to a PostgreSQL database could replace all spaces (" ") between watching braces ("[" and "]") by underscore ("_").

Parameters:
statement - The statement in MS-Access syntax.
Returns:
The SQL statement to use. The default implementation returns the string unchanged.

getAuthority

public java.lang.String getAuthority()
Deprecated. 
Returns the authority name, which is "EPSG".

Specified by:
getAuthority in class CoordinateSystemAuthorityFactory

createObject

public java.lang.Object createObject(java.lang.String code)
                              throws org.opengis.referencing.FactoryException
Deprecated. 
Returns an arbitrary object from a code. Default implementation will invokes one of createCoordinateSystem(java.lang.String), createDatum(java.lang.String), createEllipsoid(java.lang.String), or createUnit(java.lang.String) methods according the object type.

Overrides:
createObject in class CoordinateSystemAuthorityFactory
Parameters:
code - The EPSG value.
Returns:
The ellipsoid object.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CoordinateSystemAuthorityFactory.createCoordinateSystem(java.lang.String), CoordinateSystemAuthorityFactory.createDatum(java.lang.String), CoordinateSystemAuthorityFactory.createEllipsoid(java.lang.String), CoordinateSystemAuthorityFactory.createUnit(java.lang.String)

createEllipsoid

public Ellipsoid createEllipsoid(java.lang.String code)
                          throws org.opengis.referencing.FactoryException
Deprecated. 
Returns an Ellipsoid object from a code.

Specified by:
createEllipsoid in class CoordinateSystemAuthorityFactory
Parameters:
code - The EPSG value.
Returns:
The ellipsoid object.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CS_CoordinateSystemAuthorityFactory.createEllipsoid(java.lang.String)

createUnit

public Unit createUnit(java.lang.String code)
                throws org.opengis.referencing.FactoryException
Deprecated. 
Returns a Unit object from a code.

Specified by:
createUnit in class CoordinateSystemAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The unit object.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CS_CoordinateSystemAuthorityFactory.createLinearUnit(java.lang.String), CS_CoordinateSystemAuthorityFactory.createAngularUnit(java.lang.String)

createPrimeMeridian

public PrimeMeridian createPrimeMeridian(java.lang.String code)
                                  throws org.opengis.referencing.FactoryException
Deprecated. 
Returns a prime meridian, relative to Greenwich.

Specified by:
createPrimeMeridian in class CoordinateSystemAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The prime meridian object.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CS_CoordinateSystemAuthorityFactory.createPrimeMeridian(java.lang.String)

createDatum

public Datum createDatum(java.lang.String code)
                  throws org.opengis.referencing.FactoryException
Deprecated. 
Returns a datum from a code. This method may returns a vertical, horizontal or local datum.

Specified by:
createDatum in class CoordinateSystemAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The datum object.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CoordinateSystemAuthorityFactory.createHorizontalDatum(java.lang.String), CoordinateSystemAuthorityFactory.createVerticalDatum(java.lang.String)
Task:
REVISIT: Current implementation maps all "vertical" datum to DatumType.ELLIPSOIDAL and all "horizontal" datum to DatumType.GEOCENTRIC. At the time of writting, it was not clear how to maps the exact datum type from the EPSG database., REVISIT: The creation of horizontal datum use only the first WGS84ConversionInfo object, because current version of CoordinateSystemFactory do not allows more than one conversion info. We should fix that., TODO: Datum "engineering" is currently not supported.

createCoordinateSystem

public CoordinateSystem createCoordinateSystem(java.lang.String code)
                                        throws org.opengis.referencing.FactoryException
Deprecated. 
Returns a coordinate system from a code.

Specified by:
createCoordinateSystem in class CoordinateSystemAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The coordinate system object.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CoordinateSystemAuthorityFactory.createHorizontalCoordinateSystem(java.lang.String), CoordinateSystemAuthorityFactory.createGeographicCoordinateSystem(java.lang.String), CoordinateSystemAuthorityFactory.createProjectedCoordinateSystem(java.lang.String), CoordinateSystemAuthorityFactory.createVerticalCoordinateSystem(java.lang.String), CoordinateSystemAuthorityFactory.createCompoundCoordinateSystem(java.lang.String)

createGeographicCoordinateSystem

public GeographicCoordinateSystem createGeographicCoordinateSystem(java.lang.String code)
                                                            throws org.opengis.referencing.FactoryException
Deprecated. 
Returns a geographic coordinate system from an EPSG code.

Overrides:
createGeographicCoordinateSystem in class CoordinateSystemAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The geographic coordinate system object.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CS_CoordinateSystemAuthorityFactory.createGeographicCoordinateSystem(java.lang.String)

createProjectedCoordinateSystem

public ProjectedCoordinateSystem createProjectedCoordinateSystem(java.lang.String code)
                                                          throws org.opengis.referencing.FactoryException
Deprecated. 
Returns a projected coordinate system from an EPSG code.

Overrides:
createProjectedCoordinateSystem in class CoordinateSystemAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The projected coordinate system object.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CS_CoordinateSystemAuthorityFactory.createProjectedCoordinateSystem(java.lang.String)

createVerticalCoordinateSystem

public VerticalCoordinateSystem createVerticalCoordinateSystem(java.lang.String code)
                                                        throws org.opengis.referencing.FactoryException
Deprecated. 
Returns a vertical coordinate system from an EPSG code.

Overrides:
createVerticalCoordinateSystem in class CoordinateSystemAuthorityFactory
Parameters:
code - Value allocated by authority.
Returns:
The vertical coordinate system object.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CS_CoordinateSystemAuthorityFactory.createVerticalCoordinateSystem(java.lang.String)

createCompoundCoordinateSystem

public CompoundCoordinateSystem createCompoundCoordinateSystem(java.lang.String code)
                                                        throws org.opengis.referencing.FactoryException
Deprecated. 
Create a compound coordinate system from the EPSG code.

Overrides:
createCompoundCoordinateSystem in class CoordinateSystemAuthorityFactory
Parameters:
code - the EPSG code for the CS.
Returns:
the compound CS which value was given.
Throws:
NoSuchAuthorityCodeException - if this method can't find the requested code.
org.opengis.referencing.FactoryException - if some other kind of failure occured in the backing store. This exception usually have SQLException as its cause.
See Also:
CS_CoordinateSystemAuthorityFactory.createCompoundCoordinateSystem(java.lang.String)

replaceAxisUnit

protected Unit replaceAxisUnit(Unit unit)
Deprecated. 
Replace the axis's unit for a coordinate system. This method is invoked by all create...CoordinateSystem methods, but not by other methods like createPrimeMeridian. The default implementation replace sexagesimal degree units by the plain fractional degree units, which is much more suitable to computations (see Note about multi-radix units in this class's description).

If sexagesimal degrees are really wanted, subclasses can override this method and just returns unit with no change.

Parameters:
unit - The unit declared in the EPSG database for a coordinate system.
Returns:
The unit to use: unit with no change, or a substitute if unit was a multi-radix unit (e.g. sexagesimal degree).

dispose

public void dispose()
             throws org.opengis.referencing.FactoryException
Deprecated. 
Dispose any resources hold by this object. The database connection will be closed as well, except if this method is invoked on the default instance as returned by getDefault().

Overrides:
dispose in class CoordinateSystemAuthorityFactory
Throws:
org.opengis.referencing.FactoryException - if an error occured while closing the connection.

main

public static void main(java.lang.String[] args)
Deprecated. 
Construct an object from the EPSG database and print its WKT (Well Know Text) to the standard output. This method can be invoked from the command line. For example:
 java org.geotools.cs.CoordinateSystemEPSGFactory 4181
 
Should print:
 GEOGCS["Luxembourg 1930", DATUM["Luxembourg 1930", etc...
 
The following optional arguments are supported:
-connection
Set the EPSG database URL. The URL must conform to DriverManager.getConnection(String) specification. The default value is jdbc:odbc:EPSG. The specified URL is stored in system preferences and will become the default URL for every calls to getDefault(). The "default" string reset the default URL.

-driver
Set the driver class. The default value is sun.jdbc.odbc.JdbcOdbcDriver. The specified classname is stored in system preferences and will become the default driver for every calls to getDefault(). The "default" string reset the default driver.

-implementation
Set an alternative implementation. The argument must be a fully qualified class name of a CoordinateSystemEPSGFactory subclass. The implementation must have a public constructor with the following arguments:
  • The coordinate system factory as a CoordinateSystemFactory
  • The EPSG database URL as a String
  • The database driver as a String
The specified classname is stored in system preferences and will become the default implementation for every calls to getDefault(). The "default" string reset the default implementation.

-encoding
Set the console encoding for this application output. This value has no impact on CoordinateSystemEPSGFactory behavior.

Parameters:
args - A list of EPSG code to display. An arbitrary number of code can be specified on the command line.


Copyright © GeoTools. All Rights Reserved.