Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / cts / gt2 / CSUTM.java @ 2312

History | View | Annotate | Download (2.63 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.gt2;
25

    
26
import org.geotools.cs.AxisInfo;
27
import org.geotools.cs.GeographicCoordinateSystem;
28
import org.geotools.cs.Projection;
29
import org.geotools.units.Unit;
30
import org.opengis.referencing.FactoryException;
31

    
32
/**
33
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
34
 */
35
public class CSUTM extends CoordSys {
36
        public CSUTM(CSDatum datum, int zone) {
37
                super(datum);
38
                geogCS = new GeographicCoordinateSystem(
39
                        datum.getName(null), 
40
                        datum.getDatum());
41
                Unit linearUnit = Unit.METRE;
42
                
43
                javax.media.jai.ParameterList  params = 
44
                        csFactory.createProjectionParameterList("Transverse_Mercator");
45
                params.setParameter("semi_major", datum.getDatum().getEllipsoid().getSemiMajorAxis());
46
                params.setParameter("semi_minor", datum.getDatum().getEllipsoid().getSemiMinorAxis());
47
                params.setParameter("central_meridian", (double) (zone*6-183));
48
                params.setParameter("latitude_of_origin", 0.0);
49
                params.setParameter("scale_factor", 0.9996);
50
                params.setParameter("false_easting", 500000.0);
51
                params.setParameter("false_northing", 0.0);
52
                try {
53
                        Projection projection = 
54
                                csFactory.createProjection("UTM"+zone, "Transverse_Mercator", params);
55
                        projCS = csFactory.createProjectedCoordinateSystem(
56
                                        projection.getName().toString(), geogCS, projection, linearUnit, AxisInfo.X, AxisInfo.Y);
57
                } catch (FactoryException e) {
58
                        // TODO Bloque catch generado autom?ticamente
59
                        e.printStackTrace();
60
                }
61
        }
62
        public double getScale(double minX, double maxX, double w, double dpi) {
63
                double scale = super.getScale(minX, maxX, w, dpi);
64
                if (projCS != null) { // Es geogr?fico; calcula la escala.
65
                        scale = (maxX-minX)*        // metros
66
                        (dpi / 2.54 * 100.0)/        // px / metro
67
                        w;                                                // pixels
68
                }
69
                return scale;
70
        }
71
        public String toString() {
72
                return projCS.toString();
73
        }
74
}