svn-gvsig-desktop / tags / gvSIGv0_6_1RELEASE / libraries / libCq CMS for java.old / src / org / cresques / cts / gt2 / CSMercator.java @ 5222
History | View | Annotate | Download (3.38 KB)
1 | 5179 | luisw2 | /*
|
---|---|---|---|
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 | |||
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 | } |