Revision 12357

View differences:

branches/F2/libraries/libJCRS/src/org/geotools/referencing/operation/projection/Bonne.java
1
package org.geotools.referencing.operation.projection;
2

  
3
import java.awt.geom.Point2D;
4
import java.util.Collection;
5

  
6
import javax.units.NonSI;
7

  
8
import org.opengis.parameter.ParameterDescriptorGroup;
9
import org.opengis.parameter.ParameterNotFoundException;
10
import org.opengis.parameter.ParameterValueGroup;
11

  
12
import org.geotools.metadata.iso.citation.CitationImpl;
13
import org.geotools.referencing.NamedIdentifier;
14
import org.geotools.resources.XMath;
15
import org.geotools.resources.cts.ResourceKeys;
16
import org.geotools.resources.cts.Resources;
17
import org.opengis.parameter.ParameterDescriptor;
18
import org.opengis.referencing.operation.CylindricalProjection;
19
import org.opengis.referencing.operation.MathTransform;
20

  
21

  
22

  
23
public class Bonne extends MapProjection {
24

  
25
    private final double standardParallel;
26

  
27
    protected Bonne(ParameterValueGroup parameters) throws ParameterNotFoundException {
28
		super(parameters);
29
        final Collection expected = getParameterDescriptors().descriptors();
30
        if (expected.contains(Provider.STANDARD_PARALLEL)) {
31
            standardParallel = Math.abs(doubleValue(expected,
32
                                        Provider.STANDARD_PARALLEL, parameters));
33
            ensureLatitudeInRange(Provider.STANDARD_PARALLEL, standardParallel, false);
34
        } else {
35
            standardParallel = Double.NaN;
36
         }
37
	}
38

  
39
	
40
	public ParameterDescriptorGroup getParameterDescriptors() {
41
        return Provider.PARAMETERS;
42
	}
43

  
44
    public ParameterValueGroup getParameterValues() {
45
        final ParameterValueGroup values = super.getParameterValues();
46
        if (!Double.isNaN(standardParallel)) {
47
            final Collection expected = getParameterDescriptors().descriptors();
48
            set(expected,Provider.STANDARD_PARALLEL, values, standardParallel);
49
        }
50
        return values;
51
    }
52

  
53

  
54
	protected Point2D inverseTransformNormalized(double x, double y,
55
			Point2D ptDst) throws ProjectionException {
56
		// TODO Auto-generated method stub
57
		return null;
58
	}
59

  
60
	protected Point2D transformNormalized(double x, double y, Point2D ptDst)
61
			throws ProjectionException {
62
		// TODO Auto-generated method stub
63
		return null;
64
	}
65
	   
66
	public static class Provider extends AbstractProvider {
67

  
68
	        /**
69
	         * The operation parameter descriptor for the {@link #standardParallel standard parallel}
70
	         * parameter value. Valid values range is from -90 to 90. Default value is 0.
71
	         */
72
	    public static final ParameterDescriptor STANDARD_PARALLEL = createDescriptor(
73
	                new NamedIdentifier[] {
74
	                    new NamedIdentifier(CitationImpl.OGC,      "standard_parallel_1"),
75
	                    new NamedIdentifier(CitationImpl.EPSG,     "Latitude of 1st standard parallel"),
76
	                    new NamedIdentifier(CitationImpl.EPSG,     "Latitude of natural origin"),
77
	                    new NamedIdentifier(CitationImpl.GEOTIFF,  "StdParallel1")
78
	                },
79
	                0, -90, 90, NonSI.DEGREE_ANGLE);
80

  
81
	        /**
82
	         * The parameters group. Note the EPSG includes a "Latitude of natural origin" parameter instead
83
	         * of "standard_parallel_1". I have sided with ESRI and Snyder in this case.
84
	         */
85
	        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
86
	                new NamedIdentifier(CitationImpl.OGC,      "Bonne"),
87
        			new NamedIdentifier(CitationImpl.EPSG,     "Bonne")
88
 	                //new NamedIdentifier(CitationImpl.EPSG,     "9823")//,
89
	            }, new ParameterDescriptor[] {
90
	                SEMI_MAJOR,       SEMI_MINOR,
91
	                CENTRAL_MERIDIAN, STANDARD_PARALLEL,
92
	                FALSE_EASTING,    FALSE_NORTHING
93
	            });
94

  
95
			/*String[] parameterName={"central_meridian"};
96
			projectionParameterList.add(count,parameterName);
97
			addProjectionParameter(count,"standard_parallel_1");
98
			addProjectionParameter(count,"false_easting");
99
			addProjectionParameter(count,"false_northing");*/
100

  
101
	        /**
102
	         * Constructs a new provider.
103
	         */
104
	        public Provider() {
105
	            super(PARAMETERS);
106
	        }
107

  
108
	        protected Provider(final ParameterDescriptorGroup params) {
109
	            super(params);
110
	        }
111
	        /**
112
	         * Returns the operation type for this map projection.
113
	         */
114
	        protected Class getOperationType() {
115
	        	return CylindricalProjection.class;
116
	        }
117

  
118
	        /**
119
	         * Creates a transform from the specified group of parameter values.
120
	         *
121
	         * @param  parameters The group of parameter values.
122
	         * @return The created math transform.
123
	         * @throws ParameterNotFoundException if a required parameter was not found.
124
	         */
125
	        public MathTransform createMathTransform(final ParameterValueGroup parameters)
126
	                throws ParameterNotFoundException
127
	        {
128
	        	return new Bonne(parameters);
129
	        }
130
	    }
131

  
132
	public static class Provider_SouthOrientated extends Provider {
133
       /**
134
         * The operation parameter descriptor for the {@link #standardParallel standard parallel}
135
         * parameter value. Valid values range is from -90 to 90. Default value is 0.
136
         */
137
    public static final ParameterDescriptor STANDARD_PARALLEL = createDescriptor(
138
                new NamedIdentifier[] {
139
                    new NamedIdentifier(CitationImpl.OGC,      "standard_parallel_1"),
140
                    new NamedIdentifier(CitationImpl.EPSG,     "Latitude of 1st standard parallel"),
141
                    new NamedIdentifier(CitationImpl.EPSG,     "Latitude of natural origin"),
142
                    new NamedIdentifier(CitationImpl.GEOTIFF,  "StdParallel1")
143
                },
144
                0, -90, 90, NonSI.DEGREE_ANGLE);
145

  
146
        /**
147
         * The parameters group. Note the EPSG includes a "Latitude of natural origin" parameter instead
148
         * of "standard_parallel_1". I have sided with ESRI and Snyder in this case.
149
         */
150
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
151
                new NamedIdentifier(CitationImpl.OGC,      "Bonne_(South_Orientated)"),
152
    			new NamedIdentifier(CitationImpl.EPSG,     "Bonne (South Orientated)")
153
                //new NamedIdentifier(CitationImpl.EPSG,     "9823")//,
154
//                new NamedIdentifier(CitationImpl.GEOTOOLS, Vocabulary.formatInternational(
155
//                                    VocabularyKeys.EQUIDISTANT_CYLINDRICAL_PROJECTION))
156
            }, new ParameterDescriptor[] {
157
                SEMI_MAJOR,       SEMI_MINOR,
158
                CENTRAL_MERIDIAN, STANDARD_PARALLEL,
159
                FALSE_EASTING,    FALSE_NORTHING
160
            });
161

  
162
		/*String[] parameterName={"central_meridian"};
163
		projectionParameterList.add(count,parameterName);
164
		addProjectionParameter(count,"standard_parallel_1");
165
		addProjectionParameter(count,"false_easting");
166
		addProjectionParameter(count,"false_northing");*/
