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 / cts / gt2 / CSDatum.java @ 40559
History | View | Annotate | Download (9.17 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40455 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40455 | jjdelcerro | *
|
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 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40455 | jjdelcerro | * 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 | 40559 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | * MA 02110-1301, USA.
|
||
20 | 40455 | jjdelcerro | *
|
21 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40455 | jjdelcerro | */
|
24 | package org.cresques.impl.cts.gt2; |
||
25 | |||
26 | import java.util.Locale; |
||
27 | |||
28 | import org.cresques.cts.IDatum; |
||
29 | import org.geotools.cs.CoordinateSystemFactory; |
||
30 | import org.geotools.cs.GeographicCoordinateSystem; |
||
31 | import org.geotools.cs.HorizontalDatum; |
||
32 | import org.opengis.referencing.FactoryException; |
||
33 | |||
34 | |||
35 | /**
|
||
36 | * Datum (y Ellipsoid) de GeoTools2.
|
||
37 | *
|
||
38 | * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
||
39 | */
|
||
40 | public class CSDatum implements IDatum { |
||
41 | private static String line1 = "DATUM[\"WGS_1984\"," + |
||
42 | "SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]]," +
|
||
43 | "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]]";
|
||
44 | private static String line2 = "DATUM[\"European_Datum_1950\"," + |
||
45 | "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
|
||
46 | "TOWGS84[-84,-107,-120,0,0,0,0],AUTHORITY[\"EPSG\",\"6230\"]]";
|
||
47 | private static String line3 = "DATUM[\"Nouvelle_Triangulation_Francaise\"," + |
||
48 | "SPHEROID[\"Clarke 1880 (IGN)\",6378249.2,293.466021293627, AUTHORITY[\"EPSG\",\"7011\"]]," +
|
||
49 | "TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY[\"EPSG\",\"6275\"]]";
|
||
50 | private static String line4 = "DATUM[\"Datum 73\"," + |
||
51 | "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
|
||
52 | "TOWGS84[-87,-98,-121,0,0,0,0],AUTHORITY[\"EPSG\",\"4274\"]]";
|
||
53 | private static String line5 = "DATUM[\"North_American_Datum_1927\"," + |
||
54 | "SPHEROID[\"Clarke 1866\",6378206.4,294.978698213901,AUTHORITY[\"EPSG\",\"7008\"]]," +
|
||
55 | "TOWGS84[-3,142,183,0,0,0,0],AUTHORITY[\"EPSG\",\"6267\"]]";
|
||
56 | private static String line6 = "DATUM[\"North_American_Datum_1983\"," + |
||
57 | "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]," +
|
||
58 | "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6269\"]]";
|
||
59 | |||
60 | /*
|
||
61 | * INSERT INTO epsg_coordinatereferencesystem VALUES (
|
||
62 | * 4288, 'Loma Quintana', 1313, 'geographic 2D', 6422, 6288,
|
||
63 | * Null, Null, Null, Null, 'Geodetic survey.',
|
||
64 | * 'Superseded by La Canoa (code 4247).', '',
|
||
65 | * 'EPSG', '2004/01/06', '2003.37', 1, 0 );
|
||
66 | *
|
||
67 | * DX (m) = -270.933
|
||
68 | DY (m) = 115.599
|
||
69 | DZ (m) = -360.226
|
||
70 | |||
71 | EX (") = -5.266
|
||
72 | EY (") = -1.238
|
||
73 | EZ (") = 2.381
|
||
74 | FE (ppm) = -5.109
|
||
75 | */
|
||
76 | private static String line7 = "DATUM[\"Loma Quintana\"," + |
||
77 | "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
|
||
78 | "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6288\"]]";
|
||
79 | |||
80 | /*
|
||
81 | # La Canoa
|
||
82 | <4247> +proj=longlat +ellps=intl +towgs84=-273.5,110.6,-357.9,0,0,0,0
|
||
83 | no_defs <>
|
||
84 | # PSAD56
|
||
85 | <4248> +proj=longlat +ellps=intl +towgs84=-288,175,-376,0,0,0,0 no_defs <>
|
||
86 | */
|
||
87 | private static String line8 = "DATUM[\"La Canoa\"," + |
||
88 | "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
|
||
89 | "TOWGS84[-270.933,115.599,-360.226,-5.266,-1.238,2.381,-5.109],AUTHORITY[\"EPSG\",\"6288\"]]";
|
||
90 | private static String line9 = "GEOGCS[\"NTF (Paris)\","+ |
||
91 | "DATUM[\"Nouvelle_Triangulation_Francaise_Paris\"," +
|
||
92 | "SPHEROID[\"Clarke 1880 (IGN)\",6378249.2,293.4660212936269,AUTHORITY[\"EPSG\",\"7011\"]]," +
|
||
93 | "TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY[\"EPSG\",\"8903\"]]"+
|
||
94 | ",PRIMEM[\"Paris\",2.33722917,AUTHORITY[\"EPSG\",\"8903\"]]," +
|
||
95 | "UNIT[\"grad\",0.01570796326794897,AUTHORITY[\"EPSG\",\"9105\"]]," +
|
||
96 | "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
|
||
97 | "AUTHORITY[\"EPSG\",\"4807\"]]";
|
||
98 | |||
99 | private static String line10 = "GEOGCS[\"RGF93\"," + |
||
100 | "DATUM[\"Reseau Geodesique Francais 1993\"," +
|
||
101 | "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]," +
|
||
102 | "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6171\"]],"+
|
||
103 | "PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," +
|
||
104 | "UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," +
|
||
105 | "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
|
||
106 | "AUTHORITY[\"EPSG\",\"4171\"]]";
|
||
107 | private static String line11 = "GEOGCS[\"ETRS89\","+ |
||
108 | "DATUM[\"European_Terrestrial_Reference_System_1989\","+
|
||
109 | "SPHEROID[\"GRS 1980\",6378137,298.257222101,"+
|
||
110 | "AUTHORITY[\"EPSG\",\"7019\"]],"+
|
||
111 | "AUTHORITY[\"EPSG\",\"6258\"]],"+
|
||
112 | "PRIMEM[\"Greenwich\",0,"+
|
||
113 | "AUTHORITY[\"EPSG\",\"8901\"]],"+
|
||
114 | "UNIT[\"degree\",0.01745329251994328,"+
|
||
115 | "AUTHORITY[\"EPSG\",\"9122\"]],"+
|
||
116 | "AUTHORITY[\"EPSG\",\"4258\"]]";
|
||
117 | //," +
|
||
118 | //"TOWGS84[0,0,0,0,0,0,0]
|
||
119 | private static String line12 = |
||
120 | "GEOGCS[\"Mars 2000\","+
|
||
121 | "DATUM[\"D_Mars_2000\","+
|
||
122 | "SPHEROID[\"Mars_2000_IAU_IAG\",3396190.0, 169.89444722361179],"+
|
||
123 | "TOWGS84[0,0,0,0,0,0,0]],"+
|
||
124 | "PRIMEM[\"Greenwich\",0],"+
|
||
125 | "UNIT[\"Decimal_Degree\",0.0174532925199433]]";
|
||
126 | |||
127 | public final static CSDatum wgs84 = new CSDatum(line1); |
||
128 | public final static CSDatum ed50 = new CSDatum(line2); |
||
129 | public final static CSDatum ntf = new CSDatum(line3); |
||
130 | public final static CSDatum d73 = new CSDatum(line4); |
||
131 | public final static CSDatum nad27 = new CSDatum(line5); |
||
132 | public final static CSDatum nad83 = new CSDatum(line6); |
||
133 | public final static CSDatum lomaQuintana = new CSDatum(line7); |
||
134 | public final static CSDatum laCanoa = new CSDatum(line8); |
||
135 | public static CSDatum etrs89 = null; |
||
136 | public static CSDatum ntfParis = null; |
||
137 | public static CSDatum posgar = null; |
||
138 | public static CSDatum rgf93 = null; |
||
139 | public static CSDatum mars = null; |
||
140 | public static CSDatum moon = null; |
||
141 | private String sGeo1 = "GEOGCS[\"WGS 84\","; |
||
142 | private String sGeo2 = |
||
143 | ",PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," +
|
||
144 | "UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," +
|
||
145 | "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
|
||
146 | "AUTHORITY[\"EPSG\",\"4326\"]]";
|
||
147 | private HorizontalDatum datum = null; |
||
148 | static {
|
||
149 | try {
|
||
150 | ntfParis = new CSDatum().fromWKT(line9);
|
||
151 | rgf93 = new CSDatum().fromWKT(line10);
|
||
152 | etrs89 = new CSDatum().fromWKT(line11);
|
||
153 | posgar = new CSDatum().fromWKT(
|
||
154 | "GEOGCS[\"POSGAR\","+
|
||
155 | "DATUM[\"POSGAR\"," +
|
||
156 | "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]," +
|
||
157 | "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6269\"]]"+
|
||
158 | ",PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," +
|
||
159 | "UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," +
|
||
160 | "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
|
||
161 | "AUTHORITY[\"EPSG\",\"4172\"]]");
|
||
162 | mars = new CSDatum().fromWKT(line12);
|
||
163 | moon = new CSDatum().fromWKT(
|
||
164 | "GEOGCS[\"Moon 2000\"," +
|
||
165 | "DATUM[\"D_Moon_2000\"," +
|
||
166 | "SPHEROID[\"Moon_2000_IAU_IAG\",1737400.0, 0.0]," +
|
||
167 | "TOWGS84[0,0,0,0,0,0,0]],"+
|
||
168 | "PRIMEM[\"Greenwich\",0]," +
|
||
169 | "UNIT[\"Decimal_Degree\",0.0174532925199433]]");
|
||
170 | } catch (FactoryException e) {
|
||
171 | // TODO Auto-generated catch block
|
||
172 | e.printStackTrace(); |
||
173 | } |
||
174 | } |
||
175 | |||
176 | public CSDatum() {
|
||
177 | } |
||
178 | |||
179 | public CSDatum(HorizontalDatum datum) {
|
||
180 | this.datum = datum;
|
||
181 | } |
||
182 | |||
183 | public CSDatum(String sDatum) { |
||
184 | try {
|
||
185 | fromWKT(sGeo1 + sDatum + sGeo2); |
||
186 | } catch (FactoryException e) {
|
||
187 | // TODO Bloque catch generado autom?ticamente
|
||
188 | e.printStackTrace(); |
||
189 | } |
||
190 | } |
||
191 | |||
192 | public CSDatum fromWKT(String s) throws FactoryException { |
||
193 | datum = ((GeographicCoordinateSystem) CoordinateSystemFactory.getDefault() |
||
194 | .createFromWKT(s)).getHorizontalDatum(); |
||
195 | return this; |
||
196 | } |
||
197 | |||
198 | public String getName(Locale loc) { |
||
199 | return datum.getName().toString();
|
||
200 | } |
||
201 | |||
202 | HorizontalDatum getDatum() { |
||
203 | return datum;
|
||
204 | } |
||
205 | |||
206 | public double getESemiMajorAxis() { |
||
207 | return datum.getEllipsoid().getSemiMajorAxis();
|
||
208 | } |
||
209 | |||
210 | public double getEIFlattening() { |
||
211 | return datum.getEllipsoid().getInverseFlattening();
|
||
212 | } |
||
213 | |||
214 | public String toString() { |
||
215 | return datum.toString();
|
||
216 | } |
||
217 | } |