001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: *
005: * (C) 2005-2006, Geotools Project Managment Committee (PMC)
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.referencing.operation.projection;
018:
019: // J2SE dependencies and extensions
020: import java.awt.geom.Point2D;
021:
022: // OpenGIS dependencies
023: import org.opengis.parameter.ParameterDescriptor;
024: import org.opengis.parameter.ParameterDescriptorGroup;
025: import org.opengis.parameter.ParameterNotFoundException;
026: import org.opengis.parameter.ParameterValueGroup;
027: import org.opengis.referencing.operation.CylindricalProjection;
028: import org.opengis.referencing.operation.MathTransform;
029: import org.opengis.referencing.FactoryException;
030:
031: // Geotools dependencies
032: import org.geotools.metadata.iso.citation.Citations;
033: import org.geotools.referencing.NamedIdentifier;
034: import org.geotools.resources.i18n.ErrorKeys;
035: import org.geotools.resources.i18n.Errors;
036:
037: /**
038: * Plate Carree (or Equirectangular) projection. This is a particular case of
039: * {@linkplain EquidistantCylindrical Equidistant Cylindrical} projection where the
040: * {@code standard_parallel_1} is 0°.
041: *
042: * @see <A HREF="http://www.remotesensing.org/geotiff/proj_list/equirectangular.html">"Equirectangular" on RemoteSensing.org</A>
043: *
044: * @since 2.2
045: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/referencing/operation/projection/PlateCarree.java $
046: * @version $Id: PlateCarree.java 26540 2007-08-14 12:20:36Z desruisseaux $
047: * @author John Grange
048: * @author Martin Desruisseaux
049: */
050: public class PlateCarree extends EquidistantCylindrical {
051: /**
052: * Constructs a new map projection from the supplied parameters.
053: *
054: * @param parameters The parameter values in standard units.
055: * @throws ParameterNotFoundException if a mandatory parameter is missing.
056: */
057: protected PlateCarree(final ParameterValueGroup parameters)
058: throws ParameterNotFoundException {
059: super (parameters);
060: }
061:
062: /**
063: * {@inheritDoc}
064: */
065: public ParameterDescriptorGroup getParameterDescriptors() {
066: return Provider.PARAMETERS;
067: }
068:
069: /**
070: * Transforms the specified (<var>λ</var>,<var>φ</var>) coordinates
071: * (units in radians) and stores the result in {@code ptDst} (linear distance
072: * on a unit sphere).
073: */
074: protected Point2D transformNormalized(double x, double y,
075: final Point2D ptDst) throws ProjectionException {
076: if (ptDst != null) {
077: ptDst.setLocation(x, y);
078: return ptDst;
079: }
080: return new Point2D.Double(x, y);
081: }
082:
083: /**
084: * Transforms the specified (<var>x</var>,<var>y</var>) coordinates
085: * and stores the result in {@code ptDst}.
086: */
087: protected Point2D inverseTransformNormalized(double x, double y,
088: final Point2D ptDst) throws ProjectionException {
089: if (ptDst != null) {
090: ptDst.setLocation(x, y);
091: return ptDst;
092: }
093: return new Point2D.Double(x, y);
094: }
095:
096: //////////////////////////////////////////////////////////////////////////////////////////
097: //////////////////////////////////////////////////////////////////////////////////////////
098: //////// ////////
099: //////// PROVIDERS ////////
100: //////// ////////
101: //////////////////////////////////////////////////////////////////////////////////////////
102: //////////////////////////////////////////////////////////////////////////////////////////
103:
104: /**
105: * The {@linkplain org.geotools.referencing.operation.MathTransformProvider math transform
106: * provider} for an {@linkplain org.geotools.referencing.operation.projection.PlateCarree
107: * Plate Carree} projection.
108: *
109: * @since 2.2
110: * @version $Id: PlateCarree.java 26540 2007-08-14 12:20:36Z desruisseaux $
111: * @author John Grange
112: *
113: * @see org.geotools.referencing.operation.DefaultMathTransformFactory
114: */
115: public static class Provider extends AbstractProvider {
116: /**
117: * The parameters group.
118: */
119: static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(
120: new NamedIdentifier[] {
121: new NamedIdentifier(Citations.ESRI,
122: "Plate_Carree"),
123: new NamedIdentifier(Citations.OGC,
124: "Equirectangular"),
125: new NamedIdentifier(Citations.GEOTIFF,
126: "CT_Equirectangular") },
127: new ParameterDescriptor[] { SEMI_MAJOR, SEMI_MINOR,
128: CENTRAL_MERIDIAN, FALSE_EASTING, FALSE_NORTHING });
129:
130: /**
131: * Constructs a new provider.
132: */
133: public Provider() {
134: super (PARAMETERS);
135: }
136:
137: /**
138: * Returns the operation type for this map projection.
139: */
140: public Class getOperationType() {
141: return CylindricalProjection.class;
142: }
143:
144: /**
145: * Creates a transform from the specified group of parameter values.
146: *
147: * @param parameters The group of parameter values.
148: * @return The created math transform.
149: * @throws ParameterNotFoundException if a required parameter was not found.
150: */
151: protected MathTransform createMathTransform(
152: final ParameterValueGroup parameters)
153: throws ParameterNotFoundException, FactoryException {
154: if (isSpherical(parameters)) {
155: return new PlateCarree(parameters);
156: } else {
157: throw new FactoryException(Errors
158: .format(ErrorKeys.ELLIPTICAL_NOT_SUPPORTED));
159: }
160: }
161: }
162: }
|