/* * Geotools 2 - OpenSource mapping toolkit * (C) 2004, Geotools Project Managment Committee (PMC) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * Contacts: * UNITED KINGDOM: James Macgill * mailto:j.macgill@geog.leeds.ac.uk * * FRANCE: Surveillance de l'Environnement Assistée par Satellite * Institut de Recherche pour le Développement / US-Espace * mailto:seasnet@teledetection.fr */ package org.geotools.cs; // J2SE dependencies import java.sql.Connection; import java.sql.SQLException; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; /** * An EPSG factory which replaces some table or column names by other names. * This factory is used for EPSG database backed by an other software than * MS-Access. * * This class overrides {@link #adaptSQL} to change the SQL statements so they * are suitable for non-ms access versions of EPSG databases (version 6.4). * By default, the new SQL statements use the new table and field names in * the Data Description Language (DDL) scripts provided in version 6.4 to * create the schema for the database. Subclasses can changes this default * behavior by modifying the {@link #map}. *

* In order to register this ANSI version as the {@linkplain #getDefault default} * EPSG factory, invokes the following only once from the command line. * The change will by system-wide: * *
 * java org.geotools.cs.CoordinateSystemEPSGFactory -implementation=org.geotools.cs.CoordinateSystemModifiedEPSGFactory
 * 
* *

* References: * * @version $Id$ * @author Rueben Schulz * @author Martin Desruisseaux * * @deprecated Replaced by {@link org.geotools.referencing.factory.epsg.FactoryUsingAnsiSQL}. */ public class CoordinateSystemModifiedEPSGFactory extends CoordinateSystemEPSGFactory { /** * The default map using ANSI names. */ private static final String[] ANSI = { "[Area]", "epsg_area", "[Coordinate Axis]", "epsg_coordinateaxis", "[Coordinate Axis Name]", "epsg_coordinateaxisname", "[Coordinate_Operation]", "epsg_coordoperation", "[Coordinate_Operation Method]", "epsg_coordoperationmethod", "[Coordinate_Operation Parameter]", "epsg_coordoperationparam", "[Coordinate_Operation Parameter Usage]", "epsg_coordoperationparamusage", "[Coordinate_Operation Parameter Value]", "epsg_coordoperationparamvalue", "[Coordinate Reference System]", "epsg_coordinatereferencesystem", "[Coordinate System]", "epsg_coordinatesystem", "[Datum]", "epsg_datum", "[Ellipsoid]", "epsg_ellipsoid", "[Prime Meridian]", "epsg_primemeridian", "[Unit of Measure]", "epsg_unitofmeasure", "[ORDER]", "coord_axis_order" //a field in epsg_coordinateaxis }; /** * Maps the MS-Access names to ANSI names. Key are MS-Access names including bracket. * Values are ANSI names. Keys and values are case-sensitive. The default content of * this map is: * *

     *   
     *   
     *   
     *   
     *   
     *   
     *   
     *   
     *   
     *   
     *   
     *   
     *   
     *   
     *   
     *   
     * 
MS-Access name ANSI name
[Area] epsg_area
[Coordinate Axis] epsg_coordinateaxis
[Coordinate Axis Name] epsg_coordinateaxisname
[Coordinate_Operation] epsg_coordoperation
[Coordinate_Operation Method] epsg_coordoperationmethod
[Coordinate_Operation Parameter] epsg_coordoperationparam
[Coordinate_Operation Parameter Usage] epsg_coordoperationparamusage
[Coordinate_Operation Parameter Value] epsg_coordoperationparamvalue
[Coordinate Reference System] epsg_coordinatereferencesystem
[Coordinate System] epsg_coordinatesystem
[Datum] epsg_datum
[Ellipsoid] epsg_ellipsoid
[Prime Meridian] epsg_primemeridian
[Unit of Measure] epsg_unitofmeasure
[ORDER] coord_axis_order
* * Subclasses can modify this map in their constructor in order to provide a different * mapping. */ protected final Map map = new LinkedHashMap(); /** * Construct an authority factory using * the specified connection. * * @param factory The underlying factory used for objects creation. * @param connection The connection to the underlying EPSG database. */ public CoordinateSystemModifiedEPSGFactory(final CoordinateSystemFactory factory, final Connection connection) { super(factory, connection); for (int i=0; i"jdbc:postgresql://localhost/epsg?user=<user>&pass=<password>". * @param 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" stating if * the loading succeeded of failed. For postgresql, a typical value * for this argument is "org.postgresql.Driver". * This argument needs to be non-null only once for a specific driver. * * @throws SQLException if the constructor failed to connect to the EPSG database. */ public CoordinateSystemModifiedEPSGFactory(final CoordinateSystemFactory factory, final String url, final String driver) throws SQLException { super(factory, url, driver); for (int i=0; i= 0) { modified.replace(start, start+oldName.length(), newName); start += newName.length(); } } return modified.toString(); } }