svn-gvsig-desktop / branches / libProjection_v2_0_prep / libraries / libProjection / src / org / cresques / impl / cts / gt2 / CSLambertCC.java @ 27135
History | View | Annotate | Download (4.87 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.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 |
*/
|
39 |
public class CSLambertCC extends CoordSys { |
40 |
public CSLambertCC(CSDatum datum, double meridian, double origin, |
41 |
double sp1, double sp2, double est, double nort) { |
42 |
super(datum);
|
43 |
|
44 |
geogCS = new GeographicCoordinateSystem(datum.getName(null), |
45 |
datum.getDatum()); |
46 |
|
47 |
Unit linearUnit = Unit.METRE; |
48 |
|
49 |
javax.media.jai.ParameterList params = csFactory.createProjectionParameterList("Lambert_Conformal_Conic_2SP");
|
50 |
params.setParameter("semi_major",
|
51 |
datum.getDatum().getEllipsoid().getSemiMajorAxis()); |
52 |
params.setParameter("semi_minor",
|
53 |
datum.getDatum().getEllipsoid().getSemiMinorAxis()); |
54 |
params.setParameter("central_meridian", meridian);
|
55 |
params.setParameter("latitude_of_origin", origin);
|
56 |
params.setParameter("standard_parallel_1", sp1);
|
57 |
params.setParameter("standard_parallel_2", sp2);
|
58 |
params.setParameter("false_easting", est);
|
59 |
params.setParameter("false_northing", nort);
|
60 |
|
61 |
try {
|
62 |
Projection projection = csFactory.createProjection("Lambert",
|
63 |
"Lambert_Conformal_Conic_2SP",
|
64 |
params); |
65 |
projCS = csFactory.createProjectedCoordinateSystem(projection.getName() |
66 |
.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 CSLambertCC(CSDatum datum, double meridian, double origin, |
79 |
double sf, double est, double nort) { |
80 |
super(datum);
|
81 |
|
82 |
geogCS = new GeographicCoordinateSystem(datum.getName(null), |
83 |
datum.getDatum()); |
84 |
|
85 |
Unit linearUnit = Unit.METRE; |
86 |
|
87 |
javax.media.jai.ParameterList params = csFactory.createProjectionParameterList("Lambert_Conformal_Conic_1SP");
|
88 |
params.setParameter("semi_major",
|
89 |
datum.getDatum().getEllipsoid().getSemiMajorAxis()); |
90 |
params.setParameter("semi_minor",
|
91 |
datum.getDatum().getEllipsoid().getSemiMinorAxis()); |
92 |
params.setParameter("central_meridian", meridian);
|
93 |
params.setParameter("latitude_of_origin", origin);
|
94 |
params.setParameter("scale_factor", sf);
|
95 |
params.setParameter("false_easting", est);
|
96 |
params.setParameter("false_northing", nort);
|
97 |
|
98 |
try {
|
99 |
Projection projection = csFactory.createProjection("Lambert",
|
100 |
"Lambert_Conformal_Conic_1SP",
|
101 |
params); |
102 |
projCS = csFactory.createProjectedCoordinateSystem(projection.getName() |
103 |
.toString(), |
104 |
geogCS, |
105 |
projection, |
106 |
linearUnit, |
107 |
AxisInfo.X, |
108 |
AxisInfo.Y); |
109 |
} catch (FactoryException e) {
|
110 |
// TODO Bloque catch generado autom?ticamente
|
111 |
e.printStackTrace(); |
112 |
} |
113 |
} |
114 |
|
115 |
public double getScale(double minX, double maxX, double w, double dpi) { |
116 |
double scale = super.getScale(minX, maxX, w, dpi); |
117 |
|
118 |
if (projCS != null) { // Es geogr?fico; calcula la escala. |
119 |
scale = ((maxX - minX) * // metros
|
120 |
(dpi / 2.54 * 100.0)) / // px / metro |
121 |
w; // pixels
|
122 |
} |
123 |
|
124 |
return scale;
|
125 |
} |
126 |
|
127 |
public String toString() { |
128 |
return projCS.toString();
|
129 |
} |
130 |
} |