167

  
168

  
169
          /**
170
         * Constructs a new provider.
171
         */
172
        public Provider_SouthOrientated() {
173
            super(PARAMETERS);
174
        }
175

  
176
        /**
177
         * Returns the operation type for this map projection.
178
         */
179
        protected Class getOperationType() {
180
        	return CylindricalProjection.class;
181
        }
182

  
183
        /**
184
         * Creates a transform from the specified group of parameter values.
185
         *
186
         * @param  parameters The group of parameter values.
187
         * @return The created math transform.
188
         * @throws ParameterNotFoundException if a required parameter was not found.
189
         */
190
        public MathTransform createMathTransform(final ParameterValueGroup parameters)
191
                throws ParameterNotFoundException
192
        {
193
            //return null;
194
        	return new Bonne(parameters);
195
        }
196
    }
197

  
198
}
branches/F2/libraries/libJCRS/src/org/geotools/referencing/operation/projection/MillerCylindrical.java
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.CylindricalProjection;
36
import org.opengis.referencing.operation.MathTransform;
37

  
38

  
39
public class MillerCylindrical extends MapProjection {
40
    protected final double latitudeOfCenter;
41
    protected final double longitudeOfCenter;
42
    protected MillerCylindrical(final ParameterValueGroup parameters) throws ParameterNotFoundException {
43
        super(parameters);
44
        final Collection expected = getParameterDescriptors().descriptors();
45
        if (expected.contains(Provider.LATITUDE_OF_CENTER)) {
46
        	latitudeOfCenter = Math.abs(doubleValue(expected,
47
                                        Provider.LATITUDE_OF_CENTER, parameters));
48
            ensureLatitudeInRange(Provider.LATITUDE_OF_CENTER, latitudeOfCenter, false);
49
        } else {
50
            // standard parallel is the equator (Plate Carree or Equirectangular)
51
        	latitudeOfCenter = Double.NaN;
52
        }
53
        if (expected.contains(Provider.LONGITUDE_OF_CENTER)) {
54
        	longitudeOfCenter = Math.abs(doubleValue(expected,
55
                                        Provider.LONGITUDE_OF_CENTER, parameters));
56
            ensureLongitudeInRange(Provider.LONGITUDE_OF_CENTER, longitudeOfCenter, false);
57
        } else {
58
            // standard parallel is the equator (Plate Carree or Equirectangular)
59
        	longitudeOfCenter = Double.NaN;
60
        }
61
    }
62

  
63
    /**
64
     * {@inheritDoc}
65
     */
66
    public ParameterDescriptorGroup getParameterDescriptors() {
67
        return Provider.PARAMETERS;
68
    }
69

  
70
    /**
71
     * {@inheritDoc}
72
     */
73
    public ParameterValueGroup getParameterValues() {
74
        final Collection expected = getParameterDescriptors().descriptors();
75
        final ParameterValueGroup values = super.getParameterValues();
76
        set(expected, Provider.LATITUDE_OF_CENTER,       values, latitudeOfCenter      );
77
        set(expected, Provider.LONGITUDE_OF_CENTER,      values, longitudeOfCenter       );
78
        return values;
79
    }
80

  
81
    /**
82
     * Transforms the specified (<var>&lambda;</var>,<var>&phi;</var>) coordinates
83
     * (units in radians) and stores the result in {@code ptDst} (linear distance
84
     * on a unit sphere).
85
     */
86
    protected Point2D transformNormalized(final double lambda, final double phi, Point2D ptDst)
87
            throws ProjectionException
88
    {
89
        return null;
90
    }
91

  
92
    /**
93
     * Transforms the specified (<var>x</var>,<var>y</var>) coordinate
94
     * and stores the result in {@code ptDst}.
95
     */
96
    protected Point2D inverseTransformNormalized(final double x, final double y, Point2D ptDst)
97
            throws ProjectionException
98
    {
99
        return null;
100
    }
101

  
102

  
103

  
104

  
105
    //////////////////////////////////////////////////////////////////////////////////////////
106
    //////////////////////////////////////////////////////////////////////////////////////////
107
    ////////                                                                          ////////
108
    ////////                                 PROVIDER                                 ////////
109
    ////////                                                                          ////////
110
    //////////////////////////////////////////////////////////////////////////////////////////
111
    //////////////////////////////////////////////////////////////////////////////////////////
112

  
113
    /**
114
     * The {@link org.geotools.referencing.operation.MathTransformProvider}
115
     * for an {@link MillerCylindrical krovak} projection.
116
     *
117
     * @author jezekjan
118
     *
119
     * @see org.geotools.referencing.operation.DefaultMathTransformFactory
120
     */
121
    public static class Provider extends AbstractProvider {
122
        /**
123
         * The operation parameter descriptor for the {@linkPlain #latitudeOfOrigin
124
         * latitude of origin} parameter value. Valid values range is from -90 to 90.
125
         * Default value is 49.5.
126
         */
127
        public static final ParameterDescriptor LATITUDE_OF_CENTER = createDescriptor(
128
                new NamedIdentifier[] {
129
                    new NamedIdentifier(CitationImpl.OGC,     "latitude_of_center"),
130
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection center"),
131
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
132
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical latitude of origin"),
133
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of natural origin"),
134
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLat")
135
                }, 0.0, -90, 90, NonSI.DEGREE_ANGLE);
136

  
137
        /**
138
         * The operation parameter descriptor for the {@linkPlain #centralMeridian central
139
         * meridian} parameter value. Valid values range is from -180 to 180. Default value
140
         * is 2450' (= 4250' from Ferro prime meridian).
141
         */
142
        public static final ParameterDescriptor LONGITUDE_OF_CENTER = createDescriptor(
143
                new NamedIdentifier[] {
144
                    new NamedIdentifier(CitationImpl.OGC,     "longitude_of_center"),
145
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection center"),
146
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection centre"),
147
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical longitude of origin"),
148
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of natural origin"),
149
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLong")
150
                }, 0.0, -180, 180, NonSI.DEGREE_ANGLE);
151

  
152

  
153
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
154
            new NamedIdentifier(CitationImpl.OGC,     "Miller_Cylindrical"),
155
            new NamedIdentifier(CitationImpl.GEOTIFF, "MillerCylindrical"),
156
            new NamedIdentifier(CitationImpl.EPSG,    "Miller Cylindrical")//,
157
                },
158
                new ParameterDescriptor[] {
159
                    SEMI_MAJOR, SEMI_MINOR,
160
                    LATITUDE_OF_CENTER, LONGITUDE_OF_CENTER,
161
                    FALSE_EASTING, FALSE_NORTHING
162
                });
163

  
164
        /**
165
         * Constructs a new provider. 
166
         */
167
        public Provider() {
168
            super(PARAMETERS);
169
        }
170

  
171
        /**
172
         * Returns the operation type for this map projection.
173
         */
174
        protected Class getOperationType() {
175
            return CylindricalProjection.class;
176
        }
177

  
178
        /**
179
         * Creates a transform from the specified group of parameter values.
180
         *
181
         * @param parameters The group of parameter values.
182
         * @return The created math transform.
183
         * @throws ParameterNotFoundException if a required parameter was not found.
184
         */
185
        public MathTransform createMathTransform(final ParameterValueGroup parameters)
186
                throws ParameterNotFoundException
187
        {
188
            return new MillerCylindrical(parameters);
189
        }
190
    }
