svn-gvsig-desktop / branches / v02_desarrollo / libraries / libCq CMS for java.old / src / org / cresques / ui / CSSelectionModel.java @ 1229
History | View | Annotate | Download (3.07 KB)
1 |
/*
|
---|---|
2 |
* Created on 24-ene-2005
|
3 |
*/
|
4 |
package org.cresques.ui; |
5 |
|
6 |
import org.cresques.cts.IProjection; |
7 |
import org.cresques.cts.ProjectionPool; |
8 |
|
9 |
/**
|
10 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
11 |
*/
|
12 |
public class CSSelectionModel { |
13 |
public static int GEODETIC = 0x01; |
14 |
public static int TRANSVERSAL = 0x02; |
15 |
|
16 |
public String [] datumList = { |
17 |
"WGS 84", "European 1950"/*, "Datum 73", |
18 |
"Nouvelle Triangulation Francaise",
|
19 |
"North American Datum 1927"*/};
|
20 |
private String [] projList = { |
21 |
"Geodesica", "(UTM) Universal Transversal Mercator"}; |
22 |
private int [] projType = {GEODETIC, TRANSVERSAL}; |
23 |
private String [] huseList = {}; |
24 |
private int selectedDatum = 0, selectedProj = 0, selectedHuse = 0; |
25 |
/**
|
26 |
*
|
27 |
*/
|
28 |
public CSSelectionModel() {
|
29 |
super();
|
30 |
huseList = new String[60]; |
31 |
for (int i=1; i<=60; i++) |
32 |
huseList[i-1] = "Huso "+Integer.toString(i); |
33 |
|
34 |
} |
35 |
|
36 |
public String [] getDatumList() { return datumList; } |
37 |
|
38 |
public String [] getProjectionList() { return projList; } |
39 |
|
40 |
public String [] getHuseList() { return huseList; } |
41 |
|
42 |
public void setSelectedDatum(int opNr) { selectedDatum = opNr; } |
43 |
public void setSelectedDatum(Object item) { |
44 |
String [] list = datumList; |
45 |
for (int i=0; i<list.length; i++) |
46 |
if (list[i].compareTo((String) item) == 0) |
47 |
selectedDatum = i; |
48 |
} |
49 |
public int getSelectedDatum() { return selectedDatum; } |
50 |
|
51 |
public void setSelectedProj(int opNr) { selectedProj = opNr; } |
52 |
public void setSelectedProj(Object item) { |
53 |
String [] list = projList; |
54 |
for (int i=0; i<list.length; i++) |
55 |
if (list[i].compareTo((String) item) == 0) |
56 |
selectedProj = i; |
57 |
} |
58 |
public int getSelectedProj() { return selectedProj; } |
59 |
public int getSelectedProjType() { return projType[selectedProj]; } |
60 |
|
61 |
public void setSelectedHuse(int opNr) { selectedHuse = opNr; } |
62 |
public void setSelectedHuse(Object item) { |
63 |
String [] list = huseList; |
64 |
for (int i=0; i<list.length; i++) |
65 |
if (list[i].compareTo((String) item) == 0) |
66 |
selectedHuse = i; |
67 |
} |
68 |
public int getSelectedHuse() { return selectedHuse; } |
69 |
|
70 |
public void setProjection(IProjection proj) { |
71 |
String key = proj.getAbrev();
|
72 |
key = key.substring(key.length()-5);
|
73 |
if (key.endsWith(":4326")) { |
74 |
setSelectedDatum(0);
|
75 |
setSelectedProj(0);
|
76 |
setSelectedHuse(-1);
|
77 |
} else if (key.endsWith(":4230")) { |
78 |
setSelectedDatum(1);
|
79 |
setSelectedProj(0);
|
80 |
setSelectedHuse(-1);
|
81 |
} else if (key.startsWith("326")) { |
82 |
setSelectedDatum(0);
|
83 |
setSelectedProj(1);
|
84 |
setSelectedHuse(Integer.parseInt(key.substring(3))-1); |
85 |
} else if (key.startsWith("230")) { |
86 |
setSelectedDatum(1);
|
87 |
setSelectedProj(1);
|
88 |
setSelectedHuse(Integer.parseInt(key.substring(3))-1); |
89 |
} else
|
90 |
System.err.println("CAGADA EN EL PARSING DE LA PROYECCION: "+key); |
91 |
} |
92 |
|
93 |
public IProjection getProjection() {
|
94 |
IProjection proj = null;
|
95 |
String datum;
|
96 |
if (selectedDatum == 0) |
97 |
datum = "326";
|
98 |
else
|
99 |
datum = "230";
|
100 |
if (selectedProj == 0) { |
101 |
return ProjectionPool.get("EPSG:4"+datum); |
102 |
} else if (selectedProj == 1) { |
103 |
String huse = Integer.toString(selectedHuse+1); |
104 |
if (selectedHuse < 9) huse = "0"+huse; |
105 |
return ProjectionPool.get("EPSG:"+datum+huse); |
106 |
} |
107 |
return proj;
|
108 |
} |
109 |
|
110 |
} |