Statistics
| Revision:

root / org.gvsig.jcrs / libJCRS / src / org / geotools / referencing / operation / projection / IdrEquirectangular.java @ 38

History | View | Annotate | Download (5.59 KB)

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 IdrEquirectangular extends MapProjection {
20

    
21
    private final double latitudeOfOrigin;
22

    
23
    protected IdrEquirectangular(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,      "Equirectangular"),
84
                            new NamedIdentifier(CitationImpl.EPSG,     "Plate Caree"),
85
                new NamedIdentifier(CitationImpl.EPSG,     "Equidistant Cylindrical"),
86
                new NamedIdentifier(CitationImpl.EPSG,     "9823"),
87
                new NamedIdentifier(new CitationImpl("IDR"), "IDR")//,
88
//                new NamedIdentifier(CitationImpl.GEOTOOLS, Vocabulary.formatInternational(
89
//                                    VocabularyKeys.EQUIDISTANT_CYLINDRICAL_PROJECTION))
90
            }, new ParameterDescriptor[] {
91
                SEMI_MAJOR,       SEMI_MINOR,
92
                CENTRAL_MERIDIAN, LATITUDE_OF_ORIGIN,
93
                FALSE_EASTING,    FALSE_NORTHING
94
            });
95

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

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

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

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

    
132
}