Revision 1992
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/test/TestGeotools21.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import org.geotools.referencing.CRS; |
|
4 |
import org.opengis.referencing.FactoryException; |
|
5 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
6 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
7 |
|
|
8 |
public class TestGeotools21 { |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* @param args |
|
13 |
*/ |
|
14 |
public static void main(String[] args) { |
|
15 |
try { |
|
16 |
String strEpsgCode="EPSG:27572"; |
|
17 |
CoordinateReferenceSystem source; |
|
18 |
source = CRS.decode(strEpsgCode); |
|
19 |
System.out.println(source.toWKT()); |
|
20 |
|
|
21 |
} catch (NoSuchAuthorityCodeException e) { |
|
22 |
// TODO Auto-generated catch block |
|
23 |
e.printStackTrace(); |
|
24 |
} catch (FactoryException e) { |
|
25 |
// TODO Auto-generated catch block |
|
26 |
e.printStackTrace(); |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
} |
|
0 | 31 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/test/connection/UsrConnection.java | ||
---|---|---|
1 |
package es.idr.test.connection; |
|
2 |
|
|
3 |
import java.sql.Connection; |
|
4 |
import java.sql.DriverManager; |
|
5 |
import java.sql.SQLException; |
|
6 |
import java.sql.Statement; |
|
7 |
|
|
8 |
public class UsrConnection { |
|
9 |
|
|
10 |
Connection connect; |
|
11 |
|
|
12 |
public UsrConnection() { |
|
13 |
try { |
|
14 |
Class.forName("org.hsqldb.jdbcDriver"); |
|
15 |
} catch (ClassNotFoundException e) { |
|
16 |
e.printStackTrace(); |
|
17 |
} |
|
18 |
|
|
19 |
try { |
|
20 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:/home/jlgomez/gvSIGF2/gt2-usr-hsql/src/org/geotools/referencing/factory/usr/usr", "sa", ""); |
|
21 |
} catch (SQLException e1) { |
|
22 |
e1.printStackTrace(); |
|
23 |
} |
|
24 |
} |
|
25 |
|
|
26 |
public Connection getConnection(){ |
|
27 |
return connect; |
|
28 |
} |
|
29 |
|
|
30 |
public void shutdown() throws SQLException { |
|
31 |
|
|
32 |
Statement st = connect.createStatement(); |
|
33 |
|
|
34 |
// db writes out to files and performs clean shuts down |
|
35 |
// otherwise there will be an unclean shutdown |
|
36 |
// when program ends |
|
37 |
st.execute("SHUTDOWN"); |
|
38 |
connect.close(); // if there are no other open connection |
|
39 |
} |
|
40 |
|
|
41 |
public synchronized void update(String expression) throws SQLException { |
|
42 |
|
|
43 |
Statement st = null; |
|
44 |
|
|
45 |
st = connect.createStatement(); // statements |
|
46 |
|
|
47 |
int i = st.executeUpdate(expression); // run the query |
|
48 |
|
|
49 |
if (i == -1) { |
|
50 |
System.out.println("db error : " + expression); |
|
51 |
} |
|
52 |
|
|
53 |
st.close(); |
|
54 |
} |
|
55 |
} |
|
0 | 56 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/test/connection/TestConnection.java | ||
---|---|---|
1 |
package es.idr.test.connection; |
|
2 |
|
|
3 |
|
|
4 |
import java.sql.ResultSet; |
|
5 |
import java.sql.SQLException; |
|
6 |
|
|
7 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
8 |
import es.idr.teledeteccion.connection.Query; |
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
public class TestConnection { |
|
13 |
|
|
14 |
public TestConnection () { |
|
15 |
testEpsgDataBase(); |
|
16 |
testEsriDataBase(); |
|
17 |
testIau2000DataBase(); |
|
18 |
} |
|
19 |
/** |
|
20 |
* @param args |
|
21 |
*/ |
|
22 |
public static void main(String[] args) { |
|
23 |
// TODO Auto-generated method stub |
|
24 |
TestConnection tc = new TestConnection(); |
|
25 |
|
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
private void testEpsgDataBase() { |
|
30 |
EpsgConnection connect = new EpsgConnection(); |
|
31 |
connect.setConnectionEPSG(); |
|
32 |
String sentence = "SELECT coord_ref_sys_name " + |
|
33 |
"FROM epsg_coordinatereferencesystem " + |
|
34 |
"WHERE coord_ref_sys_code = 23030"; |
|
35 |
|
|
36 |
ResultSet result; |
|
37 |
try { |
|
38 |
result = Query.select(sentence,connect.getConnection()); |
|
39 |
result.next(); |
|
40 |
System.out.println(result.getString("coord_ref_sys_name")); |
|
41 |
} catch (SQLException e) { |
|
42 |
// TODO Auto-generated catch block |
|
43 |
e.printStackTrace(); |
|
44 |
} |
|
45 |
} |
|
46 |
|
|
47 |
private void testEsriDataBase (){ |
|
48 |
EpsgConnection connect = new EpsgConnection(); |
|
49 |
connect.setConnectionEsri(); |
|
50 |
String sentence = "SELECT esri_proj " + |
|
51 |
"FROM ESRI " + |
|
52 |
"WHERE esri_code = 23030"; |
|
53 |
|
|
54 |
ResultSet result = null; |
|
55 |
try { |
|
56 |
result = Query.select(sentence,connect.getConnection()); |
|
57 |
result.next(); |
|
58 |
System.out.println(result.getString("esri_proj")); |
|
59 |
} catch (SQLException e) { |
|
60 |
// TODO Auto-generated catch block |
|
61 |
e.printStackTrace(); |
|
62 |
} |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
private void testIau2000DataBase() { |
|
67 |
EpsgConnection connect = new EpsgConnection(); |
|
68 |
connect.setConnectionIAU2000(); |
|
69 |
String sentence = "SELECT iau_geog " + |
|
70 |
"FROM IAU2000 " + |
|
71 |
"WHERE iau_code = 19900"; |
|
72 |
|
|
73 |
ResultSet result = null; |
|
74 |
try { |
|
75 |
result = Query.select(sentence,connect.getConnection()); |
|
76 |
result.next(); |
|
77 |
System.out.println(result.getString("iau_geog")); |
|
78 |
} catch (SQLException e) { |
|
79 |
// TODO Auto-generated catch block |
|
80 |
e.printStackTrace(); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
} |
|
0 | 85 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/test/ValidateEpsgCRSs.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import java.sql.Connection; |
|
4 |
import java.sql.PreparedStatement; |
|
5 |
import java.sql.ResultSet; |
|
6 |
import java.sql.SQLException; |
|
7 |
import java.util.ArrayList; |
|
8 |
|
|
9 |
import javax.units.Unit; |
|
10 |
|
|
11 |
import org.geotools.referencing.CRS; |
|
12 |
import org.geotools.referencing.crs.DefaultGeographicCRS; |
|
13 |
import org.geotools.referencing.crs.DefaultProjectedCRS; |
|
14 |
import org.geotools.referencing.datum.DefaultGeodeticDatum; |
|
15 |
import org.gvsig.crs.Crs; |
|
16 |
import org.gvsig.crs.CrsException; |
|
17 |
import org.geotools.referencing.factory.epsg.HSQLDataSource; |
|
18 |
import org.opengis.referencing.FactoryException; |
|
19 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
20 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
21 |
import org.opengis.referencing.crs.GeographicCRS; |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
public class ValidateEpsgCRSs { |
|
26 |
|
|
27 |
public ValidateEpsgCRSs() { |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
/** |
|
32 |
* @param args |
|
33 |
*/ |
|
34 |
public static void main(String[] args) { |
|
35 |
HSQLDataSource ds = new HSQLDataSource(); |
|
36 |
Connection conn; |
|
37 |
try { |
|
38 |
conn = ds.getConnection(); |
|
39 |
|
|
40 |
final PreparedStatement stmt; |
|
41 |
stmt = conn.prepareStatement("SELECT COORD_REF_SYS_CODE" |
|
42 |
+ " FROM epsg_coordinatereferencesystem"); |
|
43 |
ResultSet result; |
|
44 |
|
|
45 |
result = stmt.executeQuery(); |
|
46 |
|
|
47 |
ArrayList res = new ArrayList(); |
|
48 |
ArrayList units = new ArrayList(); |
|
49 |
ArrayList validos = new ArrayList(); |
|
50 |
while (result.next()) { |
|
51 |
int cod = result.getInt("COORD_REF_SYS_CODE"); |
|
52 |
|
|
53 |
String strEpsgCode="EPSG:"+cod; |
|
54 |
CoordinateReferenceSystem source; |
|
55 |
|
|
56 |
try { |
|
57 |
source = CRS.decode(strEpsgCode); |
|
58 |
validos.add(String.valueOf(cod)); |
|
59 |
if (source instanceof DefaultProjectedCRS) { |
|
60 |
String str; |
|
61 |
boolean esta = false; |
|
62 |
DefaultProjectedCRS sour = (DefaultProjectedCRS) source; |
|
63 |
|
|
64 |
Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit(); |
|
65 |
units.add(u.toString()); |
|
66 |
|
|
67 |
/*for (int j = 0; j< units.size(); j++) { |
|
68 |
if (units.get(j).equals(u.toString())){ |
|
69 |
esta = true; |
|
70 |
break; |
|
71 |
} |
|
72 |
} |
|
73 |
if (!esta){ |
|
74 |
units.add(u.toString()); |
|
75 |
esta = false; |
|
76 |
}*/ |
|
77 |
for (int i=0; i< sour.getConversionFromBase().getParameterValues().values().size();i++) { |
|
78 |
str = sour.getConversionFromBase().getParameterValues().values().get(i).toString(); |
|
79 |
u = sour.getConversionFromBase().getParameterValues().parameter(str.split("=")[0]).getUnit(); |
|
80 |
units.add(u.toString()); |
|
81 |
|
|
82 |
} |
|
83 |
} |
|
84 |
if (source instanceof DefaultGeographicCRS) { |
|
85 |
DefaultGeographicCRS sour = (DefaultGeographicCRS) source; |
|
86 |
boolean esta = false; |
|
87 |
Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit(); |
|
88 |
units.add(u.toString()); |
|
89 |
|
|
90 |
} |
|
91 |
} catch (NoSuchAuthorityCodeException e) { |
|
92 |
res.add(String.valueOf(cod)+" --> "+e); |
|
93 |
// TODO Auto-generated catch block |
|
94 |
//e.printStackTrace(); |
|
95 |
} catch (FactoryException e) { |
|
96 |
res.add(String.valueOf(cod)+" --> "+e); |
|
97 |
// TODO Auto-generated catch block |
|
98 |
//e.printStackTrace(); |
|
99 |
} |
|
100 |
} |
|
101 |
for (int i = 0; i< res.size(); i++) { |
|
102 |
System.out.println(res.get(i)); |
|
103 |
} |
|
104 |
for (int i = 0; i< units.size(); i++) { |
|
105 |
System.out.println(units.get(i)); |
|
106 |
} |
|
107 |
System.out.println("Numero CRSs validos: " + validos.size()); |
|
108 |
System.out.println("Numero CRSs fallidos: " + res.size()); |
|
109 |
System.out.println("Numero medidas: " + units.size()); |
|
110 |
} catch (SQLException e1) { |
|
111 |
// TODO Auto-generated catch block |
|
112 |
e1.printStackTrace(); |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
} |
|
117 |
|
|
118 |
|
|
119 |
/*CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); |
|
120 |
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:23032"); |
|
121 |
|
|
122 |
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS); |
|
123 |
System.out.println("Dimensiones: "+transform.getSourceDimensions()); |
|
124 |
double points[] = {2.5,3.0}; |
|
125 |
System.out.println("Puntos fuente: "+ points[0]+" "+points[1]); |
|
126 |
transform.transform(points, 0, points, 0, 1); |
|
127 |
System.out.println("Puntos destino: "+ points[0]+" "+points[1]); |
|
128 |
|
|
129 |
int epsgCount = 0; |
|
130 |
System.out.println("CRSs Disponibles en EPSG: \n"); |
|
131 |
Set codes = CRS.getSupportedCodes("EPSG"); |
|
132 |
for (Iterator iter = codes.iterator(); iter.hasNext();) { |
|
133 |
String code = (String) iter.next(); |
|
134 |
System.out.println("EPSG:"+code); |
|
135 |
epsgCount++; |
|
136 |
} |
|
137 |
System.out.println("N�mero de CRSs en EPSG: "+epsgCount); |
|
138 |
try { |
|
139 |
System.out.println("Descripci�n de EPSG:23030: \n"+CRS.getAuthorityFactory(false).getDescriptionText("EPSG:23030")); |
|
140 |
} catch (FactoryRegistryException e) { |
|
141 |
// TODO Auto-generated catch block |
|
142 |
e.printStackTrace(); |
|
143 |
} catch (FactoryException e) { |
|
144 |
// TODO Auto-generated catch block |
|
145 |
e.printStackTrace(); |
|
146 |
} |
|
147 |
|
|
148 |
} catch (NoSuchAuthorityCodeException e) { |
|
149 |
// TODO Auto-generated catch block |
|
150 |
e.printStackTrace(); |
|
151 |
} catch (FactoryException e) { |
|
152 |
// TODO Auto-generated catch block |
|
153 |
e.printStackTrace(); |
|
154 |
}*/ |
|
155 |
|
|
0 | 156 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/test/InsertUserDataCrs.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import java.sql.SQLException; |
|
4 |
|
|
5 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
6 |
|
|
7 |
|
|
8 |
public class InsertUserDataCrs { |
|
9 |
|
|
10 |
/** |
|
11 |
* @param args |
|
12 |
*/ |
|
13 |
public static void main(String[] args) { |
|
14 |
// TODO Auto-generated method stub |
|
15 |
EpsgConnection conn = new EpsgConnection(); |
|
16 |
conn.setConnectionUsr(); |
|
17 |
|
|
18 |
String sentence = "INSERT INTO USR VALUES(2000,'PROJCS[\"Anguilla_1957_British_West_Indies_Grid\",GEOGCS[\"GCS_Anguilla_1957\",DATUM[\"D_Anguilla_1957\",SPHEROID[\"Clarke_1880_RGS\",6378249.145,293.465]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",400000.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-62.0],PARAMETER[\"Scale_Factor\",0.9995],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]','Anguilla_1957_British_West_Indies_Grid','GCS_Anguilla_1957','D_Anguilla_1957')"; |
|
19 |
|
|
20 |
try { |
|
21 |
conn.update(sentence); |
|
22 |
conn.shutdown(); |
|
23 |
} catch (SQLException e) { |
|
24 |
// TODO Auto-generated catch block |
|
25 |
e.printStackTrace(); |
|
26 |
} |
|
27 |
} |
|
28 |
|
|
29 |
} |
|
0 | 30 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/test/TestWKTandProj4Epsg.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import java.io.BufferedWriter; |
|
4 |
import java.io.FileWriter; |
|
5 |
import java.io.IOException; |
|
6 |
import java.sql.Connection; |
|
7 |
import java.sql.PreparedStatement; |
|
8 |
import java.sql.ResultSet; |
|
9 |
import java.sql.SQLException; |
|
10 |
import java.util.ArrayList; |
|
11 |
|
|
12 |
import javax.units.ConversionException; |
|
13 |
|
|
14 |
import org.geotools.referencing.factory.epsg.HSQLDataSource; |
|
15 |
import org.geotools.referencing.wkt.UnformattableObjectException; |
|
16 |
import org.gvsig.crs.Crs; |
|
17 |
import org.gvsig.crs.CrsException; |
|
18 |
import org.gvsig.crs.CrsFactory; |
|
19 |
import org.gvsig.crs.CrsGT; |
|
20 |
import org.gvsig.crs.ICrs; |
|
21 |
import org.gvsig.crs.Proj4; |
|
22 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
23 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
24 |
|
|
25 |
public class TestWKTandProj4Epsg { |
|
26 |
|
|
27 |
public static void main(String[] args) { |
|
28 |
HSQLDataSource ds = new HSQLDataSource(); |
|
29 |
Connection conn; |
|
30 |
try { |
|
31 |
conn = ds.getConnection(); |
|
32 |
int indice = 0; |
|
33 |
int fallo = 0; |
|
34 |
final PreparedStatement stmt; |
|
35 |
stmt = conn.prepareStatement("SELECT COORD_REF_SYS_CODE, COORD_REF_SYS_NAME" |
|
36 |
+" FROM epsg_coordinatereferencesystem "); |
|
37 |
//+" WHERE COORD_REF_SYS_CODE>29372"); |
|
38 |
ResultSet result; |
|
39 |
|
|
40 |
result = stmt.executeQuery(); |
|
41 |
|
|
42 |
String filename = "salida.txt"; |
|
43 |
|
|
44 |
BufferedWriter bw = new BufferedWriter(new FileWriter(filename)); |
|
45 |
|
|
46 |
while (result.next()) { |
|
47 |
ICrs crs = null; |
|
48 |
int cod = result.getInt("COORD_REF_SYS_CODE"); |
|
49 |
try { |
|
50 |
|
|
51 |
crs = new CrsFactory().getCRS("EPSG:"+cod); |
|
52 |
if (crs instanceof CrsGT) { |
|
53 |
// //continue; |
|
54 |
if (crs.getProj4String() == null){ |
|
55 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
56 |
bw.write("Cadena WKT: "+crs.getWKT()+"\n"); |
|
57 |
bw.write("Cadena Proj4: No cadena proj4 \n"); |
|
58 |
bw.write("Fallo: Fallo generando en cadena proj4 \n"); |
|
59 |
bw.write("\n\n"); |
|
60 |
} |
|
61 |
} |
|
62 |
else { |
|
63 |
if (crs != null) { |
|
64 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
65 |
bw.write("Cadena WKT: "+crs.getWKT()+"\n"); |
|
66 |
bw.write("Cadena Proj4: "+crs.getProj4String()+"\n"); |
|
67 |
bw.write("Fallo: Creado con crs antiguo \n"); |
|
68 |
bw.write("\n\n"); |
|
69 |
} |
|
70 |
else { |
|
71 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
72 |
bw.write("Fallo: Falla tanto geotools como crs antiguo \n"); |
|
73 |
bw.write("\n\n"); |
|
74 |
} |
|
75 |
|
|
76 |
} |
|
77 |
|
|
78 |
|
|
79 |
} catch (CrsException e) { |
|
80 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
81 |
bw.write("Cadena WKT: No cadena wkt \n"); |
|
82 |
bw.write("Cadena Proj4: No cadena proj4\n"); |
|
83 |
bw.write("Fallo: "+e+" \n"); |
|
84 |
bw.write("\n\n"); |
|
85 |
} catch (NumberFormatException e) { |
|
86 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
87 |
bw.write("Cadena WKT: No cadena wkt \n"); |
|
88 |
bw.write("Cadena Proj4: No cadena proj4\n"); |
|
89 |
bw.write("Fallo: "+e+" \n"); |
|
90 |
bw.write("\n\n"); |
|
91 |
} catch (ConversionException e) { |
|
92 |
bw.write("C?digo: "+cod+"\tNombre: "+result.getString("COORD_REF_SYS_NAME")+"\n"); |
|
93 |
bw.write("Cadena WKT: No cadena wkt \n"); |
|
94 |
bw.write("Cadena Proj4: No cadena proj4\n"); |
|
95 |
bw.write("Fallo: "+e+" \n"); |
|
96 |
bw.write("\n\n"); |
|
97 |
}catch (UnformattableObjectException e) { |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
bw.flush(); |
|
102 |
bw.close(); |
|
103 |
|
|
104 |
} catch (SQLException e1) { |
|
105 |
// TODO Auto-generated catch block |
|
106 |
e1.printStackTrace(); |
|
107 |
} catch (IOException e) { |
|
108 |
// TODO Auto-generated catch block |
|
109 |
e.printStackTrace(); |
|
110 |
} |
|
111 |
} |
|
112 |
} |
|
0 | 113 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/test/ValidateEsriCRSs.java | ||
---|---|---|
1 |
package es.idr.test; |
|
2 |
|
|
3 |
import java.sql.Connection; |
|
4 |
import java.sql.PreparedStatement; |
|
5 |
import java.sql.ResultSet; |
|
6 |
import java.sql.SQLException; |
|
7 |
import java.util.ArrayList; |
|
8 |
|
|
9 |
import javax.units.Unit; |
|
10 |
|
|
11 |
import org.geotools.referencing.CRS; |
|
12 |
import org.geotools.referencing.crs.DefaultGeographicCRS; |
|
13 |
import org.geotools.referencing.crs.DefaultProjectedCRS; |
|
14 |
import org.geotools.referencing.datum.DefaultGeodeticDatum; |
|
15 |
import org.geotools.referencing.factory.epsg.HSQLDataSource; |
|
16 |
import org.opengis.referencing.FactoryException; |
|
17 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
18 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
19 |
|
|
20 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
21 |
import es.idr.teledeteccion.connection.Query; |
|
22 |
|
|
23 |
public class ValidateEsriCRSs { |
|
24 |
|
|
25 |
public ValidateEsriCRSs() { |
|
26 |
|
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* @param args |
|
31 |
*/ |
|
32 |
public static void main(String[] args) { |
|
33 |
//HSQLDataSource ds = new HSQLDataSource(); |
|
34 |
EpsgConnection conn = new EpsgConnection(); |
|
35 |
//Connection conn; |
|
36 |
conn.setConnectionEsri(); |
|
37 |
try { |
|
38 |
//conn = ds.getConnection(); |
|
39 |
|
|
40 |
//final PreparedStatement stmt; |
|
41 |
/*stmt = conn.prepareStatement("SELECT esri_code" |
|
42 |
+ " FROM esri"); |
|
43 |
*/ |
|
44 |
String sentence = "SELECT esri_code,esri_wkt " + |
|
45 |
"FROM ESRI"; |
|
46 |
ResultSet result; |
|
47 |
result = Query.select(sentence,conn.getConnection()); |
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
//result = stmt.executeQuery(); |
|
52 |
|
|
53 |
ArrayList res = new ArrayList(); |
|
54 |
ArrayList units = new ArrayList(); |
|
55 |
ArrayList validos = new ArrayList(); |
|
56 |
while (result.next()) { |
|
57 |
int cod = result.getInt("esri_code"); |
|
58 |
String wkt = result.getString("esri_wkt"); |
|
59 |
//String strEpsgCode="ESRI:"+cod; |
|
60 |
CoordinateReferenceSystem source; |
|
61 |
|
|
62 |
/*try { |
|
63 |
source = CRS.parseWKT(wkt); |
|
64 |
validos.add(String.valueOf(cod)); |
|
65 |
if (source instanceof DefaultProjectedCRS) { |
|
66 |
String str; |
|
67 |
boolean esta = false; |
|
68 |
DefaultProjectedCRS sour = (DefaultProjectedCRS) source; |
|
69 |
|
|
70 |
Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit(); |
|
71 |
units.add(u.toString()); |
|
72 |
|
|
73 |
for (int j = 0; j< units.size(); j++) { |
|
74 |
if (units.get(j).equals(u.toString())){ |
|
75 |
esta = true; |
|
76 |
break; |
|
77 |
} |
|
78 |
} |
|
79 |
if (!esta){ |
|
80 |
units.add(u.toString()); |
|
81 |
esta = false; |
|
82 |
} |
|
83 |
for (int i=0; i< sour.getConversionFromBase().getParameterValues().values().size();i++) { |
|
84 |
str = sour.getConversionFromBase().getParameterValues().values().get(i).toString(); |
|
85 |
u = sour.getConversionFromBase().getParameterValues().parameter(str.split("=")[0]).getUnit(); |
|
86 |
units.add(u.toString()); |
|
87 |
|
|
88 |
} |
|
89 |
} |
|
90 |
if (source instanceof DefaultGeographicCRS) { |
|
91 |
DefaultGeographicCRS sour = (DefaultGeographicCRS) source; |
|
92 |
boolean esta = false; |
|
93 |
Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit(); |
|
94 |
units.add(u.toString()); |
|
95 |
|
|
96 |
} |
|
97 |
} catch (NoSuchAuthorityCodeException e) { |
|
98 |
res.add(String.valueOf(cod)+" --> "+e); |
|
99 |
// TODO Auto-generated catch block |
|
100 |
//e.printStackTrace(); |
|
101 |
} catch (FactoryException e) { |
|
102 |
res.add(String.valueOf(cod)+" --> "+e); |
|
103 |
// TODO Auto-generated catch block |
|
104 |
//e.printStackTrace(); |
|
105 |
}*/ |
|
106 |
} |
|
107 |
/*for (int i = 0; i< res.size(); i++) { |
|
108 |
System.out.println(res.get(i)); |
|
109 |
}*/ |
|
110 |
for (int i = 0; i< units.size(); i++) { |
|
111 |
System.out.println(units.get(i)); |
|
112 |
} |
|
113 |
System.out.println("Numero CRSs validos: " + validos.size()); |
|
114 |
System.out.println("Numero medidas: " + units.size()); |
|
115 |
System.out.println("Numero CRSs fallidos: " + res.size()); |
|
116 |
} catch (SQLException e1) { |
|
117 |
// TODO Auto-generated catch block |
|
118 |
e1.printStackTrace(); |
|
119 |
} |
|
120 |
} |
|
121 |
} |
|
0 | 122 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/crs/crsGT/ProvidersTest.java | ||
---|---|---|
1 |
package es.idr.crs.crsGT; |
|
2 |
|
|
3 |
import java.util.Arrays; |
|
4 |
import java.util.Iterator; |
|
5 |
|
|
6 |
import org.geotools.factory.FactoryRegistry; |
|
7 |
import org.geotools.referencing.operation.MathTransformProvider; |
|
8 |
|
|
9 |
public class ProvidersTest { |
|
10 |
|
|
11 |
|
|
12 |
public static void main(String[] args) { |
|
13 |
final Class[] categories = {org.geotools.referencing.operation.MathTransformProvider.class}; |
|
14 |
FactoryRegistry registry = new FactoryRegistry(Arrays.asList(categories)); |
|
15 |
Iterator providers = registry.getServiceProviders(MathTransformProvider.class); |
|
16 |
Iterator providers2 = null; |
|
17 |
MathTransformProvider provider = null; |
|
18 |
MathTransformProvider provider2 = null; |
|
19 |
while (providers.hasNext()){ |
|
20 |
provider = (MathTransformProvider) providers.next(); |
|
21 |
if(provider.nameMatches("IDR")){ |
|
22 |
providers2 = registry.getServiceProviders(MathTransformProvider.class); |
|
23 |
while (providers2.hasNext()){ |
|
24 |
provider2 = (MathTransformProvider) providers2.next(); |
|
25 |
if(provider2.nameMatches(provider.getName().toString()) && !provider2.nameMatches("IDR")) |
|
26 |
registry.deregisterServiceProvider(provider2, categories[0]); |
|
27 |
} |
|
28 |
} |
|
29 |
} |
|
30 |
providers = registry.getServiceProviders(MathTransformProvider.class); |
|
31 |
while (providers.hasNext()) { |
|
32 |
provider = (MathTransformProvider) providers.next(); |
|
33 |
if (provider.nameMatches("IDR")) |
|
34 |
System.out.println("-IDR-"+provider.toString()); |
|
35 |
else |
|
36 |
System.out.println(provider.toString()); |
|
37 |
} |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
0 | 41 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/crs/crsGT/CrsGTTest.java | ||
---|---|---|
1 |
package es.idr.crs.crsGT; |
|
2 |
|
|
3 |
import org.cresques.cts.IProjection; |
|
4 |
import org.gvsig.crs.CrsException; |
|
5 |
import org.gvsig.crs.CrsGT; |
|
6 |
import org.gvsig.crs.ICrs; |
|
7 |
import org.gvsig.crs.Proj4; |
|
8 |
import org.gvsig.crs.repository.EpsgRepositoryGT; |
|
9 |
import org.gvsig.crs.repository.EsriRepositoryGT; |
|
10 |
import org.gvsig.crs.repository.Iau2000RepositoryGT; |
|
11 |
import org.gvsig.crs.repository.UsrRepositoryGT; |
|
12 |
|
|
13 |
public class CrsGTTest { |
|
14 |
|
|
15 |
public CrsGTTest() { |
|
16 |
epsgTest(); |
|
17 |
esriTest(); |
|
18 |
iau2000Test(); |
|
19 |
usrTest(); |
|
20 |
} |
|
21 |
/** |
|
22 |
* @param args |
|
23 |
*/ |
|
24 |
public static void main(String[] args) { |
|
25 |
CrsGTTest g = new CrsGTTest(); |
|
26 |
} |
|
27 |
|
|
28 |
public void epsgTest() { |
|
29 |
EpsgRepositoryGT repo = new EpsgRepositoryGT(); |
|
30 |
IProjection crs=null; |
|
31 |
crs = repo.getCrs("23030"); |
|
32 |
if (crs!=null){ |
|
33 |
System.out.println(crs.getAbrev()); |
|
34 |
System.out.println(((ICrs)crs).getCode()); |
|
35 |
System.out.println(((ICrs)crs).getWKT()); |
|
36 |
System.out.println(((ICrs)crs).getDatum().getEIFlattening()); |
|
37 |
System.out.println(((ICrs)crs).getDatum().getESemiMajorAxis()); |
|
38 |
System.out.println(((ICrs)crs).isProjected()+"\n\n"); |
|
39 |
|
|
40 |
System.out.println("----------- CrsWkt:--------------"); |
|
41 |
System.out.println(((ICrs)crs).getCrsWkt().getAuthority()[0]+":"+((ICrs)crs).getCrsWkt().getAuthority()[1]); |
|
42 |
System.out.println(((ICrs)crs).getCrsWkt().getName()); |
|
43 |
System.out.println(((ICrs)crs).getCrsWkt().getDatumName()); |
|
44 |
System.out.println(((ICrs)crs).getCrsWkt().getGeogcs()); |
|
45 |
System.out.println(((ICrs)crs).getCrsWkt().getProjcs()); |
|
46 |
System.out.println(((ICrs)crs).getCrsWkt().getProjection()); |
|
47 |
System.out.println(((ICrs)crs).getCrsWkt().getPrimen()[0]+" -- "+ ((ICrs)crs).getCrsWkt().getPrimen()[1]+"\n\n"); |
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
try { |
|
52 |
Proj4 proj4 = new Proj4(); |
|
53 |
System.out.println(proj4.exportToProj4(((CrsGT)crs).getCrsGT())); |
|
54 |
} catch (CrsException e) { |
|
55 |
// TODO Auto-generated catch block |
|
56 |
e.printStackTrace(); |
|
57 |
} |
|
58 |
|
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
public void esriTest() { |
|
63 |
EsriRepositoryGT repo = new EsriRepositoryGT(); |
|
64 |
IProjection crs=null; |
|
65 |
crs = repo.getCrs("23030"); |
|
66 |
if (crs!=null){ |
|
67 |
System.out.println(crs.getAbrev()); |
|
68 |
System.out.println(((ICrs)crs).getCode()); |
|
69 |
System.out.println(((ICrs)crs).getWKT()); |
|
70 |
System.out.println(((ICrs)crs).getDatum().getEIFlattening()); |
|
71 |
System.out.println(((ICrs)crs).getDatum().getESemiMajorAxis()); |
|
72 |
System.out.println(((ICrs)crs).isProjected()+"\n\n"); |
|
73 |
|
|
74 |
System.out.println("----------- CrsWkt:--------------"); |
|
75 |
System.out.println(((ICrs)crs).getCrsWkt().getAuthority()[0]+":"+((ICrs)crs).getCrsWkt().getAuthority()[1]); |
|
76 |
System.out.println(((ICrs)crs).getCrsWkt().getName()); |
|
77 |
System.out.println(((ICrs)crs).getCrsWkt().getDatumName()); |
|
78 |
System.out.println(((ICrs)crs).getCrsWkt().getGeogcs()); |
|
79 |
System.out.println(((ICrs)crs).getCrsWkt().getProjcs()); |
|
80 |
System.out.println(((ICrs)crs).getCrsWkt().getProjection()); |
|
81 |
System.out.println(((ICrs)crs).getCrsWkt().getPrimen()[0]+" -- "+ ((ICrs)crs).getCrsWkt().getPrimen()[1]+"\n\n"); |
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
try { |
|
86 |
Proj4 proj4 = new Proj4(); |
|
87 |
System.out.println(proj4.exportToProj4(((CrsGT)crs).getCrsGT())); |
|
88 |
} catch (CrsException e) { |
|
89 |
// TODO Auto-generated catch block |
|
90 |
e.printStackTrace(); |
|
91 |
} |
|
92 |
|
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
public void iau2000Test() { |
|
97 |
Iau2000RepositoryGT repo = new Iau2000RepositoryGT(); |
|
98 |
IProjection crs=null; |
|
99 |
crs = repo.getCrs("19900"); |
|
100 |
if (crs!=null){ |
|
101 |
System.out.println(crs.getAbrev()); |
|
102 |
System.out.println(((ICrs)crs).getCode()); |
|
103 |
System.out.println(((ICrs)crs).getWKT()); |
|
104 |
System.out.println(((ICrs)crs).getDatum().getEIFlattening()); |
|
105 |
System.out.println(((ICrs)crs).getDatum().getESemiMajorAxis()); |
|
106 |
System.out.println(((ICrs)crs).isProjected()+"\n\n"); |
|
107 |
|
|
108 |
System.out.println("----------- CrsWkt:--------------"); |
|
109 |
System.out.println(((ICrs)crs).getCrsWkt().getAuthority()[0]+":"+((ICrs)crs).getCrsWkt().getAuthority()[1]); |
|
110 |
System.out.println(((ICrs)crs).getCrsWkt().getName()); |
|
111 |
System.out.println(((ICrs)crs).getCrsWkt().getDatumName()); |
|
112 |
System.out.println(((ICrs)crs).getCrsWkt().getGeogcs()); |
|
113 |
System.out.println(((ICrs)crs).getCrsWkt().getProjcs()); |
|
114 |
System.out.println(((ICrs)crs).getCrsWkt().getProjection()); |
|
115 |
System.out.println(((ICrs)crs).getCrsWkt().getPrimen()[0]+" -- "+ ((ICrs)crs).getCrsWkt().getPrimen()[1]+"\n\n"); |
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
try { |
|
120 |
Proj4 proj4 = new Proj4(); |
|
121 |
System.out.println(proj4.exportToProj4(((CrsGT)crs).getCrsGT())); |
|
122 |
} catch (CrsException e) { |
|
123 |
// TODO Auto-generated catch block |
|
124 |
e.printStackTrace(); |
|
125 |
} |
|
126 |
|
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
public void usrTest() { |
|
131 |
UsrRepositoryGT repo = new UsrRepositoryGT(); |
|
132 |
IProjection crs=null; |
|
133 |
crs = repo.getCrs("2000"); |
|
134 |
if (crs!=null){ |
|
135 |
System.out.println(crs.getAbrev()); |
|
136 |
System.out.println(((ICrs)crs).getCode()); |
|
137 |
System.out.println(((ICrs)crs).getWKT()); |
|
138 |
System.out.println(((ICrs)crs).getDatum().getEIFlattening()); |
|
139 |
System.out.println(((ICrs)crs).getDatum().getESemiMajorAxis()); |
|
140 |
System.out.println(((ICrs)crs).isProjected()+"\n\n"); |
|
141 |
|
|
142 |
System.out.println("----------- CrsWkt:--------------"); |
|
143 |
System.out.println(((ICrs)crs).getCrsWkt().getAuthority()[0]+":"+((ICrs)crs).getCrsWkt().getAuthority()[1]); |
|
144 |
System.out.println(((ICrs)crs).getCrsWkt().getName()); |
|
145 |
System.out.println(((ICrs)crs).getCrsWkt().getDatumName()); |
|
146 |
System.out.println(((ICrs)crs).getCrsWkt().getGeogcs()); |
|
147 |
System.out.println(((ICrs)crs).getCrsWkt().getProjcs()); |
|
148 |
System.out.println(((ICrs)crs).getCrsWkt().getProjection()); |
|
149 |
System.out.println(((ICrs)crs).getCrsWkt().getPrimen()[0]+" -- "+ ((ICrs)crs).getCrsWkt().getPrimen()[1]+"\n\n"); |
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
try { |
|
154 |
Proj4 proj4 = new Proj4(); |
|
155 |
System.out.println(proj4.exportToProj4(((CrsGT)crs).getCrsGT())); |
|
156 |
} catch (CrsException e) { |
|
157 |
// TODO Auto-generated catch block |
|
158 |
e.printStackTrace(); |
|
159 |
} |
|
160 |
|
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
} |
|
0 | 165 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/es/idr/projection/test/TestGeotools21.java | ||
---|---|---|
1 |
package es.idr.projection.test; |
|
2 |
|
|
3 |
import org.gvsig.crs.CrsException; |
|
4 |
import org.gvsig.crs.CrsFactory; |
|
5 |
import org.gvsig.crs.ICrs; |
|
6 |
import org.gvsig.crs.Proj4; |
|
7 |
import org.opengis.referencing.FactoryException; |
|
8 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
9 |
|
|
10 |
public class TestGeotools21 { |
|
11 |
|
|
12 |
|
|
13 |
/** |
|
14 |
* @param args |
|
15 |
*/ |
|
16 |
public static void main(String[] args) { |
|
17 |
try { |
|
18 |
String strEpsgCode; |
|
19 |
// Notas: |
|
20 |
// - transverse mercator south orientated no esta soportada por Proj4 |
|
21 |
// - Buscar ejemplo de la CylindricalEqualArea |
|
22 |
// - Buscar ejemplo de la AzimuthalEquidistant |
|
23 |
// - Buscar ejemplo de la Gnomonic |
|
24 |
// - Buscar ejemplo de la Bonne |
|
25 |
// - Buscar ejemplo de la Equirectangular |
|
26 |
// - Buscar ejemplo de la EquidistantConic |
|
27 |
// - Buscar ejemplo de la MillerCylindrical |
|
28 |
// - Buscar ejemplo de la Mollweide |
|
29 |
// - Buscar ejemplo de la EckertIV |
|
30 |
// - Buscar ejemplo de la EckertVI |
|
31 |
// - Buscar ejemplo de la Robinson |
|
32 |
// - Buscar ejemplo de la VanDerGrinten |
|
33 |
// - Buscar ejemplo de la Sinusoidal |
|
34 |
// - Buscar ejemplo de la GallStereographic |
|
35 |
// - Buscar ejemplo de la Goode |
|
36 |
|
|
37 |
//strEpsgCode="EPSG:2065"; // Krovak |
|
38 |
//strEpsgCode="EPSG:2052"; // tm south orientated No en mi Proj4 |
|
39 |
//strEpsgCode="EPSG:2084"; // tm south orientated |
|
40 |
//strEpsgCode="EPSG:32662"; // Plate Carree -> Funciona, problema elipsoide |
|
41 |
// Tomara como radio el semieje mayor del elipsoide |
|
42 |
//strEpsgCode="EPSG:27200"; // NewZealandMapGrid -> Mirar lo de +datum |
|
43 |
// He tenido que incluir un mecanismo para valores concretos de parametros |
|
44 |
strEpsgCode="EPSG:32761"; // CassiniSoldner -> Falla +to_meter=.. |
|
45 |
//strEpsgCode="EPSG:2099"; |
|
46 |
//strEpsgCode="EPSG:2200"; // en lugar de stere pone sterea,igual 2171 |
|
47 |
// 2036 - falla, 32661 |
|
48 |
//strEpsgCode="EPSG:2163"; // Laea esferica, funciona |
|
49 |
//strEpsgCode="EPSG:3035"; // ETRS-LAEA, funciona |
|
50 |
//strEpsgCode="EPSG:29100"; // Polyconic, falla en geotools |
|
51 |
//strEpsgCode="EPSG:2964"; // Albers-conic-equal-area |
|
52 |
// debería fallar por cambio de unidad |
|
53 |
//strEpsgCode="EPSG:24571"; // Oblicua de mercator, rf mas decimales |
|
54 |
// quitar segundo alpha |
|
55 |
//strEpsgCode="EPSG:29700"; // Oblicua de mercator, rf mas decimales |
|
56 |
//strEpsgCode="EPSG:21780"; //somer, sin alpha |
|
57 |
ICrs crs=null; |
|
58 |
//CoordinateReferenceSystem source; |
|
59 |
//source = CRS.decode(strEpsgCode); |
|
60 |
crs = new CrsFactory().getCRS(strEpsgCode); |
|
61 |
|
|
62 |
System.out.println(crs.getWKT()); |
|
63 |
System.out.println(crs.getProj4String()); //proj4.exportToProj4(crs)); |
|
64 |
|
|
65 |
|
|
66 |
} catch (CrsException e) { |
|
67 |
// TODO Auto-generated catch block |
|
68 |
e.printStackTrace(); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
} |
|
0 | 73 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/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 |
if (crs != null){ |
|
11 |
String abrev = crs.getAbrev(); |
|
12 |
System.out.println(abrev); |
|
13 |
} |
|
14 |
else |
|
15 |
System.out.println("el c?digo no existe en el repositorio."); |
|
16 |
} |
|
17 |
} |
|
0 | 18 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/test/org/gvsig/crs/jscrollpanel/ScrollPanelTest.java | ||
---|---|---|
1 |
package org.gvsig.crs.jscrollpanel; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
|
|
5 |
import javax.swing.BorderFactory; |
|
6 |
import javax.swing.JFrame; |
|
7 |
import javax.swing.JScrollPane; |
|
8 |
import javax.swing.JTable; |
|
9 |
import javax.swing.table.DefaultTableModel; |
|
10 |
import javax.swing.table.TableColumn; |
|
11 |
|
|
12 |
public class ScrollPanelTest { |
|
13 |
|
|
14 |
JTable jTable = null; |
|
15 |
JScrollPane jScrollPane = null; |
|
16 |
|
|
17 |
public ScrollPanelTest() { |
|
18 |
super(); |
|
19 |
JFrame jFrame = new JFrame(); |
|
20 |
jFrame.getContentPane().add(getJScrollPane()); |
|
21 |
jFrame.setSize(500, 150); |
|
22 |
jFrame.setVisible(true); |
|
23 |
// TODO Auto-generated constructor stub |
|
24 |
} |
|
25 |
|
|
26 |
public JTable getJTable() { |
|
27 |
if (jTable == null) { |
|
28 |
String[] columnNames= {"UNA COLUMNA", "DOS COLUMNAS"}; |
|
29 |
Object[][]data = {}; |
|
30 |
DefaultTableModel dtm = new DefaultTableModel(data, columnNames); |
|
31 |
jTable = new JTable(dtm); |
|
32 |
jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); |
|
33 |
TableColumn column = null; |
|
34 |
for (int i = 0; i < 2; i++) { |
|
35 |
column = jTable.getColumnModel().getColumn(i); |
|
36 |
if (i == 0) { |
|
37 |
column.setPreferredWidth(600); |
|
38 |
} |
|
39 |
} |
|
40 |
//jTable.setPreferredSize(new Dimension(800, 100)); |
|
41 |
|
|
42 |
} |
|
43 |
|
|
44 |
return jTable; |
|
45 |
|
|
46 |
} |
|
47 |
|
|
48 |
|
|
49 |
private JScrollPane getJScrollPane() { |
|
50 |
if (jScrollPane == null) { |
|
51 |
jScrollPane = new JScrollPane(getJTable(),JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); |
|
52 |
jScrollPane.setPreferredSize(new Dimension(500,150)); |
|
53 |
jScrollPane.setBorder( |
|
54 |
BorderFactory.createCompoundBorder( |
|
55 |
BorderFactory.createCompoundBorder( |
|
56 |
BorderFactory.createTitledBorder("TABLA GEN?RICA DE 2 CAMPOS"), |
|
57 |
BorderFactory.createEmptyBorder(5,5,5,5)), |
|
58 |
jScrollPane.getBorder())); |
|
59 |
jScrollPane.setViewportView(getJTable()); |
|
60 |
} |
|
61 |
return jScrollPane; |
|
62 |
} |
|
63 |
|
|
64 |
|
|
65 |
public static void main(String[] args){ |
|
66 |
ScrollPanelTest al = new ScrollPanelTest(); |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
} |
|
0 | 72 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/main/docs/Notas.txt | ||
---|---|---|
1 |
- COpetation.getInverted() no est? teniendo en cuenta si hay par?metros de transformaci?n -HECHO- |
|
2 |
- Resolver el tema del cacheado de CRSs en los repositorios. |
|
3 |
- Por qu? no est?n implementados getPOrig() y getPDest() de COperation? -HECHO- |
|
4 |
- Plantearse la necesidad de ICOperation: |
|
5 |
- COperation ya no la implementa. La conservo preventivamente. -HECHO- |
|
6 |
- Crs y CrsGT: No construir los objetos CrsProj en el constructor, hacerlo la primera vez que se pidan. |
|
7 |
- Habr?a que reducir el tiempo de arranque de la extensi?n. |
|
8 |
- Depuraciones para detectar ineficiencias. |
|
9 |
- COperation.operate se llama para cada punto: optimizar su contenido (creaci?n de objetos). -HECHO- |
|
10 |
- Hacer que CrsGT.getCT no construya nuevos CrsProj cada vez que se llama. |
|
11 |
- libJCrs y windows?????????????' |
|
12 |
- ICrs: mirar qu? m?todos no tienen por qu? estar en la interfaz. |
|
13 |
- Dependencias de gvSIG en libJCrs: |
|
14 |
- COperation.convert(...) utiliza: NotificationManager.addError(e) de andami; |
|
15 |
- Persistencia: depende de PluginServices de andami. -> subir la persistencia a la extension. -HECHO- |
|
16 |
- dependencia de CMS: IProjection, ICoordTrans, IDatum, ICRSFactory, org.cresques.geo.ViewPortData. |
|
17 |
|
|
18 |
- Crs.getScale(): double invF = getDatum().getEIFlattening(); if (invF == Double.POSITIVE_INFINITY){} |
|
19 |
?Qu? valor da getDatum().getEIFlattening() en el caso de una esfera? geoltools da Double.POSITIVE_INFINITY. |
|
20 |
|
|
21 |
- Busqueda IAU por zona: en mayusculas no encuentra. -HECHO- |
|
22 |
- Persistencia de transformaciones en F2. -HECHO- |
|
23 |
- Persistencia en el proyecto: Implementar IProyectio.getFullCode() y lo que esto implica. -HECHO- |
|
24 |
|
|
25 |
- OGR y WINDOWS....!!!!???? |
|
26 |
- Revisar classpath de extJCRS (?log4j-1.2.8.jar?,etc...) |
|
27 |
- Cuando CRS fuente y destino son iguales -> no operar, devolver el mismo punto. |
|
28 |
|
|
29 |
|
|
30 |
BUGS: |
|
31 |
|
|
32 |
- Cargas un shp 23030 diciendole que es 4258 con transf. EPSG (7) y salta una excepcci?n de proj4: controlar o subir estos |
|
33 |
errores (es un error como el que silenciamos de nadgrids). |
|
34 |
En este caso el error es debido a que las coordenadas se salen del rango del CRS elegido. Esta situaci?n ArcMap la maneja desavilitando |
|
35 |
la capa y dejando de visualizarla (algo parecedo a cuando gvSIG le pone la x de erroneo a una capa). |
|
36 |
|
|
37 |
- Cuando hay un fallo al elegir el CRS de la vista y despu?s guardas el proyecto, parece ser que se guarda como null (o algo as?) |
|
38 |
y falla al abrirlo. Posibles soluciones: en esos casos guardar el CRS por defecto. |
|
39 |
|
|
40 |
- Nomenclator: Cuando pulsas localizar, debe dibuajar el punto en la vista y hacer zoom a el. Lo dibuja pero aparece una |
|
41 |
excepci?n y no hace el zoom. |
|
0 | 42 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.crs.JCRSLibrary |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/main/resources/META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory | ||
---|---|---|
1 |
es.idr.teledeteccion.connection.esri.FactoryUsingHSQL |
|
2 |
es.idr.teledeteccion.connection.usr.FactoryUsingHSQL |
|
3 |
es.idr.teledeteccion.connection.iau2000.FactoryUsingHSQL |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/main/resources/META-INF/services/org.geotools.referencing.operation.MathTransformProvider | ||
---|---|---|
1 |
org.geotools.referencing.operation.projection.IdrAitoff$Provider |
|
2 |
org.geotools.referencing.operation.projection.IdrAzimuthalEquidistant$Provider |
|
3 |
org.geotools.referencing.operation.projection.IdrAzimuthalEquidistant$Provider_Modified |
|
4 |
org.geotools.referencing.operation.projection.IdrAzimuthalEquidistant$Provider_Guam |
|
5 |
org.geotools.referencing.operation.projection.IdrBonne$Provider |
|
6 |
org.geotools.referencing.operation.projection.IdrBonne$Provider_SouthOrientated |
|
7 |
org.geotools.referencing.operation.projection.IdrCassiniSoldner$Provider |
|
8 |
org.geotools.referencing.operation.projection.IdrCassiniSoldner$Provider_Hyperbolic |
|
9 |
org.geotools.referencing.operation.projection.IdrCrasterParabolic$Provider |
|
10 |
org.geotools.referencing.operation.projection.IdrCylindricalEqualArea$Provider |
|
11 |
org.geotools.referencing.operation.projection.IdrEckertI$Provider |
|
12 |
org.geotools.referencing.operation.projection.IdrEckertII$Provider |
|
13 |
org.geotools.referencing.operation.projection.IdrEckertIII$Provider |
|
14 |
org.geotools.referencing.operation.projection.IdrEckertIV$Provider |
|
15 |
org.geotools.referencing.operation.projection.IdrEckertV$Provider |
|
16 |
org.geotools.referencing.operation.projection.IdrEckertVI$Provider |
|
17 |
org.geotools.referencing.operation.projection.IdrEquidistantConic$Provider |
|
18 |
org.geotools.referencing.operation.projection.IdrEquidistantCylindrical$Provider |
|
19 |
org.geotools.referencing.operation.projection.IdrEquirectangular$Provider |
|
20 |
org.geotools.referencing.operation.projection.IdrFlatPolarQuartic$Provider |
|
21 |
org.geotools.referencing.operation.projection.IdrGallStereographic$Provider |
|
22 |
org.geotools.referencing.operation.projection.IdrGnomonic$Provider |
|
23 |
org.geotools.referencing.operation.projection.IdrGoode$Provider |
|
24 |
org.geotools.referencing.operation.projection.IdrHammerAitoff$Provider |
|
25 |
org.geotools.referencing.operation.projection.IdrKrovak$Provider |
|
26 |
org.geotools.referencing.operation.projection.IdrLabordeMadagascar$Provider |
|
27 |
org.geotools.referencing.operation.projection.IdrLambertAzimuthalEqualArea$Provider |
|
28 |
org.geotools.referencing.operation.projection.IdrLambertConformalWestOrientated$Provider |
|
29 |
org.geotools.referencing.operation.projection.IdrLambertConicNearConformal$Provider |
|
30 |
org.geotools.referencing.operation.projection.IdrLoximuthal$Provider |
|
31 |
org.geotools.referencing.operation.projection.IdrMercator$Provider1SP |
|
32 |
org.geotools.referencing.operation.projection.IdrMillerCylindrical$Provider |
|
33 |
org.geotools.referencing.operation.projection.IdrMollweide$Provider |
|
34 |
org.geotools.referencing.operation.projection.IdrNearSidedPerspective$Provider |
|
35 |
org.geotools.referencing.operation.projection.IdrNewZealandMapGrid$Provider |
|
36 |
org.geotools.referencing.operation.projection.IdrObliqueMercator$Provider |
|
37 |
org.geotools.referencing.operation.projection.IdrObliqueMercator$Provider_Hotine |
|
38 |
org.geotools.referencing.operation.projection.IdrObliqueMercator$Provider_TwoPoint |
|
39 |
org.geotools.referencing.operation.projection.IdrObliqueMercator$Provider_Hotine_TwoPoint |
|
40 |
org.geotools.referencing.operation.projection.IdrOrthographic$Provider |
|
41 |
org.geotools.referencing.operation.projection.IdrPlateCarree$Provider |
|
42 |
org.geotools.referencing.operation.projection.IdrPolyconic$Provider |
|
43 |
org.geotools.referencing.operation.projection.IdrQuarticAuthalic$Provider |
|
44 |
org.geotools.referencing.operation.projection.IdrRobinson$Provider |
|
45 |
org.geotools.referencing.operation.projection.IdrSinusoidal$Provider |
|
46 |
org.geotools.referencing.operation.projection.IdrTransverseMercator$Provider |
|
47 |
org.geotools.referencing.operation.projection.IdrTransverseMercator$Provider_SouthOrientated |
|
48 |
org.geotools.referencing.operation.projection.IdrTransverseMercator$Provider_TransverseMercatorZonedGridSystem |
|
49 |
org.geotools.referencing.operation.projection.IdrTunisiaMiningGrid$Provider |
|
50 |
org.geotools.referencing.operation.projection.IdrVanDerGrinten$Provider |
|
51 |
org.geotools.referencing.operation.projection.IdrWinkelI$Provider |
|
52 |
org.geotools.referencing.operation.projection.IdrWinkelII$Provider |
|
53 |
org.geotools.referencing.operation.projection.IdrWinkelTripel$Provider |
|
54 |
|
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/main/java/es/idr/teledeteccion/connection/Query.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 es.idr.teledeteccion.connection; |
|
42 |
|
|
43 |
import java.io.Serializable; |
|
44 |
import java.sql.Connection; |
|
45 |
import java.sql.ResultSet; |
|
46 |
import java.sql.ResultSetMetaData; |
|
47 |
import java.sql.SQLException; |
|
48 |
import java.sql.Statement; |
|
49 |
|
|
50 |
import org.slf4j.Logger; |
|
51 |
import org.slf4j.LoggerFactory; |
|
52 |
|
|
53 |
/** |
|
54 |
* Clase para realizar las consultas a las bases de datos utilizadas |
|
55 |
* |
|
56 |
* @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com) |
|
57 |
* |
|
58 |
*/ |
|
59 |
public class Query implements Serializable{ |
|
60 |
|
|
61 |
/** |
|
62 |
* |
|
63 |
*/ |
|
64 |
private static final long serialVersionUID = 1L; |
|
65 |
private static Logger logger = LoggerFactory.getLogger(Query.class); |
|
66 |
|
|
67 |
/** |
|
68 |
* Acepta la sentencia y la conexi?n a la base de datos actual, |
|
69 |
* realiza una selecci?n y devuelve los datos en un ResultSet |
|
70 |
* @param sentence |
|
71 |
* @param conn |
|
72 |
* @return |
|
73 |
*/ |
|
74 |
public static synchronized ResultSet select(String sentence, Connection conn){ |
|
75 |
Statement st = null; |
|
76 |
ResultSet rs = null; |
|
77 |
|
|
78 |
try { |
|
79 |
st = conn.createStatement(); |
|
80 |
rs = st.executeQuery(sentence); |
|
81 |
st.close(); |
|
82 |
} catch (SQLException e) { |
|
83 |
String connid = conn.toString(); |
|
84 |
try { |
|
85 |
connid = conn.getMetaData().getURL(); |
|
86 |
} catch (SQLException e1) { |
|
87 |
} |
|
88 |
logger.error("Can't create ResulSet from sentece '"+sentence+"' in connection '"+connid +"'.",e); |
|
89 |
} |
|
90 |
return rs; |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
0 | 94 |
org.gvsig.projection.jcrs/tags/org.gvsig.projection.jcrs-2.1.265/org.gvsig.projection.jcrs.lib/src/main/java/es/idr/teledeteccion/connection/usr/FactoryUsingHSQL.java | ||
---|---|---|
1 |
/* |
|
2 |
* GeoTools - OpenSource mapping toolkit |
|
3 |
* http://geotools.org |
|
4 |
* (C) 2005-2006, GeoTools Project Managment Committee (PMC) |
|
5 |
* |
|
6 |
* This library is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU Lesser General Public |
|
8 |
* License as published by the Free Software Foundation; |
|
9 |
* version 2.1 of the License. |
|
10 |
* |
|
11 |
* This library 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 GNU |
|
14 |
* Lesser General Public License for more details. |
|
15 |
*/ |
|
16 |
package es.idr.teledeteccion.connection.usr; |
|
17 |
|
|
18 |
// J2SE dependencies |
|
19 |
|
|
20 |
import java.io.IOException; |
|
21 |
import java.sql.Connection; |
|
22 |
import java.sql.PreparedStatement; |
|
23 |
import java.sql.ResultSet; |
|
24 |
import java.sql.SQLException; |
|
25 |
import java.sql.Statement; |
|
26 |
import java.text.ParseException; |
|
27 |
import java.util.Hashtable; |
|
28 |
import java.util.Set; |
|
29 |
|
|
30 |
import org.geotools.metadata.iso.citation.CitationImpl; |
|
31 |
import org.geotools.referencing.wkt.Parser; |
|
32 |
import org.gvsig.crs.CrsFactory; |
|
33 |
import org.hsqldb.jdbc.jdbcDataSource; |
|
34 |
import org.opengis.metadata.citation.Citation; |
|
35 |
import org.opengis.referencing.FactoryException; |
|
36 |
import org.opengis.referencing.IdentifiedObject; |
|
37 |
import org.opengis.referencing.crs.CRSAuthorityFactory; |
|
38 |
import org.opengis.referencing.crs.CRSFactory; |
|
39 |
import org.opengis.referencing.crs.CompoundCRS; |
|
40 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
41 |
import org.opengis.referencing.crs.DerivedCRS; |
|
42 |
import org.opengis.referencing.crs.EngineeringCRS; |
|
43 |
import org.opengis.referencing.crs.GeocentricCRS; |
|
44 |
import org.opengis.referencing.crs.GeographicCRS; |
|
45 |
import org.opengis.referencing.crs.ImageCRS; |
|
46 |
import org.opengis.referencing.crs.ProjectedCRS; |
|
47 |
import org.opengis.referencing.crs.TemporalCRS; |
|
48 |
import org.opengis.referencing.crs.VerticalCRS; |
|
49 |
import org.opengis.util.InternationalString; |
|
50 |
|
|
51 |
|
|
52 |
public class FactoryUsingHSQL extends jdbcDataSource implements CRSAuthorityFactory { |
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
/** |
|
57 |
* The connection to the EPSG database. |
|
58 |
*/ |
|
59 |
protected Connection connection; |
|
60 |
|
|
61 |
// object factory |
|
62 |
protected CRSFactory crsFactory; |
|
63 |
|
|
64 |
/** Cache of parsed CoordinateReferenceSystem WKT by ESRI_NUMBER */ |
|
65 |
private Hashtable cache = new Hashtable(); |
|
66 |
|
|
67 |
/** |
|
68 |
* The database name. |
|
69 |
* |
|
70 |
* @since 2.3 |
|
71 |
*/ |
|
72 |
public static final String DATABASE_NAME = "USR"; |
|
73 |
|
|
74 |
public FactoryUsingHSQL() { |
|
75 |
try { |
|
76 |
loadDefault(); |
|
77 |
} |
|
78 |
catch( IOException oops ){ |
|
79 |
System.err.println("Could not load "+ oops ); |
|
80 |
} |
|
81 |
//this(FactoryFinder.getCRSFactory(null)); |
|
82 |
} |
|
83 |
|
|
84 |
protected FactoryUsingHSQL(CRSFactory factory) { |
|
85 |
this.crsFactory = factory; |
|
86 |
try { |
|
87 |
loadDefault(); |
|
88 |
} |
|
89 |
catch( IOException oops ){ |
|
90 |
System.err.println("Could not load "+ oops ); |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
protected void loadDefault() throws IOException { |
|
95 |
String db = "jdbc:hsqldb:file:" + CrsFactory.getDataBaseFolder().getAbsolutePath() + "/usr"; |
|
96 |
setDatabase(db); |
|
97 |
setUser("sa"); |
|
98 |
try { |
|
99 |
connection = super.getConnection(); |
|
100 |
} catch (SQLException e) { |
|
101 |
// TODO Auto-generated catch block |
|
102 |
e.printStackTrace(); |
|
103 |
} |
|
104 |
|
|
105 |
} |
|
106 |
|
|
107 |
public CoordinateReferenceSystem createCoordinateReferenceSystem(String code) throws FactoryException { |
|
108 |
// TODO Auto-generated method stub |
|
109 |
CoordinateReferenceSystem returnValue = null; |
|
110 |
String wkt = null; |
|
111 |
String USR_NUMBER = code.substring(code.indexOf(":")+1, code.length()); |
|
112 |
int cod = Integer.parseInt(USR_NUMBER); |
|
113 |
|
|
114 |
if( cache.contains( USR_NUMBER ) ){ |
|
115 |
Object value = cache.get( USR_NUMBER ); |
|
116 |
if( value instanceof Throwable ){ |
|
117 |
throw new FactoryException( "WKT for "+code+" could not be parsed", (Throwable) value ); |
|
118 |
} |
|
119 |
if( value instanceof CoordinateReferenceSystem){ |
|
120 |
return (CoordinateReferenceSystem) value; |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
try { |
|
125 |
final PreparedStatement stmt; |
|
126 |
|
|
127 |
String sentence = "SELECT USR_WKT" |
|
128 |
+ " FROM USR" |
|
129 |
+ " WHERE USR_CODE = " + code.substring(code.indexOf(":")+1, code.length()); |
|
130 |
|
|
131 |
Statement st = null; |
|
132 |
ResultSet result = null; |
|
133 |
loadDefault(); |
|
134 |
st = connection.createStatement(); |
|
135 |
result = st.executeQuery(sentence); |
|
136 |
st.close(); |
|
137 |
connection.close(); |
|
138 |
while (result.next()) { |
|
139 |
wkt = result.getString("usr_wkt"); |
|
140 |
} |
|
141 |
result.close(); |
|
142 |
if( wkt.indexOf( cod ) == -1){ |
|
143 |
wkt = wkt.trim(); |
Also available in: Unified diff