15 |
15 |
import org.geotools.referencing.wkt.UnformattableObjectException;
|
16 |
16 |
import org.gvsig.crs.Crs;
|
17 |
17 |
import org.gvsig.crs.CrsException;
|
|
18 |
import org.gvsig.crs.CrsFactory;
|
|
19 |
import org.gvsig.crs.CrsGT;
|
|
20 |
import org.gvsig.crs.ICrs;
|
18 |
21 |
import org.gvsig.crs.Proj4;
|
19 |
22 |
import org.opengis.referencing.NoSuchAuthorityCodeException;
|
|
23 |
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
20 |
24 |
|
21 |
25 |
public class TestWKTandProj4Epsg {
|
22 |
26 |
|
... | ... | |
39 |
43 |
ArrayList name = new ArrayList();
|
40 |
44 |
ArrayList codigo = new ArrayList();
|
41 |
45 |
ArrayList fallos = new ArrayList();
|
|
46 |
|
|
47 |
String filename = "salida.txt";
|
|
48 |
|
|
49 |
BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
|
|
50 |
|
42 |
51 |
while (result.next()) {
|
43 |
52 |
wkt.add(indice,"");
|
44 |
53 |
proj4.add(indice,"");
|
45 |
|
fallos.add(indice,"");
|
46 |
|
|
|
54 |
fallos.add(indice,"");
|
47 |
55 |
int cod = result.getInt("COORD_REF_SYS_CODE");
|
48 |
56 |
codigo.add(indice,String.valueOf(cod));
|
49 |
57 |
name.add(indice,result.getString("COORD_REF_SYS_NAME"));
|
|
58 |
//if (cod > 2100) break;
|
50 |
59 |
try {
|
51 |
|
Crs crs = new Crs(cod,1);
|
|
60 |
ICrs crs;
|
|
61 |
crs = new CrsFactory().getCRS("EPSG:"+cod);
|
52 |
62 |
wkt.add(indice,crs.getWKT());
|
53 |
|
Proj4 proj= new Proj4();
|
54 |
|
proj4.add(indice,proj.exportToProj4(crs));
|
|
63 |
//Proj4 proj= new Proj4();
|
|
64 |
proj4.add(indice,crs.getProj4String());
|
|
65 |
if (crs instanceof CrsGT)
|
|
66 |
fallos.add(indice,"No falla");
|
|
67 |
else
|
|
68 |
fallos.add(indice,"Creado con crs antiguo");
|
55 |
69 |
|
56 |
|
fallos.add(indice,"No falla");
|
57 |
|
|
58 |
70 |
} catch (CrsException e) {
|
59 |
71 |
// TODO Auto-generated catch block
|
60 |
72 |
//e.printStackTrace();
|
... | ... | |
79 |
91 |
fallos.add(indice,""+cod+": "+e);
|
80 |
92 |
proj4.add(indice, "No cadena proj4");
|
81 |
93 |
fallo++;
|
82 |
|
}
|
|
94 |
}
|
|
95 |
bw.write("C?digo: "+codigo.get(indice)+"\tNombre: "+name.get(indice)+"\n");
|
|
96 |
bw.write("Cadena WKT: "+wkt.get(indice)+"\n");
|
|
97 |
bw.write("Cadena Proj4: "+proj4.get(indice)+"\n");
|
|
98 |
bw.write("Fallo:"+fallos.get(indice)+"\n");
|
|
99 |
bw.write("\n\n");
|
83 |
100 |
indice++;
|
|
101 |
|
84 |
102 |
}
|
85 |
|
String filename = "salida.txt";
|
86 |
|
try
|
87 |
|
{ // opens try
|
88 |
|
BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
|
89 |
103 |
|
|
104 |
|
90 |
105 |
for (int i = 0; i< codigo.size(); i++) {
|
91 |
106 |
|
92 |
|
bw.write("C?digo: "+codigo.get(i)+"\tNombre: "+name.get(i)+"\n");
|
|
107 |
/*bw.write("C?digo: "+codigo.get(i)+"\tNombre: "+name.get(i)+"\n");
|
93 |
108 |
bw.write("Cadena WKT: "+wkt.get(i)+"\n");
|
94 |
109 |
bw.write("Cadena Proj4: "+proj4.get(i)+"\n");
|
95 |
110 |
bw.write("Fallo:"+fallos.get(i)+"\n");
|
96 |
|
bw.write("\n\n");
|
|
111 |
bw.write("\n\n");*/
|
97 |
112 |
}
|
98 |
113 |
/*for (int i = 0; i< fallos.size(); i++) {
|
99 |
114 |
}*/
|
... | ... | |
102 |
117 |
bw.write("Numero fallos: " + fallo+"\n");
|
103 |
118 |
bw.flush();
|
104 |
119 |
bw.close();
|
105 |
|
} // closes try
|
106 |
|
catch (IOException ioe) { // open catch
|
107 |
|
}// close catch
|
|
120 |
|
108 |
121 |
} catch (SQLException e1) {
|
109 |
122 |
// TODO Auto-generated catch block
|
110 |
123 |
e1.printStackTrace();
|
|
124 |
} catch (IOException e) {
|
|
125 |
// TODO Auto-generated catch block
|
|
126 |
e.printStackTrace();
|
111 |
127 |
}
|
112 |
128 |
}
|
113 |
129 |
}
|