Statistics
| Revision:

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

History | View | Annotate | Download (19.4 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
                                /*
345
                                 * Aqui tengo que meter el codigo necesario para que se seleccione
346
                                 * la primera fila ya que me he asegurado de que no esta vacia
347
                                 * y tengo que seleccionar la primera fila.
348
                                 */
349
                        }
350
                }                
351
        }        
352
        
353
        /*
354
         * metodo auxiliar que hara la comprobacion de si el CRS buscado pertenecera
355
         * a los no soportados por proj4
356
         */
357
        private boolean notValid(String kind){                
358
                for (int i = 0; i< not_soported_crs.length; i++){
359
                        if (kind.equals(not_soported_crs[i])){
360
                                return true;
361
                        }
362
                }
363
                return false;
364
        }
365
        
366
        /*
367
         * Metodo que comprueba si el CRS buscado pertenece a algun tipo de los que soporta
368
         * la aplicacion
369
         */
370
        private boolean valid(String kind){                
371
                for (int i = 0; i< soported_crs.length; i++){
372
                        if (kind.equals(soported_crs[i])){
373
                                return true;
374
                        }
375
                }
376
                return false;
377
        }
378
        
379
        /*
380
         * metodo auxiliar que nos servira para comprobar si la proyeccion del CRS seleccionado
381
         * esta entre las 16 con las que trabaja proj4
382
         */
383
        private boolean validCRS(int projection_conv_code2) {
384
                if (projection_conv_code2 == 0) return true;
385
                String sentence = "SELECT coord_op_method_code " +
386
                                                        "FROM epsg_coordoperation " +
387
                                                        "WHERE coord_op_code = " + projection_conv_code;
388
                ResultSet result = Query.select(sentence,connect.getConnection());
389
                try {
390
                        while (result.next()){
391
                                method_code = result.getInt("coord_op_method_code");
392
                        }
393
                } catch (SQLException e) {
394
                        e.printStackTrace();
395
                }
396
                
397
                for (int i = 0; i< valid_method_code.length; i++){
398
                        if (method_code == valid_method_code[i] ){
399
                                return true;
400
                        }
401
                }                
402
                return false;
403
        }
404

    
405

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

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

    
463
                        public void keyTyped(KeyEvent arg0) {
464
                        }
465
                });
466
                return searchTextField;
467
        }
468
        
469
        public JTable getJTable() {
470
                if (jTable == null) {
471
                        String[] columnNames= {"Code of CRS","Name of CRS","Type of CRS","Name of Area","Description of Area"};
472
                        Object[][]data = {};                        
473
                        dtm = new DefaultTableModel(data, columnNames);
474
                        TableSorter sorter = new TableSorter(dtm);                        
475

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

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

    
634
}