Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / cts / ProjectionPool.java @ 8026

History | View | Annotate | Download (7.54 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 org.cresques.cts.gt2.CSDatum;
27
import org.cresques.cts.gt2.CSGaussPt;
28
import org.cresques.cts.gt2.CSLambertCC;
29
import org.cresques.cts.gt2.CSUTM;
30
import org.cresques.cts.gt2.CoordSys;
31

    
32
import java.util.ArrayList;
33
import java.util.Iterator;
34
import java.util.Map;
35
import java.util.TreeMap;
36

    
37

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

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

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

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

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

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

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

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

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

    
77
        for (int i = 1; i <= 60; i++) {
78
            String huso = Integer.toString(i);
79

    
80
            if (i < 10) {
81
                huso = "0" + huso;
82
            }
83

    
84
            cs = new CSUTM(CSDatum.wgs84, i);
85
            cs.setAbrev("EPSG:326" + huso);
86
            data.put(cs.getAbrev(), cs);
87

    
88
            cs = new CSUTM(CSDatum.ed50, i);
89
            cs.setAbrev("EPSG:230" + huso);
90
            data.put(cs.getAbrev(), cs);
91
        }
92

    
93
        for (int i = 3; i <= 23; i++) {
94
            String huso = Integer.toString(i);
95

    
96
            if (i < 10) {
97
                huso = "0" + huso;
98
            }
99

    
100
            cs = new CSUTM(CSDatum.nad27, i);
101
            cs.setAbrev("EPSG:267" + huso);
102
            data.put(cs.getAbrev(), cs);
103

    
104
            cs = new CSUTM(CSDatum.nad83, i);
105
            cs.setAbrev("EPSG:269" + huso);
106
            data.put(cs.getAbrev(), cs);
107
        }
108

    
109
        cs = CSGaussPt.hgd73;
110
        cs.setAbrev("EPSG:27492"); // Projec??o Gauss do Datum 73 de Lisboa (no EPSG found) 
111
        data.put(cs.getAbrev(), cs);
112

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

    
117
        for (int i = 18; i <= 21; i++) {
118
            String huso = Integer.toString(i);
119

    
120
            if (i < 10) {
121
                huso = "0" + huso;
122
            }
123

    
124
            cs = new CSUTM(CSDatum.lomaQuintana, i);
125
            cs.setAbrev("EPSG:288" + huso);
126
            data.put(cs.getAbrev(), cs);
127

    
128
            cs = new CSUTM(CSDatum.laCanoa, i);
129
            cs.setAbrev("EPSG:247" + huso);
130
            data.put(cs.getAbrev(), cs);
131
        }
132

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

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

    
179
        /*
180
         * EPSG:26915 - NAD83 / UTM zone 15N
181
         * EPSG:31466 - Gau?-Kr?ger band 2
182
         * EPSG:31467 - Gau?-Kr?ger band 3
183
         * EPSG:4314  - DHDN
184
         */
185
    }
186

    
187
    /**
188
     * Mete una nueva proyeccion en la Pool.
189
     * @param name abreviatura de la proyecccion (i.e. EPSG:23030)
190
     * @param proj Proyeccion
191
     */
192
    public static void add(String name, IProjection proj) {
193
        data.put(name, proj);
194
    }
195

    
196
    /**
197
     * Devuelve una proyeccion a partir de una cadena.
198
     * @param name abreviatura de la proyecccion (i.e. EPSG:23030)
199
     * @return Proyeccion si existe
200
     */
201
    public static IProjection get(String name) {
202
        IProjection proj = null;
203

    
204
        if (ProjectionPool.data.containsKey(name)) {
205
            proj = (IProjection) ProjectionPool.data.get(name);
206
        } else {
207
                // Consultation to remote EPSG database
208
                // if (right)
209
                //    buil new IProjection from GML
210
                // else
211
            System.err.println("ProjectionPool: Key '" + name + "' not set.");
212
        }
213

    
214
        return proj;
215
    }
216

    
217
    public static Iterator iterator() {
218
        ArrayList projs = new ArrayList();
219

    
220
        Iterator iter = data.entrySet().iterator();
221

    
222
        while (iter.hasNext()) {
223
            projs.add(((Map.Entry) iter.next()).getValue());
224
        }
225

    
226
        return projs.iterator();
227
    }
228

    
229
    /**
230
     * Devuelve una proyeccion a partir de un codig epsg.
231
     * @param name codigo de la proyecccion (i.e. 23030)
232
     * @return Proyeccion si existe
233
     */
234
    private static IProjection getByEpsg(String code) {
235
        IProjection proj = get("EPSG:" + code);
236

    
237
        return proj;
238
    }
239
}