Statistics
| Revision:

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 / CSMercator.java @ 40559

History | View | Annotate | Download (3.44 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.geotools.cs.AxisInfo;
27
import org.geotools.cs.GeographicCoordinateSystem;
28
import org.geotools.cs.Projection;
29

    
30
import org.geotools.units.Unit;
31

    
32
import org.opengis.referencing.FactoryException;
33

    
34

    
35
/**
36
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
37
 */
38
public class CSMercator extends CoordSys {
39
    public CSMercator(CSDatum datum) {
40
        super(datum);
41
        geogCS = new GeographicCoordinateSystem(datum.getName(null),
42
                                                datum.getDatum());
43

    
44
        Unit linearUnit = Unit.METRE;
45

    
46
        javax.media.jai.ParameterList params = csFactory.createProjectionParameterList("Mercator");
47
        params.setParameter("semi_major",
48
                            datum.getDatum().getEllipsoid().getSemiMajorAxis());
49
        params.setParameter("semi_minor",
50
                            datum.getDatum().getEllipsoid().getSemiMinorAxis());
51
        params.setParameter("central_meridian", 0D);
52
        params.setParameter("latitude_of_origin", 0D);
53
        params.setParameter("scale_factor", 1D);
54
        params.setParameter("false_easting", 0D);
55
        params.setParameter("false_northing", 0D);
56

    
57
        try {
58
            Projection projection = csFactory.createProjection("Mercator",
59
                                                               "Mercator_1SP",
60
                                                               params);
61
            projCS = csFactory.createProjectedCoordinateSystem(projection.getName()
62
                                                                         .toString(),
63
                                                               geogCS,
64
                                                               projection,
65
                                                               linearUnit,
66
                                                               AxisInfo.X,
67
                                                               AxisInfo.Y);
68
        } catch (FactoryException e) {
69
            // TODO Bloque catch generado autom?ticamente
70
            e.printStackTrace();
71
        }
72
    }
73

    
74
    public double getScale(double minX, double maxX, double w, double dpi) {
75
        double scale = super.getScale(minX, maxX, w, dpi);
76

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

    
83
        return scale;
84
    }
85

    
86
    public String toString() {
87
        return projCS.toString();
88
    }
89
}