Statistics
| Revision:

root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / panels / EPSGpanel.java @ 7732

History | View | Annotate | Download (19.7 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
        
51
        
52
        String cadWKT = "";
53
        
54
        int transf = 0;
55
        public int epsg_code  = 0;
56
        boolean source_yn = false;
57
        int source_cod = 0;
58
        int method_code = 0;
59
        int datum_code = 0;
60
        int projection_conv_code = 0;
61
        String crs_kind = null;
62
        int[] valid_method_code = {9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, 
63
                        9811, 9812, 9813, 9814, 9815, 9816, 9817, 9602, 9659};
64
        boolean select = false;
65
        
66
        String[] soported_crs = {"projected","geographic 2D","geographic 3D", "geocentric"};
67
        String[] not_soported_crs = {"engineering", "vertical", "compound"};
68
        
69
        private JRadioButton codeRadioButton = null;
70
        private JRadioButton nameRadioButton = null;
71
        private JRadioButton areaRadioButton = null;
72
        private JPanel groupRadioButton = null;        
73
        
74
        final static String epsg = "EPSG";
75
        final static String usgs = "USGS";
76
        final static String esri = "ESRI";
77
        
78
        String[] selection = {epsg, usgs, esri, "Nuevo CRS"};
79
        
80
        boolean inAnApplet = true;
81
        
82
        public EpsgConnection connect = null;
83
        
84
        private JButton infoCrs = null;
85
        private JButton searchButton = null;
86
        private JTextField searchTextField = null;
87
        public JTable jTable = null;
88
        private JScrollPane jScrollPane = null;
89
        public DefaultTableModel dtm = null;
90
        public DefaultTableModel dtm2 = null;
91
        public String key;
92
        public int selectedRowTable = -1;
93
        public int selectedRowTable2 = -1;        
94
        
95
        private int codeCRS = -1;        
96
        
97
        TransformationManualPanel manual = null;
98
        
99
        public EPSGpanel(){
100
                
101
                connect = new EpsgConnection();
102
                connect.setConnection();
103
                
104
        }
105
        
106
        public JPanel getJPanelEPSG() {        
107
                if (EPSGpanel == null){
108
                        EPSGpanel = new JPanel();
109
                        EPSGpanel.setLayout(new GridLayout(3,3));
110
                        EPSGpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
111
                                        
112
                        EPSGpanel.add(getGroupRadioButton(), null);                        
113
                        EPSGpanel.add(getSearchButton(), null);
114
                        EPSGpanel.add(getSearchTextField(), null);
115
                        EPSGpanel.add(getInfoCrs(), null);
116
                        EPSGpanel.add(getJScrollPane(), null);                        
117
                }        
118
                return EPSGpanel;
119
        }
120
        
121
        private void codeRadioButton_actionPerformed(ActionEvent e) {
122
                searchTextField.setText("");
123
                nameRadioButton.setSelected(false);
124
                areaRadioButton.setSelected(false);
125
        }
126
            
127
        private JRadioButton getCodeRadioButton() {
128
                if (codeRadioButton == null) {
129
                        codeRadioButton = new JRadioButton();
130
                        codeRadioButton.setText(PluginServices.getText(this,"Por c?digo"));//setText("By Code EPSG");
131
                        codeRadioButton.setSelected(true);
132
                        codeRadioButton.addActionListener(new java.awt.event.ActionListener() { 
133
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
134
                                        codeRadioButton_actionPerformed(e);
135
                                }
136
                        });
137
                }
138
                return codeRadioButton;
139
        }
140
        
141
        private void nameRadioButton_actionPerformed(ActionEvent e) {
142
                searchTextField.setText("");
143
                codeRadioButton.setSelected(false);
144
                areaRadioButton.setSelected(false);
145
        }
146
          
147
        private JRadioButton getNameRadioButton() {
148
                if (nameRadioButton == null) {
149
                        nameRadioButton = new JRadioButton();
150
                        nameRadioButton.setText(PluginServices.getText(this,"Por nombre"));
151
                        nameRadioButton.addActionListener(new java.awt.event.ActionListener() { 
152
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
153
                                        nameRadioButton_actionPerformed(e);
154
                                }
155
                        });
156
                }