191

  
192
}
branches/F2/libraries/libJCRS/src/org/geotools/referencing/operation/projection/LambertConicNearConformal.java
1
package org.geotools.referencing.operation.projection;
2

  
3
import java.awt.geom.Point2D;
4
import java.util.Collection;
5

  
6
import javax.units.NonSI;
7

  
8
import org.geotools.metadata.iso.citation.CitationImpl;
9
import org.geotools.referencing.NamedIdentifier;
10
import org.geotools.resources.cts.Resources;
11
import org.opengis.parameter.ParameterDescriptor;
12
import org.opengis.parameter.ParameterDescriptorGroup;
13
import org.opengis.parameter.ParameterNotFoundException;
14
import org.opengis.parameter.ParameterValueGroup;
15
import org.opengis.referencing.operation.ConicProjection;
16
import org.opengis.referencing.operation.MathTransform;
17
import org.geotools.resources.cts.ResourceKeys;
18

  
19

  
20

  
21
public class LambertConicNearConformal extends MapProjection {
22

  
23
    private final double latitudeOfOrigin;
24

  
25
    protected LambertConicNearConformal(ParameterValueGroup parameters) throws ParameterNotFoundException {
26
		super(parameters);
27
        final Collection expected = getParameterDescriptors().descriptors();
28
        if (expected.contains(Provider.LATITUDE_OF_ORIGIN)) {
29
        	latitudeOfOrigin = Math.abs(doubleValue(expected,
30
                                        Provider.LATITUDE_OF_ORIGIN, parameters));
31
            ensureLatitudeInRange(Provider.LATITUDE_OF_ORIGIN, latitudeOfOrigin, false);
32
        } else {
33
            // standard parallel is the equator (Plate Carree or Equirectangular)
34
        	latitudeOfOrigin = Double.NaN;
35
        }
36
		// TODO Auto-generated constructor stub
37
	}
38

  
39
	
40
	public ParameterDescriptorGroup getParameterDescriptors() {
41
		// TODO Auto-generated method stub
42
        return Provider.PARAMETERS;
43
	}
44

  
45
    public ParameterValueGroup getParameterValues() {
46
        final ParameterValueGroup values = super.getParameterValues();
47
        if (!Double.isNaN(latitudeOfOrigin)) {
48
            final Collection expected = getParameterDescriptors().descriptors();
49
            set(expected,Provider.LATITUDE_OF_ORIGIN, values, latitudeOfOrigin);
50
        }
51
        return values;
52
    }
53

  
54
	protected Point2D inverseTransformNormalized(double x, double y,
55
			Point2D ptDst) throws ProjectionException {
56
		// TODO Auto-generated method stub
57
		return null;
58
	}
59

  
60
	protected Point2D transformNormalized(double x, double y, Point2D ptDst)
61
			throws ProjectionException {
62
		// TODO Auto-generated method stub
63
		return null;
64
	}
65
	public static class Provider extends AbstractProvider {
66

  
67
        public static final ParameterDescriptor LATITUDE_OF_ORIGIN = createDescriptor(
68
                new NamedIdentifier[] {
69
                    new NamedIdentifier(CitationImpl.OGC,     "latitude_of_origin"),
70
                    new NamedIdentifier(CitationImpl.EPSG,    "CenterLat"),
71
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
72
                    new NamedIdentifier(CitationImpl.GEOTIFF, "NatOriginLat"),
73
                    new NamedIdentifier(CitationImpl.EPSG,    "FalseOriginLat"),
74
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of false origin"),		
75
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of natural origin"),
76
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
77
                    new NamedIdentifier(CitationImpl.EPSG,    "ProjCenterLat")
78
                }, 0.0, -90.0, 90.0, NonSI.DEGREE_ANGLE);
79

  
80
        /**
81
         * The parameters group. Note the EPSG includes a "Latitude of natural origin" parameter instead
82
         * of "standard_parallel_1". I have sided with ESRI and Snyder in this case.
83
         */
84
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
85
                new NamedIdentifier(CitationImpl.OGC,      "Lambert_Conic_Near_Conformal"),
86
    			new NamedIdentifier(CitationImpl.EPSG,     "Lambert_Conic_Near_Conformal"),
87
                new NamedIdentifier(CitationImpl.EPSG,     "Lambert Conic Near Conformal"),
88
                new NamedIdentifier(CitationImpl.EPSG,     "Lambert Conic Near-Conformal"),
89
                new NamedIdentifier(CitationImpl.EPSG,     "Lambert_Conic_Near-Conformal"),
90
                new NamedIdentifier(CitationImpl.EPSG,     "9817"),
91
                new NamedIdentifier(CitationImpl.GEOTOOLS, Resources.formatInternational(
92
                							ResourceKeys.LAMBERT_CONFORMAL_PROJECTION))
93
            }, new ParameterDescriptor[] {
94
                SEMI_MAJOR,       SEMI_MINOR,
95
                CENTRAL_MERIDIAN, LATITUDE_OF_ORIGIN,
96
                SCALE_FACTOR,
97
                FALSE_EASTING,    FALSE_NORTHING
98
            });
99

  
100
		/*String[] parameterName={"central_meridian"};
101
		projectionParameterList.add(count,parameterName);
102
		addProjectionParameter(count,"standard_parallel_1");
103
		addProjectionParameter(count,"false_easting");
104
		addProjectionParameter(count,"false_northing");*/
105

  
106
        /**
107
         * Constructs a new provider.
108
         */
109
        public Provider() {
110
            super(PARAMETERS);
111
        }
112

  
113
        /**
114
         * Returns the operation type for this map projection.
115
         */
116
        protected Class getOperationType() {
117
        	return ConicProjection.class;
118
        }
119

  
120
        /**
121
         * Creates a transform from the specified group of parameter values.
122
         *
123
         * @param  parameters The group of parameter values.
124
         * @return The created math transform.
125
         * @throws ParameterNotFoundException if a required parameter was not found.
126
         */
127
        public MathTransform createMathTransform(final ParameterValueGroup parameters)
128
                throws ParameterNotFoundException
129
        {
130
            return new LambertConicNearConformal(parameters);
131
            //return null;
132
        	//return new EquidistantCylindrical(parameters);
133
        }
134
    }
