001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.referencing.factory.epsg;
017:
018: // J2SE dependencies
019: import java.net.URL;
020:
021: // OpenGIS dependencies
022: import org.opengis.metadata.citation.Citation;
023: import org.opengis.referencing.FactoryException;
024:
025: // Geotools dependencies
026: import org.geotools.factory.Hints;
027: import org.geotools.metadata.iso.citation.Citations;
028:
029: /**
030: * Extends the EPSG database with {@linkplain CoordinateReferenceSystem Coordinate Reference Systems}
031: * defined by ESRI. Those CRS will be registered both in {@code "ESRI"} and {@code "EPSG"} name space.
032: *
033: * @since 2.4
034: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/epsg-extension/src/main/java/org/geotools/referencing/factory/epsg/EsriExtension.java $
035: * @version $Id: EsriExtension.java 25668 2007-05-29 13:44:16Z desruisseaux $
036: * @author Martin Desruisseaux
037: */
038: public class EsriExtension extends FactoryUsingWKT {
039: /**
040: * The default filename to read. This file will be searched in the
041: * {@code org/geotools/referencing/factory/espg} directory in the
042: * classpath or in a JAR file.
043: *
044: * @see #getDefinitionsURL
045: */
046: public static final String FILENAME = "esri.properties";
047:
048: /**
049: * Constructs an authority factory using the default set of factories.
050: */
051: public EsriExtension() {
052: this (null);
053: }
054:
055: /**
056: * Constructs an authority factory using a set of factories created from the specified hints.
057: * This constructor recognizes the {@link Hints#CRS_FACTORY CRS}, {@link Hints#CS_FACTORY CS},
058: * {@link Hints#DATUM_FACTORY DATUM} and {@link Hints#MATH_TRANSFORM_FACTORY MATH_TRANSFORM}
059: * {@code FACTORY} hints.
060: */
061: public EsriExtension(final Hints hints) {
062: super (hints, DEFAULT_PRIORITY - 5);
063: }
064:
065: /**
066: * Returns the set of authorities to use as identifiers for the CRS to be created.
067: * The default implementation returns {@linkplain Citations#ESRI ESRI} and
068: * {@linkplain Citations#EPSG EPSG} authorities.
069: */
070: //@Override
071: protected Citation[] getAuthorities() {
072: return new Citation[] { Citations.ESRI, Citations.EPSG };
073: }
074:
075: /**
076: * Returns the URL to the property file that contains CRS definitions.
077: * The default implementation returns the URL to the {@value #FILENAME} file.
078: *
079: * @return The URL, or {@code null} if none.
080: */
081: protected URL getDefinitionsURL() {
082: return EsriExtension.class.getResource(FILENAME);
083: }
084:
085: /**
086: * Prints a list of codes that duplicate the ones provided in the {@link DefaultFactory}.
087: * The factory tested is the one registered in {@link ReferencingFactoryFinder}. By default, this
088: * is this {@code EsriExtension} class backed by the {@value #FILENAME} property file.
089: * This method can be invoked from the command line in order to check the content of the
090: * property file. Valid arguments are:
091: * <p>
092: * <table>
093: * <tr><td>{@code -test}</td><td>Try to instantiate all CRS and reports any failure
094: * to do so.</td></tr>
095: * <tr><td>{@code -duplicated}</td><td>List all codes from the WKT factory that are
096: * duplicating a code from the SQL factory.</td></tr>
097: * </table>
098: *
099: * @param args Command line arguments.
100: * @throws FactoryException if an error occured.
101: */
102: public static void main(final String[] args)
103: throws FactoryException {
104: main(args, EsriExtension.class);
105: }
106: }
|