Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.projection / org.gvsig.projection.cresques / org.gvsig.projection.cresques.impl / src / main / java / org / cresques / impl / geo / Ellipsoid.java @ 40559

History | View | Annotate | Download (3.98 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program 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
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.cresques.impl.geo;
25

    
26
import org.cresques.cts.IDatum;
27

    
28

    
29
public class Ellipsoid implements IDatum {
30
    //'WGS72':        (6378135.0, 298.26, 1972),
31
    public static final Ellipsoid wgs72 = new Ellipsoid("WGS72", 6378135.0,
32
                                                        298.26);
33

    
34
    //'WGS84':        (6378137.0, 298.257223563, 1984),
35
    public static final Ellipsoid wgs84 = new Ellipsoid("WGS84", 6378137.0,
36
                                                        298.257223563);
37

    
38
    //'GRS80':        (6378137.0, 298.257222101, 1980), // , 6356752.314
39
    public static final Ellipsoid grs80 = new Ellipsoid("GRS80", 6378137.0,
40
                                                        298.257222101);
41

    
42
    //'Hayford':        (6378388.0, 297.0, 1909),
43
    public static final Ellipsoid hayford = new Ellipsoid("Hayford", 6378388.0,
44
                                                          297.0);
45

    
46
    //'Struve':        (6378298.0, 299.73, 1860),
47
    public static final Ellipsoid struve = new Ellipsoid("Struve", 6378298.0,
48
                                                         299.73);
49

    
50
    // ed50 ... ?hayford?
51
    public static final Ellipsoid ed50 = new Ellipsoid("ED50", 6378388.0, 297.0);
52

    
53
    // Clarcke 1866        a = 6378206.4;        f = 294.9786982;
54
    public static final Ellipsoid clarke66 = new Ellipsoid("CLARKE 1866",
55
                                                           6378206.4,
56
                                                           294.9786982);
57
    private String pName = null;
58
    private double pMajor = 0.0;
59
    private double pFlat = 0.0;
60
    public double a;
61
    public double b;
62
    public double f;
63
    public double e;
64
    public double e2;
65
    public double ep;
66
    public double ep2;
67

    
68
    public Ellipsoid(String name, double major, double flat) {
69
        pName = name;
70
        pMajor = major;
71
        pFlat = flat;
72
        a = pMajor;
73
        f = pFlat;
74
        ainvto();
75
    }
76

    
77
    public String getName() {
78
        return pName;
79
    }
80

    
81
    private void ainvto() {
82
        b = (a * (pFlat - 1.0D)) / pFlat;
83
        e2 = ((2D * pFlat) - 1.0D) / (pFlat * pFlat);
84
        e = Math.sqrt(e2);
85
        ep2 = e2 / (1.0D - e2);
86
        ep = Math.sqrt(ep2);
87
    }
88

    
89
    private void abto() {
90
        if (Math.abs(a - b) < 9.9999999999999995E-021D) {
91
            pFlat = 0.0D;
92
            e2 = 0.0D;
93
        } else {
94
            pFlat = a / (a - b);
95
            e2 = ((2D * pFlat) - 1.0D) / (pFlat * pFlat);
96
        }
97

    
98
        e = Math.sqrt(e2);
99
        ep2 = e2 / (1.0D - e2);
100
        ep = Math.sqrt(ep2);
101
    }
102

    
103
    public double[] getParam() {
104
        double[] elipar = new double[8];
105
        elipar[1] = pMajor;
106
        elipar[2] = pFlat;
107
        elipar[3] = b;
108
        elipar[4] = e;
109
        elipar[5] = e2;
110
        elipar[6] = ep;
111
        elipar[7] = ep2;
112

    
113
        return elipar;
114
    }
115

    
116
    /* (non-Javadoc)
117
     * @see org.cresques.cts.IDatum#getSemiMajorAxis()
118
     */
119
    public double getESemiMajorAxis() {
120
        return pMajor;
121
    }
122

    
123
    /* (non-Javadoc)
124
     * @see org.cresques.cts.IDatum#getEIFlattening()
125
     */
126
    public double getEIFlattening() {
127
        return pFlat;
128
    }
129
}