135

  
136
}
branches/F2/libraries/libJCRS/src/org/geotools/referencing/operation/projection/AzimuthalEquidistant.java
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.referencing.operation.projection.Bonne.Provider;
29
import org.geotools.resources.XMath;
30
import org.geotools.resources.cts.ResourceKeys;
31
import org.geotools.resources.cts.Resources;
32
import org.opengis.parameter.ParameterDescriptor;
33
import org.opengis.parameter.ParameterDescriptorGroup;
34
import org.opengis.parameter.ParameterNotFoundException;
35
import org.opengis.parameter.ParameterValueGroup;
36
import org.opengis.referencing.operation.ConicProjection;
37
import org.opengis.referencing.operation.CylindricalProjection;
38
import org.opengis.referencing.operation.MathTransform;
39

  
40

  
41
public class AzimuthalEquidistant extends MapProjection {
42
    protected final double latitudeOfCenter;
43
    protected final double longitudeOfCenter;
44
    protected AzimuthalEquidistant(final ParameterValueGroup parameters) throws ParameterNotFoundException {
45
        super(parameters);
46
        final Collection expected = getParameterDescriptors().descriptors();
47
        if (expected.contains(Provider.LATITUDE_OF_CENTER)) {
48
        	latitudeOfCenter = Math.abs(doubleValue(expected,
49
                                        Provider.LATITUDE_OF_CENTER, parameters));
50
            ensureLatitudeInRange(Provider.LATITUDE_OF_CENTER, latitudeOfCenter, false);
51
        } else {
52
            // standard parallel is the equator (Plate Carree or Equirectangular)
53
        	latitudeOfCenter = Double.NaN;
54
        }
55
        if (expected.contains(Provider.LONGITUDE_OF_CENTER)) {
56
        	longitudeOfCenter = Math.abs(doubleValue(expected,
57
                                        Provider.LONGITUDE_OF_CENTER, parameters));
58
            ensureLongitudeInRange(Provider.LONGITUDE_OF_CENTER, longitudeOfCenter, false);
59
        } else {
60
            // standard parallel is the equator (Plate Carree or Equirectangular)
61
        	longitudeOfCenter = Double.NaN;
62
        }
63
    }
64

  
65
    /**
66
     * {@inheritDoc}
67
     */
68
    public ParameterDescriptorGroup getParameterDescriptors() {
69
        return Provider.PARAMETERS;
70
    }
71

  
72
    /**
73
     * {@inheritDoc}
74
     */
75
    public ParameterValueGroup getParameterValues() {
76
        final Collection expected = getParameterDescriptors().descriptors();
77
        final ParameterValueGroup values = super.getParameterValues();
78
        set(expected, Provider.LATITUDE_OF_CENTER,       values, latitudeOfCenter      );
79
        set(expected, Provider.LONGITUDE_OF_CENTER,      values, longitudeOfCenter       );
80
        return values;
81
    }
82

  
83
    /**
84
     * Transforms the specified (<var>&lambda;</var>,<var>&phi;</var>) coordinates
85
     * (units in radians) and stores the result in {@code ptDst} (linear distance
86
     * on a unit sphere).
87
     */
88
    protected Point2D transformNormalized(final double lambda, final double phi, Point2D ptDst)
89
            throws ProjectionException
90
    {
91
        return null;
92
    }
93

  
94
    /**
95
     * Transforms the specified (<var>x</var>,<var>y</var>) coordinate
96
     * and stores the result in {@code ptDst}.
97
     */
98
    protected Point2D inverseTransformNormalized(final double x, final double y, Point2D ptDst)
99
            throws ProjectionException
100
    {
101
        return null;
102
    }
103

  
104

  
105

  
106

  
107
    //////////////////////////////////////////////////////////////////////////////////////////
108
    //////////////////////////////////////////////////////////////////////////////////////////
109
    ////////                                                                          ////////
110
    ////////                                 PROVIDER                                 ////////
111
    ////////                                                                          ////////
112
    //////////////////////////////////////////////////////////////////////////////////////////
113
    //////////////////////////////////////////////////////////////////////////////////////////
114

  
115
    public static class Provider extends AbstractProvider {
116
        /**
117
         * The operation parameter descriptor for the {@linkPlain #latitudeOfOrigin
118
         * latitude of origin} parameter value. Valid values range is from -90 to 90.
119
         * Default value is 49.5.
120
         */
121
        public static final ParameterDescriptor LATITUDE_OF_CENTER = createDescriptor(
122
                new NamedIdentifier[] {
123
                    new NamedIdentifier(CitationImpl.OGC,     "latitude_of_center"),
124
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection center"),
125
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
126
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical latitude of origin"),
127
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of natural origin"),
128
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLat")
129
                }, 0.0, -90, 90, NonSI.DEGREE_ANGLE);
130

  
131
        /**
132
         * The operation parameter descriptor for the {@linkPlain #centralMeridian central
133
         * meridian} parameter value. Valid values range is from -180 to 180. Default value
134
         * is 2450' (= 4250' from Ferro prime meridian).
135
         */
136
        public static final ParameterDescriptor LONGITUDE_OF_CENTER = createDescriptor(
137
                new NamedIdentifier[] {
138
                    new NamedIdentifier(CitationImpl.OGC,     "longitude_of_center"),
139
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection center"),
140
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection centre"),
141
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical longitude of origin"),
142
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of natural origin"),
143
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLong")
144
                }, 0.0, -180, 180, NonSI.DEGREE_ANGLE);
145

  
146

  
147
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
148
            new NamedIdentifier(CitationImpl.OGC,     "Azimuthal_Equidistant"),
149
            new NamedIdentifier(CitationImpl.GEOTIFF, "AzimuthalEquidistant"),
150
            new NamedIdentifier(CitationImpl.EPSG,    "Azimuthal Equidistant")//,
151
                },
152
                new ParameterDescriptor[] {
153
                    SEMI_MAJOR, SEMI_MINOR,
154
                    LATITUDE_OF_CENTER, LONGITUDE_OF_CENTER,
155
                    FALSE_EASTING, FALSE_NORTHING
156
                });
157

  
158
        /**
159
         * Constructs a new provider. 
160
         */
161
        public Provider() {
162
            super(PARAMETERS);
163
        }
164

  
165
        protected Provider(final ParameterDescriptorGroup params) {
166
            super(params);
167
        }
168

  
169
        /**
170
         * Returns the operation type for this map projection.
171
         */
172
        protected Class getOperationType() {
173
            return ConicProjection.class;
174
        }
175

  
176
        /**
177
         * Creates a transform from the specified group of parameter values.
178
         *
179
         * @param parameters The group of parameter values.
180
         * @return The created math transform.
181
         * @throws ParameterNotFoundException if a required parameter was not found.
182
         */
183
        public MathTransform createMathTransform(final ParameterValueGroup parameters)
184
                throws ParameterNotFoundException
185
        {
186
            return new AzimuthalEquidistant(parameters);
187
        }
188
    }
189
	public static class Provider_Modified extends Provider {
190
        /**
191
         * The operation parameter descriptor for the {@linkPlain #latitudeOfOrigin
192
         * latitude of origin} parameter value. Valid values range is from -90 to 90.
193
         * Default value is 49.5.
194
         */
195
        public static final ParameterDescriptor LATITUDE_OF_CENTER = createDescriptor(
196
                new NamedIdentifier[] {
197
                    new NamedIdentifier(CitationImpl.OGC,     "latitude_of_center"),
198
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection center"),
199
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
200
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical latitude of origin"),
201
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of natural origin"),
202
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLat")
203
                }, 0.0, -90, 90, NonSI.DEGREE_ANGLE);
204

  
205
        /**
206
         * The operation parameter descriptor for the {@linkPlain #centralMeridian central
207
         * meridian} parameter value. Valid values range is from -180 to 180. Default value
208
         * is 2450' (= 4250' from Ferro prime meridian).
209
         */
210
        public static final ParameterDescriptor LONGITUDE_OF_CENTER = createDescriptor(
211
                new NamedIdentifier[] {
212
                    new NamedIdentifier(CitationImpl.OGC,     "longitude_of_center"),
213
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection center"),
214
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection centre"),
215
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical longitude of origin"),
216
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of natural origin"),
217
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLong")
218
                }, 0.0, -180, 180, NonSI.DEGREE_ANGLE);
219

  
220

  
221
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
222
            new NamedIdentifier(CitationImpl.OGC,     "Modified_Azimuthal_Equidistant"),
223
            new NamedIdentifier(CitationImpl.GEOTIFF, "ModifiedAzimuthalEquidistant"),
224
            new NamedIdentifier(CitationImpl.EPSG,    "Modified Azimuthal Equidistant")//,
225
                },
226
                new ParameterDescriptor[] {
227
                    SEMI_MAJOR, SEMI_MINOR,
228
                    LATITUDE_OF_CENTER, LONGITUDE_OF_CENTER,
229
                    FALSE_EASTING, FALSE_NORTHING
230
                });
231

  
232

  
233

  
234
	          /**
235
	         * Constructs a new provider.
236
	         */
237
	        public Provider_Modified() {
238
	            super(PARAMETERS);
239
	        }
