Revision 1255
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/geo/ViewPortData.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.cresques.geo; |
|
25 |
|
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.geom.AffineTransform; |
|
28 |
import java.awt.geom.Point2D; |
|
29 |
import java.text.DecimalFormat; |
|
30 |
|
|
31 |
import org.cresques.cts.ICoordTrans; |
|
32 |
import org.cresques.cts.IProjection; |
|
33 |
import org.cresques.px.Extent; |
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* Datos de vista sobre las capas. |
|
38 |
* |
|
39 |
* Mantiene un conjunto de datos necesarios, que describen el modo de |
|
40 |
* ver las capas actual. |
|
41 |
* |
|
42 |
* cmartinez: Esta clase no deber?a formar parte de una API, pero |
|
43 |
* se deja hasta que se aborde el refactoring de libProjection. |
|
44 |
* |
|
45 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es> |
|
46 |
*/ |
|
47 |
public class ViewPortData implements Projected { |
|
48 |
/** |
|
49 |
* Tipo de proyecci?n de la vista. |
|
50 |
*/ |
|
51 |
IProjection proj = null; |
|
52 |
|
|
53 |
/** |
|
54 |
* Sistema de coordenadas de la vista. |
|
55 |
*/ |
|
56 |
IProjection cs = null; |
|
57 |
|
|
58 |
/** |
|
59 |
* Amplitud de la vista, en coordenadas proyectadas. |
|
60 |
*/ |
|
61 |
Extent extent = null; |
|
62 |
|
|
63 |
/** |
|
64 |
* Tama?o de la vista, en coordenadas de dispositivo. |
|
65 |
*/ |
|
66 |
Dimension size = null; |
|
67 |
|
|
68 |
/** |
|
69 |
* Transformaci?n af?n usada en la vista actual. |
|
70 |
*/ |
|
71 |
public AffineTransform mat = null; |
|
72 |
|
|
73 |
/** |
|
74 |
* Resoluci?n (Puntos por pulgada) de la vista actual. |
|
75 |
* Se necesita para los c?lculos de escala geogr?fica. |
|
76 |
*/ |
|
77 |
int dpi = java.awt.Toolkit.getDefaultToolkit().getScreenResolution(); |
|
78 |
|
|
79 |
public ViewPortData() { |
|
80 |
} |
|
81 |
|
|
82 |
public ViewPortData(IProjection proj, Extent extent, Dimension size) { |
|
83 |
this.proj = proj; |
|
84 |
this.extent = extent; |
|
85 |
this.size = size; |
|
86 |
mat = new AffineTransform(); |
|
87 |
mat.scale(1.0, -1.0); |
|
88 |
} |
|
89 |
|
|
90 |
public IProjection getProjection() { |
|
91 |
return proj; |
|
92 |
} |
|
93 |
|
|
94 |
public void setProjection(IProjection proj) { |
|
95 |
this.proj = proj; |
|
96 |
} |
|
97 |
|
|
98 |
public void reProject(ICoordTrans rp) { |
|
99 |
// TODO metodo reProject pendiente de implementar |
|
100 |
} |
|
101 |
|
|
102 |
public void setCoordSys(IProjection cs) { |
|
103 |
this.cs = cs; |
|
104 |
} |
|
105 |
|
|
106 |
//public void setCoordTrans(ICoordTrans ct) { this.ct = ct; } |
|
107 |
public AffineTransform getMat() { |
|
108 |
return mat; |
|
109 |
} |
|
110 |
|
|
111 |
public void setMat(AffineTransform mat) { |
|
112 |
this.mat = mat; |
|
113 |
} |
|
114 |
|
|
115 |
public Object clone() { |
|
116 |
ViewPortData vp = new ViewPortData(); |
|
117 |
|
|
118 |
if (mat != null) { |
|
119 |
vp.mat = new AffineTransform(mat); |
|
120 |
} |
|
121 |
|
|
122 |
if (extent != null) { |
|
123 |
vp.extent = new Extent(extent); |
|
124 |
} |
|
125 |
|
|
126 |
vp.proj = proj; |
|
127 |
vp.size = size; |
|
128 |
vp.dpi = dpi; |
|
129 |
|
|
130 |
return vp; |
|
131 |
} |
|
132 |
|
|
133 |
public double getWidth() { |
|
134 |
return size.width; |
|
135 |
} |
|
136 |
|
|
137 |
public double getHeight() { |
|
138 |
return size.height; |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* |
|
143 |
*/ |
|
144 |
public Dimension getSize() { |
|
145 |
return size; |
|
146 |
} |
|
147 |
|
|
148 |
public void setSize(double w, double h) { |
|
149 |
setSize(new Dimension((int) w, (int) h)); |
|
150 |
} |
|
151 |
|
|
152 |
public void setSize(Dimension sz) { |
|
153 |
size = sz; |
|
154 |
reExtent(); |
|
155 |
} |
|
156 |
|
|
157 |
public Extent getExtent() { |
|
158 |
return extent; |
|
159 |
} |
|
160 |
|
|
161 |
public void setExtent(Dimension sz) { |
|
162 |
Point2D.Double pt0 = new Point2D.Double(0, 0); |
|
163 |
Point2D.Double ptSz = new Point2D.Double(sz.width, sz.height); |
|
164 |
|
|
165 |
try { |
|
166 |
mat.inverseTransform(pt0, pt0); |
|
167 |
mat.inverseTransform(ptSz, ptSz); |
|
168 |
} catch (Exception e) { |
|
169 |
e.printStackTrace(); |
|
170 |
} |
|
171 |
|
|
172 |
extent = new Extent(pt0, ptSz); |
|
173 |
} |
|
174 |
|
|
175 |
public void reExtent() { |
|
176 |
setExtent(size); |
|
177 |
} |
|
178 |
|
|
179 |
public void setDPI(int dpi) { |
|
180 |
this.dpi = dpi; |
|
181 |
} |
|
182 |
|
|
183 |
public int getDPI() { |
|
184 |
return this.dpi; |
|
185 |
} |
|
186 |
|
|
187 |
/** |
|
188 |
* zoom a un marco. |
|
189 |
* |
|
190 |
* @param extent |
|
191 |
*/ |
|
192 |
public void zoom(Extent extent) { |
|
193 |
double[] scale = extent.getScale(getWidth(), getHeight()); |
|
194 |
double escala = Math.min(scale[0], scale[1]); |
|
195 |
|
|
196 |
mat.setToIdentity(); |
|
197 |
mat.scale(escala, -escala); |
|
198 |
mat.translate(-extent.minX(), -extent.maxY()); |
|
199 |
this.extent = extent; |
|
200 |
reExtent(); |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* zoom centrado en un punto. |
|
205 |
* |
|
206 |
* @param zoom |
|
207 |
* @param pt |
|
208 |
*/ |
|
209 |
public void zoom(double zoom, Point2D pt) { |
|
210 |
zoom(zoom, zoom, pt); |
|
211 |
} |
|
212 |
|
|
213 |
public void zoom(double zx, double zy, Point2D pt) { |
|
214 |
centerAt(pt); |
|
215 |
mat.scale(zx, zy); |
|
216 |
centerAt(pt); |
|
217 |
reExtent(); |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* Zoom a una escala (geogr?fica); |
|
222 |
* |
|
223 |
* @param scale |
|
224 |
*/ |
|
225 |
public void zoomToGeoScale(double scale) { |
|
226 |
double actual = getGeoScale(); |
|
227 |
double f = actual / scale; |
|
228 |
zoomToCenter(f); |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* Zoom a una escala (geogr?fica); |
|
233 |
* |
|
234 |
* @param scale |
|
235 |
*/ |
|
236 |
public void zoomToCenter(double f) { |
|
237 |
Point2D.Double ptCenter = new Point2D.Double(getWidth() / 2.0, |
|
238 |
getHeight() / 2.0); |
|
239 |
|
|
240 |
try { |
|
241 |
mat.inverseTransform(ptCenter, ptCenter); |
|
242 |
} catch (Exception e) { |
|
243 |
e.printStackTrace(); |
|
244 |
} |
|
245 |
|
|
246 |
zoom(f, ptCenter); |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* Centrar en un punto. |
|
251 |
* |
|
252 |
* @param pt |
|
253 |
*/ |
|
254 |
public void centerAt(Point2D pt) { |
|
255 |
Point2D.Double ptCenter = new Point2D.Double(getWidth() / 2.0, |
|
256 |
getHeight() / 2.0); |
|
257 |
|
|
258 |
try { |
|
259 |
mat.inverseTransform(ptCenter, ptCenter); |
|
260 |
mat.translate(ptCenter.x - pt.getX(), ptCenter.y - pt.getY()); |
|
261 |
} catch (Exception e) { |
|
262 |
e.printStackTrace(); |
|
263 |
} |
|
264 |
|
|
265 |
reExtent(); |
|
266 |
} |
|
267 |
|
|
268 |
/** |
|
269 |
* Desplaza la vista actual. |
|
270 |
* |
|
271 |
* @param pt |
|
272 |
*/ |
|
273 |
public void pan(Point2D ptIni, Point2D ptFin) { |
|
274 |
mat.translate(ptFin.getX() - ptIni.getX(), ptFin.getY() - ptIni.getY()); |
|
275 |
reExtent(); |
|
276 |
} |
|
277 |
|
|
278 |
public Point2D getCenter() { |
|
279 |
Point2D.Double ptCenter = new Point2D.Double(getWidth() / 2.0, |
|
280 |
getHeight() / 2.0); |
|
281 |
|
|
282 |
try { |
|
283 |
mat.inverseTransform(ptCenter, ptCenter); |
|
284 |
} catch (Exception e) { |
|
285 |
e.printStackTrace(); |
|
286 |
} |
|
287 |
|
|
288 |
return ptCenter; |
|
289 |
} |
|
290 |
|
|
291 |
/** |
|
292 |
* Escala Geogr?fica. |
|
293 |
* |
|
294 |
* @param dpi resolucion en puntos por pulgada |
|
295 |
*/ |
|
296 |
public double getGeoScale() { |
|
297 |
/* // TODO Actulizarlo para Geotools2 |
|
298 |
double scale = 0.0; |
|
299 |
if (proj.getClass() == UtmZone.class) { // UTM; |
|
300 |
scale = (extent.maxX()-extent.minX())* // metros |
|
301 |
(dpi / 2.54 * 100.0)/ // px / metro |
|
302 |
getWidth(); // pixels |
|
303 |
} else if (proj.getClass() == Geodetic.class) { // Geodetic |
|
304 |
scale = (extent.maxX()-extent.minX())* // grados |
|
305 |
// 1852.0 metros x minuto de meridiano |
|
306 |
(dpi / 2.54 * 100.0 * 1852.0 * 60.0)/ // px / metro |
|
307 |
getWidth(); // pixels |
|
308 |
} else if (proj.getClass() == Mercator.class) { // Mercator |
|
309 |
Projection prj = Geodetic.getProjection((Ellipsoid) proj.getDatum()); |
|
310 |
GeoPoint pt1 = (GeoPoint) prj.createPoint(1.0,0.0); |
|
311 |
GeoPoint pt2 = (GeoPoint) prj.createPoint(2.0,0.0); |
|
312 |
ProjPoint ppt1 = (ProjPoint) proj.createPoint(0.0, 0.0); |
|
313 |
ProjPoint ppt2 = (ProjPoint) proj.createPoint(0.0, 0.0); |
|
314 |
((Mercator) proj).fromGeo(pt1, ppt1); |
|
315 |
((Mercator) proj).fromGeo(pt2, ppt2); |
|
316 |
//scale = ppt2.getX()-ppt1.getX(); |
|
317 |
scale = ((extent.maxX()-extent.minX())/ (ppt2.getX()-ppt1.getX()) ) * |
|
318 |
//scale = ((extent.maxX()-extent.minX())/ getWidth());// * |
|
319 |
(dpi / 2.54 * 100.0 * 1852.0 * 60.0) / |
|
320 |
getWidth(); |
|
321 |
} */ |
|
322 |
return proj.getScale(extent.minX(), extent.maxX(), getWidth(), dpi); |
|
323 |
} |
|
324 |
|
|
325 |
public String getGeoScaleAsString(String fmt) { |
|
326 |
DecimalFormat format = new DecimalFormat(fmt); |
|
327 |
|
|
328 |
return "1:" + format.format(getGeoScale()); |
|
329 |
} |
|
330 |
} |
|
0 | 331 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/geo/.cvsignore | ||
---|---|---|
1 |
*.dfPackage |
|
2 |
*.wmf |
|
0 | 3 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/geo/cover/.cvsignore | ||
---|---|---|
1 |
*.dfPackage |
|
2 |
*.wmf |
|
0 | 3 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/geo/package.html | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<html> |
|
27 |
<body>Pixel: Clases base relacionadas con geometria. |
|
28 |
</body> |
|
29 |
</html> |
|
0 | 30 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/geo/Projected.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.cresques.geo; |
|
25 |
|
|
26 |
import org.cresques.cts.ICoordTrans; |
|
27 |
import org.cresques.cts.IProjection; |
|
28 |
|
|
29 |
|
|
30 |
/** |
|
31 |
* <p><code>Projected</code> should be implement by all objects that can be re-projected.</p> |
|
32 |
* |
|
33 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* |
|
34 |
*/ |
|
35 |
public interface Projected { |
|
36 |
/** |
|
37 |
* <p>Returns the current projection.<p> |
|
38 |
* |
|
39 |
* @return current projection |
|
40 |
* |
|
41 |
* @see #reProject(ICoordTrans) |
|
42 |
*/ |
|
43 |
public IProjection getProjection(); |
|
44 |
|
|
45 |
/** |
|
46 |
* <p>Changes projection of the graphical information of this object.</p> |
|
47 |
* |
|
48 |
* @param ct transformation coordinates for obtaining the new projection |
|
49 |
* |
|
50 |
* @see #getProjection() |
|
51 |
*/ |
|
52 |
public void reProject(ICoordTrans ct); |
|
53 |
} |
|
0 | 54 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/CRSFactoryNotRegisteredException.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* |
|
25 |
* AUTHORS (In addition to CIT): |
|
26 |
* 2008 {DiSiD Technologies} {Create a base Locator implementation} |
|
27 |
*/ |
|
28 |
package org.cresques; |
|
29 |
|
|
30 |
import org.gvsig.tools.exception.BaseRuntimeException; |
|
31 |
|
|
32 |
/** |
|
33 |
* Exception for errors related to the initialization of a Library. |
|
34 |
* |
|
35 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a> |
|
36 |
*/ |
|
37 |
public class CRSFactoryNotRegisteredException extends BaseRuntimeException { |
|
38 |
|
|
39 |
private static final long serialVersionUID = 7354573543115812224L; |
|
40 |
|
|
41 |
private static final String KEY = "_CRSFactoryNotRegisteredException"; |
|
42 |
|
|
43 |
private static final String MESSAGE = "An instance of ICRSFactory has not " + |
|
44 |
"been registered in the CRSFactory"; |
|
45 |
|
|
46 |
public CRSFactoryNotRegisteredException() { |
|
47 |
super(MESSAGE, KEY, serialVersionUID); |
|
48 |
} |
|
49 |
} |
|
0 | 50 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/DataTypes.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.cresques; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author gvSIG Team |
|
28 |
* @version $Id$ |
|
29 |
* |
|
30 |
*/ |
|
31 |
public interface DataTypes extends org.gvsig.tools.dataTypes.DataTypes { |
|
32 |
|
|
33 |
/* |
|
34 |
* |
|
35 |
*/ |
|
36 |
public static final int CRS = OBJECT + 1; |
|
37 |
} |
|
0 | 38 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/coerce/CoerceToString.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.cresques.coerce; |
|
25 |
|
|
26 |
import org.cresques.cts.IProjection; |
|
27 |
import org.gvsig.tools.dataTypes.AbstractCoercion; |
|
28 |
import org.gvsig.tools.dataTypes.CoercionException; |
|
29 |
import org.gvsig.tools.dataTypes.Coercion; |
|
30 |
import org.gvsig.tools.dataTypes.CoercionContext; |
|
31 |
|
|
32 |
/** |
|
33 |
* Convert a Projection to String. |
|
34 |
* |
|
35 |
* Support convert: |
|
36 |
* - Projection to String (do nothing) |
|
37 |
* |
|
38 |
* @author gvSIG Team |
|
39 |
* @version $Id$ |
|
40 |
* |
|
41 |
*/ |
|
42 |
public class CoerceToString extends AbstractCoercion { |
|
43 |
|
|
44 |
public CoerceToString() { |
|
45 |
// Do nothing |
|
46 |
} |
|
47 |
|
|
48 |
public Object coerce(Object value, CoercionContext context) throws CoercionException { |
|
49 |
if( value == null || value instanceof String ) { |
|
50 |
return value; |
|
51 |
} |
|
52 |
try { |
|
53 |
if( value instanceof IProjection ) { |
|
54 |
return ((IProjection)value).getFullCode(); |
|
55 |
} |
|
56 |
} catch (Exception e) { |
|
57 |
throw new CoercionException(e); |
|
58 |
} |
|
59 |
throw new CoercionException(); |
|
60 |
} |
|
61 |
|
|
62 |
} |
|
0 | 63 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/coerce/CoerceToCRS.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or modify it under |
|
7 |
* the terms of the GNU General Public License as published by the Free Software |
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later |
|
9 |
* version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
14 |
* details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us at info AT |
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.cresques.coerce; |
|
24 |
|
|
25 |
import org.cresques.cts.IProjection; |
|
26 |
import org.gvsig.fmap.crs.CRSFactory; |
|
27 |
import org.gvsig.tools.dataTypes.AbstractCoercion; |
|
28 |
import org.gvsig.tools.dataTypes.CoercionException; |
|
29 |
import org.gvsig.tools.dataTypes.CoercionContext; |
|
30 |
|
|
31 |
/** |
|
32 |
* Convert a string value of projection code to IProjection |
|
33 |
* |
|
34 |
* @author gvSIG Team |
|
35 |
* @version $Id$ |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class CoerceToCRS extends AbstractCoercion { |
|
39 |
|
|
40 |
public Object coerce(Object value, CoercionContext context) throws CoercionException { |
|
41 |
if (value == null || value instanceof IProjection) { |
|
42 |
return value; |
|
43 |
} |
|
44 |
try { |
|
45 |
Object proj = CRSFactory.getCRS(value.toString()); |
|
46 |
if (proj == null) { |
|
47 |
throw new CoercionException("Can't convert value '" + getValueAsString(value) + "' to IProjection. Probably not a valid format for a projection."); |
|
48 |
} |
|
49 |
return proj; |
|
50 |
} catch (Exception e) { |
|
51 |
throw new CoercionException("Can't convert value '" + getValueAsString(value) + "' to IProjection. Probably not a valid format for a projection.", e); |
|
52 |
} |
|
53 |
|
|
54 |
} |
|
55 |
|
|
56 |
private String getValueAsString(Object value) { |
|
57 |
try { |
|
58 |
return value.toString(); |
|
59 |
} catch (Exception e) { |
|
60 |
return "(unknow)"; |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
} |
|
0 | 65 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/ProjectionLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
25 |
* |
|
26 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
27 |
* of the Valencian Government (CIT) |
|
28 |
* |
|
29 |
* This program is free software; you can redistribute it and/or |
|
30 |
* modify it under the terms of the GNU General Public License |
|
31 |
* as published by the Free Software Foundation; either version 2 |
|
32 |
* of the License, or (at your option) any later version. |
|
33 |
* |
|
34 |
* This program is distributed in the hope that it will be useful, |
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
37 |
* GNU General Public License for more details. |
|
38 |
* |
|
39 |
* You should have received a copy of the GNU General Public License |
|
40 |
* along with this program; if not, write to the Free Software |
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
42 |
* MA 02110-1301, USA. |
|
43 |
* |
|
44 |
*/ |
|
45 |
package org.cresques; |
|
46 |
|
|
47 |
import org.cresques.coerce.CoerceToCRS; |
|
48 |
import org.cresques.coerce.CoerceToString; |
|
49 |
import org.cresques.cts.IProjection; |
|
50 |
import org.gvsig.fmap.crs.CRSFactory; |
|
51 |
import org.gvsig.fmap.crs.persistence.CoordTransPersistenceFactory; |
|
52 |
import org.gvsig.fmap.crs.persistence.ProjectionPersistenceFactory; |
|
53 |
import org.gvsig.tools.ToolsLibrary; |
|
54 |
import org.gvsig.tools.ToolsLocator; |
|
55 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
|
56 |
import org.gvsig.tools.library.AbstractLibrary; |
|
57 |
import org.gvsig.tools.library.LibraryException; |
|
58 |
import org.slf4j.Logger; |
|
59 |
import org.slf4j.LoggerFactory; |
|
60 |
|
|
61 |
public class ProjectionLibrary extends AbstractLibrary { |
|
62 |
|
|
63 |
private static final Logger logger = LoggerFactory.getLogger(ProjectionLibrary.class); |
|
64 |
|
|
65 |
public void doRegistration() { |
|
66 |
registerAsAPI(ProjectionLibrary.class); |
|
67 |
require(ToolsLibrary.class); |
|
68 |
} |
|
69 |
|
|
70 |
protected void doInitialize() throws LibraryException { |
|
71 |
} |
|
72 |
|
|
73 |
protected void doPostInitialize() throws LibraryException { |
|
74 |
if (CRSFactory.getCRSFactory()==null) { |
|
75 |
logger.warn("has not registered an implementation of " + this.getClass().getName()+"."); |
|
76 |
} |
|
77 |
|
|
78 |
DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager(); |
|
79 |
dataTypesManager.addtype( |
|
80 |
DataTypes.CRS, |
|
81 |
"CRS", |
|
82 |
"CRS", |
|
83 |
IProjection.class, |
|
84 |
new CoerceToCRS() |
|
85 |
); |
|
86 |
dataTypesManager.addCoercion(DataTypes.STRING, new CoerceToString()); |
|
87 |
|
|
88 |
// Register the PersistenceFactory to be able to persist |
|
89 |
// IProjection objects |
|
90 |
ToolsLocator.getPersistenceManager().registerFactory( |
|
91 |
new ProjectionPersistenceFactory()); |
|
92 |
ToolsLocator.getPersistenceManager().registerFactory( |
|
93 |
new CoordTransPersistenceFactory()); |
|
94 |
} |
|
95 |
|
|
96 |
} |
|
0 | 97 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/Messages.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
package org.cresques; |
|
26 |
|
|
27 |
import org.gvsig.tools.ToolsLocator; |
|
28 |
import org.gvsig.tools.i18n.I18nManager; |
|
29 |
|
|
30 |
/** |
|
31 |
* Bridge class to provide internationalization services to the library. |
|
32 |
* It uses the gvsig-i18n library as a backend, and includes its |
|
33 |
* necessary initialization. |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class Messages { |
|
37 |
private static I18nManager manager = null; |
|
38 |
/** |
|
39 |
* Loads the translations in the dictionary. It initializes the backend |
|
40 |
* gvsig-i18n library |
|
41 |
* |
|
42 |
*/ |
|
43 |
private static void init() { |
|
44 |
manager = ToolsLocator.getI18nManager(); |
|
45 |
manager.addResourceFamily("org.cresques.resources.i18n.text", Messages.class.getClassLoader(), Messages.class.getClass().getName()); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Gets the translation associated with the provided translation key. |
|
50 |
* |
|
51 |
* @param key The translation key which identifies the target text |
|
52 |
* @return The translation associated with the provided translation key. |
|
53 |
*/ |
|
54 |
public static String getText(String key) { |
|
55 |
if (manager == null ) { |
|
56 |
init(); |
|
57 |
} |
|
58 |
return manager.getTranslation(key); |
|
59 |
} |
|
60 |
|
|
61 |
} |
|
62 |
|
|
0 | 63 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/px/Extent.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.cresques.px; |
|
25 |
|
|
26 |
import java.awt.geom.Point2D; |
|
27 |
import java.awt.geom.Rectangle2D; |
|
28 |
import java.text.DecimalFormat; |
|
29 |
|
|
30 |
/** |
|
31 |
* Clase que getiona el extent de una imagen |
|
32 |
* |
|
33 |
* @author Luis W.Sevilla (sevilla_lui@gva.es) |
|
34 |
*/ |
|
35 |
public class Extent { |
|
36 |
Point2D min = null; |
|
37 |
Point2D max = null; |
|
38 |
|
|
39 |
/** |
|
40 |
* Constructor sin par?metros |
|
41 |
*/ |
|
42 |
public Extent() { |
|
43 |
min = new Point2D.Double(999999999.0, 999999999.0); |
|
44 |
max = new Point2D.Double(-999999999.0, -999999999.0); |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* Constructor |
|
49 |
* @param pt1 punto que representa la esquina superior izquierda |
|
50 |
* @param pt2 punto que representa la esquina inferior derecha |
|
51 |
*/ |
|
52 |
public Extent(Point2D pt1, Point2D pt2) { |
|
53 |
newExtent(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY()); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* Contructor |
|
58 |
* @param x1 punto que representa la coordenada X de la esquina superior izquierda |
|
59 |
* @param y1 punto que representa la coordenada Y de la esquina superior izquierda |
|
60 |
* @param x2 punto que representa la coordenada X de la esquina inferior derecha |
|
61 |
* @param y2 punto que representa la coordenada Y de la esquina inferior derecha |
|
62 |
*/ |
|
63 |
public Extent(double x1, double y1, double x2, double y2) { |
|
64 |
newExtent(x1, y1, x2, y2); |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Constructor |
|
69 |
* @param r Rectangulo 2D |
|
70 |
*/ |
|
71 |
public Extent(Rectangle2D r) { |
|
72 |
newExtent(r.getX(), r.getY(), r.getX() + r.getWidth(), |
|
73 |
r.getY() + r.getHeight()); |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Constructor de copia |
|
78 |
* @param ext Objeto Extent |
|
79 |
*/ |
|
80 |
public Extent(Extent ext) { |
|
81 |
newExtent(ext.minX(), ext.minY(), ext.maxX(), ext.maxY()); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Crea un objeto extent identico y lo retorna |
|
86 |
* @return Objeto extent |
|
87 |
*/ |
|
88 |
public Object clone() { |
|
89 |
Extent e = (Extent) clone(); |
|
90 |
e.min = (Point2D) min.clone(); |
|
91 |
e.max = (Point2D) max.clone(); |
|
92 |
|
|
93 |
return e; |
|
94 |
} |
|
95 |
|
|
96 |
private void newExtent(double x1, double y1, double x2, double y2) { |
|
97 |
min = new Point2D.Double(Math.min(x1, x2), Math.min(y1, y2)); |
|
98 |
max = new Point2D.Double(Math.max(x1, x2), Math.max(y1, y2)); |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Obtiene la coordenada X m?nima |
|
103 |
* @return valor de la coordenada X m?nima |
|
104 |
*/ |
|
105 |
public double minX() { |
|
106 |
return min.getX(); |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Obtiene la coordenada Y m?nima |
|
111 |
* @return valor de la coordenada X m?nima |
|
112 |
*/ |
|
113 |
public double minY() { |
|
114 |
return min.getY(); |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* Obtiene la coordenada X m?xima |
|
119 |
* @return valor de la coordenada X m?xima |
|
120 |
*/ |
|
121 |
public double maxX() { |
|
122 |
return max.getX(); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Obtiene la coordenada Y m?xima |
|
127 |
* @return valor de la coordenada Y m?xima |
|
128 |
*/ |
|
129 |
public double maxY() { |
|
130 |
return max.getY(); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Obtiene el punto m?nimo |
|
135 |
* @return m?nimo |
|
136 |
*/ |
|
137 |
public Point2D getMin() { |
|
138 |
return min; |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* Obtiene el punto m?ximo |
|
143 |
* @return m?ximo |
|
144 |
*/ |
|
145 |
public Point2D getMax() { |
|
146 |
return max; |
|
147 |
} |
|
148 |
|
|
149 |
public boolean isAt(Point2D pt) { |
|
150 |
if (pt.getX() < minX()) { |
|
151 |
return false; |
|
152 |
} |
|
153 |
|
|
154 |
if (pt.getX() > maxX()) { |
|
155 |
return false; |
|
156 |
} |
|
157 |
|
|
158 |
if (pt.getY() < minY()) { |
|
159 |
return false; |
|
160 |
} |
|
161 |
|
|
162 |
if (pt.getY() > maxY()) { |
|
163 |
return false; |
|
164 |
} |
|
165 |
|
|
166 |
return true; |
|
167 |
} |
|
168 |
|
|
169 |
public double width() { |
|
170 |
return Math.abs(maxX() - minX()); |
|
171 |
} |
|
172 |
|
|
173 |
public double height() { |
|
174 |
return Math.abs(maxY() - minY()); |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Verifica un punto, y modifica el extent si no est? incluido |
|
179 |
*/ |
|
180 |
public void add(Point2D pt) { |
|
181 |
if (pt == null) { |
|
182 |
return; |
|
183 |
} |
|
184 |
|
|
185 |
min.setLocation(Math.min(pt.getX(), minX()), Math.min(pt.getY(), minY())); |
|
186 |
max.setLocation(Math.max(pt.getX(), maxX()), Math.max(pt.getY(), maxY())); |
|
187 |
} |
|
188 |
|
|
189 |
public void add(Extent ext) { |
|
190 |
if (ext == null) { |
|
191 |
return; |
|
192 |
} |
|
193 |
|
|
194 |
min.setLocation(Math.min(ext.minX(), minX()), |
|
195 |
Math.min(ext.minY(), minY())); |
|
196 |
max.setLocation(Math.max(ext.maxX(), maxX()), |
|
197 |
Math.max(ext.maxY(), maxY())); |
|
198 |
} |
|
199 |
|
|
200 |
/** |
|
201 |
* Obtiene la escala |
|
202 |
* @param width Ancho |
|
203 |
* @param height Alto |
|
204 |
* @return |
|
205 |
*/ |
|
206 |
public double[] getScale(int width, int height) { |
|
207 |
return getScale((double) width, (double) height); |
|
208 |
} |
|
209 |
|
|
210 |
public double[] getScale(double width, double height) { |
|
211 |
double[] scale = new double[2]; |
|
212 |
scale[0] = ((float) width) / width(); |
|
213 |
scale[1] = ((float) height) / height(); |
|
214 |
|
|
215 |
return scale; |
|
216 |
} |
|
217 |
|
|
218 |
public Rectangle2D toRectangle2D() { |
|
219 |
return new Rectangle2D.Double(minX(), minY(), width(), height()); |
|
220 |
} |
|
221 |
|
|
222 |
public String toString() { |
|
223 |
DecimalFormat format = new DecimalFormat("####.000"); |
|
224 |
|
|
225 |
return "Extent: (" + format.format(minX()) + "," + |
|
226 |
format.format(minY()) + "), (" + format.format(maxX()) + "," + |
|
227 |
format.format(maxY()) + ")"; |
|
228 |
} |
|
229 |
|
|
230 |
public interface Has { |
|
231 |
public Extent getExtent(); |
|
232 |
} |
|
233 |
} |
|
0 | 234 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/px/.cvsignore | ||
---|---|---|
1 |
*.dfPackage |
|
2 |
*.wmf |
|
0 | 3 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/px/package.html | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<html> |
|
27 |
<body>Pixel: Clases para dibujar. |
|
28 |
</body> |
|
29 |
</html> |
|
0 | 30 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/cts/package.html | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<html> |
|
27 |
<body>Clases relacionadas con el manejo de proyecciones. |
|
28 |
</body> |
|
29 |
</html> |
|
0 | 30 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/cts/CoordTransRuntimeException.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2015 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.cresques.cts; |
|
24 |
|
|
25 |
/** |
|
26 |
* @author fdiaz |
|
27 |
* |
|
28 |
*/ |
|
29 |
public class CoordTransRuntimeException extends RuntimeException { |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
*/ |
|
34 |
private static final long serialVersionUID = 1348981767734366776L; |
|
35 |
IProjection source; |
|
36 |
IProjection target; |
|
37 |
double x; |
|
38 |
double y; |
|
39 |
|
|
40 |
/** |
|
41 |
* |
|
42 |
*/ |
|
43 |
public CoordTransRuntimeException(IProjection source, IProjection target, double x, double y, Throwable cause) { |
|
44 |
super("Error reprojecting point (" + x + "," + y + ") from " + source.getAbrev() + " to " + target.getAbrev() |
|
45 |
+ ".", cause); |
|
46 |
this.source = source; |
|
47 |
this.target = target; |
|
48 |
this.x = x; |
|
49 |
this.y = y; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* |
|
54 |
*/ |
|
55 |
public CoordTransRuntimeException(IProjection source, IProjection target, double x, double y) { |
|
56 |
this(source, target, x, y, null); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* @return the source |
|
61 |
*/ |
|
62 |
public IProjection getSource() { |
|
63 |
return source; |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* @return the target |
|
68 |
*/ |
|
69 |
public IProjection getTarget() { |
|
70 |
return target; |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* @return the x |
|
75 |
*/ |
|
76 |
public double getX() { |
|
77 |
return x; |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* @return the y |
|
82 |
*/ |
|
83 |
public double getY() { |
|
84 |
return y; |
|
85 |
} |
|
86 |
|
|
87 |
} |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/cts/IDatum.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.cresques.cts; |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* @author "Luis W. Sevilla" (sevilla_lui@gva.es) |
|
29 |
*/ |
|
30 |
public interface IDatum { |
|
31 |
/** |
|
32 |
* Semieje Mayor del elipsoide. |
|
33 |
* @return |
|
34 |
*/ |
|
35 |
public double getESemiMajorAxis(); |
|
36 |
|
|
37 |
/** |
|
38 |
* Aplanamiento del elipsoide. |
|
39 |
* @return |
|
40 |
*/ |
|
41 |
public double getEIFlattening(); |
|
42 |
} |
|
0 | 43 |
org.gvsig.projection/tags/org.gvsig.projection.api-2.0.48/src/main/java/org/cresques/cts/IProjection.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.cresques.cts; |
|
25 |
|
|
26 |
import java.awt.Color; |
|
27 |
import java.awt.Graphics2D; |
|
28 |
import java.awt.geom.Point2D; |
|
29 |
import java.awt.geom.Rectangle2D; |
|
30 |
|
|
31 |
import org.cresques.geo.ViewPortData; |
|
32 |
|
|
33 |
import org.gvsig.tools.lang.Cloneable; |
|
34 |
|
|
35 |
/** |
|
36 |
* |
|
37 |
* @author "Luis W. Sevilla" (sevilla_lui@gva.es) |
|
38 |
*/ |
|
39 |
public interface IProjection extends Cloneable{ |
|
40 |
|
|
41 |
/** |
|
42 |
* Return the string representation of projection in the format. |
|
43 |
* |
|
44 |
* Return null if can't export to format |
|
45 |
* |
|
46 |
* @param format |
|
47 |
* @return |
|
48 |
*/ |
|
49 |
public String export(String format); |
|
50 |
|
|
51 |
public IDatum getDatum(); |
|
52 |
|
|
53 |
public Point2D createPoint(double x, double y); |
|
54 |
|
|
55 |
// TODO Quitar si no son necesarias. |
|
56 |
public String getAbrev(); |
|
57 |
|
|
58 |
/** |
|
59 |
* Devuelve getAbrev() mas los parametros de transformacion si los hay |
|
60 |
* ej.: (EPSG:23030:proj@+proj...@...) |
|
61 |
* |
|
62 |
* @return getAbrev() o getAbrev()+parametros |
|
63 |
*/ |
|
64 |
public String getFullCode(); |
|
65 |
|
|
66 |
public void drawGrid(Graphics2D g, ViewPortData vp); |
|
67 |
|
|
68 |
public void setGridColor(Color c); |
|
69 |
|
|
70 |
public Color getGridColor(); |
|
71 |
|
|
72 |
/** |
|
73 |
* Crea un ICoordTrans para transformar coordenadas |
|
74 |
* desde el IProjection actual al dest. |
|
75 |
* @param dest |
|
76 |
* @return |
|
77 |
*/ |
|
78 |
|
|
79 |
public ICoordTrans getCT(IProjection dest); |
|
80 |
|
|
81 |
public Point2D toGeo(Point2D pt); |
|
82 |
|
|
83 |
public Point2D fromGeo(Point2D gPt, Point2D mPt); |
|
84 |
|
|
85 |
public boolean isProjected(); |
|
86 |
|
|
87 |
/** |
|
88 |
* First two parameters must be in meters. |
|
89 |
* This should be changed (map units should be used) and then |
|
90 |
* change the places where this method is used. |
|
91 |
* |
|
92 |
* @param minX in meters |
|
93 |
* @param maxX in meters |
|
94 |
* @param width in pixels (dots) |
|
95 |
* @param dpi dots per inch |
|
96 |
* @return Scale denominator ( the "X" in "1 : X" ) |
|
97 |
*/ |
|
98 |
public double getScale(double minX, double maxX, double width, double dpi); |
|
99 |
|
|
100 |
public Rectangle2D getExtent(Rectangle2D extent,double scale,double wImage,double hImage,double mapUnits,double distanceUnits,double dpi); |
|
101 |
} |
|
0 | 102 |
Also available in: Unified diff