Statistics
| Revision:

root / trunk / libraries / libJCRS / src / org / gvsig / crs / CrsFactory.java @ 7735

History | View | Annotate | Download (1.93 KB)

1
package org.gvsig.crs;
2

    
3
import java.util.TreeMap;
4

    
5
import org.cresques.cts.ICRSFactory;
6
import org.cresques.cts.IProjection;
7
import org.gvsig.crs.gui.panels.ProjChooserPanel;
8

    
9
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel;
10
import com.iver.cit.gvsig.project.Project;
11

    
12
public class CrsFactory implements ICRSFactory {
13
        static TreeMap data = new TreeMap();
14
        
15
        static {
16
                CRSSelectPanel.registerPanelClass(ProjChooserPanel.class);
17
                try {
18
                        Project.setDefaultProjection(new CrsFactory().getCRS("EPSG:23030"));
19
                } catch (CrsException e) {
20
                        // TODO Auto-generated catch block
21
                        e.printStackTrace();
22
                }
23
        }
24
        public CrsFactory() {        
25
        }
26
        /**
27
         * Obtiene un CRS a partir de su c?digo (p.e. EPSG:23030).
28
         * @param code
29
         * @return
30
         * @throws CrsException
31
         */
32
        public ICrs getCRS(String code) throws CrsException {
33
                if (data.containsKey(code))
34
                        return (Crs) data.get(code);
35

    
36
                Crs crs = new Crs(code);
37
                
38
                // LWS Esta l?nea sobra, cuando el cuadro de di?logo est?
39
                // mejor hecho.
40
                code = crs.getAbrev();
41
                
42
                data.put(code, crs);
43

    
44
                return crs;
45
        }
46
        
47
        public ICrs getCRS(int epsg_code, String code) throws CrsException {
48
                if (data.containsKey(code))
49
                        return (Crs) data.get(code);
50

    
51
                Crs crs = new Crs(epsg_code, code);
52
                
53
                // LWS Esta l?nea sobra, cuando el cuadro de di?logo est?
54
                // mejor hecho.
55
                code = crs.getAbrev();
56
                
57
                data.put(code, crs);
58

    
59
                return crs;
60
        }
61
        
62
        public ICrs getCRS(int epsg_code, String code, String params) throws CrsException {
63
                if (data.containsKey(code))
64
                        return (Crs) data.get(code);
65
                System.out.println(params);
66
                Crs crs = new Crs(epsg_code, code,params);
67
                
68
                // LWS Esta l?nea sobra, cuando el cuadro de di?logo est?
69
                // mejor hecho.
70
                code = crs.getAbrev();
71
                
72
                data.put(code, crs);
73

    
74
                return crs;
75
        }
76
        public IProjection get(String name) {
77
                // TODO Auto-generated method stub
78
                try {
79
                        return getCRS(name);
80
                } catch (CrsException e) {
81
                        // TODO Auto-generated catch block
82
                        e.printStackTrace();
83
                }
84
                return null;
85
        }
86
}