240

  
241
	        /**
242
	         * Returns the operation type for this map projection.
243
	         */
244
	        protected Class getOperationType() {
245
	        	return CylindricalProjection.class;
246
	        }
247

  
248
	        /**
249
	         * Creates a transform from the specified group of parameter values.
250
	         *
251
	         * @param  parameters The group of parameter values.
252
	         * @return The created math transform.
253
	         * @throws ParameterNotFoundException if a required parameter was not found.
254
	         */
255
	        public MathTransform createMathTransform(final ParameterValueGroup parameters)
256
	                throws ParameterNotFoundException
257
	        {
258
	            //return null;
259
	        	return new AzimuthalEquidistant(parameters);
260
	        }
261
	    }
262
	public static class Provider_Guam extends Provider {
263
        /**
264
         * The operation parameter descriptor for the {@linkPlain #latitudeOfOrigin
265
         * latitude of origin} parameter value. Valid values range is from -90 to 90.
266
         * Default value is 49.5.
267
         */
268
        public static final ParameterDescriptor LATITUDE_OF_CENTER = createDescriptor(
269
                new NamedIdentifier[] {
270
                    new NamedIdentifier(CitationImpl.OGC,     "latitude_of_center"),
271
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection center"),
272
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
273
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical latitude of origin"),
274
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of natural origin"),
275
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLat")
276
                }, 0.0, -90, 90, NonSI.DEGREE_ANGLE);
277

  
278
        /**
279
         * The operation parameter descriptor for the {@linkPlain #centralMeridian central
280
         * meridian} parameter value. Valid values range is from -180 to 180. Default value
281
         * is 2450' (= 4250' from Ferro prime meridian).
282
         */
283
        public static final ParameterDescriptor LONGITUDE_OF_CENTER = createDescriptor(
284
                new NamedIdentifier[] {
285
                    new NamedIdentifier(CitationImpl.OGC,     "longitude_of_center"),
286
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection center"),
287
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of projection centre"),
288
                    new NamedIdentifier(CitationImpl.EPSG,    "Spherical longitude of origin"),
289
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of natural origin"),
290
                    new NamedIdentifier(CitationImpl.GEOTIFF, "CenterLong")
291
                }, 0.0, -180, 180, NonSI.DEGREE_ANGLE);
292

  
293

  
294
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
295
            new NamedIdentifier(CitationImpl.OGC,     "Guam Projection"),
296
            new NamedIdentifier(CitationImpl.EPSG,    "Guam"),
297
            new NamedIdentifier(CitationImpl.EPSG,    "Guam_Projection"),
298
            new NamedIdentifier(CitationImpl.EPSG,    "AzimuthalEquidistant_Guam"),
299
            new NamedIdentifier(CitationImpl.EPSG,    "Azimuthal Equidistant (Guam)")//,
300
                },
301
                new ParameterDescriptor[] {
302
                    SEMI_MAJOR, SEMI_MINOR,
303
                    LATITUDE_OF_CENTER, LONGITUDE_OF_CENTER,
304
                    FALSE_EASTING, FALSE_NORTHING
305
                });
306

  
307

  
308

  
309
	          /**
310
	         * Constructs a new provider.
311
	         */
312
	        public Provider_Guam() {
313
	            super(PARAMETERS);
314
	        }
315

  
316
	        /**
317
	         * Returns the operation type for this map projection.
318
	         */
319
	        protected Class getOperationType() {
320
	        	return CylindricalProjection.class;
321
	        }
322

  
323
	        /**
324
	         * Creates a transform from the specified group of parameter values.
325
	         *
326
	         * @param  parameters The group of parameter values.
327
	         * @return The created math transform.
328
	         * @throws ParameterNotFoundException if a required parameter was not found.
329
	         */
330
	        public MathTransform createMathTransform(final ParameterValueGroup parameters)
331
	                throws ParameterNotFoundException
332
	        {
333
	            //return null;
334
	        	return new AzimuthalEquidistant(parameters);
335
	        }
336
	    }
337

  
338
}
branches/F2/libraries/libJCRS/src/org/geotools/referencing/operation/projection/Gnomonic.java
1
package org.geotools.referencing.operation.projection;
2

  
3
import java.awt.geom.Point2D;
4
import java.util.Collection;
5

  
6
import javax.units.NonSI;
7

  
8
import org.geotools.metadata.iso.citation.CitationImpl;
9
import org.geotools.referencing.NamedIdentifier;
10
import org.geotools.referencing.operation.projection.MapProjection.AbstractProvider;
11
import org.opengis.parameter.ParameterDescriptor;
12
import org.opengis.parameter.ParameterDescriptorGroup;
13
import org.opengis.parameter.ParameterNotFoundException;
14
import org.opengis.parameter.ParameterValueGroup;
15
import org.opengis.referencing.operation.CylindricalProjection;
16
import org.opengis.referencing.operation.MathTransform;
17

  
18

  
19
public class Gnomonic extends MapProjection {
20

  
21
    private final double latitudeOfOrigin;
22

  
23
    protected Gnomonic(ParameterValueGroup parameters) throws ParameterNotFoundException {
24
		super(parameters);
25
        final Collection expected = getParameterDescriptors().descriptors();
26
        if (expected.contains(Provider.LATITUDE_OF_ORIGIN)) {
27
        	latitudeOfOrigin = Math.abs(doubleValue(expected,
28
                                        Provider.LATITUDE_OF_ORIGIN, parameters));
29
            ensureLatitudeInRange(Provider.LATITUDE_OF_ORIGIN, latitudeOfOrigin, false);
30
        } else {
31
            // standard parallel is the equator (Plate Carree or Equirectangular)
32
        	latitudeOfOrigin = Double.NaN;
33
        }
34
		// TODO Auto-generated constructor stub
35
	}
36

  
37
	
38
	public ParameterDescriptorGroup getParameterDescriptors() {
39
		// TODO Auto-generated method stub
40
        return Provider.PARAMETERS;
41
	}
42

  
43
    public ParameterValueGroup getParameterValues() {
44
        final ParameterValueGroup values = super.getParameterValues();
45
        if (!Double.isNaN(latitudeOfOrigin)) {
46
            final Collection expected = getParameterDescriptors().descriptors();
47
            set(expected,Provider.LATITUDE_OF_ORIGIN, values, latitudeOfOrigin);
48
        }
49
        return values;
50
    }
51

  
52
	protected Point2D inverseTransformNormalized(double x, double y,
53
			Point2D ptDst) throws ProjectionException {
54
		// TODO Auto-generated method stub
55
		return null;
56
	}
57

  
58
	protected Point2D transformNormalized(double x, double y, Point2D ptDst)
59
			throws ProjectionException {
60
		// TODO Auto-generated method stub
61
		return null;
62
	}
63
	public static class Provider extends AbstractProvider {
64

  
65
        public static final ParameterDescriptor LATITUDE_OF_ORIGIN = createDescriptor(
66
                new NamedIdentifier[] {
67
                    new NamedIdentifier(CitationImpl.OGC,     "latitude_of_origin"),
68
                    new NamedIdentifier(CitationImpl.EPSG,    "CenterLat"),
69
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
70
                    new NamedIdentifier(CitationImpl.GEOTIFF, "NatOriginLat"),
71
                    new NamedIdentifier(CitationImpl.EPSG,    "FalseOriginLat"),
72
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of false origin"),		
73
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of natural origin"),
74
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
75
                    new NamedIdentifier(CitationImpl.EPSG,    "ProjCenterLat")
76
                }, 0.0, -90.0, 90.0, NonSI.DEGREE_ANGLE);
77

  
78
        /**
79
         * The parameters group. Note the EPSG includes a "Latitude of natural origin" parameter instead
80
         * of "standard_parallel_1". I have sided with ESRI and Snyder in this case.
81
         */
82
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
83
                new NamedIdentifier(CitationImpl.OGC,      "Gnomonic"),
84
    			new NamedIdentifier(CitationImpl.EPSG,     "Gnomonic")//,
85
//                new NamedIdentifier(CitationImpl.GEOTOOLS, Vocabulary.formatInternational(
86
//                                    VocabularyKeys.EQUIDISTANT_CYLINDRICAL_PROJECTION))
87
            }, new ParameterDescriptor[] {
88
                SEMI_MAJOR,       SEMI_MINOR,
89
                CENTRAL_MERIDIAN, LATITUDE_OF_ORIGIN,
90
                FALSE_EASTING,    FALSE_NORTHING
91
            });
