Statistics
| Revision:

root / branches / v061 / libraries / libCq CMS for java.old / src / org / cresques / cts / ProjectionPool.java @ 5179

History | View | Annotate | Download (9.83 KB)

1 125 luisw
/*
2 2809 nacho
 * 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 125 luisw
 */
24
package org.cresques.cts;
25
26 5179 luisw2
import java.util.ArrayList;
27
import java.util.Iterator;
28
import java.util.Map;
29
import java.util.TreeMap;
30
31 125 luisw
import org.cresques.cts.gt2.CSDatum;
32
import org.cresques.cts.gt2.CSGaussPt;
33
import org.cresques.cts.gt2.CSLambertCC;
34 5179 luisw2
import org.cresques.cts.gt2.CSMercator;
35 125 luisw
import org.cresques.cts.gt2.CSUTM;
36
import org.cresques.cts.gt2.CoordSys;
37
38 2809 nacho
39 125 luisw
/**
40 158 luisw
 * Pool de proyeccions (cs+datum) conocidas.
41 125 luisw
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
42
 */
43
public class ProjectionPool {
44 2809 nacho
    static TreeMap data = null;
45 158 luisw
46 2809 nacho
    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
54
        cs = (new CSUTM(CSDatum.ed50, 30)).toGeo();
55
        cs.setAbrev("EPSG:4230"); // Datum Europeu Internacional ED50
56
        data.put(cs.getAbrev(), cs);
57
58
        cs = (new CSUTM(CSDatum.d73, 30)).toGeo();
59
        cs.setAbrev("EPSG:4274"); // Datum 73 de Lisboa
60
        data.put(cs.getAbrev(), cs);
61
62
        cs = (new CSUTM(CSDatum.nad27, 30)).toGeo();
63
        cs.setAbrev("EPSG:4267"); // NAD 27
64
        data.put(cs.getAbrev(), cs);
65
66
        cs = (new CSUTM(CSDatum.nad83, 30)).toGeo();
67
        cs.setAbrev("EPSG:4269"); // NAD 83
68
        data.put(cs.getAbrev(), cs);
69
70
        cs = (new CSUTM(CSDatum.lomaQuintana, 30)).toGeo();
71
        cs.setAbrev("EPSG:4288"); // PSAD 56 'Loma Quintana'
72
        data.put(cs.getAbrev(), cs);
73
74
        cs = (new CSUTM(CSDatum.laCanoa, 30)).toGeo();
75
        cs.setAbrev("EPSG:4247"); // PSAD 56 'Loma Quintana'
76
        data.put(cs.getAbrev(), cs);
77
78 5179 luisw2
        cs = (new CSUTM(CSDatum.ntfParis, 30)).toGeo();
79
        cs.setAbrev("EPSG:4807"); // NTF Paris
80
        data.put(cs.getAbrev(), cs);
81
82 2809 nacho
        for (int i = 1; i <= 60; i++) {
83
            String huso = Integer.toString(i);
84
85
            if (i < 10) {
86
                huso = "0" + huso;
87
            }
88
89
            cs = new CSUTM(CSDatum.wgs84, i);
90
            cs.setAbrev("EPSG:326" + huso);
91
            data.put(cs.getAbrev(), cs);
92
93
            cs = new CSUTM(CSDatum.ed50, i);
94
            cs.setAbrev("EPSG:230" + huso);
95
            data.put(cs.getAbrev(), cs);
96
        }
97
98
        for (int i = 3; i <= 23; i++) {
99
            String huso = Integer.toString(i);
100
101
            if (i < 10) {
102
                huso = "0" + huso;
103
            }
104
105
            cs = new CSUTM(CSDatum.nad27, i);
106
            cs.setAbrev("EPSG:267" + huso);
107
            data.put(cs.getAbrev(), cs);
108
109
            cs = new CSUTM(CSDatum.nad83, i);
110
            cs.setAbrev("EPSG:269" + huso);
111
            data.put(cs.getAbrev(), cs);
112
        }
113
114
        cs = CSGaussPt.hgd73;
115
        cs.setAbrev("EPSG:27492"); // Projec??o Gauss do Datum 73 de Lisboa (no EPSG found)
116
        data.put(cs.getAbrev(), cs);
117
118
        cs = new CSUTM(CSDatum.d73, 29);
119
        cs.setAbrev("EPSG:27429"); // Projec??o Gauss do Datum 73 de Lisboa (no EPSG found)
120
        data.put(cs.getAbrev(), cs);
121
122
        for (int i = 18; i <= 21; i++) {
123
            String huso = Integer.toString(i);
124
125
            if (i < 10) {
126
                huso = "0" + huso;
127
            }
128
129
            cs = new CSUTM(CSDatum.lomaQuintana, i);
130
            cs.setAbrev("EPSG:288" + huso);
131
            data.put(cs.getAbrev(), cs);
132
133
            cs = new CSUTM(CSDatum.laCanoa, i);
134
            cs.setAbrev("EPSG:247" + huso);
135
            data.put(cs.getAbrev(), cs);
136
        }
137
138
        //                cs = new CSLambertCC(CSDatum.nad27, -105D, 49D, 49D, 77D, 0, 0);
139
        //                cs.setAbrev("LCCCan");
140
        //                data.put(cs.getAbrev(), cs);
141
        /* Para el server WMS de canad?:
142
         * EPSG:42101
143
         * EPSG:42304
144
         * EPSG:4269
145
         */
146
        /*
147
         * 42101,PROJCS["WGS 84 / LCC Canada",
148
         * GEOGCS["WGS 84",DATUM["WGS_1984",
149
         * SPHEROID["WGS_1984",6378137,298.257223563]],
150
         * PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],
151
         *
152
         * PROJECTION["Lambert_Conformal_Conic_2SP"],
153
         * PARAMETER["central_meridian",-95.0],
154
         * PARAMETER["latitude_of_origin",0],
155
         * PARAMETER["standard_parallel_1",49.0],
156
         * PARAMETER["standard_parallel_2",77.0],
157
         * PARAMETER["false_easting",0.0],
158
         * PARAMETER["false_northing",-8000000.0],
159
         * UNIT["Meter",1],AUTHORITY["EPSG","42101"]]
160
         */
161
        cs = new CSLambertCC(CSDatum.wgs84, -95, 0, 49, 77, 0, -8000000.0);
162
        cs.setAbrev("EPSG:42101");
163
        data.put(cs.getAbrev(), cs);
164
165
        /* 42304,PROJCS["NAD83 / NRCan LCC Canada",
166
         * GEOGCS["NAD83",DATUM["North_American_Datum_1983",
167
         * SPHEROID["GRS_1980",6378137,298.257222101]],
168
         * PRIMEM["Greenwich",0],
169
         * UNIT["Decimal_Degree",0.0174532925199433]],
170
         *
171
         * PROJECTION["Lambert_Conformal_Conic_2SP"],
172
         * PARAMETER["central_meridian",-95.0],
173
         * PARAMETER["latitude_of_origin",49.0],
174
         * PARAMETER["standard_parallel_1",49.0],
175
         * PARAMETER["standard_parallel_2",77.0],
176
         * PARAMETER["false_easting",0.0],
177
         * PARAMETER["false_northing",0.0],
178
         * UNIT["Meter",1],AUTHORITY["EPSG","42304"]]
179
         */
180
        cs = new CSLambertCC(CSDatum.nad83, -95, 49, 49, 77, 0, 0);
181
        cs.setAbrev("EPSG:42304");
182
        data.put(cs.getAbrev(), cs);
183
184
        /*
185
         * EPSG:26915 - NAD83 / UTM zone 15N
186
         * EPSG:31466 - Gau?-Kr?ger band 2
187
         * EPSG:31467 - Gau?-Kr?ger band 3
188
         * EPSG:4314  - DHDN
189
         */
190 5179 luisw2
191
        /*
192
         * 27572=PROJCS["NTF (Paris) / Lambert zone II",
193
             GEOGCS["NTF (Paris)",
194
                    DATUM["Nouvelle_Triangulation_Francaise_Paris",
195
                          SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936269,
196
                                   AUTHORITY["EPSG","7011"]],
197
                          TOWGS84[-168,-60,320,0,0,0,0],
198
                          AUTHORITY["EPSG","6807"]],
199
                    PRIMEM["Paris",2.33722917,AUTHORITY["EPSG","8903"]],
200
                    UNIT["grad",0.01570796326794897,AUTHORITY["EPSG","9105"]],
201
                    AUTHORITY["EPSG","4807"]],
202
             PROJECTION["Lambert_Conformal_Conic_1SP"],
203
                        PARAMETER["latitude_of_origin",52],
204
                        PARAMETER["central_meridian",0],
205
                        PARAMETER["scale_factor",0.99987742],
206
                        PARAMETER["false_easting",600000],
207
                        PARAMETER["false_northing",2200000],
208
                        UNIT["metre",1,AUTHORITY["EPSG","9001"]],
209
                        AUTHORITY["EPSG","27572"]]
210
         */
211
212
        cs = new CSLambertCC(CSDatum.ntfParis, 0, 46.79999999999995, 0.99987742, 600000, 2200000);
213
        cs.setAbrev("EPSG:27572");
214
        data.put(cs.getAbrev(), cs);
215
216
        cs = new CSLambertCC(CSDatum.ntfParis, 0, 52, 0.99987742, 600000, 2200000);
217
        cs.setAbrev("EPSG:27582");
218
        data.put(cs.getAbrev(), cs);
219
        /*
220
         * # RGF93
221
         * <4171> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
222
         * # RGF93 / Lambert-93
223
         */
224
        cs = (new CSUTM(CSDatum.rgf93, 30)).toGeo();
225
        cs.setAbrev("EPSG:4171"); // NTF Paris
226
        data.put(cs.getAbrev(), cs);
227
        /*
228
         *  <2154> +proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3
229
         *  +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0
230
         *  +units=m +no_defs  <>
231
         */
232
        cs = new CSLambertCC(CSDatum.rgf93, 3.0, 46.5, 49.0, 44.0, 700000.0, 6600000.0);
233
        cs.setAbrev("EPSG:2154");
234
        data.put(cs.getAbrev(), cs);
235
236
        cs = new CSMercator(CSDatum.wgs84);
237
        cs.setAbrev("EPSG:54004");
238
        data.put(cs.getAbrev(), cs);
239
        cs.setAbrev("EPSG:9804");
240
        data.put(cs.getAbrev(), cs);
241 2809 nacho
    }