157
                return nameRadioButton;
158
        }
159
        
160
        private void areaRadioButton_actionPerformed(ActionEvent e) {
161
                searchTextField.setText("");
162
                codeRadioButton.setSelected(false);
163
                nameRadioButton.setSelected(false);
164
        }
165
  
166
        private JRadioButton getAreaRadioButton() {
167
                if (areaRadioButton == null) {
168
                        areaRadioButton = new JRadioButton();
169
                        areaRadioButton.setText(PluginServices.getText(this,"Por ?rea"));
170
                        areaRadioButton.addActionListener(new java.awt.event.ActionListener() { 
171
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
172
                                        areaRadioButton_actionPerformed(e);
173
                                }
174
                        });
175
                }
176
                return areaRadioButton;
177
        }
178
         
179
        private JPanel getGroupRadioButton() {
180
                if (groupRadioButton == null) {
181
                        groupRadioButton = new JPanel();
182
                        groupRadioButton.setLayout(new GridLayout(1,0));
183
                        groupRadioButton.setPreferredSize(new Dimension(500,30));
184
                        groupRadioButton.add(getLabel());
185
                        groupRadioButton.add(getCodeRadioButton());
186
                        groupRadioButton.add(getNameRadioButton());
187
                        groupRadioButton.add(getAreaRadioButton());
188
                }
189
                return groupRadioButton;
190
        }
191
        
192
        private JLabel getLabel(){
193
                JLabel criterio = new JLabel();
194
                criterio.setPreferredSize(new Dimension(100, 20));
195
                criterio.setText(PluginServices.getText(this, "Criterio de b?squeda: "));
196
                return criterio;
197
        }