92

  
93
		/*String[] parameterName={"central_meridian"};
94
		projectionParameterList.add(count,parameterName);
95
		addProjectionParameter(count,"standard_parallel_1");
96
		addProjectionParameter(count,"false_easting");
97
		addProjectionParameter(count,"false_northing");*/
98

  
99
        /**
100
         * Constructs a new provider.
101
         */
102
        public Provider() {
103
            super(PARAMETERS);
104
        }
105

  
106
        /**
107
         * Returns the operation type for this map projection.
108
         */
109
        protected Class getOperationType() {
110
        	return CylindricalProjection.class;
111
        }
112

  
113
        /**
114
         * Creates a transform from the specified group of parameter values.
115
         *
116
         * @param  parameters The group of parameter values.
117
         * @return The created math transform.
118
         * @throws ParameterNotFoundException if a required parameter was not found.
119
         */
120
        public MathTransform createMathTransform(final ParameterValueGroup parameters)
121
                throws ParameterNotFoundException
122
        {
123
            return new Gnomonic(parameters);
124
        }
125
    }
126

  
127
}
branches/F2/libraries/libJCRS/src/org/geotools/referencing/operation/projection/Sinusoidal.java
1
package org.geotools.referencing.operation.projection;
2

  
3
import java.awt.geom.Point2D;
4
import java.util.Collection;
5

  
6
import javax.units.NonSI;
7

  
8
import org.geotools.metadata.iso.citation.CitationImpl;
9
import org.geotools.referencing.NamedIdentifier;
10
import org.geotools.referencing.operation.projection.MapProjection.AbstractProvider;
11
import org.opengis.parameter.ParameterDescriptor;
12
import org.opengis.parameter.ParameterDescriptorGroup;
13
import org.opengis.parameter.ParameterNotFoundException;
14
import org.opengis.parameter.ParameterValueGroup;
15
import org.opengis.referencing.operation.CylindricalProjection;
16
import org.opengis.referencing.operation.MathTransform;
17

  
18

  
19
public class Sinusoidal extends MapProjection {
20

  
21
    private final double longitudeOfCenter;
22

  
23
    protected Sinusoidal(ParameterValueGroup parameters) throws ParameterNotFoundException {
24
		super(parameters);
25
        final Collection expected = getParameterDescriptors().descriptors();
26
        if (expected.contains(Provider.LONGITUDE_OF_CENTER)) {
27
        	longitudeOfCenter = Math.abs(doubleValue(expected,
28
                                        Provider.LONGITUDE_OF_CENTER, parameters));
29
            ensureLatitudeInRange(Provider.LONGITUDE_OF_CENTER, longitudeOfCenter, false);
30
        } else {
31
            // standard parallel is the equator (Plate Carree or Equirectangular)
32
        	longitudeOfCenter = Double.NaN;
33
        }
34
		// TODO Auto-generated constructor stub
35
	}
36

  
37
	
38
	public ParameterDescriptorGroup getParameterDescriptors() {
39
		// TODO Auto-generated method stub
40
        return Provider.PARAMETERS;
41
	}
42

  
43
    public ParameterValueGroup getParameterValues() {
44
        final ParameterValueGroup values = super.getParameterValues();
45
        if (!Double.isNaN(longitudeOfCenter)) {
46
            final Collection expected = getParameterDescriptors().descriptors();
47
            set(expected,Provider.LONGITUDE_OF_CENTER, values, longitudeOfCenter);
48
        }
49
        return values;
50
    }
51

  
52
	protected Point2D inverseTransformNormalized(double x, double y,
53
			Point2D ptDst) throws ProjectionException {
54
		// TODO Auto-generated method stub
55
		return null;
56
	}
57

  
58
	protected Point2D transformNormalized(double x, double y, Point2D ptDst)
59
			throws ProjectionException {
60
		// TODO Auto-generated method stub
61
		return null;
62
	}
63
	public static class Provider extends AbstractProvider {
64

  
65
        public static final ParameterDescriptor LONGITUDE_OF_CENTER = createDescriptor(
66
                new NamedIdentifier[] {
67
                    new NamedIdentifier(CitationImpl.OGC,     "longitude_of_center"),
68
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of origin"),
69
                    new NamedIdentifier(CitationImpl.EPSG,    "Longitude of false origin"),
70
                    new NamedIdentifier(CitationImpl.GEOTIFF, "ProjCenterLong"),
71
                    new NamedIdentifier(CitationImpl.EPSG,    "NatOriginLong"),
72
                    new NamedIdentifier(CitationImpl.EPSG,    "central_meridian"),		
73
                    new NamedIdentifier(CitationImpl.EPSG,    "CenterLong")
74
                }, 0.0, -360.0, 360.0, NonSI.DEGREE_ANGLE);
75

  
76
        /**
77
         * The parameters group. Note the EPSG includes a "Latitude of natural origin" parameter instead
78
         * of "standard_parallel_1". I have sided with ESRI and Snyder in this case.
79
         */
80
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
81
                new NamedIdentifier(CitationImpl.OGC,      "Sinusoidal"),
82
    			new NamedIdentifier(CitationImpl.EPSG,     "Sinusoidal")//,
83
//                new NamedIdentifier(CitationImpl.GEOTOOLS, Vocabulary.formatInternational(
84
//                                    VocabularyKeys.EQUIDISTANT_CYLINDRICAL_PROJECTION))
85
            }, new ParameterDescriptor[] {
86
                SEMI_MAJOR,       SEMI_MINOR,
87
                LONGITUDE_OF_CENTER,
88
                FALSE_EASTING,    FALSE_NORTHING
89
            });
90

  
91
		/*String[] parameterName={"central_meridian"};
92
		projectionParameterList.add(count,parameterName);
93
		addProjectionParameter(count,"standard_parallel_1");
94
		addProjectionParameter(count,"false_easting");
95
		addProjectionParameter(count,"false_northing");*/
96

  
97
        /**
98
         * Constructs a new provider.
99
         */
100
        public Provider() {
101
            super(PARAMETERS);
102
        }
103

  
104
        /**
105
         * Returns the operation type for this map projection.
106
         */
107
        protected Class getOperationType() {
108
        	return CylindricalProjection.class;
109
        }
110

  
111
        /**
112
         * Creates a transform from the specified group of parameter values.
113
         *
114
         * @param  parameters The group of parameter values.
115
         * @return The created math transform.
116
         * @throws ParameterNotFoundException if a required parameter was not found.
117
         */
118
        public MathTransform createMathTransform(final ParameterValueGroup parameters)
119
                throws ParameterNotFoundException
120
        {
121
            return new Sinusoidal(parameters);
122
        }
123
    }
