Statistics
| Revision:

svn-gvsig-desktop / branches / Mobile_Compatible_Hito_1 / libProjectionDummy / src / org / gvsig / projection / dummy / ProjectionPool.java @ 21822

History | View | Annotate | Download (13.6 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 PRODEVELOP S.L. Main Development
26
*/
27
 
28
package org.gvsig.projection.dummy;
29

    
30
import java.util.ArrayList;
31
import java.util.Iterator;
32
import java.util.Map;
33
import java.util.TreeMap;
34

    
35
import org.gvsig.projection.cts.IProjection;
36
import org.gvsig.projection.dummy.cts.CSDatum;
37
import org.gvsig.projection.dummy.cts.CSUTM;
38
import org.gvsig.projection.dummy.cts.CoordSys;
39

    
40
public class ProjectionPool {
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
        private static String line7 = "DATUM[\"Loma Quintana\"," +
60
                                                          "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
61
                                                          "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6288\"]]";
62
        private static String line8 = "DATUM[\"La Canoa\"," +
63
                                                              "SPHEROID[\"International 1924\",6378388,297,AUTHORITY[\"EPSG\",\"7022\"]]," +
64
                                                              "TOWGS84[-270.933,115.599,-360.226,-5.266,-1.238,2.381,-5.109],AUTHORITY[\"EPSG\",\"6288\"]]";
65
        private static String line9 = "GEOGCS[\"NTF (Paris)\","+
66
                                                                  "DATUM[\"Nouvelle_Triangulation_Francaise_Paris\"," +
67
                                                                  "SPHEROID[\"Clarke 1880 (IGN)\",6378249.2,293.4660212936269,AUTHORITY[\"EPSG\",\"7011\"]]," +
68
                                                                  "TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY[\"EPSG\",\"8903\"]]"+
69
                                                                  ",PRIMEM[\"Paris\",2.33722917,AUTHORITY[\"EPSG\",\"8903\"]]," +
70
                                                                  "UNIT[\"grad\",0.01570796326794897,AUTHORITY[\"EPSG\",\"9105\"]]," +
71
                                                                  "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
72
                                                                  "AUTHORITY[\"EPSG\",\"4807\"]]";
73
        private static String line10 = "GEOGCS[\"RGF93\"," +
74
                                                                   "DATUM[\"Reseau Geodesique Francais 1993\"," +
75
                                                                   "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]," +
76
                                                                   "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6171\"]],"+
77
                                                                   "PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," +
78
                                                                   "UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," +
79
                                                                   "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
80
                                                                   "AUTHORITY[\"EPSG\",\"4171\"]]";
81
        private static String line11 = "GEOGCS[\"ETRS89\","+
82
                                                                      "DATUM[\"European_Terrestrial_Reference_System_1989\","+
83
                                                                      "SPHEROID[\"GRS 1980\",6378137,298.257222101,"+
84
                                                                      "AUTHORITY[\"EPSG\",\"7019\"]],"+
85
                                                                      "AUTHORITY[\"EPSG\",\"6258\"]],"+
86
                                                                      "PRIMEM[\"Greenwich\",0,"+
87
                                                                      "AUTHORITY[\"EPSG\",\"8901\"]],"+
88
                                                                      "UNIT[\"degree\",0.01745329251994328,"+
89
                                                                      "AUTHORITY[\"EPSG\",\"9122\"]],"+
90
                                                                      "AUTHORITY[\"EPSG\",\"4258\"]]";
91
        private static String line12 = "GEOGCS[\"Mars 2000\","+
92
                                                                   "DATUM[\"D_Mars_2000\","+
93
                                                                   "SPHEROID[\"Mars_2000_IAU_IAG\",3396190.0, 169.89444722361179],"+
94
                                                                   "TOWGS84[0,0,0,0,0,0,0]],"+
95
                                                                   "PRIMEM[\"Greenwich\",0],"+
96
                                                                   "UNIT[\"Decimal_Degree\",0.0174532925199433]]";
97
        private static String line13 = "GEOGCS[\"POSGAR\","+
98
                                                                   "DATUM[\"POSGAR\"," +
99
                                                                   "SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]," +
100
                                                                   "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6269\"]]"+
101
                                                                   ",PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]]," +
102
                                                                   "UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]," +
103
                                                                   "AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST]," +
104
                                                                   "AUTHORITY[\"EPSG\",\"4172\"]]";
105
        private static String line14 = "GEOGCS[\"Moon 2000\"," +
106
                                                                   "DATUM[\"D_Moon_2000\"," +
107
                                                                   "SPHEROID[\"Moon_2000_IAU_IAG\",1737400.0, 0.0]," +
108
                                                                   "TOWGS84[0,0,0,0,0,0,0]],"+
109
                                                                   "PRIMEM[\"Greenwich\",0]," +
110
                                                                   "UNIT[\"Decimal_Degree\",0.0174532925199433]]";
111
        
112
        public static CSDatum wgs84 = new CSDatum(line1).fromWKT(null);
113
        public static CSDatum ed50 = new CSDatum(line2).fromWKT(null);
114
        public static CSDatum ntf = new CSDatum(line3).fromWKT(null);
115
        public static CSDatum d73 = new CSDatum(line4).fromWKT(null);
116
        public static CSDatum nad27 = new CSDatum(line5).fromWKT(null);
117
        public static CSDatum nad83 = new CSDatum(line6).fromWKT(null);
118
        public static CSDatum lomaQuintana = new CSDatum(line7).fromWKT(null);
119
        public static CSDatum laCanoa = new CSDatum(line8).fromWKT(null);
120
        public static CSDatum ntfParis = new CSDatum(line9).fromWKT(null);
121
        public static CSDatum rgf93 = new CSDatum(line10).fromWKT(null);
122
        public static CSDatum etrs89 = new CSDatum(line11).fromWKT(null);
123
        public static CSDatum mars = new CSDatum(line12).fromWKT(null);
124
        public static CSDatum posgar = new CSDatum(line13).fromWKT(null);
125
        public static CSDatum moon = new CSDatum(line14).fromWKT(null);
126
        
127
        /**
128
         * REGISTRO DE SISTEMAS DE COORDENADAS PERO QUE NO HACEN NADA
129
         */
130
        static TreeMap data = null;
131
        static {
132
                CoordSys cs = null;
133
                data = new TreeMap();
134
                cs = (new CSUTM(wgs84, 30)).toGeo();
135
                cs.setAbrev("EPSG:4326"); // WGS84 (World Geodesic Datum)
136
                data.put(cs.getAbrev(), cs);
137
                data.put("CRS:84", cs); // CRS:84 = EPSG:4326
138
                cs = (new CSUTM(ed50, 30)).toGeo();
139
                cs.setAbrev("EPSG:4230"); // Datum Europeu Internacional ED50
140
                data.put(cs.getAbrev(), cs);
141
                cs = (new CSUTM(d73, 30)).toGeo();
142
                cs.setAbrev("EPSG:4274"); // Datum 73 de Lisboa
143
                data.put(cs.getAbrev(), cs);
144
                cs = (new CSUTM(nad27, 30)).toGeo();
145
                cs.setAbrev("EPSG:4267"); // NAD 27
146
                data.put(cs.getAbrev(), cs);
147
                cs = (new CSUTM(nad83, 30)).toGeo();
148
                cs.setAbrev("EPSG:4269"); // NAD 83
149
                data.put(cs.getAbrev(), cs);
150
                cs = (new CSUTM(lomaQuintana, 30)).toGeo();
151
                cs.setAbrev("EPSG:4288"); // PSAD 56 'Loma Quintana'
152
                data.put(cs.getAbrev(), cs);
153
                cs = (new CSUTM(laCanoa, 30)).toGeo();
154
                cs.setAbrev("EPSG:4247"); // PSAD 56 'Loma Quintana'
155
                data.put(cs.getAbrev(), cs);
156
                cs = (new CSUTM(ntfParis, 30)).toGeo();
157
                cs.setAbrev("EPSG:4807"); // NTF Paris
158
                data.put(cs.getAbrev(), cs);
159
                cs = (new CSUTM(etrs89, 30)).toGeo();
160
                cs.setAbrev("EPSG:4258"); // ETRS 89
161
                data.put(cs.getAbrev(), cs);
162
            for (int i = 1; i <= 60; i++) {
163
                    String huso = Integer.toString(i);
164
                    if (i < 10) {
165
                        huso = "0" + huso;
166
                    }
167
                    cs = new CSUTM(wgs84, i);
168
                    cs.setAbrev("EPSG:326" + huso);
169
                    data.put(cs.getAbrev(), cs);
170
                    cs = new CSUTM(ed50, i);
171
                    cs.setAbrev("EPSG:230" + huso);
172
                    data.put(cs.getAbrev(), cs);
173
                    if (i>2 && i<=23) {
174
                        cs = new CSUTM(nad27, i);
175
                        cs.setAbrev("EPSG:267" + huso);
176
                        data.put(cs.getAbrev(), cs);
177

    
178
                        cs = new CSUTM(nad83, i);
179
                        cs.setAbrev("EPSG:269" + huso);
180
                        data.put(cs.getAbrev(), cs);
181
                    }
182
                    if (i>27 && i<39) {
183
                        cs = new CSUTM(etrs89, i);
184
                        cs.setAbrev("EPSG:258" + huso);
185
                        data.put(cs.getAbrev(), cs);
186
                    }
187
                }
188
                cs = new CSUTM(d73, 29);
189
                cs.setAbrev("EPSG:27429"); // Projeco Gauss do Datum 73 de Lisboa (no EPSG found)
190
                data.put(cs.getAbrev(), cs);
191
                for (int i = 18; i <= 21; i++) {
192
                    String huso = Integer.toString(i);
193
                    if (i < 10) {
194
                        huso = "0" + huso;
195
                    }
196
                    cs = new CSUTM(laCanoa, i);
197
                    cs.setAbrev("EPSG:247" + huso);
198
                    data.put(cs.getAbrev(), cs);
199
                }
200
                for (int i = 16; i <= 22; i++) {
201
                    String huso = Integer.toString(i);
202
                    // Psad56 Ecuador
203
                    cs = new CSUTM(lomaQuintana, i);
204
                    cs.setAbrev("EPSG:288" + huso);
205
                    data.put(cs.getAbrev(), cs);
206
                    cs = new CSUTM(lomaQuintana, i, "S");
207
                    cs.setAbrev("EPSG:288" + (i+60) );
208
                    data.put(cs.getAbrev(), cs);
209
                }
210

    
211
                                
212
               /**
213
                * # RGF93
214
                * <4171> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
215
                * # RGF93 / Lambert-93
216
                */
217
                cs = (new CSUTM(rgf93, 30)).toGeo();
218
                cs.setAbrev("EPSG:4171"); // NTF Paris
219
                data.put(cs.getAbrev(), cs);
220
                
221
                /**
222
                 * Planetas
223
                 */
224
                cs = (new CSUTM(moon, 30)).toGeo();
225
                cs.setAbrev("IAU2000:30100"); // Moon
226
                data.put(cs.getAbrev(), cs);
227
                cs = (new CSUTM(mars, 30)).toGeo();
228
                cs.setAbrev("IAU2000:49900"); // Mars
229
                data.put(cs.getAbrev(), cs);
230
                
231
               /**
232
                * CRSs argentinos.
233
                * coordenadas geograficas
234
                        * PosGAr 4172 
235
                        * PosGAr98 4190
236
                        */        
237
                        cs = new CoordSys(posgar);
238
                cs.setAbrev("EPSG:4172"); // Posgar
239
                data.put(cs.getAbrev(), cs);
240
                cs = new CoordSys(
241
                                "GEOGCS[\"GCS_Campo_Inchauspe\"," +
242
                                        "DATUM[\"D_Campo_Inchauspe\"," +
243
                                                "SPHEROID[\"International_1924\",6378388,297],"+
244
                                                "TOWGS84[0,0,0,0,0,0,0]]," +
245
                                        "PRIMEM[\"Greenwich\",0]," +
246
                                        "UNIT[\"Degree\",0.017453292519943295]]");
247
                cs.setAbrev("EPSG:4221"); // Campo Inchauspe
248
                data.put(cs.getAbrev(), cs);
249
                for (int i=1; i<=7; i++) {
250
                        cs = new CoordSys(
251
                                "PROJCS[\"Argentina_Zone_"+i+"\"," +
252
                                        "GEOGCS[\"GCS_Campo_Inchauspe\"," +
253
                                                "DATUM[\"D_Campo_Inchauspe\"," +
254
                                                        "SPHEROID[\"International_1924\",6378388,297],"+
255
                                                        "TOWGS84[0,0,0,0,0,0,0]]," +
256
                                                "PRIMEM[\"Greenwich\",0]," +
257
                                                "UNIT[\"Degree\",0.017453292519943295]]," +
258
                                        "PROJECTION[\"Transverse_Mercator\"]," +
259
                                        "PARAMETER[\"False_Easting\",1500000]," +
260
                                        "PARAMETER[\"False_Northing\",0]," +
261
                                        "PARAMETER[\"Central_Meridian\","+(-75+3*i)+"]," +
262
                                        "PARAMETER[\"Scale_Factor\",1]," +
263
                                        "PARAMETER[\"Latitude_Of_Origin\",-90]," +
264
                                        "UNIT[\"Meter\",1]]");
265
                        cs.setAbrev("EPSG:2219"+i); // Posgar
266
                        data.put(cs.getAbrev(), cs);
267
                }
268
            }
269

    
270
            /**
271
             * Mete una nueva proyeccion en la Pool.
272
             * @param name abreviatura de la proyecccion (i.e. EPSG:23030)
273
             * @param proj Proyeccion
274
             */
275
            public static void add(String name, IProjection proj) {
276
                data.put(name, proj);
277
            }
278
            
279
            /**
280
             * Devuelve una proyeccion a partir de una cadena.
281
             * @param name abreviatura de la proyecccion (i.e. EPSG:23030)
282
             * @return Proyeccion si existe
283
             */
284
            public IProjection get(String name) {
285
                IProjection proj = null;
286

    
287
                if (ProjectionPool.data.containsKey(name)) {
288
                    proj = (IProjection) data.get(name);
289
                        //proj = (IProjection) ProjectionPool.data.get(name);
290
                } else {
291
                        // Consultation to remote EPSG database
292
                        // if (right)
293
                        //    build new IProjection from GML
294
                        // else
295
                    System.err.println("ProjectionPool: Key '" + name + "' not set.");
296
                }
297
                return proj;
298
            }
299

    
300
            /**
301
             * Iterador sobre la pool.
302
             */
303
            public static Iterator iterator() {
304
                ArrayList projs = new ArrayList();
305
                Iterator iter = data.entrySet().iterator();
306
                while (iter.hasNext()) {
307
                    projs.add(((Map.Entry) iter.next()).getValue());
308
                }
309
                return projs.iterator();
310
            }
311
}