198

    
199
        private void searchButton_actionPerformed(ActionEvent e) {
200
                boolean not_valid = false;
201
                searchTextField.setBackground(Color.white);
202
                
203
                if (searchTextField.getText().equals("")) {
204
                        searchTextField.setBackground(new Color(255,204,204));
205
                        JOptionPane.showMessageDialog(this, "Fill the name of CRS.", "Warning...", JOptionPane.WARNING_MESSAGE);
206
                }
207
                
208
                else {
209
            //Eliminar filas en cada nueva bsqueda
210
                        int numRow = dtm.getRowCount();
211
                        while (numRow != 0) {
212
                                numRow = numRow - 1;
213
                                dtm.removeRow(numRow);
214
                        }
215
                        
216
                        //Dependiendo de la opcion se realizada una busqueda
217
                        ResultSet result = null;
218
                        ResultSet result2 = null;
219
                        /*
220
                         * variable que indicara si la busqueda se hace primero en epsg_coordinatereferencesystem
221
                         * o en epsg_area; esto es debido a que HSQLDB no soporta la b?squeda simult?nea en ambas
222
                         * tablas, por lo cual hay que separar la b?squeda
223
                         */
224
                        int bus = 2;                          
225
                        if (codeRadioButton.isSelected()) {
226
                                bus=0;
227
                                key = searchTextField.getText();
228
                                int code = Integer.parseInt(key);
229
                                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " +
230
                                                                  "source_geogcrs_code, projection_conv_code  " +
231
                                                                  "FROM epsg_coordinatereferencesystem " +                                      
232
                                      "WHERE coord_ref_sys_code = " + code;
233
                                result = Query.select(sentence,connect.getConnection());        
234
                        }
235
                        
236
                        else if (nameRadioButton.isSelected()) {
237
                                bus=0;
238
                                key = searchTextField.getText();
239
                                String key2 = key.substring(0,1);
240
                                String key3 = key.substring(1,key.length());
241
                                key2 = key2.toUpperCase();
242
                                
243
                                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, " +
244
                                                                        "area_of_use_code, source_geogcrs_code, projection_conv_code " +
245
                                                                          "FROM epsg_coordinatereferencesystem " +                                      
246
                                                                          "WHERE (coord_ref_sys_name LIKE '%" + key + "%') OR (coord_ref_sys_name LIKE '%"+ 
247
                                                                          key.toUpperCase() +"%') " +
248
                                                                          "OR (coord_ref_sys_name LIKE '%" + key2+key3 +"%')";
249
                                result = Query.select(sentence,connect.getConnection());
250
                        }
251
                        
252
                        else {
253
                                bus=1;
254
                                key = searchTextField.getText();
255
                                String key2 = key.substring(0,1);
256
                                String key3 = key.substring(1,key.length());
257
                                key2 = key2.toUpperCase();                                
258
                                
259
                                String sentence = "SELECT area_name, area_of_use, area_code " +
260
                                      "FROM epsg_area " +
261
                                      "WHERE (area_name LIKE '%" + key + "%') OR (area_of_use LIKE '%" + key + "%') "+
262
                                      "OR (area_name LIKE '%" + key.toUpperCase() + "%') OR (area_of_use LIKE '%" + key.toUpperCase() + "%') "+
263
                                      "OR (area_name LIKE '%" + key2+key3 + "%') OR (area_of_use LIKE '%" + key2+key3 + "%') ";
264
                                result = Query.select(sentence,connect.getConnection());                                
265
                        }
266
                        
267
                        if (bus==0){
268
                                try {
269
                                        while(result.next()) {
270
                                                Object[]data = new Object[5];
271
                                                data[0] = String.valueOf(result.getInt("coord_ref_sys_code"));
272
                                                data[1] = result.getString("coord_ref_sys_name");
273
                                                crs_kind = result.getString("coord_ref_sys_kind");
274
                                                data[2] = crs_kind;
275
                                                projection_conv_code = result.getInt("projection_conv_code");
276
                                                
277
                                                int area_of_use_code = Integer.parseInt(result.getString("area_of_use_code"));
278
                                                                                
279
                                                String sentence = "SELECT area_name, area_of_use FROM epsg_area " +
280
                                                                                "WHERE area_code = "+ area_of_use_code ;
281
                                                
282
                                                result2 = Query.select(sentence,connect.getConnection());
283
                                                while(result2.next()){
284
                                                        data[3] = result2.getString("area_name");
285
                                                        data[4] = result2.getString("area_of_use");                                        
286
                                                }
287
                                                if (data[0]!=null && validCRS(projection_conv_code) && valid(crs_kind)){
288
                                                        dtm.addRow(data);
289
                                                }
290
                                        }
291
                                }
292
                                
293
                                catch (SQLException e1) {
294
                                        e1.printStackTrace();
295
                                }
296
                        }
297
                        else if (bus==1){
298
                                try {
299
                                        while(result.next()) {
300
                                                Object[]data = new Object[5];
301
                                                data[3] = result.getString("area_name");
302
                                                data[4] = result.getString("area_of_use");        
303
                                                                                        
304
                                                int area_of_use_code = Integer.parseInt(result.getString("area_code"));
305
                                                                                
306
                                                String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, " +
307
                                                                                "coord_ref_sys_kind, source_geogcrs_code, projection_conv_code " +
308
                                                                                "FROM epsg_coordinatereferencesystem " +
309
                                                                                "WHERE area_of_use_code = "+ area_of_use_code ;
310
                                                
311
                                                result2 = Query.select(sentence,connect.getConnection());
312
                                                while(result2.next()){
313
                                                        data[0] = String.valueOf(result2.getInt("coord_ref_sys_code"));
314
                                                        data[1] = result2.getString("coord_ref_sys_name");
315
                                                        data[2] = result2.getString("coord_ref_sys_kind");
316
                                                        crs_kind = (String)data[2];
317
                                                        projection_conv_code = result2.getInt("projection_conv_code");
318
                                                                                
319
                                                }
320
                                                /*
321
                                                 * Buscaremos solo aquellos CRS cuyas proyecciones esten entre las
322
                                                 * 16 soportadas por proj4 para ello creamos un metodo para validar
323
                                                 * si esta entre estas proyecciones
324
                                                 */                                                
325
                                                if (data[0]!=null && validCRS(projection_conv_code) && valid(crs_kind)){
326
                                                        dtm.addRow(data);
327
                                                }        
328
                                                if (notValid(crs_kind)){
329
                                                        not_valid = true;
330
                                                }
331
                                        }
332
                                } 
333
                                
334
                                catch (SQLException e1) {
335
                                        e1.printStackTrace();
336
                                }
337
                        }
338
                        int numr = dtm.getRowCount();
339
                        if (not_valid){
340
                                JOptionPane.showMessageDialog(this, "Algunos CRS no son v?lidos, no ser?n mostrados.", "Warning...",
341
                                                JOptionPane.WARNING_MESSAGE);
342
                                not_valid = false;
343
                        }
344
                        else if (numr == 0 ){
345
                        JOptionPane.showMessageDialog(this, "Not Results found.", "Warning...",
346
                                        JOptionPane.WARNING_MESSAGE);
347
                        }
348
                        else{
349
                                this.getJTable().setRowSelectionInterval(0,0);
350
                                /*
351
                                 * Aqui tengo que meter el codigo necesario para que se seleccione
352
                                 * la primera fila ya que me he asegurado de que no esta vacia
353
                                 * y tengo que seleccionar la primera fila.
354
                                 */
355
                        }
356
                }                
357
        }        