124

  
125
}
branches/F2/libraries/libJCRS/src/org/geotools/referencing/operation/projection/Mercator.java
1
/*
2
 * Geotools 2 - OpenSource mapping toolkit
3
 * (C) 2003, Geotools Project Managment Committee (PMC)
4
 * (C) 2001, Institut de Recherche pour le Dveloppement
5
 * (C) 1999, Fisheries and Oceans Canada
6
 *
7
 *    This library is free software; you can redistribute it and/or
8
 *    modify it under the terms of the GNU Lesser General Public
9
 *    License as published by the Free Software Foundation; either
10
 *    version 2.1 of the License, or (at your option) any later version.
11
 *
12
 *    This library is distributed in the hope that it will be useful,
13
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 *    Lesser General Public License for more details.
16
 *
17
 *    You should have received a copy of the GNU Lesser General Public
18
 *    License along with this library; if not, write to the Free Software
19
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 *
21
 *
22
 *    This package contains formulas from the PROJ package of USGS.
23
 *    USGS's work is fully acknowledged here.
24
 */
25
package org.geotools.referencing.operation.projection;
26

  
27
// J2SE dependencies and extensions
28
import java.awt.geom.Point2D;
29
import java.util.Collection;
30
import javax.units.NonSI;
31

  
32
// OpenGIS dependencies
33
import org.opengis.parameter.ParameterDescriptor;
34
import org.opengis.parameter.ParameterDescriptorGroup;
35
import org.opengis.parameter.ParameterNotFoundException;
36
import org.opengis.parameter.ParameterValueGroup;
37
import org.opengis.referencing.operation.CylindricalProjection;
38
import org.opengis.referencing.operation.MathTransform;
39

  
40
// Geotools dependencies
41
import org.geotools.measure.Latitude;
42
import org.geotools.metadata.iso.citation.CitationImpl;
43
import org.geotools.referencing.NamedIdentifier;
44
import org.geotools.referencing.operation.MathTransformProvider;
45
import org.geotools.resources.cts.ResourceKeys;
46
import org.geotools.resources.cts.Resources;
47

  
48

  
49
/**
50
 * Mercator Cylindrical Projection. The parallels and the meridians are straight lines and
51
 * cross at right angles; this projection thus produces rectangular charts. The scale is true
52
 * along the equator (by default) or along two parallels equidistant of the equator (if a scale
53
 * factor other than 1 is used). This projection is used to represent areas close to the equator.
54
 * It is also often used for maritime navigation because all the straight lines on the chart are
55
 * <em>loxodrome</em> lines, i.e. a ship following this line would keep a constant azimuth on its
56
 * compass.
57
 * <br><br>
58
 *
59
 * This implementation handles both the 1 and 2 stardard parallel cases.
60
 * For <code>Mercator_1SP</code> (EPSG code 9804), the line of contact is the equator. 
61
 * For <code>Mercator_2SP</code> (EPSG code 9805) lines of contact are symmetrical 
62
 * about the equator.
63
 * <br><br>
64
 *
65
 * <strong>References:</strong><ul>
66
 *   <li>John P. Snyder (Map Projections - A Working Manual,<br>
67
 *       U.S. Geological Survey Professional Paper 1395, 1987)</li>
68
 *   <li>"Coordinate Conversions and Transformations including Formulas",<br>
69
 *       EPSG Guidence Note Number 7, Version 19.</li>
70
 * </ul>
71
 *
72
 * @see <A HREF="http://mathworld.wolfram.com/MercatorProjection.html">Mercator projection on MathWorld</A>
73
 * @see <A HREF="http://www.remotesensing.org/geotiff/proj_list/mercator_1sp.html">"mercator_1sp" on Remote Sensing</A>
74
 * @see <A HREF="http://www.remotesensing.org/geotiff/proj_list/mercator_2sp.html">"mercator_2sp" on Remote Sensing</A>
75
 * 
76
 * @version $Id$
77
 * @author Andr Gosselin
78
 * @author Martin Desruisseaux
79
 * @author Rueben Schulz
80
 */
81
public class Mercator extends MapProjection {
82
    /**
83
     * Standard Parallel used for the <code>Mercator_2SP</code> case.
84
     * Set to {@link Double#NaN} for the <code>Mercator_1SP</code> case.
85
     */
86
    protected final double standardParallel;
87
    //protected final double latitudeOfOrigin;
88

  
89
    /**
90
     * The {@link MathTransformProvider} for a {@link Mercator} 1SP projection.
91
     *
92
     * @see <A HREF="http://www.remotesensing.org/geotiff/proj_list/mercator_1sp.html">"mercator_1sp" on Remote Sensing</A>
93
     * @see org.geotools.referencing.operation.DefaultMathTransformFactory
94
     *
95
     * @version $Id$
96
     * @author Martin Desruisseaux
97
     * @author Rueben Schulz
98
     */
99
    public static final class Provider1SP extends AbstractProvider {
100
        /**
101
         * The parameters group.
102
         */
103
    	public static final ParameterDescriptor LATITUDE_OF_ORIGIN = createDescriptor(
104
                new NamedIdentifier[] {
105
                    new NamedIdentifier(CitationImpl.OGC,     "latitude_of_origin"),
106
                    new NamedIdentifier(CitationImpl.EPSG,    "CenterLat"),
107
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
108
                    new NamedIdentifier(CitationImpl.GEOTIFF, "NatOriginLat"),
109
                    new NamedIdentifier(CitationImpl.EPSG,    "FalseOriginLat"),
110
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of false origin"),		
111
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of natural origin"),
112
                    new NamedIdentifier(CitationImpl.EPSG,    "Latitude of projection centre"),
113
                    new NamedIdentifier(CitationImpl.EPSG,    "ProjCenterLat")
114
                }, 0.0, -90.0, 90.0, NonSI.DEGREE_ANGLE);
115

  
116
    	static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
117
                new NamedIdentifier(CitationImpl.OGC,      "Mercator_1SP"),
118
                new NamedIdentifier(CitationImpl.EPSG,     "Mercator (1SP)"),
119
                new NamedIdentifier(CitationImpl.EPSG,     "9804"),
120
                new NamedIdentifier(CitationImpl.GEOTIFF,  "CT_Mercator"),
121
                new NamedIdentifier(CitationImpl.GEOTOOLS, Resources.formatInternational(
122
                                                           ResourceKeys.CYLINDRICAL_MERCATOR_PROJECTION))
123
            }, new ParameterDescriptor[] {
124
                SEMI_MAJOR,       SEMI_MINOR,
125
                CENTRAL_MERIDIAN, SCALE_FACTOR,
126
                LATITUDE_OF_ORIGIN,
127
                FALSE_EASTING,    FALSE_NORTHING
128
            });
129

  
130
        /**
131
         * Constructs a new provider. 
132
         */
133
        public Provider1SP() {
134
            super(PARAMETERS);
135
        }
136

  
137
        /**
138
         * Returns the operation type for this map projection.
139
         */
140
        protected 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
        public MathTransform createMathTransform(final ParameterValueGroup parameters)
152
                throws ParameterNotFoundException
153
        {
154
            final Collection descriptors = PARAMETERS.descriptors();
155
            if (isSpherical(parameters)) {
156
                return new Spherical(parameters, descriptors);
157
            } else {
158
                return new Mercator (parameters, descriptors);
159
            }
160
        }
161
    }
162

  
163
    /**
164
     * The {@link MathTransformProvider} for a {@link Mercator} 2SP projection.
165
     *
166
     * @see <A HREF="http://www.remotesensing.org/geotiff/proj_list/mercator_2sp.html">"mercator_2sp" on Remote Sensing</A>
167
     * @see org.geotools.referencing.operation.DefaultMathTransformFactory
168
     *
169
     * @version $Id$
170
     * @author Martin Desruisseaux
171
     * @author Rueben Schulz
172
     */
