Statistics
| Revision:

root / branches / F2 / libraries / libJCRS / src / org / geotools / referencing / operation / projection / EquidistantConic.java @ 12186

History | View | Annotate | Download (9.65 KB)

1
/*
2
 *    Geotools2 - OpenSource mapping toolkit
3
 *    http://geotools.org
4
 *    (C) 2002-2005, Geotools Project Managment Committee (PMC)
5
 *
6
 *    This library is free software; you can redistribute it and/or
7
 *    modify it under the terms of the GNU Lesser General Public
8
 *    License as published by the Free Software Foundation;
9
 *    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.operation.projection;
17

    
18
// J2SE dependencies and extensions
19
import java.awt.geom.Point2D;
20
import java.util.Collection;
21

    
22
import javax.units.SI;
23
import javax.units.NonSI;
24
import javax.units.Unit;
25

    
26
import org.geotools.metadata.iso.citation.CitationImpl;
27
import org.geotools.referencing.NamedIdentifier;
28
import org.geotools.resources.XMath;
29
import org.geotools.resources.cts.ResourceKeys;
30
import org.geotools.resources.cts.Resources;
31
import org.opengis.parameter.ParameterDescriptor;
32
import org.opengis.parameter.ParameterDescriptorGroup;
33
import org.opengis.parameter.ParameterNotFoundException;
34
import org.opengis.parameter.ParameterValueGroup;
35
import org.opengis.referencing.operation.ConicProjection;
36
import org.opengis.referencing.operation.MathTransform;
37

    
38

    
39
public class EquidistantConic extends MapProjection {
40
    protected final double latitudeOfCenter;
41
    protected final double longitudeOfCenter;
42
    private final double standardParallel1;
43
    private final double standardParallel2;
44
    protected EquidistantConic(final ParameterValueGroup parameters) throws ParameterNotFoundException {
45
        super(parameters);
46
        final Collection expected = getParameterDescriptors().descriptors();
47
        if (expected.contains(Provider.STANDARD_PARALLEL_1)) {
48
                standardParallel1 = Math.abs(doubleValue(expected,
49
                                        Provider.STANDARD_PARALLEL_1, parameters));
50
            ensureLatitudeInRange(Provider.STANDARD_PARALLEL_1, standardParallel1, false);
51
        } else {
52
            // standard parallel is the equator (Plate Carree or Equirectangular)
53
                standardParallel1 = Double.NaN;
54
        }
55
        if (expected.contains(Provider.STANDARD_PARALLEL_2)) {
56
                standardParallel2 = Math.abs(doubleValue(expected,
57
                                        Provider.STANDARD_PARALLEL_2, parameters));
58
            ensureLatitudeInRange(Provider.STANDARD_PARALLEL_2, standardParallel2, false);
59
        } else {
60
            // standard parallel is the equator (Plate Carree or Equirectangular)
61
                standardParallel2 = Double.NaN;
62
        }
63
        if (expected.contains(Provider.LATITUDE_OF_CENTER)) {
64
                latitudeOfCenter = Math.abs(doubleValue(expected,
65
                                        Provider.LATITUDE_OF_CENTER, parameters));
66
            ensureLatitudeInRange(Provider.LATITUDE_OF_CENTER, latitudeOfCenter, false);
67
        } else {
68
            // standard parallel is the equator (Plate Carree or Equirectangular)
69
                latitudeOfCenter = Double.NaN;
70
        }
71
        if (expected.contains(Provider.LONGITUDE_OF_CENTER)) {
72
                longitudeOfCenter = Math.abs(doubleValue(expected,
73
                                        Provider.LONGITUDE_OF_CENTER, parameters));
74
            ensureLongitudeInRange(Provider.LONGITUDE_OF_CENTER, longitudeOfCenter, false);
75
        } else {
76
            // standard parallel is the equator (Plate Carree or Equirectangular)
77
                longitudeOfCenter = Double.NaN;
78
        }
79
    }
80

    
81
    /**
82
     * {@inheritDoc}
83
     */
84
    public ParameterDescriptorGroup getParameterDescriptors() {
85
        return Provider.PARAMETERS;
86
    }
87

    
88
    /**
89
     * {@inheritDoc}
90
     */
91
    public ParameterValueGroup getParameterValues() {
92
        final Collection expected = getParameterDescriptors().descriptors();
93
        final ParameterValueGroup values = super.getParameterValues();
94
        set(expected, Provider.STANDARD_PARALLEL_1,       values, standardParallel1      );
95
        set(expected, Provider.STANDARD_PARALLEL_2,       values, standardParallel2      );
96
        set(expected, Provider.LATITUDE_OF_CENTER,       values, latitudeOfCenter      );
97
        set(expected, Provider.LONGITUDE_OF_CENTER,      values, longitudeOfCenter       );
98
        return values;
99
    }
