111 |
111 |
public int epsg_code = 0;
|
112 |
112 |
public int selectedRowTable = -1;
|
113 |
113 |
private int codeCRS = -1;
|
114 |
|
int[] valid_method_code = { 1024, 9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810,
|
115 |
|
9811, 9812, 9813, 9814, 9815, 9816, 9817, 9602, 9659, 9818, 9819, 9820, 9822,
|
116 |
|
9827};
|
|
114 |
int[] valid_method_code = {1024, 9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810,
|
|
115 |
9811, 9812, 9813, 9814, 9815, 9816, 9817, 9602, 9659, 9818, 9819, 9820, 9822, 9827};
|
117 |
116 |
|
118 |
|
|
119 |
117 |
boolean tecla_valida = false;
|
120 |
118 |
boolean source_yn = false;
|
121 |
119 |
|
122 |
|
|
123 |
120 |
private JRadioButton codeRadioButton = null;
|
124 |
121 |
private JRadioButton nameRadioButton = null;
|
125 |
122 |
private JRadioButton areaRadioButton = null;
|
... | ... | |
253 |
250 |
|
254 |
251 |
if (searchTextField.getText().equals("")) {
|
255 |
252 |
searchTextField.setBackground(new Color(255,204,204));
|
256 |
|
JOptionPane.showMessageDialog(this, PluginServices.getText(this,"fill_name"), "Warning...", JOptionPane.WARNING_MESSAGE);
|
|
253 |
JOptionPane.showMessageDialog(this, PluginServices.getText(this,"fill_name"), PluginServices.getText(this,"warning"), JOptionPane.WARNING_MESSAGE);
|
257 |
254 |
}
|
258 |
255 |
|
259 |
256 |
else {
|
... | ... | |
264 |
261 |
dtm.removeRow(numRow);
|
265 |
262 |
}
|
266 |
263 |
|
267 |
|
if (codeRadioButton.isSelected() && (searchTextField.getText().length()!=searchTextField.getText().replaceAll("[^0-9]", "").length())){
|
|
264 |
key = searchTextField.getText();
|
|
265 |
if (codeRadioButton.isSelected() && (key.length() != key.replaceAll("[^0-9]", "").length())){
|
268 |
266 |
not_numeric = true;
|
269 |
267 |
}
|
270 |
268 |
|
271 |
269 |
//Dependiendo de la opcion se realizada una busqueda
|
272 |
270 |
ResultSet result = null;
|
273 |
|
ResultSet result2 = null;
|
274 |
|
/*
|
275 |
|
* variable que indicara si la busqueda se hace primero en epsg_coordinatereferencesystem
|
276 |
|
* o en epsg_area; esto es debido a que HSQLDB no soporta la bsqueda simultnea en ambas
|
277 |
|
* tablas, por lo cual hay que separar la bsqueda
|
278 |
|
*/
|
279 |
|
int bus = 2;
|
|
271 |
String sentence = null;
|
|
272 |
String select = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, " +
|
|
273 |
"area_of_use_code, source_geogcrs_code, projection_conv_code, deprecated, " +
|
|
274 |
"epsg_area.area_name, epsg_area.area_of_use " +
|
|
275 |
"FROM epsg_coordinatereferencesystem " +
|
|
276 |
"INNER JOIN epsg_area " +
|
|
277 |
"ON (epsg_coordinatereferencesystem.area_of_use_code = epsg_area.area_code) ";
|
|
278 |
String condition1 = null;
|
|
279 |
String condition2 = "AND (deprecated = 0) " +
|
|
280 |
"AND (coord_ref_sys_kind IN ('geographic 2D', 'projected')) " +
|
|
281 |
"ORDER BY coord_ref_sys_name";
|
|
282 |
|
280 |
283 |
if (codeRadioButton.isSelected() && !not_numeric) {
|
281 |
|
bus=0;
|
282 |
284 |
key = searchTextField.getText();
|
283 |
285 |
int code = Integer.parseInt(key);
|
284 |
|
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " +
|
285 |
|
"source_geogcrs_code, projection_conv_code " +
|
286 |
|
"FROM epsg_coordinatereferencesystem " +
|
287 |
|
"WHERE coord_ref_sys_code = " + code;
|
288 |
|
|
289 |
|
result = Query.select(sentence,connect.getConnection());
|
290 |
|
|
|
286 |
condition1 = "WHERE coord_ref_sys_code = " + code + " ";
|
|
287 |
sentence = select + condition1 + condition2;
|
|
288 |
result = Query.select(sentence, connect.getConnection());
|
291 |
289 |
}
|
292 |
290 |
|
293 |
291 |
else if (nameRadioButton.isSelected()) {
|
294 |
|
bus=0;
|
295 |
292 |
key = searchTextField.getText();
|
296 |
293 |
key = key.toLowerCase();
|
297 |
|
String key2 = key.substring(0,1);
|
298 |
|
String key3 = key.substring(1,key.length());
|
299 |
|
key2 = key2.toUpperCase();
|
300 |
|
|
301 |
|
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, " +
|
302 |
|
"area_of_use_code, source_geogcrs_code, projection_conv_code " +
|
303 |
|
"FROM epsg_coordinatereferencesystem " +
|
304 |
|
"WHERE (coord_ref_sys_name LIKE '%" + key + "%') OR (coord_ref_sys_name LIKE '%"+
|
305 |
|
key.toUpperCase() +"%') " +
|
306 |
|
"OR (coord_ref_sys_name LIKE '%" + key2+key3 +"%')";
|
307 |
|
result = Query.select(sentence,connect.getConnection());
|
|
294 |
condition1 = "WHERE (LCASE(coord_ref_sys_name) LIKE '%" + key + "%') ";
|
|
295 |
sentence = select + condition1 + condition2;
|
|
296 |
result = Query.select(sentence, connect.getConnection());
|
308 |
297 |
}
|
309 |
298 |
|
310 |
299 |
else if (areaRadioButton.isSelected()) {
|
311 |
|
bus=1;
|
312 |
300 |
key = searchTextField.getText();
|
313 |
|
key = key.toLowerCase();
|
314 |
|
String key2 = key.substring(0,1);
|
315 |
|
String key3 = key.substring(1,key.length());
|
316 |
|
key2 = key2.toUpperCase();
|
317 |
|
|
318 |
|
String sentence = "SELECT area_name, area_of_use, area_code " +
|
319 |
|
"FROM epsg_area " +
|
320 |
|
"WHERE (area_name LIKE '%" + key + "%') OR (area_of_use LIKE '%" + key + "%') "+
|
321 |
|
"OR (area_name LIKE '%" + key.toUpperCase() + "%') OR (area_of_use LIKE '%" + key.toUpperCase() + "%') "+
|
322 |
|
"OR (area_name LIKE '%" + key2+key3 + "%') OR (area_of_use LIKE '%" + key2+key3 + "%') ";
|
323 |
|
result = Query.select(sentence,connect.getConnection());
|
|
301 |
key = key.toLowerCase();
|
|
302 |
condition1 = "WHERE ((LCASE(epsg_area.area_name) LIKE '%" + key + "%') "
|
|
303 |
+ "OR (LCASE(epsg_area.area_of_use) LIKE '%" + key + "%')) ";
|
|
304 |
sentence = select + condition1 + condition2;
|
|
305 |
result = Query.select(sentence, connect.getConnection());
|
324 |
306 |
}
|
325 |
307 |
|
326 |
|
if (bus==0){
|
|
308 |
if (result != null) {
|
327 |
309 |
try {
|
328 |
310 |
while(result.next()) {
|
329 |
|
Object[]data = new Object[5];
|
330 |
|
data[0] = String.valueOf(result.getInt("coord_ref_sys_code"));
|
|
311 |
Object[] data = new Object[5];
|
|
312 |
data[0] = result.getString("coord_ref_sys_code");
|
331 |
313 |
data[1] = result.getString("coord_ref_sys_name");
|
332 |
314 |
crs_kind = result.getString("coord_ref_sys_kind");
|
333 |
315 |
data[2] = crs_kind;
|
334 |
316 |
projection_conv_code = result.getInt("projection_conv_code");
|
335 |
317 |
setProjectionCode(projection_conv_code);
|
336 |
|
|
337 |
|
int area_of_use_code = Integer.parseInt(result.getString("area_of_use_code"));
|
338 |
|
|
339 |
|
String sentence = "SELECT area_name, area_of_use FROM epsg_area " +
|
340 |
|
"WHERE area_code = "+ area_of_use_code ;
|
341 |
|
|
342 |
|
result2 = Query.select(sentence,connect.getConnection());
|
343 |
|
while(result2.next()){
|
344 |
|
data[3] = result2.getString("area_name");
|
345 |
|
data[4] = result2.getString("area_of_use");
|
346 |
|
}
|
347 |
|
if (data[0]!=null /*&& validCRS(projection_conv_code)*/ && valid(crs_kind)){
|
|
318 |
data[3] = result.getString("area_name");
|
|
319 |
data[4] = result.getString("area_of_use");
|
|
320 |
if (data[0] != null /*&& validCRS(projection_conv_code)*/ && valid(crs_kind)){
|
348 |
321 |
dtm.addRow(data);
|
349 |
322 |
}
|
350 |
323 |
}
|
351 |
324 |
}
|
352 |
|
|
353 |
325 |
catch (SQLException e1) {
|
354 |
326 |
logger.error("Can't get values from RecordSet.",e1);
|
355 |
327 |
}
|
356 |
328 |
}
|
357 |
|
else if (bus==1){
|
358 |
|
try {
|
359 |
|
while(result.next()) {
|
360 |
|
Object[]data = new Object[5];
|
361 |
|
data[3] = result.getString("area_name");
|
362 |
|
data[4] = result.getString("area_of_use");
|
363 |
|
|
364 |
|
int area_of_use_code = Integer.parseInt(result.getString("area_code"));
|
365 |
|
|
366 |
|
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, " +
|
367 |
|
"coord_ref_sys_kind, source_geogcrs_code, projection_conv_code " +
|
368 |
|
"FROM epsg_coordinatereferencesystem " +
|
369 |
|
"WHERE area_of_use_code = "+ area_of_use_code ;
|
370 |
|
|
371 |
|
result2 = Query.select(sentence,connect.getConnection());
|
372 |
|
while(result2.next()){
|
373 |
|
data[0] = String.valueOf(result2.getInt("coord_ref_sys_code"));
|
374 |
|
data[1] = result2.getString("coord_ref_sys_name");
|
375 |
|
data[2] = result2.getString("coord_ref_sys_kind");
|
376 |
|
crs_kind = (String)data[2];
|
377 |
|
projection_conv_code = result2.getInt("projection_conv_code");
|
378 |
|
setProjectionCode(projection_conv_code);
|
379 |
|
}
|
380 |
|
/*
|
381 |
|
* Buscaremos solo aquellos CRS cuyas proyecciones esten entre las
|
382 |
|
* 16 soportadas por proj4 para ello creamos un metodo para validar
|
383 |
|
* si esta entre estas proyecciones
|
384 |
|
*/
|
385 |
|
if (data[0]!=null /*&& validCRS(projection_conv_code)*/ && valid(crs_kind)){
|
386 |
|
dtm.addRow(data);
|
387 |
|
}
|
388 |
|
if (notValid(crs_kind)){
|
389 |
|
not_valid = true;
|
390 |
|
}
|
391 |
|
}
|
392 |
|
}
|
393 |
|
|
394 |
|
catch (SQLException e1) {
|
395 |
|
logger.error("Can't get values from RecordSet.",e1);
|
396 |
|
|
397 |
|
}
|
398 |
|
}
|
|
329 |
|
399 |
330 |
int numr = dtm.getRowCount();
|
400 |
331 |
if (not_valid){
|
401 |
|
JOptionPane.showMessageDialog(this, PluginServices.getText(this,"crs_not_soported"), "Warning...",
|
|
332 |
JOptionPane.showMessageDialog(this,
|
|
333 |
PluginServices.getText(this,"crs_not_soported"),
|
|
334 |
PluginServices.getText(this,"warning"),
|
402 |
335 |
JOptionPane.WARNING_MESSAGE);
|
403 |
336 |
not_valid = false;
|
404 |
337 |
}
|
405 |
338 |
else if (not_numeric) {
|
406 |
|
JOptionPane.showMessageDialog(EPSGpanel.this,
|
407 |
|
PluginServices.getText(this,"numeric_format"),
|
408 |
|
"Warning...", JOptionPane.WARNING_MESSAGE);
|
|
339 |
JOptionPane.showMessageDialog(EPSGpanel.this,
|
|
340 |
PluginServices.getText(this,"numeric_format"),
|
|
341 |
PluginServices.getText(this,"warning"),
|
|
342 |
JOptionPane.WARNING_MESSAGE);
|
409 |
343 |
searchTextField.setText("");
|
410 |
344 |
}
|
411 |
|
else if (numr == 0){
|
412 |
|
JOptionPane.showMessageDialog(this, PluginServices.getText(this,"no_results"), "Warning...",
|
413 |
|
JOptionPane.WARNING_MESSAGE);
|
|
345 |
else if (numr == 0) {
|
|
346 |
JOptionPane.showMessageDialog(this,
|
|
347 |
PluginServices.getText(this,"no_results"),
|
|
348 |
PluginServices.getText(this,"warning"),
|
|
349 |
JOptionPane.WARNING_MESSAGE);
|
414 |
350 |
}
|
415 |
|
else{
|
|
351 |
else {
|
416 |
352 |
this.getJTable().setRowSelectionInterval(0,0);
|
417 |
353 |
}
|
418 |
354 |
}
|
... | ... | |
546 |
482 |
else if (i == 2) {
|
547 |
483 |
column.setPreferredWidth(80);
|
548 |
484 |
}
|
549 |
|
else if (i==4){
|
|
485 |
else if (i == 4){
|
550 |
486 |
column.setPreferredWidth(300);
|
551 |
487 |
}
|
552 |
488 |
else {
|
... | ... | |
634 |
570 |
*/
|
635 |
571 |
String sentence = "SELECT source_geogcrs_code, projection_conv_code, " +
|
636 |
572 |
"coord_ref_sys_kind, datum_code " +
|
637 |
|
"FROM epsg_coordinatereferencesystem " +
|
638 |
|
"WHERE coord_ref_sys_code = "+ epsg_code ;
|
|
573 |
"FROM epsg_coordinatereferencesystem " +
|
|
574 |
"WHERE coord_ref_sys_code = " + epsg_code;
|
639 |
575 |
ResultSet result = Query.select(sentence,connect.getConnection());
|
640 |
576 |
|
641 |
577 |
try {
|
... | ... | |
674 |
610 |
else {
|
675 |
611 |
JOptionPane.showMessageDialog(this,
|
676 |
612 |
PluginServices.getText(this,"crs_no_selected."),
|
677 |
|
"Warning...", JOptionPane.WARNING_MESSAGE);
|
|
613 |
PluginServices.getText(this,"warning"), JOptionPane.WARNING_MESSAGE);
|
678 |
614 |
|
679 |
615 |
}
|
680 |
616 |
cadWKT = wkt.getWKT();
|
... | ... | |
695 |
631 |
public void loadViewCRS(int code){
|
696 |
632 |
connection();
|
697 |
633 |
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " +
|
698 |
|
"source_geogcrs_code, projection_conv_code " +
|
|
634 |
"source_geogcrs_code, projection_conv_code, deprecated " +
|
699 |
635 |
"FROM epsg_coordinatereferencesystem " +
|
700 |
|
"WHERE coord_ref_sys_code = " + code;
|
|
636 |
"WHERE coord_ref_sys_code = " + code + " AND deprecated = 0";
|
701 |
637 |
ResultSet result = Query.select(sentence,connect.getConnection());
|
702 |
638 |
|
703 |
639 |
try {
|
704 |
640 |
result.next();
|
705 |
641 |
Object[]data = new Object[5];
|
706 |
|
data[0] = String.valueOf(result.getInt("coord_ref_sys_code"));
|
|
642 |
data[0] = result.getString("coord_ref_sys_code");
|
707 |
643 |
data[1] = result.getString("coord_ref_sys_name");
|
708 |
644 |
crs_kind = result.getString("coord_ref_sys_kind");
|
709 |
645 |
data[2] = crs_kind;
|
... | ... | |
774 |
710 |
searchTextField.setBackground(new Color(255,204,204));
|
775 |
711 |
JOptionPane.showMessageDialog(EPSGpanel.this,
|
776 |
712 |
PluginServices.getText(this,"fill_name"),
|
777 |
|
"Warning...", JOptionPane.WARNING_MESSAGE);
|
|
713 |
PluginServices.getText(this,"warning"), JOptionPane.WARNING_MESSAGE);
|
778 |
714 |
}
|
779 |
715 |
else {
|
780 |
716 |
searchButton();
|
... | ... | |
820 |
756 |
|
821 |
757 |
String sentence = "SELECT projection_conv_code " +
|
822 |
758 |
"FROM epsg_coordinatereferencesystem " +
|
823 |
|
"WHERE coord_ref_sys_code = " + code;
|
|
759 |
"WHERE coord_ref_sys_code = " + code;
|
824 |
760 |
|
825 |
761 |
ResultSet result = Query.select(sentence,connect.getConnection());
|
826 |
762 |
int projCode = 0;
|