Revision 76

View differences:

org.gvsig.jcrs/trunk/libJCRS/src/org/gvsig/crs/CrsFactory.java
44 44

  
45 45
import org.cresques.cts.ICRSFactory;
46 46
import org.cresques.cts.IProjection;
47
import org.slf4j.Logger;
48
import org.slf4j.LoggerFactory;
49

  
47 50
import org.gvsig.crs.repository.EpsgRepository;
48 51
import org.gvsig.crs.repository.EpsgRepositoryGT;
49 52
import org.gvsig.crs.repository.EsriRepository;
......
65 68
 */
66 69

  
67 70
public class CrsFactory implements ICRSFactory {
71
    
72
    private static Logger logger = LoggerFactory.getLogger(CrsFactory.class);
68 73
	static TreeMap data = new TreeMap();
69 74

  
70 75
	public CrsFactory() {
......
83 88
		String repoId = "";
84 89
		String crsCode = "";
85 90
		ICrs crs = null;
91
		ICrsRepository repo = null;
86 92

  
87 93
		if(code.indexOf(":", code.indexOf(":")+1)<0){
88 94
			repoId = code.substring(0, code.indexOf(":"));
89 95
			crsCode = code.substring(code.indexOf(":")+1);
90 96

  
91
			ICrsRepository repo = null;
92

  
93 97
			if(repoId.equals("EPSG")){
94 98
				repo = new EpsgRepositoryGT();
95 99
				crs = repo.getCrs(crsCode);
......
148 152
					targetParams = null;
149 153
			}
150 154
			crs = getCRS(crsCode);
151
			crs.setTransformationParams(sourceParams,targetParams);
155
			if (crs != null) {
156
			    crs.setTransformationParams(sourceParams,targetParams);
157
			}
158
			
152 159
		}
153 160

  
154 161
		/*code = crs.getAbrev();
155 162

  
156 163
		data.put(code, crs);*/
157 164

  
165
		if (crs == null) {
166
		    logger.warn("Did not find CRS " + code + " in available repositories.");
167
		} else {
168
		    logger.info("Found CRS " + code +
169
		        (repo == null ? "" : (" (" + repo.getClass().getSimpleName() + ")")));
170
		}
158 171
		return crs;
159 172

  
160 173
		/*if (data.containsKey(code))
org.gvsig.jcrs/trunk/libJCRS/src/org/gvsig/crs/repository/Iau2000RepositoryGT.java
20 20
			CoordinateReferenceSystem crs = CRS.decode("IAU2000:"+code);
21 21
			crsGT = new CrsGT(crs);
22 22
		} catch (NoSuchAuthorityCodeException e) {
23
		    LOG.error("Impossible to get the CRS", e);
23
		    LOG.info("Impossible to get the CRS", e);
24 24
			return null;			
25 25
		} catch (FactoryException e) {
26
		    LOG.error("Impossible to get the CRS", e);
26
		    LOG.info("Impossible to get the CRS", e);
27 27
			return null;
28 28
		}
29 29
		return crsGT;
org.gvsig.jcrs/trunk/libJCRS/src/org/gvsig/crs/repository/EsriRepositoryGT.java
20 20
			CoordinateReferenceSystem crs = CRS.decode("ESRI:"+code);
21 21
			crsGT = new CrsGT(crs);
22 22
		} catch (NoSuchAuthorityCodeException e) {
23
		    LOG.error("Impossible to get the CRS", e);
23
		    LOG.info("Impossible to get the CRS", e);
24 24
			return null;			
25 25
		} catch (FactoryException e) {
26
		    LOG.error("Impossible to get the CRS", e);
26
		    LOG.info("Impossible to get the CRS", e);
27 27
			return null;
28 28
		}
29 29
		return crsGT;
org.gvsig.jcrs/trunk/libJCRS/src/org/gvsig/crs/repository/EpsgRepository.java
112 112
			crs_kind = result.getString("coord_ref_sys_kind");
113 113
			datum_code = result.getInt("datum_code");
114 114
		} catch (SQLException e1) {
115
		    LOG.error("Error executing the SQL", e1);
115
		    LOG.info("Error executing the SQL", e1);
116
		    return null;
116 117
		}
117 118
		
118 119
		if (datum_code != 0){
......
141 142
		try {
142 143
			crs = new Crs(Integer.parseInt(code),wkt.getWKT());
143 144
		} catch (CrsException e) {
144
		    LOG.error("Impossible to parse the CRS", e);
145
		    LOG.info("Impossible to parse the CRS", e);
146
		    return null;
145 147
		}
146 148
		return crs;
147 149
	}
org.gvsig.jcrs/trunk/libJCRS/src/org/gvsig/crs/repository/NoAuthRepository.java
89 89
				return null;	
90 90
			cadWKT = result.getString("crs_wkt");			
91 91
		} catch (SQLException e1) {
92
		    LOG.error("Error executing the SQL", e1);
92
		    LOG.info("Error executing the SQL", e1);
93
		    return null;
93 94
		}		
94 95
		cadWKT = cadWKT.substring(0, cadWKT.length()-1)
95 96
		    + ", AUTHORITY[\"CRS\","+ Integer.parseInt(code)+"]]";
......
97 98
		try {
98 99
			crs = new Crs(Integer.parseInt(code),cadWKT);
99 100
		} catch (CrsException e) {
100
		    LOG.error("Impossible to parse the CRS", e);
101
		    LOG.info("Impossible to parse the CRS", e);
101 102
		}
102 103
		
103 104
		return crs;
org.gvsig.jcrs/trunk/libJCRS/src/org/gvsig/crs/repository/Iau2000Repository.java
89 89
		try {
90 90
			connection.shutdown();
91 91
		} catch (SQLException e) {
92
		    LOG.error("Error executing the SQL", e);
92
		    LOG.info("Error while shutting down the connection", e);
93 93
		}
94 94
		try {
95 95
			if (!result.next())
96 96
				return null;			
97 97
			cadWKT = result.getString("iau_wkt");			
98 98
		} catch (SQLException e1) {
99
		    LOG.error("Error executing the SQL", e1);
99
		    LOG.info("Error executing the SQL", e1);
100
		    return null;
100 101
		}		
101 102
		cadWKT = cadWKT.substring(0, cadWKT.length()-1) + ", AUTHORITY[\"IAU2000\","+ Integer.parseInt(code)+"]]";
102 103
		if (cadWKT.charAt(0) == 'P'){
......
107 108
		try {
108 109
			crs = new Crs(Integer.parseInt(code),cadWKT);
109 110
		} catch (CrsException e) {
110
		    LOG.error("Impossible to parse the CRS", e);
111
		    LOG.info("Impossible to parse the CRS", e);
111 112
		}
112 113
		
113 114
		return crs;
org.gvsig.jcrs/trunk/libJCRS/src/org/gvsig/crs/repository/EsriRepository.java
92 92
				return null;	
93 93
			cadWKT = result.getString("esri_wkt");			
94 94
		} catch (SQLException e1) {
95
		    LOG.error("Error executing the SQL", e1);
95
		    LOG.info("Error executing the SQL", e1);
96
		    return null;
96 97
		}		
97 98
		cadWKT = cadWKT.substring(0, cadWKT.length()-1) + ", AUTHORITY[\"ESRI\","+ Integer.parseInt(code)+"]]";
98 99
		if (cadWKT.charAt(0) == 'P'){
......
103 104
		try {
104 105
			crs = new Crs(Integer.parseInt(code),cadWKT);
105 106
		} catch (CrsException e) {
106
		    LOG.error("Impossible to parse the CRS", e);
107
		    LOG.info("Impossible to parse the CRS", e);
108
		    return null;
107 109
		}
108 110
		
109 111
		return crs;
org.gvsig.jcrs/trunk/libJCRS/src/org/gvsig/crs/repository/EpsgRepositoryGT.java
68 68
			CoordinateReferenceSystem crs = CRS.decode("EPSG:"+code);
69 69
			crsGT = new CrsGT(crs);
70 70
		} catch (NoSuchAuthorityCodeException e) {
71
			LOG.error("Impossible to get the CRS", e);
71
			LOG.info("CRS not found in GT repository: " + code);
72 72
			return null;			
73 73
		} catch (FactoryException e) {
74
		    LOG.error("Impossible to get the CRS", e);
74
            LOG.info("CRS not found in GT repository: " + code);
75 75
			return null;
76 76
		}
77 77
		return crsGT;
org.gvsig.jcrs/trunk/libJCRS/src/org/gvsig/crs/repository/UsrRepository.java
38 38
		try {
39 39
			connection.shutdown();
40 40
		} catch (SQLException e) {
41
		    LOG.error("Error executing the SQL", e);
41
		    LOG.info("Error executing the SQL", e);
42
		    return null;
42 43
		}
43 44
		try {
44 45
			if (!result.next())
45 46
				return null;		
46 47
			cadWKT = result.getString("usr_wkt");			
47 48
		} catch (SQLException e1) {
48
			e1.printStackTrace();
49
		    LOG.info("Impossible to execute the SQL", e1);
50
		    return null;
49 51
		}		
50 52
		cadWKT = cadWKT.substring(0, cadWKT.length()-1) + ", AUTHORITY[\"USR\","+ Integer.parseInt(code)+"]]";
51 53
				
52 54
		try {
53 55
			crs = new Crs(Integer.parseInt(code),cadWKT);
54 56
		} catch (CrsException e) {
55
		    LOG.error("Impossible to parse the CRS", e);
57
		    LOG.info("Impossible to parse the CRS", e);
56 58
		}
57 59
		
58 60
		return crs;		

Also available in: Unified diff