Revision 10154
branches/F2/libraries/libJCRS/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>crsgdal</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> |
|
15 |
<triggers>full,incremental,</triggers> |
|
16 |
<arguments> |
|
17 |
<dictionary> |
|
18 |
<key>LaunchConfigHandle</key> |
|
19 |
<value><project>/.externalToolBuilders/crsgdal build.xml [Builder].launch</value> |
|
20 |
</dictionary> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
23 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
26 |
</natures> |
|
27 |
</projectDescription> |
|
0 | 28 |
branches/F2/libraries/libJCRS/src-test/org/gvsig/crs/jgridshift/JGridShiftTest.java | ||
---|---|---|
1 |
package org.gvsig.crs.jgridshift; |
|
2 |
|
|
3 |
import java.io.FileNotFoundException; |
|
4 |
import java.io.IOException; |
|
5 |
import java.io.RandomAccessFile; |
|
6 |
|
|
7 |
import au.com.objectix.jgridshift.GridShift; |
|
8 |
import au.com.objectix.jgridshift.GridShiftFile; |
|
9 |
import au.com.objectix.jgridshift.SubGrid; |
|
10 |
|
|
11 |
public class JGridShiftTest { |
|
12 |
|
|
13 |
public static void main(String[] args){ |
|
14 |
//InputStream fis = null; |
|
15 |
RandomAccessFile raf = null; |
|
16 |
try { |
|
17 |
raf = new RandomAccessFile("/home/dguerrero/Desarrollo-gvSIG/crs/workspace/extJCRS/data/sped2et.gsb","r"); |
|
18 |
//fis = new FileInputStream("/home/dguerrero/Desarrollo-gvSIG/crs/workspace/extJCRS/data/sped2et.gsb"); |
|
19 |
} catch (FileNotFoundException e) { |
|
20 |
// TODO Auto-generated catch block |
|
21 |
e.printStackTrace(); |
|
22 |
} |
|
23 |
GridShiftFile gsf = new GridShiftFile(); |
|
24 |
try { |
|
25 |
gsf.loadGridShiftFile(raf); |
|
26 |
} catch (IOException e) { |
|
27 |
// TODO Auto-generated catch block |
|
28 |
e.printStackTrace(); |
|
29 |
} |
|
30 |
|
|
31 |
SubGrid subGrid[] = gsf.getSubGridTree(); |
|
32 |
System.out.println(subGrid.length); |
|
33 |
System.out.println(subGrid[0].getMaxLat()); |
|
34 |
System.out.println(subGrid[0].getMinLat()); |
|
35 |
System.out.println(subGrid[0].getMaxLon()); |
|
36 |
System.out.println(subGrid[0].getMinLon()); |
|
37 |
GridShift gridShift = new GridShift(); |
|
38 |
} |
|
39 |
|
|
40 |
} |
|
0 | 41 |
branches/F2/libraries/libJCRS/src-test/org/gvsig/crs/repository/RepositoryTest.java | ||
---|---|---|
1 |
package org.gvsig.crs.repository; |
|
2 |
|
|
3 |
import org.gvsig.crs.Crs; |
|
4 |
|
|
5 |
|
|
6 |
public class RepositoryTest { |
|
7 |
public static void main(String[] args){ |
|
8 |
EpsgRepository epsgRep= new EpsgRepository(); |
|
9 |
Crs crs = (Crs)epsgRep.getCrs("23030"); |
|
10 |
String abrev = crs.getAbrev(); |
|
11 |
System.out.println(abrev); |
|
12 |
} |
|
13 |
} |
|
0 | 14 |
branches/F2/libraries/libJCRS/src-test/org/gvsig/crs/gui/TransformationNadgridsPanelTest.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
|
|
3 |
import javax.swing.JFrame; |
|
4 |
|
|
5 |
import org.gvsig.crs.gui.panels.TransformationNadgridsPanel; |
|
6 |
|
|
7 |
public class TransformationNadgridsPanelTest { |
|
8 |
|
|
9 |
public static void main(String[] args){ |
|
10 |
TransformationNadgridsPanel trPanel = new TransformationNadgridsPanel(); |
|
11 |
JFrame jFrame = new JFrame(); |
|
12 |
jFrame.getContentPane().add(trPanel); |
|
13 |
jFrame.setSize(500, 700); |
|
14 |
jFrame.setVisible(true); |
|
15 |
} |
|
16 |
|
|
17 |
} |
|
0 | 18 |
branches/F2/libraries/libJCRS/src-test/org/gvsig/crs/jscrollpanel/ScrollPanelTest.java | ||
---|---|---|
1 |
package org.gvsig.crs.jscrollpanel; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.Frame; |
|
5 |
|
|
6 |
import javax.swing.BorderFactory; |
|
7 |
import javax.swing.JFrame; |
|
8 |
import javax.swing.JScrollPane; |
|
9 |
import javax.swing.JTable; |
|
10 |
import javax.swing.ListSelectionModel; |
|
11 |
import javax.swing.table.DefaultTableModel; |
|
12 |
import javax.swing.table.TableColumn; |
|
13 |
|
|
14 |
import com.iver.andami.PluginServices; |
|
15 |
import com.iver.cit.gvsig.gui.TableSorter; |
|
16 |
|
|
17 |
public class ScrollPanelTest { |
|
18 |
|
|
19 |
JTable jTable = null; |
|
20 |
JScrollPane jScrollPane = null; |
|
21 |
|
|
22 |
public ScrollPanelTest() { |
|
23 |
super(); |
|
24 |
JFrame jFrame = new JFrame(); |
|
25 |
jFrame.getContentPane().add(getJScrollPane()); |
|
26 |
jFrame.setSize(500, 150); |
|
27 |
jFrame.setVisible(true); |
|
28 |
// TODO Auto-generated constructor stub |
|
29 |
} |
|
30 |
|
|
31 |
public JTable getJTable() { |
|
32 |
if (jTable == null) { |
|
33 |
String[] columnNames= {"UNA COLUMNA", "DOS COLUMNAS"}; |
|
34 |
Object[][]data = {}; |
|
35 |
DefaultTableModel dtm = new DefaultTableModel(data, columnNames); |
|
36 |
jTable = new JTable(dtm); |
|
37 |
jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
|
38 |
TableColumn column = null; |
|
39 |
for (int i = 0; i < 2; i++) { |
|
40 |
column = jTable.getColumnModel().getColumn(i); |
|
41 |
if (i == 0) { |
|
42 |
column.setPreferredWidth(600); |
|
43 |
} |
|
44 |
} |
|
45 |
//jTable.setPreferredSize(new Dimension(800, 100)); |
|
46 |
|
|
47 |
} |
|
48 |
|
|
49 |
return jTable; |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
|
|
54 |
private JScrollPane getJScrollPane() { |
|
55 |
if (jScrollPane == null) { |
|
56 |
jScrollPane = new JScrollPane(getJTable(),JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); |
|
57 |
jScrollPane.setPreferredSize(new Dimension(500,150)); |
|
58 |
jScrollPane.setBorder( |
|
59 |
BorderFactory.createCompoundBorder( |
|
60 |
BorderFactory.createCompoundBorder( |
|
61 |
BorderFactory.createTitledBorder("TABLA GEN?RICA DE 2 CAMPOS"), |
|
62 |
BorderFactory.createEmptyBorder(5,5,5,5)), |
|
63 |
jScrollPane.getBorder())); |
|
64 |
jScrollPane.setViewportView(getJTable()); |
|
65 |
} |
|
66 |
return jScrollPane; |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
public static void main(String[] args){ |
|
71 |
ScrollPanelTest al = new ScrollPanelTest(); |
|
72 |
} |
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
} |
|
0 | 77 |
branches/F2/libraries/libJCRS/src/org/gvsig/crs/Crs.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs; |
|
42 |
|
|
43 |
import java.awt.Color; |
|
44 |
import java.awt.Graphics2D; |
|
45 |
import java.awt.geom.Point2D; |
|
46 |
import java.awt.geom.Rectangle2D; |
|
47 |
|
|
48 |
import org.cresques.cts.ICoordTrans; |
|
49 |
import org.cresques.cts.IDatum; |
|
50 |
import org.cresques.cts.IProjection; |
|
51 |
import org.cresques.geo.ViewPortData; |
|
52 |
import org.gvsig.crs.ogr.CrsOgr; |
|
53 |
import org.gvsig.crs.ogr.CrsOgrException; |
|
54 |
import org.gvsig.crs.ogr.OGRException; |
|
55 |
import org.gvsig.crs.ogr.OGRSpatialReference; |
|
56 |
import org.gvsig.crs.ogr.crsgdalException; |
|
57 |
import org.gvsig.crs.proj.CrsProj; |
|
58 |
import org.gvsig.crs.proj.CrsProjException; |
|
59 |
import org.gvsig.crs.proj.JNIBaseCrs; |
|
60 |
import org.gvsig.crs.proj.OperationCrsException; |
|
61 |
|
|
62 |
/** |
|
63 |
* Clase que construye el CRS a partir de la cadena WKT |
|
64 |
* @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com) |
|
65 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
|
66 |
* @author Miguel Garc?a Jim?nez (garciajimenez.miguel@gmail.com) |
|
67 |
* |
|
68 |
*/ |
|
69 |
public class Crs implements ICrs { |
|
70 |
private static final Color basicGridColor = new Color(64, 64, 64, 128); |
|
71 |
private String proj4; |
|
72 |
private String trans; |
|
73 |
//private String transOrigin = ""; |
|
74 |
private String abrev; |
|
75 |
private String name = ""; |
|
76 |
private CrsProj crsProj4; |
|
77 |
private CrsProj crsBase = null; |
|
78 |
private CrsWkt crsWkt; |
|
79 |
private int epsg_code = 23030; |
|
80 |
boolean targetNad = false; |
|
81 |
String nad = ""; |
|
82 |
String wkt = null; |
|
83 |
Color gridColor = basicGridColor; |
|
84 |
CRSDatum datum = null; |
|
85 |
|
|
86 |
/** |
|
87 |
* Construye un CRS a partir del c?digo EPSG o de la cadena WKT. |
|
88 |
* |
|
89 |
* @param code |
|
90 |
* @throws CrsException |
|
91 |
*/ |
|
92 |
public Crs(String code) throws CrsException { |
|
93 |
String fullCode; |
|
94 |
setWKT(code); |
|
95 |
if(code.charAt(0) == 'E' || code.charAt(0) == 'G' || code.charAt(0) == 'P') |
|
96 |
fullCode = code; |
|
97 |
else fullCode = "EPSG:"+code; |
|
98 |
String cod = ""; |
|
99 |
if(code.length() < 15 ) { |
|
100 |
code = code.substring(code.indexOf(":")+1); |
|
101 |
try { |
|
102 |
//Creamos el objeto que tendra los diferentes parametros de la cadena Wkt |
|
103 |
crsWkt = new CrsWkt(fullCode); |
|
104 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
|
105 |
CrsOgr.importFromEPSG(oSRSSource, |
|
106 |
Integer.parseInt(code)); |
|
107 |
//Guardamos la cadena Proj4 devuelva por la OGRSpatialReference |
|
108 |
proj4 = CrsOgr.exportToProj4(oSRSSource); |
|
109 |
crsProj4 = new CrsProj(proj4); |
|
110 |
setName(fullCode); |
|
111 |
setAbrev(fullCode); |
|
112 |
|
|
113 |
} catch (OGRException e) { |
|
114 |
throw new CrsException(e); |
|
115 |
} catch (crsgdalException e) { |
|
116 |
throw new CrsException(e); |
|
117 |
} catch (CrsOgrException e) { |
|
118 |
throw new CrsException(e); |
|
119 |
} |
|
120 |
}else { |
|
121 |
String aux; |
|
122 |
String code2 = ""; |
|
123 |
for(int i = 0; i < code.length(); i++) { |
|
124 |
aux = ""+code.charAt(i); |
|
125 |
if(!aux.equals(" ")) { |
|
126 |
code2+=aux; |
|
127 |
}else { |
|
128 |
code2 += ""; |
|
129 |
} |
|
130 |
} |
|
131 |
crsWkt = new CrsWkt(code2); |
|
132 |
try { |
|
133 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
|
134 |
CrsOgr.importFromWkt(oSRSSource,code2); |
|
135 |
proj4 =CrsOgr.exportToProj4(oSRSSource); |
|
136 |
crsProj4 = new CrsProj(proj4); |
|
137 |
setName(fullCode); |
|
138 |
//setAbrev(crsWkt.getName()); |
|
139 |
setAbrev(crsWkt.getAuthority()[0]+":"+crsWkt.getAuthority()[1]); |
|
140 |
} catch (OGRException e) { |
|
141 |
throw new CrsException(e); |
|
142 |
} catch (crsgdalException e) { |
|
143 |
throw new CrsException(e); |
|
144 |
} catch (CrsOgrException e) { |
|
145 |
throw new CrsException(e); |
|
146 |
} |
|
147 |
} |
|
148 |
// Asignar el datum y el crs base (en el caso de ser projectado): |
|
149 |
if (!(crsWkt.getSpheroid()[1].equals("")||crsWkt.getSpheroid()[2].equals(""))){ |
|
150 |
double eSemiMajorAxis = Double.valueOf(crsWkt.getSpheroid()[1]).doubleValue(); |
|
151 |
double eIFlattening = Double.valueOf(crsWkt.getSpheroid()[2]).doubleValue(); |
|
152 |
datum = new CRSDatum(eSemiMajorAxis,eIFlattening); |
|
153 |
|
|
154 |
//crs base (en el caso de ser projectado): |
|
155 |
if(this.isProjected()){ |
|
156 |
String proj4Base = "+proj=latlong +a=" + crsWkt.getSpheroid()[1] + " +rf=" + crsWkt.getSpheroid()[2] ; |
|
157 |
crsBase = new CrsProj(proj4Base); |
|
158 |
} |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
/** |
|
163 |
*Construye un CRS a partir del c?digo EPSG o de la cadena WKT. |
|
164 |
* |
|
165 |
* @param epsg_cod |
|
166 |
* @param code |
|
167 |
* @throws CrsException |
|
168 |
*/ |
|
169 |
public Crs(int epsg_cod, String code) throws CrsException { |
|
170 |
String fullCode; |
|
171 |
setWKT(code); |
|
172 |
setCode(epsg_cod); |
|
173 |
if(code != null || code.charAt(0) == 'E' || code.charAt(0) == 'G' || code.charAt(0) == 'P') |
|
174 |
fullCode = code; |
|
175 |
else fullCode = "EPSG:"+code; |
|
176 |
String cod = ""; |
|
177 |
if(code.length() < 15 ) { |
|
178 |
code = code.substring(code.indexOf(":")+1); |
|
179 |
try { |
|
180 |
//Creamos el objeto que tendra los diferentes parametros de la cadena Wkt |
|
181 |
crsWkt = new CrsWkt(fullCode); |
|
182 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
|
183 |
CrsOgr.importFromEPSG(oSRSSource, |
|
184 |
Integer.parseInt(code)); |
|
185 |
//Guardamos la cadena Proj4 devuelva por la OGRSpatialReference |
|
186 |
proj4 = CrsOgr.exportToProj4(oSRSSource); |
|
187 |
crsProj4 = new CrsProj(proj4); |
|
188 |
setName(fullCode); |
|
189 |
setAbrev(fullCode); |
|
190 |
|
|
191 |
} catch (OGRException e) { |
|
192 |
throw new CrsException(e); |
|
193 |
} catch (crsgdalException e) { |
|
194 |
throw new CrsException(e); |
|
195 |
} catch (CrsOgrException e) { |
|
196 |
throw new CrsException(e); |
|
197 |
} |
|
198 |
}else { |
|
199 |
String aux; |
|
200 |
String code2 = ""; |
|
201 |
for(int i = 0; i < code.length(); i++) { |
|
202 |
aux = ""+code.charAt(i); |
|
203 |
if(!aux.equals(" ")) { |
|
204 |
code2+=aux; |
|
205 |
}else { |
|
206 |
code2 += ""; |
|
207 |
} |
|
208 |
} |
|
209 |
crsWkt = new CrsWkt(code2); |
|
210 |
/* |
|
211 |
* Arreglo temporal para ver si funcionan de la iau2000 las proyecciones |
|
212 |
* cilindrica equidistante y oblicua cilindrica equidistante |
|
213 |
* que no estan en gdal, por lo que asignaremos directamente su cadena |
|
214 |
* en proj4 para trabajar con ellas |
|
215 |
*/ |
|
216 |
if (!crsWkt.getProjection().equals("Equidistant_Cylindrical") && !crsWkt.getProjection().equals("Oblique_Cylindrical_Equal_Area")){ |
|
217 |
try { |
|
218 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
|
219 |
CrsOgr.importFromWkt(oSRSSource,code2); |
|
220 |
proj4 = CrsOgr.exportToProj4(oSRSSource); |
|
221 |
crsProj4 = new CrsProj(proj4); |
|
222 |
setName(fullCode); |
|
223 |
//setAbrev(crsWkt.getName()); |
|
224 |
setAbrev(crsWkt.getAuthority()[0]+":"+crsWkt.getAuthority()[1]); |
|
225 |
} catch (OGRException e) { |
|
226 |
throw new CrsException(e); |
|
227 |
} catch (crsgdalException e) { |
|
228 |
throw new CrsException(e); |
|
229 |
} catch (CrsOgrException e) { |
|
230 |
throw new CrsException(e); |
|
231 |
} |
|
232 |
} |
|
233 |
else if (crsWkt.getProjection().equals("Equidistant_Cylindrical")){ |
|
234 |
String spheroid1 = crsWkt.getSpheroid()[1]; |
|
235 |
String spheroid2 = crsWkt.getSpheroid()[2]; |
|
236 |
String centralMeridian = ""; |
|
237 |
String falseNorthing = ""; |
|
238 |
String falseEasting = ""; |
|
239 |
String standardParallel1 = "0.0"; |
|
240 |
for (int i=0; i<crsWkt.getParam_name().length;i++){ |
|
241 |
if (crsWkt.getParam_name()[i].equals("Central_Meridian")) |
|
242 |
centralMeridian = crsWkt.getParam_value()[i]; |
|
243 |
if (crsWkt.getParam_name()[i].equals("False_Easting")) |
|
244 |
falseEasting = crsWkt.getParam_value()[i]; |
|
245 |
if(crsWkt.getParam_name()[i].equals("False_Northing")) |
|
246 |
falseNorthing = crsWkt.getParam_value()[i]; |
|
247 |
if (crsWkt.getParam_name()[i].equals("Standard_Parallel_1")) |
|
248 |
standardParallel1 = crsWkt.getParam_value()[i]; |
|
249 |
} |
|
250 |
if (spheroid2.equals("0.0")){ |
|
251 |
proj4 = "+proj=eqc +a=" + spheroid1 + |
|
252 |
" +lon_0="+ centralMeridian + " +x_0="+falseEasting+" +y_0="+falseNorthing + |
|
253 |
" +lat_ts="+standardParallel1; |
|
254 |
} else { |
|
255 |
proj4 = "+proj=eqc +a="+ spheroid1 +" +rf=" + spheroid2 + |
|
256 |
" +lon_0="+ centralMeridian + " +x_0="+falseEasting+" +y_0="+falseNorthing + |
|
257 |
" +lat_ts="+standardParallel1; |
|
258 |
} |
|
259 |
|
|
260 |
crsProj4 = new CrsProj(proj4); |
|
261 |
setName(fullCode); |
|
262 |
//setAbrev(crsWkt.getName()); |
|
263 |
setAbrev(crsWkt.getAuthority()[0]+":"+crsWkt.getAuthority()[1]); |
|
264 |
|
|
265 |
} |
|
266 |
else if (crsWkt.getProjection().equals("Oblique_Cylindrical_Equal_Area")){ |
|
267 |
String spheroid1 = crsWkt.getSpheroid()[1]; |
|
268 |
String spheroid2 = crsWkt.getSpheroid()[2]; |
|
269 |
String centralMeridian = ""; |
|
270 |
String falseNorthing = ""; |
|
271 |
String falseEasting = ""; |
|
272 |
String standardParallel1 = ""; |
|
273 |
String standardParallel2 = "0.0"; |
|
274 |
for (int i=0; i<crsWkt.getParam_name().length;i++){ |
|
275 |
if (crsWkt.getParam_name()[i].equals("Central_Meridian")) |
|
276 |
centralMeridian = crsWkt.getParam_value()[i]; |
|
277 |
if (crsWkt.getParam_name()[i].equals("False_Easting")) |
|
278 |
falseEasting = crsWkt.getParam_value()[i]; |
|
279 |
if(crsWkt.getParam_name()[i].equals("False_Northing")) |
|
280 |
falseNorthing = crsWkt.getParam_value()[i]; |
|
281 |
if (crsWkt.getParam_name()[i].equals("Standard_Parallel_1")) |
|
282 |
standardParallel1 = crsWkt.getParam_value()[i]; |
|
283 |
if (crsWkt.getParam_name()[i].equals("Standard_Parallel_2")) |
|
284 |
standardParallel2 = crsWkt.getParam_value()[i]; |
|
285 |
} |
|
286 |
if (spheroid2.equals("0.0")){ |
|
287 |
proj4 = "+proj=ocea +a="+ spheroid1 + |
|
288 |
" +lon_0="+ centralMeridian + " +x_0="+falseEasting+" +y_0="+falseNorthing + |
|
289 |
" +lat_1="+standardParallel1+" +lat_2="+standardParallel2+" +lon_1=long_1" + |
|
290 |
" +lon_2=long_2 +no_defs"; |
|
291 |
} else { |
|
292 |
proj4 = "+proj=ocea +a="+ spheroid1 + " +rf=" + spheroid2 + |
|
293 |
" +lon_0="+ centralMeridian + " +x_0="+falseEasting+" +y_0="+falseNorthing + |
|
294 |
" +lat_1="+standardParallel1+" +lat_2="+standardParallel2+" +lon_1=long_1" + |
|
295 |
" +lon_2=long_2 +no_defs"; |
|
296 |
} |
|
297 |
|
|
298 |
crsProj4 = new CrsProj(proj4); |
|
299 |
setName(fullCode); |
|
300 |
//setAbrev(crsWkt.getName()); |
|
301 |
setAbrev(crsWkt.getAuthority()[0]+":"+crsWkt.getAuthority()[1]); |
|
302 |
} |
|
303 |
} |
|
304 |
// Asignar el datum: |
|
305 |
if (!(crsWkt.getSpheroid()[1].equals("")||crsWkt.getSpheroid()[2].equals(""))){ |
|
306 |
double eSemiMajorAxis = Double.valueOf(crsWkt.getSpheroid()[1]).doubleValue(); |
|
307 |
double eIFlattening = Double.valueOf(crsWkt.getSpheroid()[2]).doubleValue(); |
|
308 |
datum = new CRSDatum(eSemiMajorAxis,eIFlattening); |
|
309 |
|
|
310 |
// Crs base (en el caso de ser projectado): |
|
311 |
if(this.isProjected()){ |
|
312 |
String proj4Base = "+proj=latlong +a=" + crsWkt.getSpheroid()[1] + " +rf=" + crsWkt.getSpheroid()[2] ; |
|
313 |
crsBase = new CrsProj(proj4Base); |
|
314 |
} |
|
315 |
} |
|
316 |
} |
|
317 |
|
|
318 |
/** |
|
319 |
* Construye un CRS a partir del c?digo EPSG o de la cadena WKT. |
|
320 |
* En el caso de WKT le a?ade a la cadena proj4 el string params. |
|
321 |
* |
|
322 |
* @param epsg_cod |
|
323 |
* @param code |
|
324 |
* @param params |
|
325 |
* @throws CrsException |
|
326 |
*/ |
|
327 |
public Crs(int epsg_cod, String code,String params) throws CrsException { |
|
328 |
String fullCode; |
|
329 |
setCode(epsg_cod); |
|
330 |
setWKT(code); |
|
331 |
if(code.charAt(0) == 'E' || code.charAt(0) == 'G' || code.charAt(0) == 'P') |
|
332 |
fullCode = code; |
|
333 |
else fullCode = "EPSG:"+code; |
|
334 |
String cod = ""; |
|
335 |
if(code.length() < 15 ) { |
|
336 |
code = code.substring(code.indexOf(":")+1); |
|
337 |
try { |
|
338 |
//Creamos el objeto que tendra los diferentes parametros de la cadena Wkt |
|
339 |
crsWkt = new CrsWkt(fullCode); |
|
340 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
|
341 |
CrsOgr.importFromEPSG(oSRSSource, |
|
342 |
Integer.parseInt(code)); |
|
343 |
//Guardamos la cadena Proj4 devuelva por la OGRSpatialReference |
|
344 |
proj4 = CrsOgr.exportToProj4(oSRSSource); |
|
345 |
crsProj4 = new CrsProj(proj4); |
|
346 |
setName(fullCode); |
|
347 |
setAbrev(fullCode); |
|
348 |
|
|
349 |
} catch (OGRException e) { |
|
350 |
throw new CrsException(e); |
|
351 |
} catch (crsgdalException e) { |
|
352 |
throw new CrsException(e); |
|
353 |
} catch (CrsOgrException e) { |
|
354 |
throw new CrsException(e); |
|
355 |
} |
|
356 |
}else { |
|
357 |
String aux; |
|
358 |
String code2 = ""; |
|
359 |
for(int i = 0; i < code.length(); i++) { |
|
360 |
aux = ""+code.charAt(i); |
|
361 |
if(!aux.equals(" ")) { |
|
362 |
code2+=aux; |
|
363 |
}else { |
|
364 |
code2 += ""; |
|
365 |
} |
|
366 |
} |
|
367 |
crsWkt = new CrsWkt(code2); |
|
368 |
try { |
|
369 |
OGRSpatialReference oSRSSource = new OGRSpatialReference(); |
|
370 |
CrsOgr.importFromWkt(oSRSSource,code2); |
|
371 |
proj4 =CrsOgr.exportToProj4(oSRSSource)+params+" "; |
|
372 |
crsProj4 = new CrsProj(proj4); |
|
373 |
setName(fullCode); |
|
374 |
//setAbrev(crsWkt.getName()); |
|
375 |
setAbrev(crsWkt.getAuthority()[0]+":"+crsWkt.getAuthority()[1]); |
|
376 |
} catch (OGRException e) { |
|
377 |
throw new CrsException(e); |
|
378 |
} catch (crsgdalException e) { |
|
379 |
throw new CrsException(e); |
|
380 |
} catch (CrsOgrException e) { |
|
381 |
throw new CrsException(e); |
|
382 |
} |
|
383 |
} |
|
384 |
// Asignar el datum: |
|
385 |
if (!(crsWkt.getSpheroid()[1].equals("")||crsWkt.getSpheroid()[2].equals(""))){ |
|
386 |
double eSemiMajorAxis = Double.valueOf(crsWkt.getSpheroid()[1]).doubleValue(); |
|
387 |
double eIFlattening = Double.valueOf(crsWkt.getSpheroid()[2]).doubleValue(); |
|
388 |
datum = new CRSDatum(eSemiMajorAxis,eIFlattening); |
|
389 |
|
|
390 |
// Crs base (en el caso de ser projectado): |
|
391 |
if(this.isProjected()){ |
|
392 |
String proj4Base = "+proj=latlong +a=" + crsWkt.getSpheroid()[1] + " +rf=" + crsWkt.getSpheroid()[2] ; |
|
393 |
crsBase = new CrsProj(proj4Base); |
|
394 |
} |
|
395 |
} |
|
396 |
} |
|
397 |
|
|
398 |
/* public Crs(CrsEpsg source) throws CrsException { |
|
399 |
crsProj4 = source; |
|
400 |
}*/ |
|
401 |
|
|
402 |
/** |
|
403 |
* @param code |
|
404 |
*/ |
|
405 |
public void setTrans(String code) { |
|
406 |
trans = code; |
|
407 |
changeTrans(trans); |
|
408 |
} |
|
409 |
|
|
410 |
/** |
|
411 |
* |
|
412 |
* @param code |
|
413 |
*/ |
|
414 |
public void changeTrans(String code) { |
|
415 |
crsProj4.changeStrCrs(code); |
|
416 |
} |
|
417 |
|
|
418 |
/** |
|
419 |
* |
|
420 |
*/ |
|
421 |
public String getAbrev() { |
|
422 |
return abrev; |
|
423 |
} |
|
424 |
|
|
425 |
/** |
|
426 |
* |
|
427 |
* @param code |
|
428 |
*/ |
|
429 |
protected void setAbrev(String code) { |
|
430 |
abrev = code; |
|
431 |
} |
|
432 |
|
|
433 |
/** |
|
434 |
* |
|
435 |
* @param nom |
|
436 |
*/ |
|
437 |
public void setName(String nom) { |
|
438 |
name = nom; |
|
439 |
} |
|
440 |
|
|
441 |
/** |
|
442 |
* @return |
|
443 |
*/ |
|
444 |
public IDatum getDatum() { |
|
445 |
/*CSDatum datum = new CSDatum(); |
|
446 |
try { |
|
447 |
datum.fromWKT(getWKT()); |
|
448 |
} catch (FactoryException e) { |
|
449 |
// TODO Auto-generated catch block |
|
450 |
e.printStackTrace(); |
|
451 |
}*/ |
|
452 |
return datum; |
|
453 |
} |
|
454 |
|
|
455 |
/** |
|
456 |
* @return |
|
457 |
*/ |
|
458 |
public CrsWkt getCrsWkt() { |
|
459 |
return crsWkt; |
|
460 |
} |
|
461 |
|
|
462 |
/** |
|
463 |
* |
|
464 |
* @param wkt |
|
465 |
*/ |
|
466 |
public void setWKT(String wkt){ |
|
467 |
this.wkt = wkt; |
|
468 |
} |
|
469 |
|
|
470 |
/** |
|
471 |
* @return |
|
472 |
*/ |
|
473 |
public String getWKT(){ |
|
474 |
return this.wkt; |
|
475 |
} |
|
476 |
|
|
477 |
/** |
|
478 |
* |
|
479 |
* @param nad |
|
480 |
*/ |
|
481 |
public void setNadGrid(String nad){ |
|
482 |
this.nad = nad; |
|
483 |
} |
|
484 |
|
|
485 |
/** |
|
486 |
* @return |
|
487 |
*/ |
|
488 |
public String getNadGrid(){ |
|
489 |
return this.nad; |
|
490 |
} |
|
491 |
|
|
492 |
/** |
|
493 |
* @param target |
|
494 |
* @return |
|
495 |
*/ |
|
496 |
public ICOperation getCOp(ICrs target) throws CrsException { |
|
497 |
if (!this.getNadGrid().equals("")) { |
|
498 |
ICrs crs = new Crs(target.getCode(), target.getWKT(), this.getNadGrid()); |
|
499 |
return new COperation(this, crs); |
|
500 |
} |
|
501 |
else return new COperation(this, target); |
|
502 |
} |
|
503 |
|
|
504 |
/** |
|
505 |
* |
|
506 |
* @return |
|
507 |
*/ |
|
508 |
protected CrsProj getCrsProj() { |
|
509 |
return crsProj4; |
|
510 |
} |
|
511 |
|
|
512 |
/** |
|
513 |
* @param x |
|
514 |
* @param y |
|
515 |
* @return |
|
516 |
*/ |
|
517 |
public Point2D createPoint(double x, double y) { |
|
518 |
return new Point2D.Double(x,y); |
|
519 |
} |
|
520 |
|
|
521 |
/** |
|
522 |
* @param g |
|
523 |
* @param vp |
|
524 |
*/ |
|
525 |
public void drawGrid(Graphics2D g, ViewPortData vp) { |
|
526 |
// TODO Auto-generated method stub |
|
527 |
|
|
528 |
} |
|
529 |
|
|
530 |
/** |
|
531 |
* @param c |
|
532 |
*/ |
|
533 |
public void setGridColor(Color c) { |
|
534 |
gridColor = c; |
|
535 |
} |
|
536 |
|
|
537 |
/** |
|
538 |
* @return |
|
539 |
*/ |
|
540 |
public Color getGridColor() { |
|
541 |
return gridColor; |
|
542 |
} |
|
543 |
|
|
544 |
/** |
|
545 |
* @param dest |
|
546 |
* @return |
|
547 |
*/ |
|
548 |
public ICoordTrans getCT(IProjection dest) { |
|
549 |
COperation operation = null; |
|
550 |
Crs crsDest = (Crs)dest; |
|
551 |
try { |
|
552 |
operation = new COperation(this, (ICrs)dest); |
|
553 |
} catch (CrsException e) { |
|
554 |
// TODO Auto-generated catch block |
|
555 |
e.printStackTrace(); |
|
556 |
} |
|
557 |
|
|
558 |
if (!getNadGrid().equals("")){ |
|
559 |
if (isTargetNad()) |
|
560 |
operation.setNadCrsProj(new CrsProj(crsDest.getProj4()+getNadGrid()), true); |
|
561 |
else |
|
562 |
operation.setNadCrsProj(new CrsProj(getProj4()+getNadGrid()), false); |
|
563 |
|
|
564 |
return operation; |
|
565 |
} |
|
566 |
|
|
567 |
return operation; |
|
568 |
|
|
569 |
/*ICrs crs = (ICrs) dest; |
|
570 |
try { |
|
571 |
if (!this.getNadGrid().equals("")) { |
|
572 |
crs = new Crs(crs.getCode(), crs.getWKT(), this.getNadGrid()); |
|
573 |
return new COperation(this, crs); |
|
574 |
} |
|
575 |
else return new COperation(this, crs); |
|
576 |
} catch (CrsException e) { |
|
577 |
// TODO Auto-generated catch block |
|
578 |
e.printStackTrace(); |
|
579 |
} |
|
580 |
return null;*/ |
|
581 |
} |
|
582 |
|
|
583 |
/** |
|
584 |
* @param pt |
|
585 |
* @return |
|
586 |
*/ |
|
587 |
public Point2D toGeo(Point2D pt) { |
|
588 |
if (isProjected()){ |
|
589 |
double x[] = {pt.getX()}; |
|
590 |
double y[] = {pt.getY()}; |
|
591 |
double z[] = {0D}; |
|
592 |
try { |
|
593 |
JNIBaseCrs.operate( x , y, z, |
|
594 |
crsProj4,crsBase); |
|
595 |
} catch (OperationCrsException e) { |
|
596 |
// TODO Auto-generated catch block |
|
597 |
e.printStackTrace(); |
|
598 |
} catch (CrsProjException e) { |
|
599 |
// TODO Auto-generated catch block |
|
600 |
e.printStackTrace(); |
|
601 |
} |
|
602 |
return new Point2D.Double(x[0],y[0]); |
|
603 |
} |
|
604 |
else |
|
605 |
return pt; |
|
606 |
} |
|
607 |
|
|
608 |
/** |
|
609 |
* @param gPt |
|
610 |
* @param mPt |
|
611 |
* @return |
|
612 |
*/ |
|
613 |
public Point2D fromGeo(Point2D gPt, Point2D mPt) { |
|
614 |
// TODO Auto-generated method stub |
|
615 |
return null; |
|
616 |
} |
|
617 |
|
|
618 |
/** |
|
619 |
* @return |
|
620 |
*/ |
|
621 |
public boolean isProjected() { |
|
622 |
return !crsProj4.isLatlong(); |
|
623 |
} |
|
624 |
|
|
625 |
/** |
|
626 |
* @param minX |
|
627 |
* @param maxX |
|
628 |
* @param width |
|
629 |
* @param dpi |
|
630 |
* @return |
|
631 |
*/ |
|
632 |
public double getScale(double minX, double maxX, double width, double dpi) { |
|
633 |
double scale = 0D; |
|
634 |
if (!isProjected()) { // Es geogr?fico; calcula la escala. |
|
635 |
scale = ((maxX - minX) * // grados |
|
636 |
|
|
637 |
// 1852.0 metros x minuto de meridiano |
|
638 |
(dpi / 2.54 * 100.0 * 1852.0 * 60.0)) / // px / metro |
|
639 |
width; // pixels |
|
640 |
} |
|
641 |
else{ |
|
642 |
scale = ((maxX - minX) * // metros |
|
643 |
(dpi / 2.54 * 100.0)) / // px / metro |
|
644 |
width; // pixels |
|
645 |
} |
|
646 |
return scale; |
|
647 |
} |
|
648 |
|
|
649 |
/** |
|
650 |
* |
|
651 |
* @param epsg_cod |
|
652 |
*/ |
|
653 |
public void setCode(int epsg_cod){ |
|
654 |
epsg_code = epsg_cod; |
|
655 |
} |
|
656 |
|
|
657 |
/** |
|
658 |
* @return |
|
659 |
*/ |
|
660 |
public int getCode() { |
|
661 |
// TODO Auto-generated method stub |
|
662 |
return epsg_code; |
|
663 |
} |
|
664 |
|
|
665 |
/** |
|
666 |
* |
|
667 |
*/ |
|
668 |
public Rectangle2D getExtent(Rectangle2D extent, double scale, double wImage, double hImage, double changeUnits, double dpi) { |
|
669 |
// TODO Auto-generated method stub |
|
670 |
return null; |
|
671 |
} |
|
672 |
|
|
673 |
/** |
|
674 |
* @return |
|
675 |
*/ |
|
676 |
public boolean isTargetNad() { |
|
677 |
return targetNad; |
|
678 |
} |
|
679 |
|
|
680 |
/** |
|
681 |
* @param targetNad |
|
682 |
*/ |
|
683 |
public void setNadInTarget(boolean targetNad) { |
|
684 |
this.targetNad = targetNad; |
|
685 |
} |
|
686 |
|
|
687 |
/** |
|
688 |
* |
|
689 |
* @return |
|
690 |
*/ |
|
691 |
public String getProj4() { |
|
692 |
return proj4; |
|
693 |
} |
|
694 |
|
|
695 |
} |
|
0 | 696 |
branches/F2/libraries/libJCRS/src/org/gvsig/crs/proj/OperationCrsException.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs.proj; |
|
42 |
|
|
43 |
/** |
|
44 |
* |
|
45 |
* @author Miguel Garc?a Jim?nez (garciajimenez.miguel@gmail.com) |
|
46 |
* |
|
47 |
*/ |
|
48 |
public class OperationCrsException extends Exception { |
|
49 |
/** |
|
50 |
* |
|
51 |
*/ |
|
52 |
private static final long serialVersionUID = 1L; |
|
53 |
private String _strSrcCrs,_strDestCrs; |
|
54 |
|
|
55 |
public OperationCrsException(CrsProj srcCrs, CrsProj destCrs, String message) { |
|
56 |
super("Error in CRS operation: "+ message); |
|
57 |
_strSrcCrs=srcCrs.getStr(); |
|
58 |
_strDestCrs=destCrs.getStr(); |
|
59 |
} |
|
60 |
|
|
61 |
public String getStrError() { |
|
62 |
return ("Error en operacion del CRS "+_strSrcCrs+" al CRS "+_strDestCrs); |
|
63 |
} |
|
64 |
} |
|
0 | 65 |
branches/F2/libraries/libJCRS/src/org/gvsig/crs/proj/JNIBaseOperation.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs.proj; |
|
42 |
|
|
43 |
/** |
|
44 |
* |
|
45 |
* @author Miguel Garc?a Jim?nez (garciajimenez.miguel@gmail.com) |
|
46 |
* |
|
47 |
*/ |
|
48 |
public class JNIBaseOperation |
|
49 |
{ |
|
50 |
protected static native int operation(double[] firstCoord, |
|
51 |
double[] secondCoord, |
|
52 |
double[] values, |
|
53 |
long srcCodeString, |
|
54 |
long destCodeString); |
|
55 |
|
|
56 |
protected static native int operationSimple(double firstcoord, |
|
57 |
double secondcoord, |
|
58 |
double values, |
|
59 |
long srcCodeString, |
|
60 |
long destCodeString); |
|
61 |
|
|
62 |
protected static native int operationArraySimple(double[] Coord, |
|
63 |
long srcCodeString, |
|
64 |
long destCodeString); |
|
65 |
protected static native int compareDatums(long datum1, long datum2); |
|
66 |
static |
|
67 |
{ |
|
68 |
System.loadLibrary("crsjniproj"); |
|
69 |
} |
|
70 |
} |
|
0 | 71 |
branches/F2/libraries/libJCRS/src/org/gvsig/crs/proj/package.html | ||
---|---|---|
1 |
<html> |
|
2 |
<body>Clases relacionadas con el wrapper de proj4 de la extensi?n CRS. |
|
3 |
</body> |
|
4 |
</html> |
|
0 | 5 |
branches/F2/libraries/libJCRS/src/org/gvsig/crs/proj/CrsProjException.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs.proj; |
|
42 |
|
|
43 |
/** |
|
44 |
* Clase que gestiona las excepciones en la creaci?n del CRS |
|
45 |
* mediante una cadena proj4 |
|
46 |
* |
|
47 |
* @author Miguel Garc?a Jim?nez (garciajimenez.miguel@gmail.com) |
|
48 |
* |
|
49 |
*/ |
|
50 |
public class CrsProjException extends Exception { |
|
51 |
/** |
|
52 |
* |
|
53 |
*/ |
|
54 |
|
|
55 |
private static final long serialVersionUID = 1L; |
|
56 |
|
|
57 |
public CrsProjException(String message) |
|
58 |
{ |
|
59 |
super(message); |
|
60 |
} |
|
61 |
} |
|
0 | 62 |
branches/F2/libraries/libJCRS/src/org/gvsig/crs/proj/CrsProj.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs.proj; |
|
42 |
|
|
43 |
import com.iver.andami.messages.NotificationManager; |
|
44 |
|
|
45 |
/** |
|
46 |
* Clase que crea el CRS a partir de una cadena proj4 |
|
47 |
* |
|
48 |
* @author Miguel Garc?a Jim?nez (garciajimenez.miguel@gmail.com) |
|
49 |
* |
|
50 |
*/ |
|
51 |
public class CrsProj extends JNIBaseCrs { |
|
52 |
/** |
|
53 |
* |
|
54 |
* |
|
55 |
* @param strCrs Cadena proj4. |
|
56 |
*/ |
|
57 |
public CrsProj(String strCrs) { |
|
58 |
try { |
|
59 |
createCrs(strCrs); |
|
60 |
} catch(CrsProjException e) { |
|
61 |
NotificationManager.addError(e); |
|
62 |
} |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
protected void finalize() { |
|
67 |
deleteCrs(); |
|
68 |
} |
|
69 |
} |
|
0 | 70 |
branches/F2/libraries/libJCRS/src/org/gvsig/crs/proj/JNIBaseCrs.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs.proj; |
|
42 |
|
|
43 |
/** |
|
44 |
* |
|
45 |
* @author Miguel Garc?a Jim?nez (garciajimenez.miguel@gmail.com) |
|
46 |
* |
|
47 |
*/ |
|
48 |
public class JNIBaseCrs |
|
49 |
{ |
|
50 |
protected long cPtr; |
|
51 |
protected int latLong; |
|
52 |
protected String _strCrs; |
|
53 |
protected native long loadCrs(String crs); |
|
54 |
protected native void freeCrs(long crs); |
|
55 |
protected native int isLatlong(long crs); |
|
56 |
protected static native int compareDatums(long datum1, long datum2); |
|
57 |
protected native int getErrno(); |
|
58 |
protected static native String strErrno(int errno); |
|
59 |
|
|
60 |
|
|
61 |
protected static native int operation(double[] firstCoord, |
|
62 |
double[] secondCoord, |
|
63 |
double[] values, |
|
64 |
long srcCodeString, |
|
65 |
long destCodeString); |
|
66 |
|
|
67 |
protected static native int operationSimple(double firstcoord, |
|
68 |
double secondcoord, |
|
69 |
double values, |
|
70 |
long srcCodeString, |
|
71 |
long destCodeString); |
|
72 |
|
|
73 |
protected static native int operationArraySimple(double[] Coord, |
|
74 |
long srcCodeString, |
|
75 |
long destCodeString); |
|
76 |
|
|
77 |
static { |
|
78 |
System.loadLibrary("crsjniproj"); |
|
79 |
} |
|
80 |
|
|
81 |
protected void createCrs(String strCrs) throws CrsProjException { |
|
82 |
cPtr=loadCrs(strCrs); |
|
83 |
|
|
84 |
int errNo = getErrNo(); |
|
85 |
if (errNo<0 && errNo!=-10) throw new CrsProjException("Error creating CRS: "+strErrNo(errNo)); |
|
86 |
_strCrs=strCrs; |
|
87 |
} |
|
88 |
|
|
89 |
protected void deleteCrs() { |
|
90 |
if(cPtr>0) freeCrs(cPtr); |
|
91 |
} |
|
92 |
|
|
93 |
public boolean isLatlong() { |
|
94 |
latLong = isLatlong(cPtr); |
|
95 |
if(latLong == 0) |
|
96 |
return false; |
|
97 |
return true; |
|
98 |
} |
|
99 |
|
|
100 |
protected long getPtr() throws CrsProjException { |
|
101 |
if (cPtr>0) return cPtr; |
|
102 |
else throw new CrsProjException(_strCrs); |
|
103 |
} |
|
104 |
|
|
105 |
public String getStr() { |
|
106 |
return _strCrs; |
|
107 |
} |
|
108 |
|
|
109 |
public void changeStrCrs(String code) { |
|
110 |
_strCrs += code; |
|
111 |
} |
|
112 |
|
|
113 |
protected int getErrNo(){ |
|
114 |
return getErrno(); |
|
115 |
} |
|
116 |
|
|
117 |
protected static String strErrNo(int errno){ |
|
118 |
return strErrno(errno); |
|
119 |
} |
|
120 |
|
|
121 |
//OPERATIONS |
|
122 |
|
|
123 |
public static int operate(double[] firstCoord, |
|
124 |
double[] secondCoord, |
|
125 |
double[] thirdCoord, |
|
126 |
CrsProj srcCrs, |
|
127 |
CrsProj destCrs) |
Also available in: Unified diff