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