Revision 11106 branches/F2/libraries/libJCRS/src-test/es/idr/test/ValidateEpsgCRSs.java

View differences:

ValidateEpsgCRSs.java
6 6
import java.sql.SQLException;
7 7
import java.util.ArrayList;
8 8

  
9
import javax.units.Unit;
10

  
9 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;
10 15
import org.geotools.referencing.factory.epsg.HSQLDataSource;
11 16
import org.gvsig.crs.Crs;
12 17
import org.gvsig.crs.CrsException;
13 18
import org.opengis.referencing.FactoryException;
14 19
import org.opengis.referencing.NoSuchAuthorityCodeException;
15 20
import org.opengis.referencing.crs.CoordinateReferenceSystem;
21
import org.opengis.referencing.crs.GeographicCRS;
16 22

  
17 23

  
18 24

  
......
39 45
			result = stmt.executeQuery();
40 46
			
41 47
	        ArrayList res = new ArrayList();
48
	        ArrayList units = new ArrayList();
42 49
	        while (result.next()) {
43 50
	        	int cod = result.getInt("COORD_REF_SYS_CODE");
44 51
	        	
......
47 54
        		
48 55
        			try {
49 56
						source = CRS.decode(strEpsgCode);
50
					} catch (NoSuchAuthorityCodeException e) {
57
						if (source instanceof DefaultProjectedCRS) {
58
							String str;
59
							boolean esta = false;
60
							DefaultProjectedCRS sour = (DefaultProjectedCRS) source;
61
						
62
							Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit();
63
							units.add(u.toString());
64
							
65
							/*for (int j = 0; j< units.size(); j++) {
66
					        	if (units.get(j).equals(u.toString())){
67
					        		esta = true;
68
					        		break;
69
					        	}						        	
70
					        }
71
							if (!esta){
72
								units.add(u.toString());
73
								esta = false;
74
							}*/
75
							for (int i=0; i< sour.getConversionFromBase().getParameterValues().values().size();i++) {
76
								str = sour.getConversionFromBase().getParameterValues().values().get(i).toString();
77
								u = sour.getConversionFromBase().getParameterValues().parameter(str.split("=")[0]).getUnit();
78
								units.add(u.toString());
79
																																								
80
							}
81
						}
82
						if (source instanceof DefaultGeographicCRS) {
83
							DefaultGeographicCRS sour = (DefaultGeographicCRS) source;
84
							boolean esta = false;
85
							Unit u = ((DefaultGeodeticDatum) sour.getDatum()).getPrimeMeridian().getAngularUnit();
86
							units.add(u.toString());							
87
													
88
						}
89
					} catch (NoSuchAuthorityCodeException e) {						
51 90
						res.add(String.valueOf(cod)+" --> "+e);
52 91
						// TODO Auto-generated catch block
53 92
						//e.printStackTrace();
......
58 97
					}
59 98
	        }
60 99
	        for (int i = 0; i< res.size(); i++) {
61
	        	System.out.println(res.get(i));
100
	        	System.out.println(res.get(i));	        	
62 101
	        }	       
102
	        for (int i = 0; i< units.size(); i++) {
103
	        	System.out.println(units.get(i));
104
	        }
63 105
	        System.out.println("Numero CRSs fallidos: " + res.size());
106
	        System.out.println("Numero medidas: " + units.size());
64 107
		} catch (SQLException e1) {
65 108
			// TODO Auto-generated catch block
66 109
			e1.printStackTrace();

Also available in: Unified diff