Revision 229
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/es/idr/teledeteccion/connection/EpsgConnection.java | ||
---|---|---|
16 | 16 |
* along with this program; if not, write to the Free Software |
17 | 17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
18 | 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 | 19 |
*/ |
40 |
|
|
41 | 20 |
package es.idr.teledeteccion.connection; |
42 | 21 |
|
43 | 22 |
import java.sql.Connection; |
... | ... | |
56 | 35 |
* Clase para la conexi?n con la base de datos de hsqldb. |
57 | 36 |
* Establece el driver necesario, as? como la cadena de |
58 | 37 |
* conexi?n a la base de datos de la EPSG y la IAU2000 |
59 |
*
|
|
38 |
* |
|
60 | 39 |
* @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com) |
61 | 40 |
* |
62 | 41 |
*/ |
63 |
|
|
64 | 42 |
public class EpsgConnection extends jdbcDataSource { |
65 | 43 |
|
66 |
private static final Logger logger = LoggerFactory.getLogger(EpsgConnection.class); |
|
67 |
Connection connect; |
|
44 |
private static final Logger logger = LoggerFactory.getLogger(EpsgConnection.class); |
|
45 |
|
|
46 |
Connection connect = null; |
|
47 |
String connectionType = null; |
|
68 | 48 |
|
69 |
public EpsgConnection() { |
|
70 |
/* try { |
|
71 |
Class.forName("org.hsqldb.jdbcDriver"); |
|
72 |
} catch (ClassNotFoundException e) { |
|
73 |
logger.error("Can't create EpsgConnection",e); |
|
74 |
}*/ |
|
75 |
} |
|
76 |
|
|
77 |
public void setConnectionEPSG() { |
|
78 |
HSQLDataSource ds = new HSQLDataSource(); |
|
79 |
|
|
80 |
try { |
|
81 |
connect = ds.getConnection(); |
|
82 |
} catch (SQLException e) { |
|
83 |
logger.error("Cant get conection from HSQLDataSource.", e); |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Establece la conexi?n con la base de datos de la IAU2000 |
|
89 |
* |
|
90 |
*/ |
|
91 |
public void setConnectionIAU2000() { |
|
92 |
String db = "jdbc:hsqldb:file:" + CrsFactory.getDataBaseFolder().getAbsolutePath() + "/iau2000"; |
|
93 |
setDatabase(db); |
|
94 |
setUser("sa"); |
|
95 |
try { |
|
96 |
connect = super.getConnection(); |
|
97 |
} catch (SQLException e) { |
|
98 |
logger.error("Can't get conection from database '"+db+"'.", e); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Establece la conexi?n con la base de datos de ESRI |
|
104 |
* |
|
105 |
*/ |
|
106 |
public void setConnectionEsri() { |
|
107 |
String db = "jdbc:hsqldb:file:" + CrsFactory.getDataBaseFolder().getAbsolutePath() + "/esri"; |
|
108 |
setDatabase(db); |
|
109 |
setUser("sa"); |
|
110 |
try { |
|
111 |
connect = super.getConnection(); |
|
112 |
} catch (SQLException e) { |
|
113 |
logger.error("Can't get conection from database '"+db+"'.",e); |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
|
|
118 |
/** |
|
49 |
public EpsgConnection() { |
|
50 |
/* try { |
|
51 |
Class.forName("org.hsqldb.jdbcDriver"); |
|
52 |
} catch (ClassNotFoundException e) { |
|
53 |
logger.error("Can't create EpsgConnection",e); |
|
54 |
}*/ |
|
55 |
} |
|
56 |
|
|
57 |
private void setConnection(Connection connection, String type) { |
|
58 |
this.connect = connection; |
|
59 |
this.connectionType = type; |
|
60 |
logger.debug("Created connection to '"+connectionType+"'."); |
|
61 |
} |
|
62 |
|
|
63 |
public void setConnectionEPSG() { |
|
64 |
HSQLDataSource ds = new HSQLDataSource(); |
|
65 |
|
|
66 |
try { |
|
67 |
setConnection(ds.getConnection(), "EPSG"); |
|
68 |
} catch (SQLException e) { |
|
69 |
logger.warn("Cant get conection from HSQLDataSource.", e); |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Establece la conexi?n con la base de datos de la IAU2000 |
|
75 |
* |
|
76 |
*/ |
|
77 |
public void setConnectionIAU2000() { |
|
78 |
String db = "jdbc:hsqldb:file:" + CrsFactory.getDataBaseFolder().getAbsolutePath() + "/iau2000"; |
|
79 |
setDatabase(db); |
|
80 |
setUser("sa"); |
|
81 |
try { |
|
82 |
setConnection(super.getConnection(),"IAU2000"); |
|
83 |
} catch (SQLException e) { |
|
84 |
logger.warn("Can't get conection from database '" + db + "'.", e); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Establece la conexi?n con la base de datos de ESRI |
|
90 |
* |
|
91 |
*/ |
|
92 |
public void setConnectionEsri() { |
|
93 |
String db = "jdbc:hsqldb:file:" + CrsFactory.getDataBaseFolder().getAbsolutePath() + "/esri"; |
|
94 |
setDatabase(db); |
|
95 |
setUser("sa"); |
|
96 |
try { |
|
97 |
setConnection(super.getConnection(),"Esri"); |
|
98 |
} catch (SQLException e) { |
|
99 |
logger.warn("Can't get conection from database '" + db + "'.", e); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
119 | 104 |
* Sets connection for CRS:* coordinate reference systems |
120 | 105 |
* such as CRS:84 |
121 | 106 |
* |
122 | 107 |
*/ |
123 | 108 |
public void setConnectionNoAuth() { |
124 |
String db = "jdbc:hsqldb:file:" + CrsFactory.getDataBaseFolder().getAbsolutePath() + "/noauth";
|
|
109 |
String db = "jdbc:hsqldb:file:" + CrsFactory.getDataBaseFolder().getAbsolutePath() + "/noauth";
|
|
125 | 110 |
setDatabase(db); |
126 | 111 |
setUser("sa"); |
127 | 112 |
try { |
128 |
connect = super.getConnection();
|
|
113 |
setConnection(super.getConnection(),"NoAuth");
|
|
129 | 114 |
} catch (SQLException e) { |
130 |
logger.error("Can't get conection from database '"+db+"'.",e);
|
|
115 |
logger.warn("Can't get conection from database '" + db + "'.", e);
|
|
131 | 116 |
} |
132 | 117 |
} |
133 |
|
|
134 |
/** |
|
135 |
* Establece la conexi?n con la base de datos de USR |
|
136 |
* |
|
137 |
*/ |
|
138 |
public void setConnectionUsr() { |
|
139 |
String db = "jdbc:hsqldb:file:" + CrsFactory.getDataBaseFolder().getAbsolutePath() + "/usr"; |
|
140 |
setDatabase(db); |
|
141 |
setUser("sa"); |
|
142 |
try { |
|
143 |
connect = super.getConnection(); |
|
144 |
} catch (SQLException e) { |
|
145 |
logger.error("Can't get conection from database '"+db+"'.",e); |
|
146 |
} |
|
147 |
} |
|
148 |
|
|
149 |
public Connection getConnection(){ |
|
150 |
return connect; |
|
151 |
} |
|
152 |
|
|
153 |
public void shutdown() throws SQLException { |
|
154 | 118 |
|
119 |
/** |
|
120 |
* Establece la conexi?n con la base de datos de USR |
|
121 |
* |
|
122 |
*/ |
|
123 |
public void setConnectionUsr() { |
|
124 |
String db = "jdbc:hsqldb:file:" + CrsFactory.getDataBaseFolder().getAbsolutePath() + "/usr"; |
|
125 |
setDatabase(db); |
|
126 |
setUser("sa"); |
|
127 |
try { |
|
128 |
setConnection(super.getConnection(),"Usr"); |
|
129 |
} catch (SQLException e) { |
|
130 |
logger.warn("Can't get conection from database '" + db + "'.", e); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
public Connection getConnection() { |
|
135 |
return connect; |
|
136 |
} |
|
137 |
|
|
138 |
public void shutdown() throws SQLException { |
|
139 |
|
|
155 | 140 |
Statement st = connect.createStatement(); |
156 | 141 |
|
157 |
// db writes out to files and performs clean shuts down |
|
142 |
// db writes out to files and performs clean shuts down
|
|
158 | 143 |
// otherwise there will be an unclean shutdown |
159 | 144 |
// when program ends |
160 | 145 |
st.execute("SHUTDOWN"); |
161 | 146 |
connect.close(); // if there are no other open connection |
147 |
logger.debug("Shutdown connection to '"+connectionType+"' database."); |
|
162 | 148 |
} |
163 |
|
|
164 |
public synchronized void update(String expression) throws SQLException { |
|
165 | 149 |
|
166 |
Statement st = null;
|
|
150 |
public synchronized void update(String expression) throws SQLException {
|
|
167 | 151 |
|
168 |
st = connect.createStatement(); // statements |
|
169 |
|
|
170 |
int i = st.executeUpdate(expression); // run the query |
|
171 |
|
|
172 |
if (i == -1) { |
|
173 |
System.out.println("db error : " + expression); |
|
152 |
Statement st = null; |
|
153 |
st = connect.createStatement(); |
|
154 |
int i = st.executeUpdate(expression); |
|
155 |
if ( i == -1 ) { |
|
156 |
logger.warn("db("+connectionType+") error in statement: " + expression); |
|
174 | 157 |
} |
175 |
|
|
176 | 158 |
st.close(); |
177 | 159 |
} |
178 |
/* |
|
179 |
*//** |
|
180 |
* Establece la conexi?n con la base de datos de la EPSG |
|
181 |
* |
|
182 |
*//* |
|
183 |
public void setConnectionEPSG() { |
|
184 |
try { |
|
185 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs.extension/db_epsg", "sa", ""); |
|
186 |
} catch (SQLException e1) { |
|
187 |
logger.... |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
*//** |
|
192 |
* Establece la conexi?n con la base de datos de la IAU2000 |
|
193 |
* |
|
194 |
*//* |
|
195 |
public void setConnectionIAU2000() { |
|
196 |
try { |
|
197 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs.extension/db_iau2000", "sa", ""); |
|
198 |
} catch (SQLException e1) { |
|
199 |
logger.... |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
*//** |
|
204 |
* Establece la conexi?n con la base de datos de ESRI |
|
205 |
* |
|
206 |
*//* |
|
207 |
public void setConnectionEsri() { |
|
208 |
try { |
|
209 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:/home/jlgomez/gvSIGF2/_fwAndami/gvSIG/extensiones/org.gvsig.crs.extension/db_esri", "sa", ""); |
|
210 |
} catch (SQLException e1) { |
|
211 |
logger.... |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
*//** |
|
216 |
* Establece la conexi?n con la base de datos de USR |
|
217 |
* |
|
218 |
*//* |
|
219 |
public void setConnectionUsr() { |
|
220 |
try { |
|
221 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs.extension/db_usr", "sa", ""); |
|
222 |
} catch (SQLException e1) { |
|
223 |
logger.... |
|
224 |
} |
|
225 |
} |
|
226 |
|
|
227 |
public Connection getConnection(){ |
|
228 |
return connect; |
|
229 |
} |
|
230 |
|
|
231 |
public void shutdown() throws SQLException { |
|
232 |
|
|
233 |
Statement st = connect.createStatement(); |
|
234 |
|
|
235 |
// db writes out to files and performs clean shuts down |
|
236 |
// otherwise there will be an unclean shutdown |
|
237 |
// when program ends |
|
238 |
st.execute("SHUTDOWN"); |
|
239 |
connect.close(); // if there are no other open connection |
|
240 |
}*/ |
|
241 |
|
|
242 |
/** |
|
243 |
* Returns {@code true} if the database contains data. This method returns {@code false} |
|
244 |
* if an empty EPSG database has been automatically created by HSQL and not yet populated. |
|
245 |
*/ |
|
246 |
private static boolean dataExists(final Connection connection) throws SQLException { |
|
247 |
final ResultSet tables = connection.getMetaData().getTables( |
|
248 |
null, null, "IAU2000_%", new String[] {"TABLE"}); |
|
249 |
final boolean exists = tables.next(); |
|
250 |
tables.close(); |
|
251 |
return exists; |
|
252 |
} |
|
253 | 160 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/CrsFactory.java | ||
---|---|---|
37 | 37 |
* |
38 | 38 |
* +34 967 599 200 |
39 | 39 |
*/ |
40 |
|
|
41 | 40 |
package org.gvsig.crs; |
42 | 41 |
|
43 | 42 |
import java.io.File; |
... | ... | |
56 | 55 |
import org.gvsig.crs.repository.NoAuthRepositoryGT; |
57 | 56 |
import org.gvsig.crs.repository.UsrRepository; |
58 | 57 |
import org.gvsig.crs.repository.UsrRepositoryGT; |
58 |
import org.gvsig.tools.dispose.Disposable; |
|
59 | 59 |
import org.slf4j.Logger; |
60 | 60 |
import org.slf4j.LoggerFactory; |
61 | 61 |
|
... | ... | |
66 | 66 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
67 | 67 |
* |
68 | 68 |
*/ |
69 |
public class CrsFactory implements ICRSFactory { |
|
69 | 70 |
|
70 |
public class CrsFactory implements ICRSFactory { |
|
71 |
|
|
72 | 71 |
private static Logger logger = LoggerFactory.getLogger(CrsFactory.class); |
73 |
static TreeMap data = new TreeMap();
|
|
72 |
static TreeMap data = new TreeMap();
|
|
74 | 73 |
|
75 |
private static File databaseFolder = null; |
|
76 |
private static File projLibFolder = null; |
|
77 |
|
|
78 |
public CrsFactory() { |
|
79 |
} |
|
80 |
/** |
|
81 |
* Obtiene un CRS a partir de su c?digo (p.e. EPSG:23030). |
|
82 |
* @param code |
|
83 |
* @return |
|
84 |
* @throws CrsException |
|
85 |
*/ |
|
86 |
public ICrs getCRS(String code) throws CrsException { |
|
74 |
private static File databaseFolder = null; |
|
75 |
private static File projLibFolder = null; |
|
87 | 76 |
|
88 |
/*if (data.containsKey(code))
|
|
89 |
return (ICrs) data.get(code);*/
|
|
77 |
public CrsFactory() {
|
|
78 |
}
|
|
90 | 79 |
|
91 |
String repoId = ""; |
|
92 |
String crsCode = ""; |
|
93 |
ICrs crs = null; |
|
94 |
ICrsRepository repo = null; |
|
80 |
/** |
|
81 |
* Obtiene un CRS a partir de su c?digo (p.e. EPSG:23030). |
|
82 |
* |
|
83 |
* @param code |
|
84 |
* @return |
|
85 |
* @throws CrsException |
|
86 |
*/ |
|
87 |
public ICrs getCRS(String code) throws CrsException { |
|
95 | 88 |
|
96 |
if(code.indexOf(":", code.indexOf(":")+1)<0){ |
|
97 |
repoId = code.substring(0, code.indexOf(":")); |
|
98 |
crsCode = code.substring(code.indexOf(":")+1); |
|
89 |
/*if (data.containsKey(code)) |
|
90 |
return (ICrs) data.get(code);*/ |
|
91 |
String repoId = ""; |
|
92 |
String crsCode = ""; |
|
93 |
ICrs crs = null; |
|
94 |
ICrsRepository repo = null; |
|
99 | 95 |
|
100 |
if(repoId.equals("EPSG")){ |
|
101 |
repo = new EpsgRepositoryGT(); |
|
102 |
crs = repo.getCrs(crsCode); |
|
103 |
if (crs==null) { |
|
104 |
repo = new EpsgRepository(); |
|
105 |
crs = repo.getCrs(crsCode); |
|
106 |
} |
|
107 |
}else if (repoId.equals("IAU2000")){ |
|
108 |
repo = new Iau2000RepositoryGT(); |
|
109 |
crs = repo.getCrs(crsCode); |
|
110 |
if (crs==null) { |
|
111 |
repo = new Iau2000Repository(); |
|
112 |
crs = repo.getCrs(crsCode); |
|
113 |
} |
|
114 |
}else if (repoId.equals("CRS")){ |
|
115 |
repo = new NoAuthRepositoryGT(); |
|
116 |
crs = repo.getCrs(crsCode); |
|
117 |
if (crs==null) { |
|
118 |
repo = new NoAuthRepository(); |
|
96 |
try { |
|
97 |
if ( code.indexOf(":", code.indexOf(":") + 1) < 0 ) { |
|
98 |
repoId = code.substring(0, code.indexOf(":")); |
|
99 |
crsCode = code.substring(code.indexOf(":") + 1); |
|
100 |
|
|
101 |
if ( repoId.equals("EPSG") ) { |
|
102 |
repo = new EpsgRepositoryGT(); |
|
119 | 103 |
crs = repo.getCrs(crsCode); |
104 |
if ( crs == null ) { |
|
105 |
repo = new EpsgRepository(); |
|
106 |
crs = repo.getCrs(crsCode); |
|
107 |
} |
|
108 |
} else if ( repoId.equals("IAU2000") ) { |
|
109 |
repo = new Iau2000RepositoryGT(); |
|
110 |
crs = repo.getCrs(crsCode); |
|
111 |
if ( crs == null ) { |
|
112 |
repo = new Iau2000Repository(); |
|
113 |
crs = repo.getCrs(crsCode); |
|
114 |
} |
|
115 |
} else if ( repoId.equals("CRS") ) { |
|
116 |
repo = new NoAuthRepositoryGT(); |
|
117 |
crs = repo.getCrs(crsCode); |
|
118 |
if ( crs == null ) { |
|
119 |
repo = new NoAuthRepository(); |
|
120 |
crs = repo.getCrs(crsCode); |
|
121 |
} |
|
122 |
} else if ( repoId.equals("ESRI") ) { |
|
123 |
repo = new EsriRepositoryGT(); |
|
124 |
crs = repo.getCrs(crsCode); |
|
125 |
if ( crs == null ) { |
|
126 |
repo = new EsriRepository(); |
|
127 |
crs = repo.getCrs(crsCode); |
|
128 |
} |
|
129 |
} else if ( repoId.equals("USR") ) { |
|
130 |
repo = new UsrRepositoryGT(); |
|
131 |
crs = repo.getCrs(crsCode); |
|
132 |
if ( crs == null ) { |
|
133 |
repo = new UsrRepository(); |
|
134 |
crs = repo.getCrs(crsCode); |
|
135 |
} |
|
120 | 136 |
} |
121 |
}else if (repoId.equals("ESRI")){ |
|
122 |
repo = new EsriRepositoryGT(); |
|
123 |
crs = repo.getCrs(crsCode); |
|
124 |
if (crs==null) { |
|
125 |
repo = new EsriRepository(); |
|
126 |
crs = repo.getCrs(crsCode); |
|
127 |
} |
|
128 |
}else if (repoId.equals("USR")){ |
|
129 |
repo = new UsrRepositoryGT(); |
|
130 |
crs = repo.getCrs(crsCode); |
|
131 |
if (crs==null) { |
|
132 |
repo = new UsrRepository(); |
|
133 |
crs = repo.getCrs(crsCode); |
|
134 |
} |
|
135 |
} |
|
136 |
} |
|
137 |
else{ |
|
138 |
String sourceParams = null; |
|
139 |
String targetParams = null; |
|
137 |
} else { |
|
138 |
String sourceParams = null; |
|
139 |
String targetParams = null; |
|
140 | 140 |
|
141 |
crsCode = code.substring(0,code.indexOf(":",code.indexOf(":")+1));
|
|
142 |
if (code.indexOf("@")==-1){
|
|
143 |
crsCode=crsCode.substring(0, crsCode.indexOf(","));
|
|
144 |
}else{
|
|
145 |
sourceParams = code.substring(code.indexOf("@")+1,code.lastIndexOf("@"));
|
|
146 |
targetParams = code.substring(code.lastIndexOf("@")+1);
|
|
141 |
crsCode = code.substring(0, code.indexOf(":", code.indexOf(":") + 1));
|
|
142 |
if ( code.indexOf("@") == -1 ) {
|
|
143 |
crsCode = crsCode.substring(0, crsCode.indexOf(","));
|
|
144 |
} else {
|
|
145 |
sourceParams = code.substring(code.indexOf("@") + 1, code.lastIndexOf("@"));
|
|
146 |
targetParams = code.substring(code.lastIndexOf("@") + 1);
|
|
147 | 147 |
|
148 |
if (sourceParams.equals(""))
|
|
149 |
sourceParams = null;
|
|
150 |
else if (targetParams.equals("1")){ // Compativilidad con versiones de libJCrs sin soporte para transf. compuestas.
|
|
151 |
targetParams = sourceParams;
|
|
152 |
sourceParams = "";
|
|
153 |
}
|
|
154 |
if (targetParams.equals("")||targetParams.equals("0")) // Compativilidad con versiones de libJCrs sin soporte para transf. compuestas.
|
|
155 |
targetParams = null;
|
|
156 |
}
|
|
157 |
crs = getCRS(crsCode);
|
|
158 |
if (crs != null) {
|
|
159 |
crs.setTransformationParams(sourceParams,targetParams);
|
|
160 |
}
|
|
161 |
|
|
162 |
}
|
|
148 |
if ( sourceParams.equals("") ) {
|
|
149 |
sourceParams = null;
|
|
150 |
} else if ( targetParams.equals("1") ) { // Compativilidad con versiones de libJCrs sin soporte para transf. compuestas.
|
|
151 |
targetParams = sourceParams;
|
|
152 |
sourceParams = "";
|
|
153 |
}
|
|
154 |
if ( targetParams.equals("") || targetParams.equals("0") ) // Compativilidad con versiones de libJCrs sin soporte para transf. compuestas.
|
|
155 |
{
|
|
156 |
targetParams = null;
|
|
157 |
}
|
|
158 |
}
|
|
159 |
crs = getCRS(crsCode);
|
|
160 |
if ( crs != null ) {
|
|
161 |
crs.setTransformationParams(sourceParams, targetParams); |
|
162 |
}
|
|
163 | 163 |
|
164 |
/*code = crs.getAbrev();
|
|
164 |
}
|
|
165 | 165 |
|
166 |
data.put(code, crs);*/
|
|
166 |
/*code = crs.getAbrev();
|
|
167 | 167 |
|
168 |
if (crs == null) { |
|
169 |
logger.warn("Did not find CRS " + code + " in available repositories."); |
|
170 |
} else { |
|
171 |
logger.info("Found CRS " + code + |
|
172 |
(repo == null ? "" : (" (" + repo.getClass().getSimpleName() + ")"))); |
|
173 |
} |
|
174 |
return crs; |
|
168 |
data.put(code, crs);*/ |
|
169 |
if ( crs == null ) { |
|
170 |
logger.debug("Can't find CRS '" + code + "' in available repositories."); |
|
171 |
} else { |
|
172 |
logger.debug("Found CRS '" + code + "' in repository '" + |
|
173 |
(repo == null ? "unknow" : (repo.getClass().getSimpleName())) + "'."); |
|
174 |
} |
|
175 |
return crs; |
|
176 |
} finally { |
|
177 |
if( repo instanceof Disposable ) { |
|
178 |
((Disposable)repo).dispose(); |
|
179 |
} |
|
180 |
} |
|
181 |
/*if (data.containsKey(code)) |
|
182 |
return (Crs) data.get(code); |
|
175 | 183 |
|
176 |
/*if (data.containsKey(code)) |
|
177 |
return (Crs) data.get(code); |
|
184 |
Crs crs = new Crs(code); |
|
178 | 185 |
|
179 |
Crs crs = new Crs(code); |
|
186 |
// LWS Esta l?nea sobra, cuando el cuadro de di?logo est? |
|
187 |
// mejor hecho. |
|
188 |
code = crs.getAbrev(); |
|
180 | 189 |
|
181 |
// LWS Esta l?nea sobra, cuando el cuadro de di?logo est? |
|
182 |
// mejor hecho. |
|
183 |
code = crs.getAbrev(); |
|
190 |
data.put(code, crs); |
|
184 | 191 |
|
185 |
data.put(code, crs); |
|
192 |
return crs;*/ |
|
193 |
} |
|
186 | 194 |
|
187 |
return crs;*/ |
|
188 |
} |
|
195 |
/** |
|
196 |
* |
|
197 |
* @param epsg_code |
|
198 |
* @param code |
|
199 |
* @return |
|
200 |
* @throws CrsException |
|
201 |
*/ |
|
202 |
public ICrs getCRS(int epsg_code, String code) throws CrsException { |
|
203 |
/*if (data.containsKey(code)) |
|
204 |
return (Crs) data.get(code);*/ |
|
189 | 205 |
|
190 |
/** |
|
191 |
* |
|
192 |
* @param epsg_code |
|
193 |
* @param code |
|
194 |
* @return |
|
195 |
* @throws CrsException |
|
196 |
*/ |
|
197 |
public ICrs getCRS(int epsg_code, String code) throws CrsException { |
|
198 |
/*if (data.containsKey(code)) |
|
199 |
return (Crs) data.get(code);*/ |
|
206 |
Crs crs = new Crs(epsg_code, code); |
|
200 | 207 |
|
201 |
Crs crs = new Crs(epsg_code, code); |
|
202 |
|
|
203 |
// LWS Esta l?nea sobra, cuando el cuadro de di?logo est? |
|
204 |
// mejor hecho. |
|
208 |
// LWS Esta l?nea sobra, cuando el cuadro de di?logo est? |
|
209 |
// mejor hecho. |
|
205 | 210 |
/*code = crs.getAbrev(); |
206 | 211 |
|
207 |
data.put(code, crs);*/ |
|
212 |
data.put(code, crs);*/ |
|
213 |
return crs; |
|
214 |
} |
|
208 | 215 |
|
209 |
return crs; |
|
210 |
} |
|
216 |
/** |
|
217 |
* |
|
218 |
* @param epsg_code |
|
219 |
* @param code |
|
220 |
* @param params |
|
221 |
* @return |
|
222 |
* @throws CrsException |
|
223 |
*/ |
|
224 |
public ICrs getCRS(int epsg_code, String code, String params) throws CrsException { |
|
225 |
/*if (data.containsKey(code)) |
|
226 |
return (Crs) data.get(code);*/ |
|
211 | 227 |
|
212 |
/** |
|
213 |
* |
|
214 |
* @param epsg_code |
|
215 |
* @param code |
|
216 |
* @param params |
|
217 |
* @return |
|
218 |
* @throws CrsException |
|
219 |
*/ |
|
220 |
public ICrs getCRS(int epsg_code, String code, String params) throws CrsException { |
|
221 |
/*if (data.containsKey(code)) |
|
222 |
return (Crs) data.get(code);*/ |
|
228 |
Crs crs = new Crs(epsg_code, code, params); |
|
223 | 229 |
|
224 |
Crs crs = new Crs(epsg_code, code,params); |
|
225 |
|
|
226 |
// LWS Esta l?nea sobra, cuando el cuadro de di?logo est? |
|
227 |
// mejor hecho. |
|
230 |
// LWS Esta l?nea sobra, cuando el cuadro de di?logo est? |
|
231 |
// mejor hecho. |
|
228 | 232 |
/*code = crs.getAbrev(); |
229 | 233 |
|
230 |
data.put(code, crs);*/ |
|
234 |
data.put(code, crs);*/ |
|
235 |
return crs; |
|
236 |
} |
|
231 | 237 |
|
232 |
return crs; |
|
233 |
} |
|
238 |
/** |
|
239 |
* |
|
240 |
*/ |
|
241 |
public IProjection get(String name) { |
|
242 |
try { |
|
243 |
return getCRS(name); |
|
244 |
} catch (CrsException e) { |
|
245 |
logger.error("Can't cget CRS name '" + name + "'.", e); |
|
246 |
} |
|
247 |
return null; |
|
248 |
} |
|
234 | 249 |
|
235 |
/** |
|
236 |
* |
|
237 |
*/ |
|
238 |
public IProjection get(String name) { |
|
239 |
try { |
|
240 |
return getCRS(name); |
|
241 |
} catch (CrsException e) { |
|
242 |
logger.error("Can't cget CRS name '"+name+"'.",e); |
|
243 |
} |
|
244 |
return null; |
|
245 |
} |
|
250 |
/** |
|
251 |
* |
|
252 |
*/ |
|
253 |
public boolean doesRigurousTransformations() { |
|
254 |
return true; |
|
255 |
} |
|
246 | 256 |
|
247 |
/** |
|
248 |
* |
|
249 |
*/ |
|
250 |
public boolean doesRigurousTransformations() { |
|
251 |
return true; |
|
252 |
} |
|
253 |
|
|
254 |
public static File getDataBaseFolder() { |
|
255 |
return databaseFolder; |
|
256 |
} |
|
257 |
|
|
258 |
public static void setDataBaseFolder(File folder) { |
|
259 |
databaseFolder = folder; |
|
260 |
} |
|
257 |
public static File getDataBaseFolder() { |
|
258 |
return databaseFolder; |
|
259 |
} |
|
261 | 260 |
|
262 |
public static File getProjLibFolder() { |
|
263 |
return projLibFolder; |
|
264 |
} |
|
265 |
|
|
266 |
public static void setProjLibFolder(File folder) { |
|
267 |
projLibFolder = folder; |
|
268 |
} |
|
261 |
public static void setDataBaseFolder(File folder) { |
|
262 |
databaseFolder = folder; |
|
263 |
} |
|
264 |
|
|
265 |
public static File getProjLibFolder() { |
|
266 |
return projLibFolder; |
|
267 |
} |
|
268 |
|
|
269 |
public static void setProjLibFolder(File folder) { |
|
270 |
projLibFolder = folder; |
|
271 |
} |
|
269 | 272 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/EsriRepository.java | ||
---|---|---|
52 | 52 |
import org.gvsig.crs.CrsException; |
53 | 53 |
import org.gvsig.crs.ICrs; |
54 | 54 |
import org.gvsig.crs.ogr.Esri2wkt; |
55 |
import org.gvsig.tools.dispose.Disposable; |
|
55 | 56 |
|
56 | 57 |
|
57 | 58 |
/** |
... | ... | |
61 | 62 |
* |
62 | 63 |
*/ |
63 | 64 |
|
64 |
public class EsriRepository implements ICrsRepository { |
|
65 |
public class EsriRepository implements ICrsRepository, Disposable {
|
|
65 | 66 |
private static final Logger logger = |
66 | 67 |
LoggerFactory.getLogger(EsriRepository.class); |
67 | 68 |
|
... | ... | |
112 | 113 |
|
113 | 114 |
} |
114 | 115 |
|
116 |
|
|
117 |
public void dispose() { |
|
118 |
try { |
|
119 |
this.connection.shutdown(); |
|
120 |
this.connection = null; |
|
121 |
} catch (SQLException ex) { |
|
122 |
logger.warn("Con't shutdown the connection.",ex); |
|
123 |
} |
|
124 |
} |
|
115 | 125 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/UsrRepositoryGT.java | ||
---|---|---|
11 | 11 |
import org.gvsig.crs.ICrs; |
12 | 12 |
|
13 | 13 |
public class UsrRepositoryGT implements ICrsRepository { |
14 |
private static final Logger LOG = |
|
15 |
LoggerFactory.getLogger(UsrRepositoryGT.class); |
|
16 |
|
|
17 |
public ICrs getCrs(String code) { |
|
18 |
CrsGT crsGT = null; |
|
19 |
try { |
|
20 |
CoordinateReferenceSystem crs = CRS.decode("USR:"+code); |
|
21 |
crsGT = new CrsGT(crs); |
|
22 |
} catch (NoSuchAuthorityCodeException e) { |
|
23 |
LOG.info("Impossible to get the CRS from Geotools."); |
|
24 |
return null; |
|
25 |
} catch (FactoryException e) { |
|
26 |
LOG.info("Impossible to get the CRS from Geotools."); |
|
27 |
return null; |
|
28 |
} |
|
29 |
return crsGT; |
|
30 |
} |
|
31 | 14 |
|
15 |
private static final Logger LOG |
|
16 |
= LoggerFactory.getLogger(UsrRepositoryGT.class); |
|
17 |
|
|
18 |
public ICrs getCrs(String code) { |
|
19 |
CrsGT crsGT = null; |
|
20 |
try { |
|
21 |
CoordinateReferenceSystem crs = CRS.decode("USR:" + code); |
|
22 |
crsGT = new CrsGT(crs); |
|
23 |
} catch (NoSuchAuthorityCodeException e) { |
|
24 |
LOG.debug("Can't get the CRS '"+code+"' authority 'USR' in GT repository. No such authority code"); |
|
25 |
return null; |
|
26 |
} catch (FactoryException e) { |
|
27 |
LOG.debug("Can't get the CRS '"+code+"' authority 'USR' in GT repository", e); |
|
28 |
return null; |
|
29 |
} |
|
30 |
return crsGT; |
|
31 |
} |
|
32 |
|
|
32 | 33 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/EpsgRepositoryGT.java | ||
---|---|---|
37 | 37 |
* |
38 | 38 |
* +34 967 599 200 |
39 | 39 |
*/ |
40 |
|
|
41 | 40 |
package org.gvsig.crs.repository; |
42 | 41 |
|
43 |
|
|
44 | 42 |
import org.geotools.referencing.CRS; |
45 | 43 |
import org.opengis.referencing.FactoryException; |
46 | 44 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
... | ... | |
53 | 51 |
|
54 | 52 |
/** |
55 | 53 |
* Repositorio de CRSs de EPSG basado en Geotools. |
56 |
*
|
|
54 |
* |
|
57 | 55 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
58 | 56 |
* |
59 | 57 |
*/ |
60 |
|
|
61 | 58 |
public class EpsgRepositoryGT implements ICrsRepository { |
62 |
private static final Logger LOG = |
|
63 |
LoggerFactory.getLogger(EpsgRepositoryGT.class); |
|
64 |
|
|
65 |
public ICrs getCrs(String code) { |
|
66 |
CrsGT crsGT = null; |
|
67 |
try { |
|
68 |
CoordinateReferenceSystem crs = CRS.decode("EPSG:"+code); |
|
69 |
crsGT = new CrsGT(crs); |
|
70 |
} catch (NoSuchAuthorityCodeException e) { |
|
71 |
LOG.info("CRS not found in GT repository: " + code); |
|
72 |
return null; |
|
73 |
} catch (FactoryException e) { |
|
74 |
LOG.info("CRS not found in GT repository: " + code); |
|
75 |
return null; |
|
76 |
} |
|
77 |
return crsGT; |
|
78 |
} |
|
79 | 59 |
|
60 |
private static final Logger LOG |
|
61 |
= LoggerFactory.getLogger(EpsgRepositoryGT.class); |
|
62 |
|
|
63 |
public ICrs getCrs(String code) { |
|
64 |
CrsGT crsGT = null; |
|
65 |
try { |
|
66 |
CoordinateReferenceSystem crs = CRS.decode("EPSG:" + code); |
|
67 |
crsGT = new CrsGT(crs); |
|
68 |
} catch (NoSuchAuthorityCodeException e) { |
|
69 |
LOG.debug("Can't get the CRS '"+code+"', authority 'EPSG' in GT repository. No such authority code"); |
|
70 |
return null; |
|
71 |
} catch (FactoryException e) { |
|
72 |
LOG.debug("Can't get the CRS '"+code+"', authority 'EPSG' in GT repository", e); |
|
73 |
return null; |
|
74 |
} |
|
75 |
return crsGT; |
|
76 |
} |
|
77 |
|
|
80 | 78 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/NoAuthRepositoryGT.java | ||
---|---|---|
11 | 11 |
import org.gvsig.crs.ICrs; |
12 | 12 |
|
13 | 13 |
public class NoAuthRepositoryGT implements ICrsRepository { |
14 |
private static final Logger logger = |
|
15 |
LoggerFactory.getLogger(NoAuthRepositoryGT.class); |
|
16 |
|
|
17 |
public ICrs getCrs(String code) { |
|
18 |
CrsGT crsGT = null; |
|
19 |
try { |
|
20 |
CoordinateReferenceSystem crs = CRS.decode("CRS:"+code); |
|
21 |
crsGT = new CrsGT(crs); |
|
22 |
} catch (NoSuchAuthorityCodeException e) { |
|
23 |
return null; |
|
24 |
} catch (FactoryException e) { |
|
25 |
logger.info("Can't create CRS from autority 'CRS' and code '+code+'.",e); |
|
26 |
return null; |
|
27 |
} |
|
28 |
return crsGT; |
|
29 |
} |
|
30 | 14 |
|
15 |
private static final Logger logger |
|
16 |
= LoggerFactory.getLogger(NoAuthRepositoryGT.class); |
|
17 |
|
|
18 |
public ICrs getCrs(String code) { |
|
19 |
CrsGT crsGT = null; |
|
20 |
try { |
|
21 |
CoordinateReferenceSystem crs = CRS.decode("CRS:" + code); |
|
22 |
crsGT = new CrsGT(crs); |
|
23 |
} catch (NoSuchAuthorityCodeException e) { |
|
24 |
logger.debug("Can't get the CRS '"+code+"', authority 'CRS' in GT repository. No such authority code"); |
|
25 |
return null; |
|
26 |
} catch (FactoryException e) { |
|
27 |
logger.debug("Can't get the CRS '"+code+"', authority 'CRS' in GT repository", e); |
|
28 |
return null; |
|
29 |
} |
|
30 |
return crsGT; |
|
31 |
} |
|
32 |
|
|
31 | 33 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/UsrRepository.java | ||
---|---|---|
12 | 12 |
import org.gvsig.crs.Crs; |
13 | 13 |
import org.gvsig.crs.CrsException; |
14 | 14 |
import org.gvsig.crs.ICrs; |
15 |
import org.gvsig.tools.dispose.Disposable; |
|
15 | 16 |
|
16 |
public class UsrRepository implements ICrsRepository { |
|
17 |
public class UsrRepository implements ICrsRepository, Disposable {
|
|
17 | 18 |
private static final Logger LOG = |
18 | 19 |
LoggerFactory.getLogger(UsrRepository.class); |
19 | 20 |
|
... | ... | |
60 | 61 |
return crs; |
61 | 62 |
} |
62 | 63 |
|
64 |
|
|
65 |
public void dispose() { |
|
66 |
try { |
|
67 |
this.connection.shutdown(); |
|
68 |
this.connection = null; |
|
69 |
} catch (SQLException ex) { |
|
70 |
LOG.warn("Con't shutdown the connection.",ex); |
|
71 |
} |
|
72 |
} |
|
63 | 73 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/Iau2000RepositoryGT.java | ||
---|---|---|
11 | 11 |
import org.gvsig.crs.ICrs; |
12 | 12 |
|
13 | 13 |
public class Iau2000RepositoryGT implements ICrsRepository { |
14 |
private static final Logger LOG = |
|
15 |
LoggerFactory.getLogger(Iau2000RepositoryGT.class); |
|
16 |
|
|
17 |
public ICrs getCrs(String code) { |
|
18 |
CrsGT crsGT = null; |
|
19 |
try { |
|
20 |
CoordinateReferenceSystem crs = CRS.decode("IAU2000:"+code); |
|
21 |
crsGT = new CrsGT(crs); |
|
22 |
} catch (NoSuchAuthorityCodeException e) { |
|
23 |
LOG.info("Impossible to get the CRS", e); |
|
24 |
return null; |
|
25 |
} catch (FactoryException e) { |
|
26 |
LOG.info("Impossible to get the CRS", e); |
|
27 |
return null; |
|
28 |
} |
|
29 |
return crsGT; |
|
30 |
} |
|
31 | 14 |
|
15 |
private static final Logger LOG |
|
16 |
= LoggerFactory.getLogger(Iau2000RepositoryGT.class); |
|
17 |
|
|
18 |
public ICrs getCrs(String code) { |
|
19 |
CrsGT crsGT = null; |
|
20 |
try { |
|
21 |
CoordinateReferenceSystem crs = CRS.decode("IAU2000:" + code); |
|
22 |
crsGT = new CrsGT(crs); |
|
23 |
} catch (NoSuchAuthorityCodeException e) { |
|
24 |
LOG.debug("Can't get the CRS '"+code+"' authority 'IAU2000' in GT repository. No such authority code"); |
|
25 |
return null; |
|
26 |
} catch (FactoryException e) { |
|
27 |
LOG.debug("Can't get the CRS '"+code+"' authority 'IAU2000' in GT repository", e); |
|
28 |
return null; |
|
29 |
} |
|
30 |
return crsGT; |
|
31 |
} |
|
32 |
|
|
32 | 33 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/EsriRepositoryGT.java | ||
---|---|---|
11 | 11 |
import org.gvsig.crs.ICrs; |
12 | 12 |
|
13 | 13 |
public class EsriRepositoryGT implements ICrsRepository { |
14 |
private static final Logger LOG = |
|
15 |
LoggerFactory.getLogger(EsriRepositoryGT.class); |
|
16 |
|
|
17 |
public ICrs getCrs(String code) { |
|
18 |
CrsGT crsGT = null; |
|
19 |
try { |
|
20 |
CoordinateReferenceSystem crs = CRS.decode("ESRI:"+code); |
|
21 |
crsGT = new CrsGT(crs); |
|
22 |
} catch (NoSuchAuthorityCodeException e) { |
|
23 |
LOG.info("Impossible to get the CRS", e); |
|
24 |
return null; |
|
25 |
} catch (FactoryException e) { |
|
26 |
LOG.info("Impossible to get the CRS", e); |
|
27 |
return null; |
|
28 |
} |
|
29 |
return crsGT; |
|
30 |
} |
|
31 | 14 |
|
15 |
private static final Logger LOG |
|
16 |
= LoggerFactory.getLogger(EsriRepositoryGT.class); |
|
17 |
|
|
18 |
public ICrs getCrs(String code) { |
|
19 |
CrsGT crsGT = null; |
|
20 |
try { |
|
21 |
CoordinateReferenceSystem crs = CRS.decode("ESRI:" + code); |
|
22 |
crsGT = new CrsGT(crs); |
|
23 |
} catch (NoSuchAuthorityCodeException e) { |
|
24 |
LOG.debug("Can't get the CRS '"+code+"' authority 'ESRI' in GT repository. No such authority code"); |
|
25 |
return null; |
|
26 |
} catch (FactoryException e) { |
|
27 |
LOG.debug("Can't get the CRS '"+code+"' authority 'ESRI' in GT repository", e); |
|
28 |
return null; |
|
29 |
} |
|
30 |
return crsGT; |
|
31 |
} |
|
32 |
|
|
32 | 33 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/EpsgRepository.java | ||
---|---|---|
45 | 45 |
|
46 | 46 |
import es.idr.teledeteccion.connection.EpsgConnection; |
47 | 47 |
import es.idr.teledeteccion.connection.Query; |
48 |
import java.util.logging.Level; |
|
48 | 49 |
|
49 | 50 |
import org.slf4j.Logger; |
50 | 51 |
import org.slf4j.LoggerFactory; |
... | ... | |
54 | 55 |
import org.gvsig.crs.ICrs; |
55 | 56 |
import org.gvsig.crs.ogr.CrsEPSG; |
56 | 57 |
import org.gvsig.crs.ogr.Epsg2wkt; |
58 |
import org.gvsig.tools.dispose.Disposable; |
|
57 | 59 |
/** |
58 | 60 |
* Repositorio de CRSs de EPSG |
59 | 61 |
* |
60 | 62 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
61 | 63 |
* |
62 | 64 |
*/ |
63 |
public class EpsgRepository implements ICrsRepository { |
|
65 |
public class EpsgRepository implements ICrsRepository, Disposable {
|
|
64 | 66 |
private static final Logger logger = |
65 | 67 |
LoggerFactory.getLogger(EpsgRepository.class); |
66 | 68 |
|
... | ... | |
112 | 114 |
crs_kind = result.getString("coord_ref_sys_kind"); |
113 | 115 |
datum_code = result.getInt("datum_code"); |
114 | 116 |
} catch (SQLException e1) { |
115 |
logger.info("Error executing the SQL", e1);
|
|
117 |
logger.warn("Error executing the SQL", e1);
|
|
116 | 118 |
return null; |
117 | 119 |
} |
118 | 120 |
|
... | ... | |
142 | 144 |
try { |
143 | 145 |
crs = new Crs(Integer.parseInt(code),wkt.getWKT()); |
144 | 146 |
} catch (CrsException e) { |
145 |
logger.info("Impossible to parse the CRS", e);
|
|
147 |
logger.warn("Impossible to parse the CRS", e);
|
|
146 | 148 |
return null; |
147 | 149 |
} |
148 | 150 |
return crs; |
149 | 151 |
} |
152 |
|
|
153 |
public void dispose() { |
|
154 |
try { |
|
155 |
this.connection.shutdown(); |
|
156 |
this.connection = null; |
|
157 |
} catch (SQLException ex) { |
|
158 |
logger.warn("Can't shutdown the connection.",ex); |
|
159 |
} |
|
160 |
} |
|
150 | 161 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/NoAuthRepository.java | ||
---|---|---|
50 | 50 |
|
51 | 51 |
import es.idr.teledeteccion.connection.EpsgConnection; |
52 | 52 |
import es.idr.teledeteccion.connection.Query; |
53 |
import org.gvsig.tools.dispose.Disposable; |
|
53 | 54 |
|
54 | 55 |
/** |
55 | 56 |
* Repository for CRS without Auth, for example CRS:84 |
56 | 57 |
* @author jldominguez |
57 | 58 |
* |
58 | 59 |
*/ |
59 |
public class NoAuthRepository implements ICrsRepository { |
|
60 |
public class NoAuthRepository implements ICrsRepository, Disposable {
|
|
60 | 61 |
private static final Logger logger = |
61 | 62 |
LoggerFactory.getLogger(NoAuthRepository.class); |
62 | 63 |
|
... | ... | |
103 | 104 |
|
104 | 105 |
} |
105 | 106 |
|
107 |
|
|
108 |
public void dispose() { |
|
109 |
try { |
|
110 |
this.connection.shutdown(); |
|
111 |
this.connection = null; |
|
112 |
} catch (SQLException ex) { |
|
113 |
logger.warn("Con't shutdown the connection.",ex); |
|
114 |
} |
|
115 |
} |
|
106 | 116 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/repository/Iau2000Repository.java | ||
---|---|---|
53 | 53 |
import org.gvsig.crs.CrsException; |
54 | 54 |
import org.gvsig.crs.ICrs; |
55 | 55 |
import org.gvsig.crs.ogr.Iau2wkt; |
56 |
import org.gvsig.tools.dispose.Disposable; |
|
56 | 57 |
|
57 | 58 |
/** |
58 | 59 |
* Repositorio de CRSs de IAU2000 |
... | ... | |
60 | 61 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
61 | 62 |
* |
62 | 63 |
*/ |
63 |
public class Iau2000Repository implements ICrsRepository { |
|
64 |
public class Iau2000Repository implements ICrsRepository, Disposable {
|
|
64 | 65 |
private static final Logger LOG = |
65 | 66 |
LoggerFactory.getLogger(Iau2000Repository.class); |
66 | 67 |
|
... | ... | |
113 | 114 |
|
114 | 115 |
return crs; |
115 | 116 |
} |
117 |
|
|
118 |
public void dispose() { |
|
119 |
try { |
|
120 |
this.connection.shutdown(); |
|
121 |
this.connection = null; |
|
122 |
} catch (SQLException ex) { |
|
123 |
LOG.warn("Con't shutdown the connection.",ex); |
|
124 |
} |
|
125 |
} |
|
116 | 126 |
} |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/JCRSLibrary.java | ||
---|---|---|
34 | 34 |
import org.slf4j.Logger; |
35 | 35 |
import org.slf4j.LoggerFactory; |
36 | 36 |
|
37 |
|
|
38 | 37 |
/** |
39 | 38 |
* @author gvSIG Team |
40 | 39 |
* @version $Id$ |
41 | 40 |
* |
42 | 41 |
*/ |
43 | 42 |
public class JCRSLibrary extends AbstractLibrary { |
44 |
|
|
45 |
private static final Logger logger = LoggerFactory.getLogger(JCRSLibrary.class);
|
|
46 |
|
|
43 |
|
|
44 |
private static final Logger logger = LoggerFactory.getLogger(JCRSLibrary.class);
|
|
45 |
|
|
47 | 46 |
public void doRegistration() { |
48 | 47 |
registerAsImplementationOf(ProjectionLibrary.class, 10); |
49 | 48 |
} |
50 | 49 |
|
51 | 50 |
protected void doInitialize() throws LibraryException { |
52 |
// cleanGeotoolsDatabase(); |
|
53 |
initializeGeotoolsProviders(); |
|
54 |
CRSFactory.registerCRSFactory(new CrsFactory()); |
|
51 |
initializeGeotoolsProviders(); |
|
52 |
CRSFactory.registerCRSFactory(new CrsFactory()); |
|
55 | 53 |
} |
56 | 54 |
|
57 | 55 |
protected void doPostInitialize() throws LibraryException { |
58 | 56 |
// nothing to do |
59 | 57 |
} |
60 | 58 |
|
61 |
//Hemos cambiado el jar de epsg-hsql y tal vez esto ya no sea necesario |
|
62 |
// private void cleanGeotoolsDatabase(){ |
|
63 |
// |
|
64 |
// // Parche para limpiar los archivos temporales de la base de datos cacheada de EPSG cuando ha podido quedar corrupta |
|
65 |
// String tempFolder = System.getProperty("java.io.tmpdir") ; |
|
66 |
// String pathSeparator = System.getProperty("file.separator") ; |
|
67 |
// String cachedDatabasesDir = tempFolder+pathSeparator+"Geotools"+pathSeparator+"Cached databases"; |
|
68 |
// |
|
69 |
// File fileProperties = new File(cachedDatabasesDir+pathSeparator+"EPSG.properties"); |
|
70 |
// File fileScript = new File(cachedDatabasesDir+pathSeparator+"EPSG.script"); |
|
71 |
// File fileData = new File(cachedDatabasesDir+pathSeparator+"EPSG.data"); |
|
72 |
// |
|
73 |
// boolean canDelete = true; |
|
74 |
// if ((fileProperties.exists() || fileScript.exists()) && !fileData.exists()){ |
|
75 |
// File cachedDatabasesDirFile = new File(cachedDatabasesDir); |
|
76 |
// String[] fileNames = cachedDatabasesDirFile.list(); |
|
77 |
// for (int i = 0; i < fileNames.length; i++) { |
|
78 |
// File file = new File(cachedDatabasesDir+pathSeparator+fileNames[i]); |
|
79 |
// canDelete &= file.delete(); |
|
80 |
// } |
|
81 |
// if (!canDelete){ |
|
82 |
// NotificationManager.showMessageWarning("La base de datos de EPSG ha quedado corrupta, por favor salga de la aplicaci?n y borre manualmente el directorio "+cachedDatabasesDir, null); |
|
83 |
// } |
|
84 |
// } |
|
85 |
// // Fin del parche |
|
86 |
// |
|
87 |
// /* Parche para prevenir una posible corrupci?n de la base de datos de EPSG que se |
|
88 |
// * produce en windows al tener m?s de una instancia de gvSIG abierta. |
|
89 |
// */ |
|
90 |
// if (fileProperties.exists()){ |
|
91 |
// if (!fileProperties.delete()){ |
|
92 |
// NotificationManager.showMessageWarning("La base de datos de EPSG ha podido quedar corrupta, por favor salga de la aplicaci?n y borre manualmente el directorio "+cachedDatabasesDir, null); |
|
93 |
// } |
|
94 |
// } |
|
95 |
// // Fin del parche |
|
96 |
// |
|
97 |
// |
|
98 |
// } |
|
99 |
|
|
100 |
private void initializeGeotoolsProviders(){ |
|
101 |
/* |
|
102 |
* Se eliminan del registro de geotools las proyecciones que aporta libJCrs para asegurar que |
|
103 |
* son estas ?ltimas las que se utilizan. |
|
104 |
*/ |
|
105 |
final Class[] categories = {org.geotools.referencing.operation.MathTransformProvider.class}; |
|
106 |
FactoryRegistry registry = new FactoryRegistry(Arrays.asList(categories)); |
|
107 |
Iterator providers = registry.getServiceProviders(MathTransformProvider.class); |
|
108 |
Iterator providers2 = null; |
|
109 |
MathTransformProvider provider = null; |
|
110 |
MathTransformProvider provider2 = null; |
|
59 |
private void initializeGeotoolsProviders() { |
|
60 |
/* |
|
61 |
* Se eliminan del registro de geotools las proyecciones que aporta libJCrs para asegurar que |
|
62 |
* son estas ?ltimas las que se utilizan. |
|
63 |
*/ |
|
64 |
final Class[] categories = {org.geotools.referencing.operation.MathTransformProvider.class}; |
|
65 |
FactoryRegistry registry = new FactoryRegistry(Arrays.asList(categories)); |
|
66 |
Iterator providers = registry.getServiceProviders(MathTransformProvider.class); |
|
67 |
Iterator providers2 = null; |
|
68 |
MathTransformProvider provider = null; |
|
69 |
MathTransformProvider provider2 = null; |
|
111 | 70 |
|
112 |
while (providers.hasNext()){
|
|
113 |
provider = (MathTransformProvider) providers.next();
|
|
114 |
if(provider.nameMatches("IDR")){
|
|
115 |
providers2 = registry.getServiceProviders(MathTransformProvider.class);
|
|
116 |
while (providers2.hasNext()){
|
|
117 |
provider2 = (MathTransformProvider) providers2.next();
|
|
118 |
if(provider2.nameMatches(provider.getName().toString()) && !provider2.nameMatches("IDR")) {
|
|
119 |
registry.deregisterServiceProvider(provider2, categories[0]);
|
|
120 |
}
|
|
121 |
}
|
|
122 |
}
|
|
123 |
}
|
|
71 |
while ( providers.hasNext() ) {
|
|
72 |
provider = (MathTransformProvider) providers.next();
|
|
73 |
if ( provider.nameMatches("IDR") ) {
|
|
74 |
providers2 = registry.getServiceProviders(MathTransformProvider.class);
|
|
75 |
while ( providers2.hasNext() ) {
|
|
76 |
provider2 = (MathTransformProvider) providers2.next();
|
|
77 |
if ( provider2.nameMatches(provider.getName().toString()) && !provider2.nameMatches("IDR") ) {
|
|
78 |
registry.deregisterServiceProvider(provider2, categories[0]);
|
|
79 |
}
|
|
80 |
}
|
|
81 |
}
|
|
82 |
}
|
|
124 | 83 |
|
125 |
logger.debug("Dump of CRS MathTransformProviders");
|
|
126 |
providers = registry.getServiceProviders(MathTransformProvider.class);
|
|
127 |
while (providers.hasNext()) {
|
|
84 |
logger.debug("Dump of CRS MathTransformProviders");
|
|
85 |
providers = registry.getServiceProviders(MathTransformProvider.class);
|
|
86 |
while ( providers.hasNext() ) {
|
|
128 | 87 |
provider = (MathTransformProvider) providers.next(); |
129 | 88 |
logger.debug(provider.toString()); |
130 |
}
|
|
131 |
}
|
|
89 |
}
|
|
90 |
}
|
|
132 | 91 |
|
133 | 92 |
} |
134 | 93 |
org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/pom.xml | ||
---|---|---|
9 | 9 |
<parent> |
10 | 10 |
<groupId>org.gvsig</groupId> |
11 | 11 |
<artifactId>org.gvsig.desktop</artifactId> |
12 |
<version>2.0.25</version>
|
|
12 |
<version>2.0.37-SNAPSHOT</version>
|
|
13 | 13 |
</parent> |
14 | 14 |
|
15 | 15 |
<description> |
Also available in: Unified diff