01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.referencing.factory.wms;
17:
18: // J2SE dependencies
19: import java.util.Collections;
20:
21: // OpenGIS dependencies
22: import org.opengis.parameter.ParameterValueGroup;
23: import org.opengis.referencing.FactoryException;
24: import org.opengis.referencing.IdentifiedObject;
25: import org.opengis.referencing.crs.ProjectedCRS;
26:
27: // Geotools dependencies
28: import org.geotools.referencing.factory.ReferencingFactoryContainer;
29: import org.geotools.referencing.cs.DefaultCartesianCS;
30: import org.geotools.referencing.crs.DefaultGeographicCRS;
31:
32: /**
33: * Mini Plug-In API for {@linkplain ProjectedCRS projected CRS} from the {@code AUTO} authority.
34: *
35: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/referencing/factory/wms/Factlet.java $
36: * @version $Id: Factlet.java 25940 2007-06-20 02:26:14Z jgarnett $
37: * @author Jody Garnett
38: * @author Rueben Schulz
39: * @author Martin Desruisseaux
40: */
41: abstract class Factlet {
42: /**
43: * Returns the {@code AUTO} code for this plugin.
44: */
45: public abstract int code();
46:
47: /**
48: * Returns the name for the CRS to be created by this plugin.
49: */
50: public abstract String getName();
51:
52: /**
53: * Returns the classification of projection method.
54: * For example {@code "Transverse_Mercator"}.
55: */
56: public abstract String getClassification();
57:
58: /**
59: * Creates a coordinate reference system from the specified code. The default
60: * implementation creates a {@linkplain ParameterValueGroup parameter group}
61: * for the {@linkplain #getClassification projection classification}, and then
62: * invokes {@link #setProjectionParameters} in order to fill the parameter values.
63: */
64: public final ProjectedCRS create(final Code code,
65: final ReferencingFactoryContainer factories)
66: throws FactoryException {
67: final String classification = getClassification();
68: final ParameterValueGroup parameters;
69: parameters = factories.getMathTransformFactory()
70: .getDefaultParameters(classification);
71: setProjectionParameters(parameters, code);
72: return factories.createProjectedCRS(Collections.singletonMap(
73: IdentifiedObject.NAME_KEY, getName()),
74: DefaultGeographicCRS.WGS84, null, parameters,
75: DefaultCartesianCS.PROJECTED);
76: }
77:
78: /**
79: * Fills the parameter values for the specified code.
80: */
81: protected abstract void setProjectionParameters(
82: ParameterValueGroup parameters, Code code);
83: }
|