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