100

    
101
    /**
102
     * Transforms the specified (<var>&lambda;</var>,<var>&phi;</var>) coordinates
103
     * (units in radians) and stores the result in {@code ptDst} (linear distance
104
     * on a unit sphere).
105
     */
106
    protected Point2D transformNormalized(final double lambda, final double phi, Point2D ptDst)
107
            throws ProjectionException
108
    {
109
        return null;
110
    }
111

    
112
    /**
113
     * Transforms the specified (<var>x</var>,<var>y</var>) coordinate
114
     * and stores the result in {@code ptDst}.
115
     */
116
    protected Point2D inverseTransformNormalized(final double x, final double y, Point2D ptDst)
117
            throws ProjectionException
118
    {
119
        return null;
120
    }
121

    
122

    
123

    
124

    
125
    //////////////////////////////////////////////////////////////////////////////////////////
126
    //////////////////////////////////////////////////////////////////////////////////////////
127
    ////////                                                                          ////////
128
    ////////                                 PROVIDER                                 ////////
129
    ////////                                                                          ////////
130
    //////////////////////////////////////////////////////////////////////////////////////////
131
    //////////////////////////////////////////////////////////////////////////////////////////
132

    
133
    public static class Provider extends AbstractProvider {
134
        public static final ParameterDescriptor LATITUDE_OF_CENTER = createDescriptor(
135
                new NamedIdentifier[] {
136
                    new NamedIdentifier(CitationImpl.OGC,     "latitude_of_center"),
137
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection center"),
138
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
139
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical latitude of origin"),
140
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of natural origin"),
141
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLat")
142
                }, 0.0, -90, 90, NonSI.DEGREE_ANGLE);
143

    
144
        public static final ParameterDescriptor LONGITUDE_OF_CENTER = createDescriptor(
145
                new NamedIdentifier[] {
146
                    new NamedIdentifier(CitationImpl.OGC,     "longitude_of_center"),
147
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection center"),
148
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection centre"),
149
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical longitude of origin"),
150
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of natural origin"),
151
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLong")
152
                }, 0.0, -180, 180, NonSI.DEGREE_ANGLE);
153

    
154
        public static final ParameterDescriptor STANDARD_PARALLEL_1 = createDescriptor(
155
                new NamedIdentifier[] {
156
                    new NamedIdentifier(CitationImpl.OGC,      "standard_parallel_1"),
157
                    new NamedIdentifier(CitationImpl.EPSG,     "Latitude of 1st standard parallel"),
158
                    new NamedIdentifier(CitationImpl.EPSG,     "Latitude of natural origin"),
159
                    new NamedIdentifier(CitationImpl.GEOTIFF,  "StdParallel1")
160
                }, 0.0, -90, 90, NonSI.DEGREE_ANGLE);
161

    
162
        public static final ParameterDescriptor STANDARD_PARALLEL_2 = createDescriptor(
163
                new NamedIdentifier[] {
164
                    new NamedIdentifier(CitationImpl.OGC,     "standard_parallel_2"),
165
                    new NamedIdentifier(CitationImpl.EPSG,     "Latitude of 2nd standard parallel"),
166
                    new NamedIdentifier(CitationImpl.EPSG,     "Latitude of natural origin"),
167
                    new NamedIdentifier(CitationImpl.GEOTIFF,  "StdParallel2")
168
                }, 0.0, -90, 90, NonSI.DEGREE_ANGLE);
169

    
170

    
171
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
172
            new NamedIdentifier(CitationImpl.OGC,     "Equidistant_Conic "),
173
            new NamedIdentifier(CitationImpl.GEOTIFF, "EquidistantConic"),
174
            new NamedIdentifier(CitationImpl.EPSG,    "        Equidistant Conic")//,
175
                },
176
                new ParameterDescriptor[] {
177
                    SEMI_MAJOR,                         SEMI_MINOR,
178
                    STANDARD_PARALLEL_1,        STANDARD_PARALLEL_2,
179
                    LATITUDE_OF_CENTER,         LONGITUDE_OF_CENTER,
180
                    FALSE_EASTING,                         FALSE_NORTHING
181
                });
182

    
183
        /**
184
         * Constructs a new provider. 
185
         */
186
        public Provider() {
187
            super(PARAMETERS);
188
        }
189

    
190
        /**
191
         * Returns the operation type for this map projection.
192
         */
193
        protected Class getOperationType() {
194
            return ConicProjection.class;
195
        }
196

    
197
        /**
198
         * Creates a transform from the specified group of parameter values.
199
         *
200
         * @param parameters The group of parameter values.
201
         * @return The created math transform.
202
         * @throws ParameterNotFoundException if a required parameter was not found.
203
         */
204
        public MathTransform createMathTransform(final ParameterValueGroup parameters)
205
                throws ParameterNotFoundException
206
        {
207
            return new EquidistantConic(parameters);
208
        }
209
    }
210

    
211
}