Revision 674 org.gvsig.projection.jcrs/trunk/org.gvsig.projection.jcrs/org.gvsig.projection.jcrs.lib/src/main/java/org/gvsig/crs/CrsFactory.java
CrsFactory.java | ||
---|---|---|
291 | 291 |
logger.warn("Can't initialize Database.",ex); |
292 | 292 |
} |
293 | 293 |
} |
294 |
|
|
294 |
|
|
295 | 295 |
public static void initializeDatabaseInbackground() { |
296 | 296 |
Thread th = new Thread(new Runnable() { |
297 |
@Override |
|
298 | 297 |
public void run() { |
299 | 298 |
CrsFactory.initializeDatabase(); |
300 | 299 |
} |
301 | 300 |
}, |
302 | 301 |
"EPGS-Initialization" |
303 | 302 |
); |
304 |
th.start();
|
|
303 |
th.start(); |
|
305 | 304 |
} |
306 |
|
|
305 |
|
|
307 | 306 |
public IProjection get(String format, String value) { |
308 | 307 |
if (ICRSFactory.FORMAT_WKT_ESRI.equalsIgnoreCase(format)) { |
309 | 308 |
SpatialReference sr = new SpatialReference(); |
... | ... | |
363 | 362 |
} |
364 | 363 |
|
365 | 364 |
public int searchBestCandidateEPSG(SpatialReference sr, boolean bProj4) throws SQLException { |
366 |
|
|
365 |
|
|
367 | 366 |
int code0 = 0; |
368 | 367 |
int dist0 = 99; |
369 | 368 |
int best_code = code0; |
370 | 369 |
int best_dist = dist0; |
371 | 370 |
int dist = dist0; |
372 |
|
|
371 |
|
|
373 | 372 |
String kind = null; |
374 | 373 |
String attr = null; |
375 | 374 |
if (sr.IsGeographic() == 1) { |
... | ... | |
381 | 380 |
attr = "PROJCS"; |
382 | 381 |
} |
383 | 382 |
} |
384 |
|
|
383 |
|
|
385 | 384 |
String source_sr_name = StringUtils.replace(StringUtils.lowerCase(sr.GetAttrValue(attr)), "_", " "); |
386 |
|
|
385 |
|
|
387 | 386 |
EpsgConnection conn = new EpsgConnection(); |
388 | 387 |
conn.setConnectionEPSG(); |
389 |
|
|
388 |
|
|
390 | 389 |
String sql = "SELECT DISTINCT coord_ref_sys_code FROM epsg_coordinatereferencesystem " |
391 | 390 |
+ "WHERE coord_ref_sys_kind = '" + kind + "' AND deprecated = 0"; |
392 |
|
|
391 |
|
|
393 | 392 |
ResultSet result = Query.select(sql, conn.getConnection()); |
394 |
|
|
393 |
|
|
395 | 394 |
while (result.next()) { |
396 | 395 |
int code = result.getInt("coord_ref_sys_code"); |
397 | 396 |
try { |
... | ... | |
424 | 423 |
//logger.info("Can't ImportFromEPSG.", e); |
425 | 424 |
//logger.info("Can't ImportFromEPSG."); |
426 | 425 |
} |
427 |
|
|
426 |
|
|
428 | 427 |
} |
429 |
|
|
428 |
|
|
430 | 429 |
return best_code; |
431 | 430 |
} |
432 | 431 |
|
Also available in: Unified diff