173
    public static final class Provider2SP extends AbstractProvider {
174
        /**
175
         * The operation parameter descriptor for the {@link #standardParallel standard parallel}
176
         * parameter value. Valid values range is from -90 to 90. Default value is 0.
177
         */
178
        public static final ParameterDescriptor STANDARD_PARALLEL = createDescriptor(
179
                new NamedIdentifier[] {
180
                    new NamedIdentifier(CitationImpl.OGC,      "standard_parallel_1"),
181
                    new NamedIdentifier(CitationImpl.EPSG,     "Latitude of 1st standard parallel"),
182
                    new NamedIdentifier(CitationImpl.GEOTIFF,  "StdParallel1")
183
                },
184
                0, -90, 90, NonSI.DEGREE_ANGLE);
185

  
186
        /**
187
         * The parameters group.
188
         */
189
        static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup(new NamedIdentifier[] {
190
                new NamedIdentifier(CitationImpl.OGC,      "Mercator_2SP"),
191
                new NamedIdentifier(CitationImpl.EPSG,     "Mercator (2SP)"),
192
                new NamedIdentifier(CitationImpl.EPSG,     "9805"),
193
                new NamedIdentifier(CitationImpl.GEOTIFF,  "CT_Mercator"),
194
                new NamedIdentifier(CitationImpl.ESRI,     "Mercator"),
195
                new NamedIdentifier(CitationImpl.GEOTOOLS, Resources.formatInternational(
196
                                                           ResourceKeys.CYLINDRICAL_MERCATOR_PROJECTION))
197
            }, new ParameterDescriptor[] {
198
                SEMI_MAJOR,       SEMI_MINOR,
199
                CENTRAL_MERIDIAN, STANDARD_PARALLEL,
200
                FALSE_EASTING,    FALSE_NORTHING
201
            });
202

  
203
        /**
204
         * Constructs a new provider. 
205
         */
206
        public Provider2SP() {
207
            super(PARAMETERS);
208
        }
209

  
210
        /**
211
         * Returns the operation type for this map projection.
212
         */
213
        protected Class getOperationType() {
214
            return CylindricalProjection.class;
215
        }
216

  
217
        /**
218
         * Creates a transform from the specified group of parameter values.
219
         *
220
         * @param  parameters The group of parameter values.
221
         * @return The created math transform.
222
         * @throws ParameterNotFoundException if a required parameter was not found.
223
         */
224
        public MathTransform createMathTransform(final ParameterValueGroup parameters)
225
                throws ParameterNotFoundException
226
        {
227
            final Collection descriptors = PARAMETERS.descriptors();
228
            if (isSpherical(parameters)) {
229
                return new Spherical(parameters, descriptors);
230
            } else {
231
                return new Mercator (parameters, descriptors);
232
            }
233
        }
234
    }
235

  
236

  
237
    /**
238
     * Constructs a new map projection from the supplied parameters.
239
     *
240
     * @param  parameters The parameter values in standard units.
241
     * @throws ParameterNotFoundException if a mandatory parameter is missing.
242
     */
243
    protected Mercator(final ParameterValueGroup parameters)
244
            throws ParameterNotFoundException
245
    {
246
        this(parameters, getDescriptor(parameters).descriptors());
247
    }
248

  
249
    /**
250
     * Work around for RFE #4093999 in Sun's bug database
251
     * ("Relax constraint on placement of this()/super() call in constructors").
252
     */
253
    private static ParameterDescriptorGroup getDescriptor(final ParameterValueGroup parameters) {
254
        try {
255
            parameters.parameter(Provider2SP.STANDARD_PARALLEL.getName().getCode());
256
            return Provider2SP.PARAMETERS;
257
        } catch (ParameterNotFoundException ignore) {
258
            return Provider1SP.PARAMETERS;
259
        }
260
    }
261

  
262
    /**
263
     * Constructs a new map projection from the supplied parameters.
264
     *
265
     * @param  parameters The parameter values in standard units.
266
     * @param  expected The expected parameter descriptors.
267
     * @throws ParameterNotFoundException if a mandatory parameter is missing.
268
     */
269
    Mercator(final ParameterValueGroup parameters, final Collection expected)
270
            throws ParameterNotFoundException
271
    {
272
        //Fetch parameters 
273
        super(parameters, expected);
274
        if (expected.contains(Provider2SP.STANDARD_PARALLEL)) {
275
            // scaleFactor is not a parameter in the Mercator_2SP case and is computed from
276
            // the standard parallel.   The super-class constructor should have initialized
277
            // 'scaleFactor' to 1. We still use the '*=' operator rather than '=' in case a
278
            // user implementation still provides a scale factor for its custom projections.
279
            standardParallel = Math.abs(doubleValue(expected,
280
                                        Provider2SP.STANDARD_PARALLEL, parameters));
281
            ensureLatitudeInRange(Provider2SP.STANDARD_PARALLEL, standardParallel, false);
282
            if (isSpherical) {
283
                scaleFactor *= Math.cos(standardParallel);
284
            }  else {
285
                scaleFactor *= msfn(Math.sin(standardParallel),
286
                                    Math.cos(standardParallel));
287
            }
288
            globalScale = scaleFactor*semiMajor;
289
        } else {
290
            // No standard parallel. Instead, uses the scale factor explicitely provided.
291
            standardParallel = Double.NaN;
292
        }
293
        //assert latitudeOfOrigin == 0 : latitudeOfOrigin;
294
    }
295

  
296
    /**
297
     * {@inheritDoc}
298
     */
299
    public ParameterDescriptorGroup getParameterDescriptors() {
300
        return Double.isNaN(standardParallel) ? Provider1SP.PARAMETERS
301
                                              : Provider2SP.PARAMETERS;
302
    }
303

  
304
    /**
305
     * {@inheritDoc}
306
     */
307
    public ParameterValueGroup getParameterValues() {
308
        final ParameterValueGroup values = super.getParameterValues();
309
        if (!Double.isNaN(standardParallel)) {
310
            final Collection expected = getParameterDescriptors().descriptors();
311
            set(expected, Provider2SP.STANDARD_PARALLEL, values, standardParallel);
312
        }
313
        return values;
314
    }
315
    
316
    /**
317
     * Transforms the specified (<var>x</var>,<var>y</var>) coordinate (units in radians)
318
     * and stores the result in <code>ptDst</code> (linear distance on a unit sphere).
319
     */
320
    protected Point2D transformNormalized(double x, double y, final Point2D ptDst)
321
            throws ProjectionException
322
    {
323
        if (Math.abs(y) > (Math.PI/2 - EPS)) {
324
            throw new ProjectionException(Resources.format(
325
                    ResourceKeys.ERROR_POLE_PROJECTION_$1, new Latitude(Math.toDegrees(y))));
326
        }
327

  
328
        y = - Math.log(tsfn(y, Math.sin(y)));
329

  
330
        if (ptDst != null) {
331
            ptDst.setLocation(x,y);
332
            return ptDst;
333
        }
334
        return new Point2D.Double(x,y);
335
    }
336
    
337
    /**
338
     * Transforms the specified (<var>x</var>,<var>y</var>) coordinate
339
     * and stores the result in <code>ptDst</code>.
340
     */
341
    protected Point2D inverseTransformNormalized(double x, double y, final Point2D ptDst)
342
            throws ProjectionException
343
    {
344
        y = Math.exp(-y);
345
        y = cphi2(y);
346

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff