svn-gvsig-desktop / branches / v02_desarrollo / libraries / libCq CMS for java.old / src / org / cresques / ui / cts / CSSelectionModel.java @ 1527
History | View | Annotate | Download (4.64 KB)
1 |
/*
|
---|---|
2 |
* Created on 24-ene-2005
|
3 |
*/
|
4 |
package org.cresques.ui.cts; |
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 NONE = 0x01; |
14 |
public static int GEODETIC = 0x02; |
15 |
public static int TRANSVERSAL = 0x03; |
16 |
|
17 |
public String [] datumList = { |
18 |
"WGS 84", "European 1950", "Datum 73", |
19 |
"North American Datum 1927",
|
20 |
"North American Datum 1983"/*, |
21 |
"Nouvelle Triangulation Francaise",
|
22 |
*/};
|
23 |
private String [] projList = { |
24 |
"Geodesica", "(UTM) Universal Transversal Mercator", |
25 |
"Datum 73 / Modified Portuguese Grid", "WGS 84 / LCC Canada", |
26 |
"NAD83 / NRCan LCC Canada"};
|
27 |
private int [] projType = {GEODETIC, TRANSVERSAL, NONE, NONE, NONE}; |
28 |
private String [] huseList = {}; |
29 |
private int selectedDatum = 0, selectedProj = 0, selectedHuse = 0; |
30 |
/**
|
31 |
*
|
32 |
*/
|
33 |
public CSSelectionModel() {
|
34 |
super();
|
35 |
huseList = new String[60]; |
36 |
for (int i=1; i<=60; i++) |
37 |
huseList[i-1] = "Huso "+Integer.toString(i); |
38 |
|
39 |
} |
40 |
|
41 |
public String [] getDatumList() { return datumList; } |
42 |
|
43 |
public String [] getProjectionList() { return projList; } |
44 |
|
45 |
public String [] getHuseList() { return huseList; } |
46 |
|
47 |
public void setSelectedDatum(int opNr) { selectedDatum = opNr; } |
48 |
public void setSelectedDatum(Object item) { |
49 |
String [] list = datumList; |
50 |
for (int i=0; i<list.length; i++) |
51 |
if (list[i].compareTo((String) item) == 0) |
52 |
selectedDatum = i; |
53 |
} |
54 |
public int getSelectedDatum() { return selectedDatum; } |
55 |
|
56 |
public void setSelectedProj(int opNr) { selectedProj = opNr; } |
57 |
public void setSelectedProj(Object item) { |
58 |
String [] list = projList; |
59 |
for (int i=0; i<list.length; i++) |
60 |
if (list[i].compareTo((String) item) == 0) |
61 |
selectedProj = i; |
62 |
} |
63 |
public int getSelectedProj() { return selectedProj; } |
64 |
public int getSelectedProjType() { return projType[selectedProj]; } |
65 |
|
66 |
public void setSelectedHuse(int opNr) { selectedHuse = opNr; } |
67 |
public void setSelectedHuse(Object item) { |
68 |
String [] list = huseList; |
69 |
for (int i=0; i<list.length; i++) |
70 |
if (list[i].compareTo((String) item) == 0) |
71 |
selectedHuse = i; |
72 |
} |
73 |
public int getSelectedHuse() { return selectedHuse; } |
74 |
|
75 |
public void setProjection(IProjection proj) { |
76 |
String key = proj.getAbrev();
|
77 |
key = key.substring(key.length()-5);
|
78 |
if (key.endsWith(":4326")) { |
79 |
setSelectedDatum(0);
|
80 |
setSelectedProj(0);
|
81 |
setSelectedHuse(-1);
|
82 |
} else if (key.endsWith(":4230")) { |
83 |
setSelectedDatum(1);
|
84 |
setSelectedProj(0);
|
85 |
setSelectedHuse(-1);
|
86 |
} else if (key.endsWith(":4267")) { |
87 |
setSelectedDatum(2);
|
88 |
setSelectedProj(0);
|
89 |
setSelectedHuse(-1);
|
90 |
} else if (key.endsWith(":4269")) { |
91 |
setSelectedDatum(3);
|
92 |
setSelectedProj(0);
|
93 |
setSelectedHuse(-1);
|
94 |
} else if (key.startsWith("326")) { |
95 |
setSelectedDatum(0);
|
96 |
setSelectedProj(1);
|
97 |
setSelectedHuse(Integer.parseInt(key.substring(3))-1); |
98 |
} else if (key.startsWith("230")) { |
99 |
setSelectedDatum(1);
|
100 |
setSelectedProj(1);
|
101 |
setSelectedHuse(Integer.parseInt(key.substring(3))-1); |
102 |
} else if (key.startsWith("267")) { |
103 |
setSelectedDatum(2);
|
104 |
setSelectedProj(1);
|
105 |
setSelectedHuse(Integer.parseInt(key.substring(3))-1); |
106 |
} else if (key.startsWith("269")) { |
107 |
setSelectedDatum(3);
|
108 |
setSelectedProj(1);
|
109 |
setSelectedHuse(Integer.parseInt(key.substring(3))-1); |
110 |
} else if (key.startsWith("27492")) { // Datum 73 / Modified Portuguese Grid |
111 |
setSelectedDatum(-1);
|
112 |
setSelectedProj(2);
|
113 |
setSelectedHuse(-1);
|
114 |
} else if (key.startsWith("42101")) { // WGS 84 / LCC Canada |
115 |
setSelectedDatum(-1);
|
116 |
setSelectedProj(3);
|
117 |
setSelectedHuse(-1);
|
118 |
} else if (key.startsWith("42304")) { // NAD83 / / LCC Canada |
119 |
setSelectedDatum(-1);
|
120 |
setSelectedProj(4);
|
121 |
setSelectedHuse(-1);
|
122 |
} else
|
123 |
System.err.println("CAGADA EN EL PARSING DE LA PROYECCION: "+key); |
124 |
} |
125 |
|
126 |
public IProjection getProjection() {
|
127 |
if (selectedProj == 2) { |
128 |
return ProjectionPool.get("EPSG:27492"); |
129 |
} else if (selectedProj == 3) { |
130 |
return ProjectionPool.get("EPSG:42101"); |
131 |
} else if (selectedProj == 4) { |
132 |
return ProjectionPool.get("EPSG:42304"); |
133 |
} |
134 |
IProjection proj = null;
|
135 |
String datum= "326"; |
136 |
if (selectedDatum == 0) |
137 |
datum = "326";
|
138 |
else if (selectedDatum == 1) |
139 |
datum = "230";
|
140 |
else if (selectedDatum == 2) |
141 |
datum = "267";
|
142 |
else if (selectedDatum == 3) |
143 |
datum = "269";
|
144 |
if (selectedProj == 0) { |
145 |
return ProjectionPool.get("EPSG:4"+datum); |
146 |
} else if (selectedProj == 1) { |
147 |
String huse = Integer.toString(selectedHuse+1); |
148 |
if (selectedHuse < 9) huse = "0"+huse; |
149 |
if (selectedDatum == 2 || selectedDatum == 3) { |
150 |
if (selectedHuse < 3) huse = "03"; |
151 |
if (selectedHuse > 23) huse = "23"; |
152 |
} |
153 |
return ProjectionPool.get("EPSG:"+datum+huse); |
154 |
} |
155 |
return proj;
|
156 |
} |
157 |
|
158 |
} |