Statistics
| Revision:

root / branches / Mobile_Compatible_Hito_1 / libProjectionCresques / src / org / gvsig / projection / cresques / cts / gt2 / CSUTM.java @ 21932

History | View | Annotate | Download (3.4 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-7.
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.gvsig.projection.cresques.cts.gt2;
25

    
26

    
27
import org.geotools.cs.AxisInfo;
28
import org.geotools.cs.Projection;
29
import org.geotools.units.Unit;
30
import org.gvsig.projection.cts.IDatum;
31
import org.gvsig.projection.cts.UTM;
32
import org.opengis.referencing.FactoryException;
33

    
34

    
35
/**
36
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
37
 */
38
public class CSUTM extends CoordSys implements UTM {
39
    public CSUTM(CSDatum datum, int zone) {
40
        super(datum);
41
        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
 
49
    public void init(IDatum datum, int zone, String ns) {
50
        org.geotools.units.Unit linearUnit = org.geotools.units.Unit.METRE;
51

    
52
        javax.media.jai.ParameterList params = csFactory.createProjectionParameterList("Transverse_Mercator");
53
        params.setParameter("semi_major",((CSDatum)datum).getDatum().getEllipsoid().getSemiMajorAxis());
54
        params.setParameter("semi_minor",((CSDatum)datum).getDatum().getEllipsoid().getSemiMinorAxis());
55
        params.setParameter("central_meridian", (double) ((zone * 6) - 183));
56
        params.setParameter("latitude_of_origin", 0.0);
57
        params.setParameter("scale_factor", 0.9996);
58
        params.setParameter("false_easting", 500000.0);
59
        if (ns.toUpperCase().compareTo("S") == 0)
60
                params.setParameter("false_northing", 10000000.0);
61
        else
62
                params.setParameter("false_northing", 0.0);
63

    
64
        try {
65
            Projection projection = csFactory.createProjection("UTM" + zone,"Transverse_Mercator",params);
66
            projCS = csFactory.createProjectedCoordinateSystem(projection.getName().toString(),
67
                                                                                                                    geogCS,
68
                                                                                                                    projection,
69
                                                                                                                    linearUnit,
70
                                                                                                                    AxisInfo.X,
71
                                                                                                                    AxisInfo.Y);
72
        } catch (FactoryException e) {
73
            // TODO Bloque catch generado autom?ticamente
74
            e.printStackTrace();
75
        }
76
    }
77

    
78
    public double getScale(double minX, double maxX, double w, double dpi) {
79
        double scale = super.getScale(minX, maxX, w, dpi);
80

    
81
        if (projCS != null) { // Es geogr?fico; calcula la escala.
82
            scale = ((maxX - minX) * // metros
83
                    (dpi / 2.54 * 100.0)) / // px / metro
84
                    w; // pixels
85
        }
86

    
87
        return scale;
88
    }
89

    
90
    public String toString() {
91
        return projCS.toString();
92
    }
93
}