svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.projection / org.gvsig.projection.cresques / org.gvsig.projection.cresques.impl / src / main / java / org / cresques / impl / cts / gt2 / CSUTM.java @ 40559
History | View | Annotate | Download (3.86 KB)
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.impl.cts.gt2; |
25 |
|
26 |
import org.cresques.cts.UTM; |
27 |
import org.geotools.cs.AxisInfo; |
28 |
import org.geotools.cs.Projection; |
29 |
import org.geotools.units.Unit; |
30 |
import org.gvsig.fmap.crs.CRSFactory; |
31 |
import org.opengis.referencing.FactoryException; |
32 |
|
33 |
|
34 |
/**
|
35 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
36 |
*/
|
37 |
public class CSUTM extends CoordSys implements UTM { |
38 |
public CSUTM(CSDatum datum, int zone) { |
39 |
super(datum);
|
40 |
init(datum, zone, "N");
|
41 |
} |
42 |
|
43 |
public CSUTM(CSDatum datum, int zone, String ns) { |
44 |
super(datum);
|
45 |
init(datum, zone, ns); |
46 |
} |
47 |
|
48 |
public void init(CSDatum datum, int zone, String ns) { |
49 |
Unit linearUnit = Unit.METRE; |
50 |
|
51 |
javax.media.jai.ParameterList params = csFactory.createProjectionParameterList("Transverse_Mercator");
|
52 |
params.setParameter("semi_major",
|
53 |
datum.getDatum().getEllipsoid().getSemiMajorAxis()); |
54 |
params.setParameter("semi_minor",
|
55 |
datum.getDatum().getEllipsoid().getSemiMinorAxis()); |
56 |
params.setParameter("central_meridian", (double) ((zone * 6) - 183)); |
57 |
params.setParameter("latitude_of_origin", 0.0); |
58 |
params.setParameter("scale_factor", 0.9996); |
59 |
params.setParameter("false_easting", 500000.0); |
60 |
if (ns.toUpperCase().compareTo("S") == 0) |
61 |
params.setParameter("false_northing", 10000000.0); |
62 |
else
|
63 |
params.setParameter("false_northing", 0.0); |
64 |
|
65 |
try {
|
66 |
Projection projection = csFactory.createProjection("UTM" + zone,
|
67 |
"Transverse_Mercator",
|
68 |
params); |
69 |
projCS = csFactory.createProjectedCoordinateSystem(projection.getName() |
70 |
.toString(), |
71 |
geogCS, |
72 |
projection, |
73 |
linearUnit, |
74 |
AxisInfo.X, |
75 |
AxisInfo.Y); |
76 |
} catch (FactoryException e) {
|
77 |
// TODO Bloque catch generado autom?ticamente
|
78 |
e.printStackTrace(); |
79 |
} |
80 |
} |
81 |
|
82 |
public double getScale(double minX, double maxX, double w, double dpi) { |
83 |
double scale = super.getScale(minX, maxX, w, dpi); |
84 |
|
85 |
if (projCS != null) { // Es geogr?fico; calcula la escala. |
86 |
scale = ((maxX - minX) * // metros
|
87 |
(dpi / 2.54 * 100.0)) / // px / metro |
88 |
w; // pixels
|
89 |
} |
90 |
|
91 |
return scale;
|
92 |
} |
93 |
|
94 |
public String toString() { |
95 |
return projCS.toString();
|
96 |
} |
97 |
|
98 |
public Object clone() throws CloneNotSupportedException { |
99 |
return CRSFactory.getCRS( this.getFullCode() ); |
100 |
} |
101 |
|
102 |
} |