Statistics
| Revision:

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

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

    
406

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

    
461
                        public void keyReleased(KeyEvent arg0) {                                
462
                        }
463

    
464
                        public void keyTyped(KeyEvent arg0) {
465
                        }
466
                });
467
                return searchTextField;
468
        }
469
        
470
        public JTable getJTable() {
471
                if (jTable == null) {
472
                        String[] columnNames= {"Code of CRS","Name of CRS","Type of CRS","Name of Area","Description of Area"};
473
                        Object[][]data = {};                        
474
                        dtm = new DefaultTableModel(data, columnNames);
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
                /*String sentence = "SELECT coord_ref_sys_code, coord_ref_sys_name, coord_ref_sys_kind, area_of_use_code, " +
564
                  "source_geogcrs_code, projection_conv_code  " +
565
                  "FROM epsg_coordinatereferencesystem " +                                      
566
        "WHERE coord_ref_sys_code = " + code;
567
        
568
        result = Query.select(sentence,connect.getConnection());        */
569

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

    
635
}