Revision 11043

View differences:

branches/F2/libraries/libJCRS/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 org.geotools.referencing.CRS;
10
import org.geotools.referencing.factory.epsg.HSQLDataSource;
11
import org.gvsig.crs.Crs;
12
import org.gvsig.crs.CrsException;
13
import org.opengis.referencing.FactoryException;
14
import org.opengis.referencing.NoSuchAuthorityCodeException;
15
import org.opengis.referencing.crs.CoordinateReferenceSystem;
16

  
17

  
18

  
19
public class ValidateEpsgCRSs {
20

  
21
	public ValidateEpsgCRSs() {
22
		
23
	}
24

  
25
	/**
26
	 * @param args
27
	 */
28
	public static void main(String[] args) {
29
		HSQLDataSource ds = new HSQLDataSource();
30
		Connection conn;
31
		try {
32
			conn = ds.getConnection();
33
		
34
			final PreparedStatement stmt;
35
	        stmt = conn.prepareStatement("SELECT COORD_REF_SYS_CODE"
36
	                                      + " FROM epsg_coordinatereferencesystem");
37
	        ResultSet result;
38
			
39
			result = stmt.executeQuery();
40
			
41
	        ArrayList res = new ArrayList();
42
	        while (result.next()) {
43
	        	int cod = result.getInt("COORD_REF_SYS_CODE");
44
	        	
45
        		String strEpsgCode="EPSG:"+cod;		
46
        		CoordinateReferenceSystem source;
47
        		
48
        			try {
49
						source = CRS.decode(strEpsgCode);
50
					} catch (NoSuchAuthorityCodeException e) {
51
						res.add(String.valueOf(cod)+" --> "+e);
52
						// TODO Auto-generated catch block
53
						//e.printStackTrace();
54
					} catch (FactoryException e) {
55
						res.add(String.valueOf(cod)+" --> "+e);
56
						// TODO Auto-generated catch block
57
						//e.printStackTrace();
58
					}
59
	        }
60
	        for (int i = 0; i< res.size(); i++) {
61
	        	System.out.println(res.get(i));
62
	        }	       
63
	        System.out.println("Numero CRSs fallidos: " + res.size());
64
		} catch (SQLException e1) {
65
			// TODO Auto-generated catch block
66
			e1.printStackTrace();
67
		}	
68
	}
69
		
70
}
71
			
72
			
73
			/*CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
74
			CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:23032");
75

  
76
			MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
77
			System.out.println("Dimensiones: "+transform.getSourceDimensions());
78
			double points[] = {2.5,3.0};
79
			System.out.println("Puntos fuente: "+ points[0]+"  "+points[1]);
80
			transform.transform(points, 0, points, 0, 1);
81
			System.out.println("Puntos destino: "+ points[0]+"  "+points[1]);
82

  
83
			int epsgCount = 0;
84
			System.out.println("CRSs Disponibles en EPSG: \n");
85
			Set codes = CRS.getSupportedCodes("EPSG");
86
			for (Iterator iter = codes.iterator(); iter.hasNext();) {
87
			String code = (String) iter.next();
88
			System.out.println("EPSG:"+code);
89
			epsgCount++;
90
			}
91
			System.out.println("N�mero de CRSs en EPSG: "+epsgCount);
92
			try {
93
			System.out.println("Descripci�n de EPSG:23030:  \n"+CRS.getAuthorityFactory(false).getDescriptionText("EPSG:23030"));
94
			} catch (FactoryRegistryException e) {
95
//			 TODO Auto-generated catch block
96
			e.printStackTrace();
97
			} catch (FactoryException e) {
98
//			 TODO Auto-generated catch block
99
			e.printStackTrace();
100
			}
101
			
102
		} catch (NoSuchAuthorityCodeException e) {
103
			// TODO Auto-generated catch block
104
			e.printStackTrace();
105
		} catch (FactoryException e) {
106
			// TODO Auto-generated catch block
107
			e.printStackTrace();
108
		}*/  
109

  
0 110

  

Also available in: Unified diff