358
        
359
        /*
360
         * metodo auxiliar que hara la comprobacion de si el CRS buscado pertenecera
361
         * a los no soportados por proj4
362
         */
363
        private boolean notValid(String kind){                
364
                for (int i = 0; i< not_soported_crs.length; i++){
365
                        if (kind.equals(not_soported_crs[i])){
366
                                return true;
367
                        }
368
                }
369
                return false;
370
        }
371
        
372
        /*
373
         * Metodo que comprueba si el CRS buscado pertenece a algun tipo de los que soporta
374
         * la aplicacion
375
         */
376
        private boolean valid(String kind){                
377
                for (int i = 0; i< soported_crs.length; i++){
378
                        if (kind.equals(soported_crs[i])){
379
                                return true;
380
                        }
381
                }
382
                return false;
383
        }
384
        
385
        /*
386
         * metodo auxiliar que nos servira para comprobar si la proyeccion del CRS seleccionado
387
         * esta entre las 16 con las que trabaja proj4
388
         */
389
        private boolean validCRS(int projection_conv_code2) {
390
                if (projection_conv_code2 == 0) return true;
391
                String sentence = "SELECT coord_op_method_code " +
392
                                                        "FROM epsg_coordoperation " +
393
                                                        "WHERE coord_op_code = " + projection_conv_code;
394
                ResultSet result = Query.select(sentence,connect.getConnection());
395
                try {
396
                        while (result.next()){
397
                                method_code = result.getInt("coord_op_method_code");
398
                        }
399
                } catch (SQLException e) {
400
                        e.printStackTrace();
401
                }
402
                
403
                for (int i = 0; i< valid_method_code.length; i++){
404
                        if (method_code == valid_method_code[i] ){
405
                                return true;
406
                        }
407
                }                
408
                return false;
409
        }
410

    
411

    
412
        private JButton getSearchButton() {
413
                if (searchButton == null) {
414
                        searchButton = new JButton();
415
                        searchButton.setPreferredSize(new Dimension(75,20));
416
                        searchButton.setText(PluginServices.getText(this,"Buscar"));
417
                        searchButton.setMnemonic('S');
418
                        searchButton.setToolTipText("Search of a CRS by selected criterion");
419
                        searchButton.addActionListener(new java.awt.event.ActionListener() { 
420
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
421
                                        searchTextField.setBackground(Color.white);
422
                                        if (searchTextField.getText().equals("")) {
423
                                                searchTextField.setBackground(new Color(255,204,204));
424
                                                JOptionPane.showMessageDialog(EPSGpanel.this, 
425
                                                                "Fill the key-word of the search.", 
426
                                                                "Warning...", JOptionPane.WARNING_MESSAGE);
427
                                        }
428
                                        else {
429
                                                searchButton_actionPerformed(e);
430
                                        }
431
                                }
432
                        });                        
433
                }
