Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libCq CMS for java.old / src / org / cresques / cts / ProjectionPool.java @ 7538

History | View | Annotate | Download (16.1 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.cts;
25

    
26
import java.util.ArrayList;
27
import java.util.Iterator;
28
import java.util.Map;
29
import java.util.TreeMap;
30

    
31
import org.cresques.cts.gt2.CSDatum;
32
import org.cresques.cts.gt2.CSGaussPt;
33
import org.cresques.cts.gt2.CSLambertCC;
34
import org.cresques.cts.gt2.CSMercator;
35
import org.cresques.cts.gt2.CSUTM;
36
import org.cresques.cts.gt2.CoordSys;
37

    
38

    
39
/**
40
 * Pool de proyeccions (cs+datum) conocidas.
41
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
42
 */
43
public class ProjectionPool {
44
    static TreeMap data = null;
45

    
46
    static {
47
        CoordSys cs = null;
48
        data = new TreeMap();
49

    
50
        cs = (new CSUTM(CSDatum.wgs84, 30)).toGeo();
51
        cs.setAbrev("EPSG:4326"); // WGS84 (World Geodesic Datum)
52
        data.put(cs.getAbrev(), cs);
53
        data.put("CRS:84", cs); // CRS:84 = EPSG:4326
54

    
55
        cs = (new CSUTM(CSDatum.ed50, 30)).toGeo();
56
        cs.setAbrev("EPSG:4230"); // Datum Europeu Internacional ED50
57
        data.put(cs.getAbrev(), cs);
58

    
59
        cs = (new CSUTM(CSDatum.d73, 30)).toGeo();
60
        cs.setAbrev("EPSG:4274"); // Datum 73 de Lisboa
61
        data.put(cs.getAbrev(), cs);
62

    
63
        cs = (new CSUTM(CSDatum.nad27, 30)).toGeo();
64
        cs.setAbrev("EPSG:4267"); // NAD 27
65
        data.put(cs.getAbrev(), cs);
66

    
67
        cs = (new CSUTM(CSDatum.nad83, 30)).toGeo();
68
        cs.setAbrev("EPSG:4269"); // NAD 83
69
        data.put(cs.getAbrev(), cs);
70

    
71
        cs = (new CSUTM(CSDatum.lomaQuintana, 30)).toGeo();
72
        cs.setAbrev("EPSG:4288"); // PSAD 56 'Loma Quintana'
73
        data.put(cs.getAbrev(), cs);
74

    
75
        cs = (new CSUTM(CSDatum.laCanoa, 30)).toGeo();
76
        cs.setAbrev("EPSG:4247"); // PSAD 56 'Loma Quintana'
77
        data.put(cs.getAbrev(), cs);
78

    
79
        cs = (new CSUTM(CSDatum.ntfParis, 30)).toGeo();
80
        cs.setAbrev("EPSG:4807"); // NTF Paris
81
        data.put(cs.getAbrev(), cs);
82

    
83
        cs = (new CSUTM(CSDatum.etrs89, 30)).toGeo();
84
        cs.setAbrev("EPSG:4258"); // ETRS 89
85
        data.put(cs.getAbrev(), cs);
86
        for (int i = 1; i <= 60; i++) {
87
            String huso = Integer.toString(i);
88

    
89
            if (i < 10) {
90
                huso = "0" + huso;
91
            }
92

    
93
            cs = new CSUTM(CSDatum.wgs84, i);
94
            cs.setAbrev("EPSG:326" + huso);
95
            data.put(cs.getAbrev(), cs);
96

    
97
            cs = new CSUTM(CSDatum.ed50, i);
98
            cs.setAbrev("EPSG:230" + huso);
99
            data.put(cs.getAbrev(), cs);
100
            if (i>2 && i<=23) {
101
                cs = new CSUTM(CSDatum.nad27, i);
102
                cs.setAbrev("EPSG:267" + huso);
103
                data.put(cs.getAbrev(), cs);
104

    
105
                cs = new CSUTM(CSDatum.nad83, i);
106
                cs.setAbrev("EPSG:269" + huso);
107
                data.put(cs.getAbrev(), cs);
108
            }
109
            if (i>27 && i<39) {
110
                cs = new CSUTM(CSDatum.etrs89, i);
111
                cs.setAbrev("EPSG:258" + huso);
112
                data.put(cs.getAbrev(), cs);
113
            }
114
        }
115

    
116
        cs = CSGaussPt.hgd73;
117
        cs.setAbrev("EPSG:27492"); // Projec??o Gauss do Datum 73 de Lisboa (no EPSG found)
118
        data.put(cs.getAbrev(), cs);
119

    
120
        cs = new CSUTM(CSDatum.d73, 29);
121
        cs.setAbrev("EPSG:27429"); // Projec??o Gauss do Datum 73 de Lisboa (no EPSG found)
122
        data.put(cs.getAbrev(), cs);
123

    
124
        for (int i = 18; i <= 21; i++) {
125
            String huso = Integer.toString(i);
126

    
127
            if (i < 10) {
128
                huso = "0" + huso;
129
            }
130

    
131
            cs = new CSUTM(CSDatum.lomaQuintana, i);
132
            cs.setAbrev("EPSG:288" + huso);
133
            data.put(cs.getAbrev(), cs);
134

    
135
            cs = new CSUTM(CSDatum.laCanoa, i);
136
            cs.setAbrev("EPSG:247" + huso);
137
            data.put(cs.getAbrev(), cs);
138
        }
139

    
140
        //                cs = new CSLambertCC(CSDatum.nad27, -105D, 49D, 49D, 77D, 0, 0);
141
        //                cs.setAbrev("LCCCan");
142
        //                data.put(cs.getAbrev(), cs);
143
        /* Para el server WMS de canad?:
144
         * EPSG:42101
145
         * EPSG:42304
146
         * EPSG:4269
147
         */
148
        /*
149
         * 42101,PROJCS["WGS 84 / LCC Canada",
150
         * GEOGCS["WGS 84",DATUM["WGS_1984",
151
         * SPHEROID["WGS_1984",6378137,298.257223563]],
152
         * PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],
153
         *
154
         * PROJECTION["Lambert_Conformal_Conic_2SP"],
155
         * PARAMETER["central_meridian",-95.0],
156
         * PARAMETER["latitude_of_origin",0],
157
         * PARAMETER["standard_parallel_1",49.0],
158
         * PARAMETER["standard_parallel_2",77.0],
159
         * PARAMETER["false_easting",0.0],
160
         * PARAMETER["false_northing",-8000000.0],
161
         * UNIT["Meter",1],AUTHORITY["EPSG","42101"]]
162
         */
163
        cs = new CSLambertCC(CSDatum.wgs84, -95, 0, 49, 77, 0, -8000000.0);
164
        cs.setAbrev("EPSG:42101");
165
        data.put(cs.getAbrev(), cs);
166

    
167
        /* 42304,PROJCS["NAD83 / NRCan LCC Canada",
168
         * GEOGCS["NAD83",DATUM["North_American_Datum_1983",
169
         * SPHEROID["GRS_1980",6378137,298.257222101]],
170
         * PRIMEM["Greenwich",0],
171
         * UNIT["Decimal_Degree",0.0174532925199433]],
172
         *
173
         * PROJECTION["Lambert_Conformal_Conic_2SP"],
174
         * PARAMETER["central_meridian",-95.0],
175
         * PARAMETER["latitude_of_origin",49.0],
176
         * PARAMETER["standard_parallel_1",49.0],
177
         * PARAMETER["standard_parallel_2",77.0],
178
         * PARAMETER["false_easting",0.0],
179
         * PARAMETER["false_northing",0.0],
180
         * UNIT["Meter",1],AUTHORITY["EPSG","42304"]]
181
         */
182
        cs = new CSLambertCC(CSDatum.nad83, -95, 49, 49, 77, 0, 0);
183
        cs.setAbrev("EPSG:42304");
184
        data.put(cs.getAbrev(), cs);
185

    
186
        /*
187
         * EPSG:26915 - NAD83 / UTM zone 15N
188
         * EPSG:31466 - Gau?-Kr?ger band 2
189
         * EPSG:31467 - Gau?-Kr?ger band 3
190
         * EPSG:4314  - DHDN
191
         */
192
        /*
193
         * 27572=PROJCS["NTF (Paris) / Lambert zone II",
194
             GEOGCS["NTF (Paris)",
195
                    DATUM["Nouvelle_Triangulation_Francaise_Paris",
196
                          SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936269,
197
                                   AUTHORITY["EPSG","7011"]],
198
                          TOWGS84[-168,-60,320,0,0,0,0],
199
                          AUTHORITY["EPSG","6807"]],
200
                    PRIMEM["Paris",2.33722917,AUTHORITY["EPSG","8903"]],
201
                    UNIT["grad",0.01570796326794897,AUTHORITY["EPSG","9105"]],
202
                    AUTHORITY["EPSG","4807"]],
203
             PROJECTION["Lambert_Conformal_Conic_1SP"],
204
                        PARAMETER["latitude_of_origin",52],
205
                        PARAMETER["central_meridian",0],
206
                        PARAMETER["scale_factor",0.99987742],
207
                        PARAMETER["false_easting",600000],
208
                        PARAMETER["false_northing",2200000],
209
                        UNIT["metre",1,AUTHORITY["EPSG","9001"]],
210
                        AUTHORITY["EPSG","27572"]]
211
         */
212

    
213
        cs = new CSLambertCC(CSDatum.ntfParis, 0, 46.79999999999995, 0.99987742, 600000, 2200000);
214
        cs.setAbrev("EPSG:27572");
215
        data.put(cs.getAbrev(), cs);
216
        
217
        cs = new CSLambertCC(CSDatum.ntfParis, 0, 52, 0.99987742, 600000, 2200000);
218
        cs.setAbrev("EPSG:27582");
219
        data.put(cs.getAbrev(), cs);
220
        /*
221
         * # RGF93
222
         * <4171> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
223
         * # RGF93 / Lambert-93
224
         */
225
        cs = (new CSUTM(CSDatum.rgf93, 30)).toGeo();
226
        cs.setAbrev("EPSG:4171"); // NTF Paris
227
        data.put(cs.getAbrev(), cs);
228
        /*
229
         *  <2154> +proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
230
         *  +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0
231
         *  +units=m +no_defs  <>
232
         */
233
        cs = new CSLambertCC(CSDatum.rgf93, 3.0, 46.5, 49.0, 44.0, 700000.0, 6600000.0);
234
        cs.setAbrev("EPSG:2154");
235
        data.put(cs.getAbrev(), cs);
236

    
237
        cs = new CSMercator(CSDatum.wgs84);
238
        cs.setAbrev("EPSG:54004");
239
        data.put(cs.getAbrev(), cs);
240
        cs.setAbrev("EPSG:9804");
241
        data.put(cs.getAbrev(), cs);
242
        
243
        // Lo que faltaba: ?planetas!
244
        cs = (new CSUTM(CSDatum.moon, 30)).toGeo();
245
        cs.setAbrev("IAU2000:30100"); // Moon
246
        data.put(cs.getAbrev(), cs);
247

    
248
        cs = (new CSUTM(CSDatum.mars, 30)).toGeo();
249
        cs.setAbrev("IAU2000:49900"); // Mars
250
        data.put(cs.getAbrev(), cs);
251
        
252
        /*
253
         * CRSs argentinos.
254
         * coordenadas geograficas
255
                        PosGAr 4172 
256
                        PosGAr98 4190
257
                        
258
                        coordenadas proyectadas
259
                        POSGAR 94/Argentina 1 22191 
260
                        POSGAR 94/Argentina 2 22192
261
                        POSGAR 94/Argentina 3 22193
262
                        POSGAR 94/Argentina 4 22194
263
                        POSGAR 94/Argentina 5 22195
264
                        POSGAR 94/Argentina 6 22196
265
                        POSGAR 94/Argentina 7 22197
266
                        
267
                        POSGAR 98/Argentina 1 22181
268
                        POSGAR 98/Argentina 2 22182
269
                        POSGAR 98/Argentina 3 22183
270
                        POSGAR 98/Argentina 4 22184
271
                        POSGAR 98/Argentina 5 22185
272
                        POSGAR 98/Argentina 6 22186
273
                        POSGAR 98/Argentina 7 22187
274
                        
275
                        4221 GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388,297]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
276
                        
277
                        22191        EPSG        22191        PROJCS["Argentina_Zone_1",GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388,297]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",1500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-72],PARAMETER["Scale_Factor",1],PARAMETER["Latitude_Of_Origin",-90],UNIT["Meter",1]]        +proj=tmerc +lat_0=-90 +lon_0=-72 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=intl +units=m
278
                        22192        EPSG        22192        PROJCS["Argentina_Zone_2",GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388,297]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",2500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-69],PARAMETER["Scale_Factor",1],PARAMETER["Latitude_Of_Origin",-90],UNIT["Meter",1]]        +proj=tmerc +lat_0=-90 +lon_0=-69 +k=1.000000 +x_0=2500000 +y_0=0 +ellps=intl +units=m
279
                        22193        EPSG        22193        PROJCS["Argentina_Zone_3",GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388,297]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",3500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-66],PARAMETER["Scale_Factor",1],PARAMETER["Latitude_Of_Origin",-90],UNIT["Meter",1]]        +proj=tmerc +lat_0=-90 +lon_0=-66 +k=1.000000 +x_0=3500000 +y_0=0 +ellps=intl +units=m
280
                        22194        EPSG        22194        PROJCS["Argentina_Zone_4",GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388,297]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",4500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-63],PARAMETER["Scale_Factor",1],PARAMETER["Latitude_Of_Origin",-90],UNIT["Meter",1]]        +proj=tmerc +lat_0=-90 +lon_0=-63 +k=1.000000 +x_0=4500000 +y_0=0 +ellps=intl +units=m
281
                        22195        EPSG        22195        PROJCS["Argentina_Zone_5",GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388,297]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",5500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-60],PARAMETER["Scale_Factor",1],PARAMETER["Latitude_Of_Origin",-90],UNIT["Meter",1]]        +proj=tmerc +lat_0=-90 +lon_0=-60 +k=1.000000 +x_0=5500000 +y_0=0 +ellps=intl +units=m
282
                        22196        EPSG        22196        PROJCS["Argentina_Zone_6",GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388,297]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",6500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-57],PARAMETER["Scale_Factor",1],PARAMETER["Latitude_Of_Origin",-90],UNIT["Meter",1]]        +proj=tmerc +lat_0=-90 +lon_0=-57 +k=1.000000 +x_0=6500000 +y_0=0 +ellps=intl +units=m
283
                        22197        EPSG        22197        PROJCS["Argentina_Zone_7",GEOGCS["GCS_Campo_Inchauspe",DATUM["D_Campo_Inchauspe",SPHEROID["International_1924",6378388,297]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",7500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",-54],PARAMETER["Scale_Factor",1],PARAMETER["Latitude_Of_Origin",-90],UNIT["Meter",1]]        +proj=tmerc +lat_0=-90 +lon_0=-54 +k=1.000000 +x_0=7500000 +y_0=0 +ellps=intl +units=m
284

285
         */
286
        cs = new CoordSys(CSDatum.posgar);
287
        cs.setAbrev("EPSG:4172"); // Posgar
288
        data.put(cs.getAbrev(), cs);
289
        
290
        cs = new CoordSys(
291
                        "GEOGCS[\"GCS_Campo_Inchauspe\"," +
292
                                "DATUM[\"D_Campo_Inchauspe\"," +
293
                                        "SPHEROID[\"International_1924\",6378388,297],"+
294
                                        "TOWGS84[0,0,0,0,0,0,0]]," +
295
                                "PRIMEM[\"Greenwich\",0]," +
296
                                "UNIT[\"Degree\",0.017453292519943295]]");
297
        cs.setAbrev("EPSG:4221"); // Campo Inchauspe
298
        data.put(cs.getAbrev(), cs);
299
        
300
       for (int i=1; i<=7; i++) {
301
                cs = new CoordSys(
302
                        "PROJCS[\"Argentina_Zone_"+i+"\"," +
303
                                "GEOGCS[\"GCS_Campo_Inchauspe\"," +
304
                                        "DATUM[\"D_Campo_Inchauspe\"," +
305
                                                "SPHEROID[\"International_1924\",6378388,297],"+
306
                                                "TOWGS84[0,0,0,0,0,0,0]]," +
307
                                        "PRIMEM[\"Greenwich\",0]," +
308
                                        "UNIT[\"Degree\",0.017453292519943295]]," +
309
                                "PROJECTION[\"Transverse_Mercator\"]," +
310
                                "PARAMETER[\"False_Easting\",1500000]," +
311
                                "PARAMETER[\"False_Northing\",0]," +
312
                                "PARAMETER[\"Central_Meridian\","+(-75+3*i)+"]," +
313
                                "PARAMETER[\"Scale_Factor\",1]," +
314
                                "PARAMETER[\"Latitude_Of_Origin\",-90]," +
315
                                "UNIT[\"Meter\",1]]");
316
                cs.setAbrev("EPSG:2219"+i); // Posgar
317
                data.put(cs.getAbrev(), cs);
318
        }
319
    }
320

    
321
    /**
322
     * Mete una nueva proyeccion en la Pool.
323
     * @param name abreviatura de la proyecccion (i.e. EPSG:23030)
324
     * @param proj Proyeccion
325
     */
326
    public static void add(String name, IProjection proj) {
327
        data.put(name, proj);
328
    }
329

    
330
    /**
331
     * Devuelve una proyeccion a partir de una cadena.
332
     * @param name abreviatura de la proyecccion (i.e. EPSG:23030)
333
     * @return Proyeccion si existe
334
     */
335
    public static IProjection get(String name) {
336
        IProjection proj = null;
337

    
338
        if (ProjectionPool.data.containsKey(name)) {
339
            proj = (IProjection) ProjectionPool.data.get(name);
340
        } else {
341
                // Consultation to remote EPSG database
342
                // if (right)
343
                //    buil new IProjection from GML
344
                // else
345
            System.err.println("ProjectionPool: Key '" + name + "' not set.");
346
        }
347

    
348
        return proj;
349
    }
350

    
351
    public static Iterator iterator() {
352
        ArrayList projs = new ArrayList();
353

    
354
        Iterator iter = data.entrySet().iterator();
355

    
356
        while (iter.hasNext()) {
357
            projs.add(((Map.Entry) iter.next()).getValue());
358
        }
359

    
360
        return projs.iterator();
361
    }
362

    
363
    /**
364
     * LWS ?obsoleto?
365
     * Devuelve una proyeccion a partir de un codig epsg.
366
     * @param name codigo de la proyecccion (i.e. 23030)
367
     * @return Proyeccion si existe
368
     * /
369
    private static IProjection getByEpsg(String code) {
370
        IProjection proj = get("EPSG:" + code);
371

372
        return proj;
373
    }*/
374
}