svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / geo / Ellipsoid.java @ 2312
History | View | Annotate | Download (3.09 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
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 2
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.geo; |
25 |
|
26 |
import org.cresques.cts.IDatum; |
27 |
|
28 |
public class Ellipsoid implements IDatum { |
29 |
//'WGS72': (6378135.0, 298.26, 1972),
|
30 |
public static final Ellipsoid wgs72 = new Ellipsoid("WGS72", 6378135.0, 298.26); |
31 |
//'WGS84': (6378137.0, 298.257223563, 1984),
|
32 |
public static final Ellipsoid wgs84 = new Ellipsoid("WGS84", 6378137.0, 298.257223563); |
33 |
//'GRS80': (6378137.0, 298.257222101, 1980), // , 6356752.314
|
34 |
public static final Ellipsoid grs80 = new Ellipsoid("GRS80", 6378137.0, 298.257222101); |
35 |
//'Hayford': (6378388.0, 297.0, 1909),
|
36 |
public static final Ellipsoid hayford = new Ellipsoid("Hayford", 6378388.0, 297.0); |
37 |
//'Struve': (6378298.0, 299.73, 1860),
|
38 |
public static final Ellipsoid struve = new Ellipsoid("Struve", 6378298.0, 299.73); |
39 |
// ed50 ... ?hayford?
|
40 |
public static final Ellipsoid ed50 = new Ellipsoid("ED50", 6378388.0, 297.0); |
41 |
// Clarcke 1866 a = 6378206.4; f = 294.9786982;
|
42 |
public static final Ellipsoid clarke66 = new Ellipsoid("CLARKE 1866", 6378206.4, 294.9786982); |
43 |
|
44 |
|
45 |
private String pName = null; |
46 |
private double pMajor = 0.0; |
47 |
private double pFlat = 0.0; |
48 |
public double a, b, f, e, e2, ep, ep2; |
49 |
public Ellipsoid(String name, double major, double flat) { |
50 |
pName = name; |
51 |
pMajor = major; |
52 |
pFlat = flat; |
53 |
a = pMajor; |
54 |
f = pFlat; |
55 |
ainvto(); |
56 |
} |
57 |
public String getName() { return pName; } |
58 |
private void ainvto() |
59 |
{ |
60 |
b = (a * (pFlat - 1.0D)) / pFlat;
|
61 |
e2 = (2D * pFlat - 1.0D) / (pFlat * pFlat); |
62 |
e = Math.sqrt(e2);
|
63 |
ep2 = e2 / (1.0D - e2);
|
64 |
ep = Math.sqrt(ep2);
|
65 |
} |
66 |
|
67 |
private void abto() |
68 |
{ |
69 |
if(Math.abs(a - b) < 9.9999999999999995E-021D) |
70 |
{ |
71 |
pFlat = 0.0D;
|
72 |
e2 = 0.0D;
|
73 |
} else
|
74 |
{ |
75 |
pFlat = a / (a - b); |
76 |
e2 = (2D * pFlat - 1.0D) / (pFlat * pFlat); |
77 |
} |
78 |
e = Math.sqrt(e2);
|
79 |
ep2 = e2 / (1.0D - e2);
|
80 |
ep = Math.sqrt(ep2);
|
81 |
} |
82 |
|
83 |
public double [] getParam() { |
84 |
double [] elipar = new double[8]; |
85 |
elipar[1] = pMajor;
|
86 |
elipar[2] = pFlat;
|
87 |
elipar[3] = b;
|
88 |
elipar[4] = e;
|
89 |
elipar[5] = e2;
|
90 |
elipar[6] = ep;
|
91 |
elipar[7] = ep2;
|
92 |
return elipar;
|
93 |
} |
94 |
/* (non-Javadoc)
|
95 |
* @see org.cresques.cts.IDatum#getSemiMajorAxis()
|
96 |
*/
|
97 |
public double getESemiMajorAxis() { |
98 |
return pMajor;
|
99 |
} |
100 |
/* (non-Javadoc)
|
101 |
* @see org.cresques.cts.IDatum#getEIFlattening()
|
102 |
*/
|
103 |
public double getEIFlattening() { |
104 |
return pFlat;
|
105 |
} |
106 |
} |