434
                return searchButton;
435
        }        
436
        
437
        private JTextField getSearchTextField() {
438
                if (searchTextField == null) {
439
                        searchTextField = new JTextField();
440
                        searchTextField.setPreferredSize(new Dimension(300,20));
441
                }
442
                searchTextField.addKeyListener(new KeyListener() {
443
                        public void keyPressed(KeyEvent e) {                                
444
                                if (e.getKeyCode() == 10) {
445
                                        searchButton_actionPerformed(null);
446
                                }
447
                                if (codeRadioButton.isSelected()){
448
                                        if ((e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || 
449
                                                        (e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){                                                
450
                                        }
451
                                        else {
452
                                                JOptionPane.showMessageDialog(EPSGpanel.this, 
453
                                                                "Only number format.", 
454
                                                                "Warning...", JOptionPane.WARNING_MESSAGE);
455
                                                String aux = searchTextField.getText();
456
                                                if (aux.length() == 1){
457
                                                        searchTextField.setText("");
458
                                                }
459
                                                else {
460
                                                        searchTextField.setText(aux.substring(0, aux.length()-1));
461
                                                }
462
                                        }
463
                                }
464
                        }
465

    
466
                        public void keyReleased(KeyEvent arg0) {                                
467
                        }
468

    
469
                        public void keyTyped(KeyEvent arg0) {
470
                        }
471
                });
472
                return searchTextField;
473
        }
474
        
475
        public JTable getJTable() {
476
                if (jTable == null) {
477
                        String[] columnNames= {"Code of CRS","Name of CRS","Type of CRS","Name of Area","Description of Area"};
478
                        Object[][]data = {};                        
479
                        dtm = new DefaultTableModel(data, columnNames)
480
                         {
481
                                public boolean isCellEditable(int row, int column) {
482
                                        return false;
483
                                }
484
                                };
485
                        TableSorter sorter = new TableSorter(dtm);                        
486

    
487
                        jTable = new JTable(sorter);
488
                        sorter.setTableHeader(jTable.getTableHeader());                        
489
                        jTable.setCellSelectionEnabled(false);
490
                        jTable.setRowSelectionAllowed(true);
491
                        jTable.setColumnSelectionAllowed(false);
492
                        jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
493
                        TableColumn column = null;
494
                        for (int i = 0; i < 5; i++) {
495
                            column = jTable.getColumnModel().getColumn(i);
496
                            if (i == 0) {
497
                                column.setPreferredWidth(40); //code column is shorter                                     
498
                            }else if (i == 2) {
499
                                    column.setPreferredWidth(80);
500
                            }
501
                            else {                            
502
                                column.setPreferredWidth(160);
503
                            }
504
                        }                        
505
        }
506
                return jTable;
507
                
508
        }
509
        
510
        public void setCodeCRS(int code) {
511
                codeCRS = code;
512
        }
513
        
514
        public int getCodeCRS() {
515
                return codeCRS;
516
        }        
517
        
518
        private JScrollPane getJScrollPane() {
519
                if (jScrollPane == null) {
520
                        jScrollPane = new JScrollPane();
521
                        jScrollPane.setPreferredSize(new Dimension(500,150));
522
                        jScrollPane.setBorder(
523
                                    BorderFactory.createCompoundBorder(
524
                                        BorderFactory.createCompoundBorder(
525
                                                        BorderFactory.createTitledBorder(PluginServices.getText(this,"Coordinate Reference Systems")),
526
                                                        BorderFactory.createEmptyBorder(5,5,5,5)),
527
                                                        jScrollPane.getBorder()));
528
                        jScrollPane.setViewportView(getJTable());
529
                }
530
                return jScrollPane;
531
        }
532
        
533
        public JButton getInfoCrs() {
534
                if(infoCrs == null) {
535
                        infoCrs = new JButton();
536
                        infoCrs.setPreferredSize(new Dimension(75,20));
537
                        infoCrs.setText(PluginServices.getText(this,"InfoCrs"));                        
538
                        infoCrs.setMnemonic('I');
539
                        infoCrs.setEnabled(false);
540
                        infoCrs.setToolTipText("Mostrar la informacion del Crs selecionado");
541
                        infoCrs.addActionListener(new java.awt.event.ActionListener() { 
542
                                public void actionPerformed(java.awt.event.ActionEvent e) {    
543
                                        infoCrs_actionPerformed(e);                
544
                                }        
545
                        });
546
                }
547
                return infoCrs;
548
        }
549
        
550
        private void infoCrs_actionPerformed(ActionEvent e) {
551
                InfoCRSPanel info = new InfoCRSPanel(getProjection());
552
                info.setSize(new Dimension(550,350));
553
                info.setLayout(new GridLayout(0,1));
554
                info.setLayout(new FlowLayout(FlowLayout.LEFT,10,5));
555
                PluginServices.getMDIManager().addWindow(info);
556
        }
557
        
558
        public ICrs getProjection() {
559
                try {
560
                        String txt = getWKT();                        
561
                        ICrs crs = new CrsFactory().getCRS(epsg_code, txt); 
562
                        return crs ;
563
                } catch (CrsException e) {
564
                        e.printStackTrace();
565
                }
566
                return null;
567
        }
568
        
569
        
570
        public void setWKT(){
571
                Epsg2wkt wkt = null;
572
                
573
                /*String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " +
574
                  "source_geogcrs_code, projection_conv_code  " +
575
                  "FROM epsg_coordinatereferencesystem " +                                      
576
        "WHERE coord_ref_sys_code = " + code;
577
        
578
        result = Query.select(sentence,connect.getConnection());        */
579

    
580
                
581
                epsg_code = getCodeCRS();
582
                if (epsg_code != -1){                
583
                        /*
584
                         * ahora que he escogido, recojo toda la informacion que me va a hacer falta
585
                         */
586
                        String sentence = "SELECT source_geogcrs_code, projection_conv_code, " +
587
                                        "coord_ref_sys_kind, datum_code " +
588
                                                        "FROM epsg_coordinatereferencesystem " +
589
                                                        "WHERE coord_ref_sys_code = "+ epsg_code ;
590
                        ResultSet result = Query.select(sentence,connect.getConnection());
591
                        
592
                        try {
593
                                result.next();
594
                                source_cod = result.getInt("source_geogcrs_code");
595
                                projection_conv_code = result.getInt("projection_conv_code");
596
                                crs_kind = result.getString("coord_ref_sys_kind");
597
                                datum_code = result.getInt("datum_code");
598
                        } catch (SQLException e1) {
599
                                e1.printStackTrace();
600
                        }
601
                        
602
                        if (datum_code != 0){
603
                                source_yn = true;
604
                                GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, connect);
605
                                ep.Getepsgdata();
606
                        }
607
                        else if (source_cod != 0){
608
                                source_yn = false;
609
                        }
610
                        else source_yn = true;
611
                        
612
                        GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, connect);
613
                        ep.Getepsgdata();
614
                        
615
                        if (crs_kind.equals("geographic 2D") || crs_kind.equals("geographic 3D")){
616
                                wkt = new Epsg2wkt(ep , "geog");                        
617
                        }
618
                        else if (crs_kind.equals("projected")){
619
                                wkt = new Epsg2wkt(ep, "proj");
620
                        }
621
                        else if (crs_kind.equals("compound")){
622
                                wkt = new Epsg2wkt(ep,"comp");
623
                        }
624
                        else if (crs_kind.equals("geocentric")){
625
                                wkt = new Epsg2wkt(ep,"geoc");
626
                        }
627
                }
628
                else {
629
                        JOptionPane.showMessageDialog(this, 
630
                                        "No CRS selected.", 
631
                                        "Warning...", JOptionPane.WARNING_MESSAGE);
632
                        
633
                }
634
                cadWKT = wkt.getWKT();
635
        }
636
        
637
        public String getWKT(){
638
                return cadWKT;
639
        }
640
        
641
        public void setProjection(IProjection crs) {
642
                //setCrs((ICrs) crs);
643
        }
644

    
645
}