svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / cts / ProjectionPool.java @ 2312
History | View | Annotate | Download (6.41 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.CSUTM; |
35 |
import org.cresques.cts.gt2.CoordSys; |
36 |
|
37 |
/**
|
38 |
* Pool de proyeccions (cs+datum) conocidas.
|
39 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
40 |
*/
|
41 |
public class ProjectionPool { |
42 |
static TreeMap data = null; |
43 |
|
44 |
static {
|
45 |
CoordSys cs = null;
|
46 |
data = new TreeMap(); |
47 |
|
48 |
cs = (new CSUTM(CSDatum.wgs84, 30)).toGeo(); |
49 |
cs.setAbrev("EPSG:4326"); // WGS84 (World Geodesic Datum) |
50 |
data.put(cs.getAbrev(), cs); |
51 |
|
52 |
cs = (new CSUTM(CSDatum.ed50, 30)).toGeo(); |
53 |
cs.setAbrev("EPSG:4230"); // Datum Europeu Internacional ED50 |
54 |
data.put(cs.getAbrev(), cs); |
55 |
|
56 |
cs = (new CSUTM(CSDatum.d73, 30)).toGeo(); |
57 |
cs.setAbrev("EPSG:4274"); // Datum 73 de Lisboa |
58 |
data.put(cs.getAbrev(), cs); |
59 |
|
60 |
cs = (new CSUTM(CSDatum.nad27, 30)).toGeo(); |
61 |
cs.setAbrev("EPSG:4267"); // NAD 27 |
62 |
data.put(cs.getAbrev(), cs); |
63 |
|
64 |
cs = (new CSUTM(CSDatum.nad83, 30)).toGeo(); |
65 |
cs.setAbrev("EPSG:4269"); // NAD 83 |
66 |
data.put(cs.getAbrev(), cs); |
67 |
|
68 |
cs = (new CSUTM(CSDatum.lomaQuintana, 30)).toGeo(); |
69 |
cs.setAbrev("EPSG:4288"); // PSAD 56 'Loma Quintana' |
70 |
data.put(cs.getAbrev(), cs); |
71 |
|
72 |
cs = (new CSUTM(CSDatum.laCanoa, 30)).toGeo(); |
73 |
cs.setAbrev("EPSG:4247"); // PSAD 56 'Loma Quintana' |
74 |
data.put(cs.getAbrev(), cs); |
75 |
|
76 |
for (int i=1; i<=60; i++) { |
77 |
String huso = Integer.toString(i); |
78 |
if (i<10) huso = "0"+huso; |
79 |
|
80 |
cs = new CSUTM(CSDatum.wgs84, i);
|
81 |
cs.setAbrev("EPSG:326"+huso);
|
82 |
data.put(cs.getAbrev(), cs); |
83 |
|
84 |
cs = new CSUTM(CSDatum.ed50, i);
|
85 |
cs.setAbrev("EPSG:230"+huso);
|
86 |
data.put(cs.getAbrev(), cs); |
87 |
} |
88 |
|
89 |
for (int i=3; i<=23; i++) { |
90 |
String huso = Integer.toString(i); |
91 |
if (i<10) huso = "0"+huso; |
92 |
|
93 |
cs = new CSUTM(CSDatum.nad27, i);
|
94 |
cs.setAbrev("EPSG:267"+huso);
|
95 |
data.put(cs.getAbrev(), cs); |
96 |
|
97 |
cs = new CSUTM(CSDatum.nad83, i);
|
98 |
cs.setAbrev("EPSG:269"+huso);
|
99 |
data.put(cs.getAbrev(), cs); |
100 |
} |
101 |
|
102 |
cs = CSGaussPt.hgd73; |
103 |
cs.setAbrev("EPSG:27492"); // Projec??o Gauss do Datum 73 de Lisboa (no EPSG found) |
104 |
data.put(cs.getAbrev(), cs); |
105 |
|
106 |
cs = new CSUTM(CSDatum.d73, 29); |
107 |
cs.setAbrev("EPSG:27429"); // Projec??o Gauss do Datum 73 de Lisboa (no EPSG found) |
108 |
data.put(cs.getAbrev(), cs); |
109 |
|
110 |
for (int i=18; i<=21; i++) { |
111 |
String huso = Integer.toString(i); |
112 |
if (i<10) huso = "0"+huso; |
113 |
|
114 |
cs = new CSUTM(CSDatum.lomaQuintana, i);
|
115 |
cs.setAbrev("EPSG:288"+huso);
|
116 |
data.put(cs.getAbrev(), cs); |
117 |
|
118 |
cs = new CSUTM(CSDatum.laCanoa, i);
|
119 |
cs.setAbrev("EPSG:247"+huso);
|
120 |
data.put(cs.getAbrev(), cs); |
121 |
} |
122 |
|
123 |
|
124 |
// cs = new CSLambertCC(CSDatum.nad27, -105D, 49D, 49D, 77D, 0, 0);
|
125 |
// cs.setAbrev("LCCCan");
|
126 |
// data.put(cs.getAbrev(), cs);
|
127 |
|
128 |
/* Para el server WMS de canad?:
|
129 |
* EPSG:42101
|
130 |
* EPSG:42304
|
131 |
* EPSG:4269
|
132 |
*/
|
133 |
/*
|
134 |
* 42101,PROJCS["WGS 84 / LCC Canada",
|
135 |
* GEOGCS["WGS 84",DATUM["WGS_1984",
|
136 |
* SPHEROID["WGS_1984",6378137,298.257223563]],
|
137 |
* PRIMEM["Greenwich",0],UNIT["Decimal_Degree",0.0174532925199433]],
|
138 |
*
|
139 |
* PROJECTION["Lambert_Conformal_Conic_2SP"],
|
140 |
* PARAMETER["central_meridian",-95.0],
|
141 |
* PARAMETER["latitude_of_origin",0],
|
142 |
* PARAMETER["standard_parallel_1",49.0],
|
143 |
* PARAMETER["standard_parallel_2",77.0],
|
144 |
* PARAMETER["false_easting",0.0],
|
145 |
* PARAMETER["false_northing",-8000000.0],
|
146 |
* UNIT["Meter",1],AUTHORITY["EPSG","42101"]]
|
147 |
*/
|
148 |
cs = new CSLambertCC(CSDatum.wgs84, -95, 0, 49, 77, 0, -8000000.0); |
149 |
cs.setAbrev("EPSG:42101");
|
150 |
data.put(cs.getAbrev(), cs); |
151 |
/* 42304,PROJCS["NAD83 / NRCan LCC Canada",
|
152 |
* GEOGCS["NAD83",DATUM["North_American_Datum_1983",
|
153 |
* SPHEROID["GRS_1980",6378137,298.257222101]],
|
154 |
* PRIMEM["Greenwich",0],
|
155 |
* UNIT["Decimal_Degree",0.0174532925199433]],
|
156 |
*
|
157 |
* PROJECTION["Lambert_Conformal_Conic_2SP"],
|
158 |
* PARAMETER["central_meridian",-95.0],
|
159 |
* PARAMETER["latitude_of_origin",49.0],
|
160 |
* PARAMETER["standard_parallel_1",49.0],
|
161 |
* PARAMETER["standard_parallel_2",77.0],
|
162 |
* PARAMETER["false_easting",0.0],
|
163 |
* PARAMETER["false_northing",0.0],
|
164 |
* UNIT["Meter",1],AUTHORITY["EPSG","42304"]]
|
165 |
*/
|
166 |
cs = new CSLambertCC(CSDatum.nad83, -95, 49, 49, 77, 0, 0); |
167 |
cs.setAbrev("EPSG:42304");
|
168 |
data.put(cs.getAbrev(), cs); |
169 |
/*
|
170 |
* EPSG:26915 - NAD83 / UTM zone 15N
|
171 |
* EPSG:31466 - Gau?-Kr?ger band 2
|
172 |
* EPSG:31467 - Gau?-Kr?ger band 3
|
173 |
* EPSG:4314 - DHDN
|
174 |
*/
|
175 |
} |
176 |
|
177 |
/**
|
178 |
* Mete una nueva proyeccion en la Pool.
|
179 |
* @param name abreviatura de la proyecccion (i.e. EPSG:23030)
|
180 |
* @param proj Proyeccion
|
181 |
*/
|
182 |
public static void add(String name, IProjection proj) { |
183 |
data.put(name, proj); |
184 |
} |
185 |
|
186 |
/**
|
187 |
* Devuelve una proyeccion a partir de una cadena.
|
188 |
* @param name abreviatura de la proyecccion (i.e. EPSG:23030)
|
189 |
* @return Proyeccion si existe
|
190 |
*/
|
191 |
public static IProjection get(String name) { |
192 |
IProjection proj = null;
|
193 |
if (ProjectionPool.data.containsKey(name))
|
194 |
proj = (IProjection) ProjectionPool.data.get(name); |
195 |
else
|
196 |
System.err.println("ProjectionPool: Key '"+name+"' not set."); |
197 |
return proj;
|
198 |
} |
199 |
|
200 |
public static Iterator iterator() { |
201 |
ArrayList projs = new ArrayList(); |
202 |
|
203 |
Iterator iter = data.entrySet().iterator();
|
204 |
while (iter.hasNext()) {
|
205 |
projs.add(((Map.Entry) iter.next()).getValue());
|
206 |
} |
207 |
return projs.iterator();
|
208 |
} |
209 |
|
210 |
/**
|
211 |
* Devuelve una proyeccion a partir de un codig epsg.
|
212 |
* @param name codigo de la proyecccion (i.e. 23030)
|
213 |
* @return Proyeccion si existe
|
214 |
*/
|
215 |
private static IProjection getByEpsg(String code) { |
216 |
IProjection proj = get("EPSG:"+code);
|
217 |
return proj;
|
218 |
} |
219 |
} |
220 |
|