root / trunk / libraries / libCq CMS for java.old / src / org / cresques / cts / ProjectionPool.java @ 6529
History | View | Annotate | Download (7.59 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 |
data.put("CRS:84", cs); // CRS:84 = EPSG:4326 |
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 |
for (int i = 1; i <= 60; i++) { |
79 |
String huso = Integer.toString(i); |
80 |
|
81 |
if (i < 10) { |
82 |
huso = "0" + huso;
|
83 |
} |
84 |
|
85 |
cs = new CSUTM(CSDatum.wgs84, i);
|
86 |
cs.setAbrev("EPSG:326" + huso);
|
87 |
data.put(cs.getAbrev(), cs); |
88 |
|
89 |
cs = new CSUTM(CSDatum.ed50, i);
|
90 |
cs.setAbrev("EPSG:230" + huso);
|
91 |
data.put(cs.getAbrev(), cs); |
92 |
} |
93 |
|
94 |
for (int i = 3; i <= 23; i++) { |
95 |
String huso = Integer.toString(i); |
96 |
|
97 |
if (i < 10) { |
98 |
huso = "0" + huso;
|
99 |
} |
100 |
|
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 |
|
110 |
cs = CSGaussPt.hgd73; |
111 |
cs.setAbrev("EPSG:27492"); // Projec??o Gauss do Datum 73 de Lisboa (no EPSG found) |
112 |
data.put(cs.getAbrev(), cs); |
113 |
|
114 |
cs = new CSUTM(CSDatum.d73, 29); |
115 |
cs.setAbrev("EPSG:27429"); // Projec??o Gauss do Datum 73 de Lisboa (no EPSG found) |
116 |
data.put(cs.getAbrev(), cs); |
117 |
|
118 |
for (int i = 18; i <= 21; i++) { |
119 |
String huso = Integer.toString(i); |
120 |
|
121 |
if (i < 10) { |
122 |
huso = "0" + huso;
|
123 |
} |
124 |
|
125 |
cs = new CSUTM(CSDatum.lomaQuintana, i);
|
126 |
cs.setAbrev("EPSG:288" + huso);
|
127 |
data.put(cs.getAbrev(), cs); |
128 |
|
129 |
cs = new CSUTM(CSDatum.laCanoa, i);
|
130 |
cs.setAbrev("EPSG:247" + huso);
|
131 |
data.put(cs.getAbrev(), cs); |
132 |
} |
133 |
|
134 |
// cs = new CSLambertCC(CSDatum.nad27, -105D, 49D, 49D, 77D, 0, 0);
|
135 |
// cs.setAbrev("LCCCan");
|
136 |
// data.put(cs.getAbrev(), cs);
|
137 |
/* Para el server WMS de canad?:
|
138 |
* EPSG:42101
|
139 |
* EPSG:42304
|
140 |
* EPSG:4269
|
141 |
*/
|
142 |
/*
|
143 |
* 42101,PROJCS["WGS 84 / LCC Canada",
|
144 |
* GEOGCS["WGS 84",DATUM["WGS_1984",
|
145 |
* SPHEROID["WGS_1984",6378137,298.257223563]],
|
146 |
* PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],
|
147 |
*
|
148 |
* PROJECTION["Lambert_Conformal_Conic_2SP"],
|
149 |
* PARAMETER["central_meridian",-95.0],
|
150 |
* PARAMETER["latitude_of_origin",0],
|
151 |
* PARAMETER["standard_parallel_1",49.0],
|
152 |
* PARAMETER["standard_parallel_2",77.0],
|
153 |
* PARAMETER["false_easting",0.0],
|
154 |
* PARAMETER["false_northing",-8000000.0],
|
155 |
* UNIT["Meter",1],AUTHORITY["EPSG","42101"]]
|
156 |
*/
|
157 |
cs = new CSLambertCC(CSDatum.wgs84, -95, 0, 49, 77, 0, -8000000.0); |
158 |
cs.setAbrev("EPSG:42101");
|
159 |
data.put(cs.getAbrev(), cs); |
160 |
|
161 |
/* 42304,PROJCS["NAD83 / NRCan LCC Canada",
|
162 |
* GEOGCS["NAD83",DATUM["North_American_Datum_1983",
|
163 |
* SPHEROID["GRS_1980",6378137,298.257222101]],
|
164 |
* PRIMEM["Greenwich",0],
|
165 |
* UNIT["Decimal_Degree",0.0174532925199433]],
|
166 |
*
|
167 |
* PROJECTION["Lambert_Conformal_Conic_2SP"],
|
168 |
* PARAMETER["central_meridian",-95.0],
|
169 |
* PARAMETER["latitude_of_origin",49.0],
|
170 |
* PARAMETER["standard_parallel_1",49.0],
|
171 |
* PARAMETER["standard_parallel_2",77.0],
|
172 |
* PARAMETER["false_easting",0.0],
|
173 |
* PARAMETER["false_northing",0.0],
|
174 |
* UNIT["Meter",1],AUTHORITY["EPSG","42304"]]
|
175 |
*/
|
176 |
cs = new CSLambertCC(CSDatum.nad83, -95, 49, 49, 77, 0, 0); |
177 |
cs.setAbrev("EPSG:42304");
|
178 |
data.put(cs.getAbrev(), cs); |
179 |
|
180 |
/*
|
181 |
* EPSG:26915 - NAD83 / UTM zone 15N
|
182 |
* EPSG:31466 - Gau?-Kr?ger band 2
|
183 |
* EPSG:31467 - Gau?-Kr?ger band 3
|
184 |
* EPSG:4314 - DHDN
|
185 |
*/
|
186 |
} |
187 |
|
188 |
/**
|
189 |
* Mete una nueva proyeccion en la Pool.
|
190 |
* @param name abreviatura de la proyecccion (i.e. EPSG:23030)
|
191 |
* @param proj Proyeccion
|
192 |
*/
|
193 |
public static void add(String name, IProjection proj) { |
194 |
data.put(name, proj); |
195 |
} |
196 |
|
197 |
/**
|
198 |
* Devuelve una proyeccion a partir de una cadena.
|
199 |
* @param name abreviatura de la proyecccion (i.e. EPSG:23030)
|
200 |
* @return Proyeccion si existe
|
201 |
*/
|
202 |
public static IProjection get(String name) { |
203 |
IProjection proj = null;
|
204 |
|
205 |
if (ProjectionPool.data.containsKey(name)) {
|
206 |
proj = (IProjection) ProjectionPool.data.get(name); |
207 |
} else {
|
208 |
// Consultation to remote EPSG database
|
209 |
// if (right)
|
210 |
// buil new IProjection from GML
|
211 |
// else
|
212 |
System.err.println("ProjectionPool: Key '" + name + "' not set."); |
213 |
} |
214 |
|
215 |
return proj;
|
216 |
} |
217 |
|
218 |
public static Iterator iterator() { |
219 |
ArrayList projs = new ArrayList(); |
220 |
|
221 |
Iterator iter = data.entrySet().iterator();
|
222 |
|
223 |
while (iter.hasNext()) {
|
224 |
projs.add(((Map.Entry) iter.next()).getValue());
|
225 |
} |
226 |
|
227 |
return projs.iterator();
|
228 |
} |
229 |
|
230 |
/**
|
231 |
* Devuelve una proyeccion a partir de un codig epsg.
|
232 |
* @param name codigo de la proyecccion (i.e. 23030)
|
233 |
* @return Proyeccion si existe
|
234 |
*/
|
235 |
private static IProjection getByEpsg(String code) { |
236 |
IProjection proj = get("EPSG:" + code);
|
237 |
|
238 |
return proj;
|
239 |
} |
240 |
} |