242
243
    /**
244
     * Mete una nueva proyeccion en la Pool.
245
     * @param name abreviatura de la proyecccion (i.e. EPSG:23030)
246
     * @param proj Proyeccion
247
     */
248
    public static void add(String name, IProjection proj) {
249
        data.put(name, proj);
250
    }
251
252
    /**
253
     * Devuelve una proyeccion a partir de una cadena.
254
     * @param name abreviatura de la proyecccion (i.e. EPSG:23030)
255
     * @return Proyeccion si existe
256
     */
257
    public static IProjection get(String name) {
258
        IProjection proj = null;
259
260
        if (ProjectionPool.data.containsKey(name)) {
261
            proj = (IProjection) ProjectionPool.data.get(name);
262
        } else {
263
            System.err.println("ProjectionPool: Key '" + name + "' not set.");
264
        }
265
266
        return proj;
267
    }
268
269
    public static Iterator iterator() {
270
        ArrayList projs = new ArrayList();
271
272
        Iterator iter = data.entrySet().iterator();
273
274
        while (iter.hasNext()) {
275
            projs.add(((Map.Entry) iter.next()).getValue());
276
        }
277
278
        return projs.iterator();
279
    }
280
281
    /**
282
     * Devuelve una proyeccion a partir de un codig epsg.
283
     * @param name codigo de la proyecccion (i.e. 23030)
284
     * @return Proyeccion si existe
285
     */
286
    private static IProjection getByEpsg(String code) {
287
        IProjection proj = get("EPSG:" + code);
288
289
        return proj;
290
    }
291 125 luisw
}