root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / panels / EPSGpanel.java @ 7823
History | View | Annotate | Download (19 KB)
1 |
package org.gvsig.crs.gui.panels; |
---|---|
2 |
import java.awt.Color; |
3 |
import java.awt.Dimension; |
4 |
import java.awt.FlowLayout; |
5 |
import java.awt.GridLayout; |
6 |
import java.awt.event.ActionEvent; |
7 |
import java.awt.event.KeyEvent; |
8 |
import java.awt.event.KeyListener; |
9 |
import java.awt.event.MouseListener; |
10 |
import java.sql.ResultSet; |
11 |
import java.sql.SQLException; |
12 |
|
13 |
import javax.swing.BorderFactory; |
14 |
import javax.swing.JButton; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JOptionPane; |
17 |
import javax.swing.JPanel; |
18 |
import javax.swing.JRadioButton; |
19 |
import javax.swing.JScrollPane; |
20 |
import javax.swing.JTable; |
21 |
import javax.swing.JTextField; |
22 |
import javax.swing.ListSelectionModel; |
23 |
import javax.swing.table.DefaultTableModel; |
24 |
import javax.swing.table.TableColumn; |
25 |
|
26 |
import org.cresques.cts.IProjection; |
27 |
import org.gvsig.crs.CrsException; |
28 |
import org.gvsig.crs.CrsFactory; |
29 |
import org.gvsig.crs.EpsgConnection; |
30 |
import org.gvsig.crs.ICrs; |
31 |
import org.gvsig.crs.Query; |
32 |
import org.gvsig.crs.gui.InfoCRSPanel; |
33 |
import org.gvsig.crs.ogr.Epsg2wkt; |
34 |
import org.gvsig.crs.ogr.GetCRSepsg; |
35 |
|
36 |
import com.iver.andami.PluginServices; |
37 |
import com.iver.cit.gvsig.gui.TableSorter; |
38 |
|
39 |
public class EPSGpanel extends JPanel{ |
40 |
|
41 |
/**
|
42 |
*
|
43 |
*/
|
44 |
private static final long serialVersionUID = 1L; |
45 |
public JPanel EPSGpanel = null; |
46 |
|
47 |
JLabel jLabel = null; |
48 |
JTextField crsTextFld = null; |
49 |
|
50 |
String cadWKT = ""; |
51 |
|
52 |
int transf = 0; |
53 |
public int epsg_code = 0; |
54 |
boolean source_yn = false; |
55 |
int source_cod = 0; |
56 |
int method_code = 0; |
57 |
int datum_code = 0; |
58 |
int projection_conv_code = 0; |
59 |
public String crs_kind = null; |
60 |
int[] valid_method_code = {9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, |
61 |
9811, 9812, 9813, 9814, 9815, 9816, 9817, 9602, 9659}; |
62 |
boolean select = false; |
63 |
|
64 |
String[] soported_crs = {"projected","geographic 2D","geographic 3D", "engineering", "vertical", "compound", "geocentric"}; |
65 |
String[] not_soported_crs = {}; |
66 |
|
67 |
private JRadioButton codeRadioButton = null; |
68 |
private JRadioButton nameRadioButton = null; |
69 |
private JRadioButton areaRadioButton = null; |
70 |
private JPanel groupRadioButton = null; |
71 |
|
72 |
boolean inAnApplet = true; |
73 |
|
74 |
public EpsgConnection connect = null; |
75 |
|
76 |
private JButton infoCrs = null; |
77 |
private JButton searchButton = null; |
78 |
private JTextField searchTextField = null; |
79 |
public JTable jTable = null; |
80 |
private JScrollPane jScrollPane = null; |
81 |
public DefaultTableModel dtm = null; |
82 |
public DefaultTableModel dtm2 = null; |
83 |
public String key; |
84 |
public int selectedRowTable = -1; |
85 |
public int selectedRowTable2 = -1; |
86 |
|
87 |
private int codeCRS = -1; |
88 |
|
89 |
TransformationManualPanel manual = null;
|
90 |
|
91 |
public EPSGpanel(){
|
92 |
|
93 |
connect = new EpsgConnection();
|
94 |
connect.setConnection(); |
95 |
|
96 |
} |
97 |
|
98 |
public JPanel getJPanelEPSG() { |
99 |
if (EPSGpanel == null){ |
100 |
EPSGpanel = new JPanel(); |
101 |
EPSGpanel.setLayout(new GridLayout(3,3)); |
102 |
EPSGpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
103 |
|
104 |
EPSGpanel.add(getGroupRadioButton(), null);
|
105 |
EPSGpanel.add(getSearchButton(), null);
|
106 |
EPSGpanel.add(getSearchTextField(), null);
|
107 |
EPSGpanel.add(getInfoCrs(), null);
|
108 |
EPSGpanel.add(getJScrollPane(), null);
|
109 |
} |
110 |
return EPSGpanel;
|
111 |
} |
112 |
|
113 |
private void codeRadioButton_actionPerformed(ActionEvent e) { |
114 |
searchTextField.setText("");
|
115 |
codeRadioButton.setSelected(true);
|
116 |
nameRadioButton.setSelected(false);
|
117 |
areaRadioButton.setSelected(false);
|
118 |
} |
119 |
|
120 |
private JRadioButton getCodeRadioButton() { |
121 |
if (codeRadioButton == null) { |
122 |
codeRadioButton = new JRadioButton(); |
123 |
codeRadioButton.setText(PluginServices.getText(this,"Por c?digo"));//setText("By Code EPSG"); |
124 |
codeRadioButton.setSelected(true);
|
125 |
codeRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
126 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
127 |
codeRadioButton_actionPerformed(e); |
128 |
} |
129 |
}); |
130 |
} |
131 |
return codeRadioButton;
|
132 |
} |
133 |
|
134 |
private void nameRadioButton_actionPerformed(ActionEvent e) { |
135 |
searchTextField.setText("");
|
136 |
nameRadioButton.setSelected(true);
|
137 |
codeRadioButton.setSelected(false);
|
138 |
areaRadioButton.setSelected(false);
|
139 |
} |
140 |
|
141 |
private JRadioButton getNameRadioButton() { |
142 |
if (nameRadioButton == null) { |
143 |
nameRadioButton = new JRadioButton(); |
144 |
nameRadioButton.setText(PluginServices.getText(this,"Por nombre")); |
145 |
nameRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
146 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
147 |
nameRadioButton_actionPerformed(e); |
148 |
} |
149 |
}); |
150 |
} |
151 |
return nameRadioButton;
|
152 |
} |
153 |
|
154 |
private void areaRadioButton_actionPerformed(ActionEvent e) { |
155 |
searchTextField.setText("");
|
156 |
areaRadioButton.setSelected(true);
|
157 |
codeRadioButton.setSelected(false);
|
158 |
nameRadioButton.setSelected(false);
|
159 |
} |
160 |
|
161 |
private JRadioButton getAreaRadioButton() { |
162 |
if (areaRadioButton == null) { |
163 |
areaRadioButton = new JRadioButton(); |
164 |
areaRadioButton.setText(PluginServices.getText(this,"Por ?rea")); |
165 |
areaRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
166 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
167 |
areaRadioButton_actionPerformed(e); |
168 |
} |
169 |
}); |
170 |
} |
171 |
return areaRadioButton;
|
172 |
} |
173 |
|
174 |
private JPanel getGroupRadioButton() { |
175 |
if (groupRadioButton == null) { |
176 |
groupRadioButton = new JPanel(); |
177 |
groupRadioButton.setLayout(new GridLayout(1,0)); |
178 |
groupRadioButton.setPreferredSize(new Dimension(500,30)); |
179 |
groupRadioButton.add(getLabel()); |
180 |
groupRadioButton.add(getCodeRadioButton()); |
181 |
groupRadioButton.add(getNameRadioButton()); |
182 |
groupRadioButton.add(getAreaRadioButton()); |
183 |
} |
184 |
return groupRadioButton;
|
185 |
} |
186 |
|
187 |
private JLabel getLabel(){ |
188 |
JLabel criterio = new JLabel(); |
189 |
criterio.setPreferredSize(new Dimension(100, 20)); |
190 |
criterio.setText(PluginServices.getText(this, "Criterio de b?squeda: ")); |
191 |
return criterio;
|
192 |
} |
193 |
|
194 |
private void searchButton_actionPerformed(ActionEvent e) { |
195 |
boolean not_valid = false; |
196 |
searchTextField.setBackground(Color.white);
|
197 |
|
198 |
if (searchTextField.getText().equals("")) { |
199 |
searchTextField.setBackground(new Color(255,204,204)); |
200 |
JOptionPane.showMessageDialog(this, "Fill the name of CRS.", "Warning...", JOptionPane.WARNING_MESSAGE); |
201 |
} |
202 |
|
203 |
else {
|
204 |
//Eliminar filas en cada nueva bsqueda
|
205 |
int numRow = dtm.getRowCount();
|
206 |
while (numRow != 0) { |
207 |
numRow = numRow - 1;
|
208 |
dtm.removeRow(numRow); |
209 |
} |
210 |
|
211 |
//Dependiendo de la opcion se realizada una busqueda
|
212 |
ResultSet result = null; |
213 |
ResultSet result2 = null; |
214 |
/*
|
215 |
* variable que indicara si la busqueda se hace primero en epsg_coordinatereferencesystem
|
216 |
* o en epsg_area; esto es debido a que HSQLDB no soporta la b?squeda simult?nea en ambas
|
217 |
* tablas, por lo cual hay que separar la b?squeda
|
218 |
*/
|
219 |
int bus = 2; |
220 |
if (codeRadioButton.isSelected()) {
|
221 |
bus=0;
|
222 |
key = searchTextField.getText(); |
223 |
int code = Integer.parseInt(key); |
224 |
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " + |
225 |
"source_geogcrs_code, projection_conv_code " +
|
226 |
"FROM epsg_coordinatereferencesystem " +
|
227 |
"WHERE coord_ref_sys_code = " + code;
|
228 |
result = Query.select(sentence,connect.getConnection());
|
229 |
} |
230 |
|
231 |
else if (nameRadioButton.isSelected()) { |
232 |
bus=0;
|
233 |
key = searchTextField.getText(); |
234 |
String key2 = key.substring(0,1); |
235 |
String key3 = key.substring(1,key.length()); |
236 |
key2 = key2.toUpperCase(); |
237 |
|
238 |
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, " + |
239 |
"area_of_use_code, source_geogcrs_code, projection_conv_code " +
|
240 |
"FROM epsg_coordinatereferencesystem " +
|
241 |
"WHERE (coord_ref_sys_name LIKE '%" + key + "%') OR (coord_ref_sys_name LIKE '%"+ |
242 |
key.toUpperCase() +"%') " +
|
243 |
"OR (coord_ref_sys_name LIKE '%" + key2+key3 +"%')"; |
244 |
result = Query.select(sentence,connect.getConnection());
|
245 |
} |
246 |
|
247 |
else {
|
248 |
bus=1;
|
249 |
key = searchTextField.getText(); |
250 |
String key2 = key.substring(0,1); |
251 |
String key3 = key.substring(1,key.length()); |
252 |
key2 = key2.toUpperCase(); |
253 |
|
254 |
String sentence = "SELECT area_name, area_of_use, area_code " + |
255 |
"FROM epsg_area " +
|
256 |
"WHERE (area_name LIKE '%" + key + "%') OR (area_of_use LIKE '%" + key + "%') "+ |
257 |
"OR (area_name LIKE '%" + key.toUpperCase() + "%') OR (area_of_use LIKE '%" + key.toUpperCase() + "%') "+ |
258 |
"OR (area_name LIKE '%" + key2+key3 + "%') OR (area_of_use LIKE '%" + key2+key3 + "%') "; |
259 |
result = Query.select(sentence,connect.getConnection());
|
260 |
} |
261 |
|
262 |
if (bus==0){ |
263 |
try {
|
264 |
while(result.next()) {
|
265 |
Object[]data = new Object[5]; |
266 |
data[0] = String.valueOf(result.getInt("coord_ref_sys_code")); |
267 |
data[1] = result.getString("coord_ref_sys_name"); |
268 |
crs_kind = result.getString("coord_ref_sys_kind");
|
269 |
data[2] = crs_kind;
|
270 |
projection_conv_code = result.getInt("projection_conv_code");
|
271 |
|
272 |
int area_of_use_code = Integer.parseInt(result.getString("area_of_use_code")); |
273 |
|
274 |
String sentence = "SELECT area_name, area_of_use FROM epsg_area " + |
275 |
"WHERE area_code = "+ area_of_use_code ;
|
276 |
|
277 |
result2 = Query.select(sentence,connect.getConnection());
|
278 |
while(result2.next()){
|
279 |
data[3] = result2.getString("area_name"); |
280 |
data[4] = result2.getString("area_of_use"); |
281 |
} |
282 |
if (data[0]!=null && validCRS(projection_conv_code) && valid(crs_kind)){ |
283 |
dtm.addRow(data); |
284 |
} |
285 |
} |
286 |
} |
287 |
|
288 |
catch (SQLException e1) { |
289 |
e1.printStackTrace(); |
290 |
} |
291 |
} |
292 |
else if (bus==1){ |
293 |
try {
|
294 |
while(result.next()) {
|
295 |
Object[]data = new Object[5]; |
296 |
data[3] = result.getString("area_name"); |
297 |
data[4] = result.getString("area_of_use"); |
298 |
|
299 |
int area_of_use_code = Integer.parseInt(result.getString("area_code")); |
300 |
|
301 |
String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, " + |
302 |
"coord_ref_sys_kind, source_geogcrs_code, projection_conv_code " +
|
303 |
"FROM epsg_coordinatereferencesystem " +
|
304 |
"WHERE area_of_use_code = "+ area_of_use_code ;
|
305 |
|
306 |
result2 = Query.select(sentence,connect.getConnection());
|
307 |
while(result2.next()){
|
308 |
data[0] = String.valueOf(result2.getInt("coord_ref_sys_code")); |
309 |
data[1] = result2.getString("coord_ref_sys_name"); |
310 |
data[2] = result2.getString("coord_ref_sys_kind"); |
311 |
crs_kind = (String)data[2]; |
312 |
projection_conv_code = result2.getInt("projection_conv_code");
|
313 |
|
314 |
} |
315 |
/*
|
316 |
* Buscaremos solo aquellos CRS cuyas proyecciones esten entre las
|
317 |
* 16 soportadas por proj4 para ello creamos un metodo para validar
|
318 |
* si esta entre estas proyecciones
|
319 |
*/
|
320 |
if (data[0]!=null && validCRS(projection_conv_code) && valid(crs_kind)){ |
321 |
dtm.addRow(data); |
322 |
} |
323 |
if (notValid(crs_kind)){
|
324 |
not_valid = true;
|
325 |
} |
326 |
} |
327 |
} |
328 |
|
329 |
catch (SQLException e1) { |
330 |
e1.printStackTrace(); |
331 |
} |
332 |
} |
333 |
int numr = dtm.getRowCount();
|
334 |
if (not_valid){
|
335 |
JOptionPane.showMessageDialog(this, "CRS no soportado.", "Warning...", |
336 |
JOptionPane.WARNING_MESSAGE);
|
337 |
not_valid = false;
|
338 |
} |
339 |
else if (numr == 0 ){ |
340 |
JOptionPane.showMessageDialog(this, "Not Results found.", "Warning...", |
341 |
JOptionPane.WARNING_MESSAGE);
|
342 |
} |
343 |
else{
|
344 |
this.getJTable().setRowSelectionInterval(0,0); |
345 |
} |
346 |
} |
347 |
} |
348 |
|
349 |
/*
|
350 |
* metodo auxiliar que hara la comprobacion de si el CRS buscado pertenecera
|
351 |
* a los no soportados por proj4
|
352 |
*/
|
353 |
private boolean notValid(String kind){ |
354 |
for (int i = 0; i< not_soported_crs.length; i++){ |
355 |
if (kind.equals(not_soported_crs[i])){
|
356 |
return true; |
357 |
} |
358 |
} |
359 |
return false; |
360 |
} |
361 |
|
362 |
/*
|
363 |
* Metodo que comprueba si el CRS buscado pertenece a algun tipo de los que soporta
|
364 |
* la aplicacion
|
365 |
*/
|
366 |
private boolean valid(String kind){ |
367 |
for (int i = 0; i< soported_crs.length; i++){ |
368 |
if (kind.equals(soported_crs[i])){
|
369 |
return true; |
370 |
} |
371 |
} |
372 |
return false; |
373 |
} |
374 |
|
375 |
/*
|
376 |
* metodo auxiliar que nos servira para comprobar si la proyeccion del CRS seleccionado
|
377 |
* esta entre las 16 con las que trabaja proj4
|
378 |
*/
|
379 |
private boolean validCRS(int projection_conv_code2) { |
380 |
if (projection_conv_code2 == 0) return true; |
381 |
String sentence = "SELECT coord_op_method_code " + |
382 |
"FROM epsg_coordoperation " +
|
383 |
"WHERE coord_op_code = " + projection_conv_code;
|
384 |
ResultSet result = Query.select(sentence,connect.getConnection()); |
385 |
try {
|
386 |
while (result.next()){
|
387 |
method_code = result.getInt("coord_op_method_code");
|
388 |
} |
389 |
} catch (SQLException e) { |
390 |
e.printStackTrace(); |
391 |
} |
392 |
|
393 |
for (int i = 0; i< valid_method_code.length; i++){ |
394 |
if (method_code == valid_method_code[i] ){
|
395 |
return true; |
396 |
} |
397 |
} |
398 |
return false; |
399 |
} |
400 |
|
401 |
|
402 |
private JButton getSearchButton() { |
403 |
if (searchButton == null) { |
404 |
searchButton = new JButton(); |
405 |
searchButton.setPreferredSize(new Dimension(75,20)); |
406 |
searchButton.setText(PluginServices.getText(this,"Buscar")); |
407 |
searchButton.setMnemonic('S');
|
408 |
searchButton.setToolTipText("Search of a CRS by selected criterion");
|
409 |
searchButton.addActionListener(new java.awt.event.ActionListener() {
|
410 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
411 |
searchTextField.setBackground(Color.white);
|
412 |
if (searchTextField.getText().equals("")) { |
413 |
searchTextField.setBackground(new Color(255,204,204)); |
414 |
JOptionPane.showMessageDialog(EPSGpanel.this,
|
415 |
"Fill the key-word of the search.",
|
416 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
417 |
} |
418 |
else {
|
419 |
searchButton_actionPerformed(e); |
420 |
} |
421 |
} |
422 |
}); |
423 |
} |
424 |
return searchButton;
|
425 |
} |
426 |
|
427 |
private JTextField getSearchTextField() { |
428 |
if (searchTextField == null) { |
429 |
searchTextField = new JTextField(); |
430 |
searchTextField.setPreferredSize(new Dimension(300,20)); |
431 |
} |
432 |
searchTextField.addKeyListener(new KeyListener() { |
433 |
public void keyPressed(KeyEvent e) { |
434 |
if (e.getKeyCode() == 10) { |
435 |
searchButton_actionPerformed(null);
|
436 |
} |
437 |
if (codeRadioButton.isSelected()){
|
438 |
if ((e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || |
439 |
(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){ |
440 |
} |
441 |
else {
|
442 |
JOptionPane.showMessageDialog(EPSGpanel.this,
|
443 |
"Only number format.",
|
444 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
445 |
String aux = searchTextField.getText();
|
446 |
if (aux.length() == 1){ |
447 |
searchTextField.setText("");
|
448 |
} |
449 |
else {
|
450 |
searchTextField.setText(aux.substring(0, aux.length()-1)); |
451 |
} |
452 |
} |
453 |
} |
454 |
} |
455 |
|
456 |
public void keyReleased(KeyEvent arg0) { |
457 |
} |
458 |
|
459 |
public void keyTyped(KeyEvent arg0) { |
460 |
} |
461 |
}); |
462 |
return searchTextField;
|
463 |
} |
464 |
|
465 |
public JTable getJTable() { |
466 |
if (jTable == null) { |
467 |
String[] columnNames= {"Code of CRS","Name of CRS","Type of CRS","Name of Area","Description of Area"}; |
468 |
Object[][]data = {}; |
469 |
dtm = new DefaultTableModel(data, columnNames) |
470 |
{ |
471 |
public boolean isCellEditable(int row, int column) { |
472 |
return false; |
473 |
} |
474 |
}; |
475 |
TableSorter sorter = new TableSorter(dtm);
|
476 |
|
477 |
jTable = new JTable(sorter); |
478 |
sorter.setTableHeader(jTable.getTableHeader()); |
479 |
jTable.setCellSelectionEnabled(false);
|
480 |
jTable.setRowSelectionAllowed(true);
|
481 |
jTable.setColumnSelectionAllowed(false);
|
482 |
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
483 |
TableColumn column = null; |
484 |
for (int i = 0; i < 5; i++) { |
485 |
column = jTable.getColumnModel().getColumn(i); |
486 |
if (i == 0) { |
487 |
column.setPreferredWidth(40); //code column is shorter |
488 |
}else if (i == 2) { |
489 |
column.setPreferredWidth(80);
|
490 |
} |
491 |
else {
|
492 |
column.setPreferredWidth(160);
|
493 |
} |
494 |
} |
495 |
} |
496 |
return jTable;
|
497 |
|
498 |
} |
499 |
|
500 |
public void setCodeCRS(int code) { |
501 |
codeCRS = code; |
502 |
} |
503 |
|
504 |
public int getCodeCRS() { |
505 |
return codeCRS;
|
506 |
} |
507 |
|
508 |
private JScrollPane getJScrollPane() { |
509 |
if (jScrollPane == null) { |
510 |
jScrollPane = new JScrollPane(); |
511 |
jScrollPane.setPreferredSize(new Dimension(500,150)); |
512 |
jScrollPane.setBorder( |
513 |
BorderFactory.createCompoundBorder(
|
514 |
BorderFactory.createCompoundBorder(
|
515 |
BorderFactory.createTitledBorder(PluginServices.getText(this,"Coordinate Reference Systems")), |
516 |
BorderFactory.createEmptyBorder(5,5,5,5)), |
517 |
jScrollPane.getBorder())); |
518 |
jScrollPane.setViewportView(getJTable()); |
519 |
} |
520 |
return jScrollPane;
|
521 |
} |
522 |
|
523 |
public JButton getInfoCrs() { |
524 |
if(infoCrs == null) { |
525 |
infoCrs = new JButton(); |
526 |
infoCrs.setPreferredSize(new Dimension(75,20)); |
527 |
infoCrs.setText(PluginServices.getText(this,"InfoCrs")); |
528 |
infoCrs.setMnemonic('I');
|
529 |
infoCrs.setEnabled(false);
|
530 |
infoCrs.setToolTipText("Mostrar la informacion del Crs selecionado");
|
531 |
infoCrs.addActionListener(new java.awt.event.ActionListener() {
|
532 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
533 |
infoCrs_actionPerformed(e); |
534 |
} |
535 |
}); |
536 |
} |
537 |
return infoCrs;
|
538 |
} |
539 |
|
540 |
private void infoCrs_actionPerformed(ActionEvent e) { |
541 |
InfoCRSPanel info = new InfoCRSPanel(getProjection());
|
542 |
info.setSize(new Dimension(550,350)); |
543 |
info.setLayout(new GridLayout(0,1)); |
544 |
info.setLayout(new FlowLayout(FlowLayout.LEFT,10,5)); |
545 |
PluginServices.getMDIManager().addWindow(info); |
546 |
} |
547 |
|
548 |
public ICrs getProjection() {
|
549 |
try {
|
550 |
String txt = getWKT();
|
551 |
ICrs crs = new CrsFactory().getCRS(epsg_code, txt);
|
552 |
return crs ;
|
553 |
} catch (CrsException e) {
|
554 |
e.printStackTrace(); |
555 |
} |
556 |
return null; |
557 |
} |
558 |
|
559 |
|
560 |
public void setWKT(){ |
561 |
Epsg2wkt wkt = null;
|
562 |
|
563 |
epsg_code = getCodeCRS(); |
564 |
if (epsg_code != -1){ |
565 |
/*
|
566 |
* ahora que he escogido, recojo toda la informacion que me va a hacer falta
|
567 |
*/
|
568 |
String sentence = "SELECT source_geogcrs_code, projection_conv_code, " + |
569 |
"coord_ref_sys_kind, datum_code " +
|
570 |
"FROM epsg_coordinatereferencesystem " +
|
571 |
"WHERE coord_ref_sys_code = "+ epsg_code ;
|
572 |
ResultSet result = Query.select(sentence,connect.getConnection()); |
573 |
|
574 |
try {
|
575 |
result.next(); |
576 |
source_cod = result.getInt("source_geogcrs_code");
|
577 |
projection_conv_code = result.getInt("projection_conv_code");
|
578 |
crs_kind = result.getString("coord_ref_sys_kind");
|
579 |
datum_code = result.getInt("datum_code");
|
580 |
} catch (SQLException e1) { |
581 |
e1.printStackTrace(); |
582 |
} |
583 |
|
584 |
if (datum_code != 0){ |
585 |
source_yn = true;
|
586 |
GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, connect);
|
587 |
ep.Getepsgdata(); |
588 |
} |
589 |
else if (source_cod != 0){ |
590 |
source_yn = false;
|
591 |
} |
592 |
else source_yn = true; |
593 |
|
594 |
GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, connect);
|
595 |
ep.Getepsgdata(); |
596 |
|
597 |
if (crs_kind.equals("geographic 2D") || crs_kind.equals("geographic 3D")){ |
598 |
wkt = new Epsg2wkt(ep , "geog"); |
599 |
} |
600 |
else if (crs_kind.equals("projected")){ |
601 |
wkt = new Epsg2wkt(ep, "proj"); |
602 |
} |
603 |
else if (crs_kind.equals("compound")){ |
604 |
wkt = new Epsg2wkt(ep,"comp"); |
605 |
} |
606 |
else if (crs_kind.equals("geocentric")){ |
607 |
wkt = new Epsg2wkt(ep,"geoc"); |
608 |
} |
609 |
} |
610 |
else {
|
611 |
JOptionPane.showMessageDialog(this, |
612 |
"No CRS selected.",
|
613 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
614 |
|
615 |
} |
616 |
cadWKT = wkt.getWKT(); |
617 |
} |
618 |
|
619 |
public String getWKT(){ |
620 |
return cadWKT;
|
621 |
} |
622 |
|
623 |
public void setProjection(IProjection crs) { |
624 |
//setCrs((ICrs) crs);
|
625 |
} |
626 |
|
627 |
} |