Revision 35721
tags/v1_11_0_Build_1306/libraries/libJCRS/.cvsignore | ||
---|---|---|
1 |
bin |
|
0 | 2 |
tags/v1_11_0_Build_1306/libraries/libJCRS/.settings/org.eclipse.core.resources.prefs | ||
---|---|---|
1 |
#Tue Jul 25 14:11:17 CEST 2006 |
|
2 |
eclipse.preferences.version=1 |
|
3 |
encoding/<project>=ISO-8859-1 |
|
0 | 4 |
tags/v1_11_0_Build_1306/libraries/libJCRS/.cdtproject | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<?eclipse-cdt version="2.0"?> |
|
3 |
|
|
4 |
<cdtproject/> |
|
0 | 5 |
tags/v1_11_0_Build_1306/libraries/libJCRS/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>libJCRS</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
<buildCommand> |
|
14 |
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> |
|
15 |
<triggers>full,incremental,</triggers> |
|
16 |
<arguments> |
|
17 |
<dictionary> |
|
18 |
<key>LaunchConfigHandle</key> |
|
19 |
<value><project>/.externalToolBuilders/crsgdal build.xml [Builder].launch</value> |
|
20 |
</dictionary> |
|
21 |
</arguments> |
|
22 |
</buildCommand> |
|
23 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
26 |
</natures> |
|
27 |
</projectDescription> |
|
0 | 28 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/es/idr/teledeteccion/connection/EpsgConnection.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package es.idr.teledeteccion.connection; |
|
42 |
|
|
43 |
import java.sql.Connection; |
|
44 |
import java.sql.ResultSet; |
|
45 |
import java.sql.SQLException; |
|
46 |
import java.sql.Statement; |
|
47 |
|
|
48 |
import org.geotools.referencing.factory.epsg.HSQLDataSource; |
|
49 |
import org.hsqldb.jdbc.jdbcDataSource; |
|
50 |
|
|
51 |
/** |
|
52 |
* Clase para la conexi?n con la base de datos de hsqldb. |
|
53 |
* Establece el driver necesario, as? como la cadena de |
|
54 |
* conexi?n a la base de datos de la EPSG y la IAU2000 |
|
55 |
* |
|
56 |
* @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com) |
|
57 |
* |
|
58 |
*/ |
|
59 |
|
|
60 |
public class EpsgConnection extends jdbcDataSource { |
|
61 |
|
|
62 |
Connection connect; |
|
63 |
private static String usrConnectionStr = "jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs/usr"; |
|
64 |
|
|
65 |
public EpsgConnection() { |
|
66 |
/* try { |
|
67 |
Class.forName("org.hsqldb.jdbcDriver"); |
|
68 |
} catch (ClassNotFoundException e) { |
|
69 |
e.printStackTrace(); |
|
70 |
}*/ |
|
71 |
} |
|
72 |
|
|
73 |
public void setConnectionEPSG() { |
|
74 |
HSQLDataSource ds = new HSQLDataSource(); |
|
75 |
|
|
76 |
try { |
|
77 |
connect = ds.getConnection(); |
|
78 |
} catch (SQLException e) { |
|
79 |
// TODO Auto-generated catch block |
|
80 |
e.printStackTrace(); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Establece la conexi?n con la base de datos de la IAU2000 |
|
86 |
* |
|
87 |
*/ |
|
88 |
public void setConnectionIAU2000() { |
|
89 |
setDatabase("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs/iau2000"); |
|
90 |
setUser("sa"); |
|
91 |
try { |
|
92 |
connect = super.getConnection(); |
|
93 |
} catch (SQLException e) { |
|
94 |
// TODO Auto-generated catch block |
|
95 |
e.printStackTrace(); |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Establece la conexi?n con la base de datos de ESRI |
|
101 |
* |
|
102 |
*/ |
|
103 |
public void setConnectionEsri() { |
|
104 |
setDatabase("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs/esri"); |
|
105 |
setUser("sa"); |
|
106 |
try { |
|
107 |
connect = super.getConnection(); |
|
108 |
} catch (SQLException e) { |
|
109 |
// TODO Auto-generated catch block |
|
110 |
e.printStackTrace(); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* Establece la conexi?n con la base de datos de USR |
|
116 |
* |
|
117 |
*/ |
|
118 |
public void setConnectionUsr() { |
|
119 |
setDatabase(usrConnectionStr); |
|
120 |
setUser("sa"); |
|
121 |
try { |
|
122 |
connect = super.getConnection(); |
|
123 |
} catch (SQLException e) { |
|
124 |
e.printStackTrace(); |
|
125 |
if (!usrConnectionStr.endsWith("-ro")) { |
|
126 |
// if the DB is already open, use a ro copy of it |
|
127 |
usrConnectionStr = usrConnectionStr+"-ro"; |
|
128 |
setConnectionUsr(); |
|
129 |
} |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
public Connection getConnection(){ |
|
134 |
return connect; |
|
135 |
} |
|
136 |
|
|
137 |
public void shutdown() throws SQLException { |
|
138 |
|
|
139 |
Statement st = connect.createStatement(); |
|
140 |
|
|
141 |
// db writes out to files and performs clean shuts down |
|
142 |
// otherwise there will be an unclean shutdown |
|
143 |
// when program ends |
|
144 |
st.execute("SHUTDOWN"); |
|
145 |
connect.close(); // if there are no other open connection |
|
146 |
} |
|
147 |
|
|
148 |
public synchronized void update(String expression) throws SQLException { |
|
149 |
|
|
150 |
Statement st = null; |
|
151 |
|
|
152 |
st = connect.createStatement(); // statements |
|
153 |
|
|
154 |
int i = st.executeUpdate(expression); // run the query |
|
155 |
|
|
156 |
if (i == -1) { |
|
157 |
System.out.println("db error : " + expression); |
|
158 |
} |
|
159 |
|
|
160 |
st.close(); |
|
161 |
} |
|
162 |
/* |
|
163 |
*//** |
|
164 |
* Establece la conexi?n con la base de datos de la EPSG |
|
165 |
* |
|
166 |
*//* |
|
167 |
public void setConnectionEPSG() { |
|
168 |
try { |
|
169 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs/db_epsg", "sa", ""); |
|
170 |
} catch (SQLException e1) { |
|
171 |
e1.printStackTrace(); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
*//** |
|
176 |
* Establece la conexi?n con la base de datos de la IAU2000 |
|
177 |
* |
|
178 |
*//* |
|
179 |
public void setConnectionIAU2000() { |
|
180 |
try { |
|
181 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs/db_iau2000", "sa", ""); |
|
182 |
} catch (SQLException e1) { |
|
183 |
e1.printStackTrace(); |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
*//** |
|
188 |
* Establece la conexi?n con la base de datos de ESRI |
|
189 |
* |
|
190 |
*//* |
|
191 |
public void setConnectionEsri() { |
|
192 |
try { |
|
193 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:/home/jlgomez/gvSIGF2/_fwAndami/gvSIG/extensiones/org.gvsig.crs/db_esri", "sa", ""); |
|
194 |
} catch (SQLException e1) { |
|
195 |
e1.printStackTrace(); |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
*//** |
|
200 |
* Establece la conexi?n con la base de datos de USR |
|
201 |
* |
|
202 |
*//* |
|
203 |
public void setConnectionUsr() { |
|
204 |
try { |
|
205 |
connect = DriverManager.getConnection("jdbc:hsqldb:file:gvSIG/extensiones/org.gvsig.crs/db_usr", "sa", ""); |
|
206 |
} catch (SQLException e1) { |
|
207 |
e1.printStackTrace(); |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
public Connection getConnection(){ |
|
212 |
return connect; |
|
213 |
} |
|
214 |
|
|
215 |
public void shutdown() throws SQLException { |
|
216 |
|
|
217 |
Statement st = connect.createStatement(); |
|
218 |
|
|
219 |
// db writes out to files and performs clean shuts down |
|
220 |
// otherwise there will be an unclean shutdown |
|
221 |
// when program ends |
|
222 |
st.execute("SHUTDOWN"); |
|
223 |
connect.close(); // if there are no other open connection |
|
224 |
}*/ |
|
225 |
|
|
226 |
/** |
|
227 |
* Returns {@code true} if the database contains data. This method returns {@code false} |
|
228 |
* if an empty EPSG database has been automatically created by HSQL and not yet populated. |
|
229 |
*/ |
|
230 |
private static boolean dataExists(final Connection connection) throws SQLException { |
|
231 |
final ResultSet tables = connection.getMetaData().getTables( |
|
232 |
null, null, "IAU2000_%", new String[] {"TABLE"}); |
|
233 |
final boolean exists = tables.next(); |
|
234 |
tables.close(); |
|
235 |
return exists; |
|
236 |
} |
|
237 |
} |
|
0 | 238 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/es/idr/teledeteccion/connection/Query.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package es.idr.teledeteccion.connection; |
|
42 |
|
|
43 |
import java.io.Serializable; |
|
44 |
import java.sql.Connection; |
|
45 |
import java.sql.ResultSet; |
|
46 |
import java.sql.ResultSetMetaData; |
|
47 |
import java.sql.SQLException; |
|
48 |
import java.sql.Statement; |
|
49 |
|
|
50 |
/** |
|
51 |
* Clase para realizar las consultas a las bases de datos utilizadas |
|
52 |
* |
|
53 |
* @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com) |
|
54 |
* |
|
55 |
*/ |
|
56 |
public class Query implements Serializable{ |
|
57 |
|
|
58 |
/** |
|
59 |
* |
|
60 |
*/ |
|
61 |
private static final long serialVersionUID = 1L; |
|
62 |
|
|
63 |
/** |
|
64 |
* Acepta la sentencia y la conexi?n a la base de datos actual, |
|
65 |
* realiza una selecci?n y devuelve los datos en un ResultSet |
|
66 |
* @param sentence |
|
67 |
* @param conn |
|
68 |
* @return |
|
69 |
*/ |
|
70 |
public static synchronized ResultSet select(String sentence, Connection conn){ |
|
71 |
Statement st = null; |
|
72 |
ResultSet rs = null; |
|
73 |
|
|
74 |
try { |
|
75 |
st = conn.createStatement(); |
|
76 |
rs = st.executeQuery(sentence); |
|
77 |
st.close(); |
|
78 |
} catch (SQLException e) { |
|
79 |
e.printStackTrace(); |
|
80 |
} |
|
81 |
return rs; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
0 | 85 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/CrsFactory.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha) |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs; |
|
42 |
|
|
43 |
import java.util.TreeMap; |
|
44 |
|
|
45 |
import org.cresques.cts.ICRSFactory; |
|
46 |
import org.cresques.cts.IProjection; |
|
47 |
import org.gvsig.crs.repository.EpsgRepository; |
|
48 |
import org.gvsig.crs.repository.EpsgRepositoryGT; |
|
49 |
import org.gvsig.crs.repository.EsriRepository; |
|
50 |
import org.gvsig.crs.repository.EsriRepositoryGT; |
|
51 |
import org.gvsig.crs.repository.ICrsRepository; |
|
52 |
import org.gvsig.crs.repository.Iau2000Repository; |
|
53 |
import org.gvsig.crs.repository.Iau2000RepositoryGT; |
|
54 |
import org.gvsig.crs.repository.UsrRepository; |
|
55 |
import org.gvsig.crs.repository.UsrRepositoryGT; |
|
56 |
|
|
57 |
/** |
|
58 |
* Clase que consigue el CRS a trav?s del c?digo de la EPSG o de |
|
59 |
* la cadena WKT |
|
60 |
* |
|
61 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
|
62 |
* |
|
63 |
*/ |
|
64 |
|
|
65 |
public class CrsFactory implements ICRSFactory { |
|
66 |
static TreeMap data = new TreeMap(); |
|
67 |
|
|
68 |
public CrsFactory() { |
|
69 |
} |
|
70 |
/** |
|
71 |
* Obtiene un CRS a partir de su c?digo (p.e. EPSG:23030). |
|
72 |
* @param code |
|
73 |
* @return |
|
74 |
* @throws CrsException |
|
75 |
*/ |
|
76 |
public ICrs getCRS(String code) throws CrsException { |
|
77 |
|
|
78 |
/*if (data.containsKey(code)) |
|
79 |
return (ICrs) data.get(code);*/ |
|
80 |
|
|
81 |
String repoId = ""; |
|
82 |
String crsCode = ""; |
|
83 |
ICrs crs = null; |
|
84 |
|
|
85 |
if(code.indexOf(":", code.indexOf(":")+1)<0){ |
|
86 |
repoId = code.substring(0, code.indexOf(":")); |
|
87 |
crsCode = code.substring(code.indexOf(":")+1); |
|
88 |
|
|
89 |
ICrsRepository repo = null; |
|
90 |
|
|
91 |
if(repoId.equals("EPSG")){ |
|
92 |
repo = new EpsgRepositoryGT(); |
|
93 |
crs = repo.getCrs(crsCode); |
|
94 |
if (crs==null) { |
|
95 |
repo = new EpsgRepository(); |
|
96 |
crs = repo.getCrs(crsCode); |
|
97 |
} |
|
98 |
}else if (repoId.equals("IAU2000")){ |
|
99 |
repo = new Iau2000RepositoryGT(); |
|
100 |
crs = repo.getCrs(crsCode); |
|
101 |
if (crs==null) { |
|
102 |
repo = new Iau2000Repository(); |
|
103 |
crs = repo.getCrs(crsCode); |
|
104 |
} |
|
105 |
}else if (repoId.equals("ESRI")){ |
|
106 |
repo = new EsriRepositoryGT(); |
|
107 |
crs = repo.getCrs(crsCode); |
|
108 |
if (crs==null) { |
|
109 |
repo = new EsriRepository(); |
|
110 |
crs = repo.getCrs(crsCode); |
|
111 |
} |
|
112 |
}else if (repoId.equals("USR")){ |
|
113 |
repo = new UsrRepositoryGT(); |
|
114 |
crs = repo.getCrs(crsCode); |
|
115 |
if (crs==null) { |
|
116 |
repo = new UsrRepository(); |
|
117 |
crs = repo.getCrs(crsCode); |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
else{ |
|
122 |
String sourceParams = null; |
|
123 |
String targetParams = null; |
|
124 |
|
|
125 |
crsCode = code.substring(0,code.indexOf(":",code.indexOf(":")+1)); |
|
126 |
if (code.indexOf("@")==-1){ |
|
127 |
crsCode=crsCode.substring(0, crsCode.indexOf(",")); |
|
128 |
}else{ |
|
129 |
sourceParams = code.substring(code.indexOf("@")+1,code.lastIndexOf("@")); |
|
130 |
targetParams = code.substring(code.lastIndexOf("@")+1); |
|
131 |
|
|
132 |
if (sourceParams.equals("")) |
|
133 |
sourceParams = null; |
|
134 |
else if (targetParams.equals("1")){ // Compativilidad con versiones de libJCrs sin soporte para transf. compuestas. |
|
135 |
targetParams = sourceParams; |
|
136 |
sourceParams = ""; |
|
137 |
} |
|
138 |
if (targetParams.equals("")||targetParams.equals("0")) // Compativilidad con versiones de libJCrs sin soporte para transf. compuestas. |
|
139 |
targetParams = null; |
|
140 |
} |
|
141 |
crs = getCRS(crsCode); |
|
142 |
crs.setTransformationParams(sourceParams,targetParams); |
|
143 |
} |
|
144 |
|
|
145 |
/*code = crs.getAbrev(); |
|
146 |
|
|
147 |
data.put(code, crs);*/ |
|
148 |
|
|
149 |
return crs; |
|
150 |
|
|
151 |
/*if (data.containsKey(code)) |
|
152 |
return (Crs) data.get(code); |
|
153 |
|
|
154 |
Crs crs = new Crs(code); |
|
155 |
|
|
156 |
// LWS Esta l?nea sobra, cuando el cuadro de di?logo est? |
|
157 |
// mejor hecho. |
|
158 |
code = crs.getAbrev(); |
|
159 |
|
|
160 |
data.put(code, crs); |
|
161 |
|
|
162 |
return crs;*/ |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* |
|
167 |
* @param epsg_code |
|
168 |
* @param code |
|
169 |
* @return |
|
170 |
* @throws CrsException |
|
171 |
*/ |
|
172 |
public ICrs getCRS(int epsg_code, String code) throws CrsException { |
|
173 |
/*if (data.containsKey(code)) |
|
174 |
return (Crs) data.get(code);*/ |
|
175 |
|
|
176 |
Crs crs = new Crs(epsg_code, code); |
|
177 |
|
|
178 |
// LWS Esta l?nea sobra, cuando el cuadro de di?logo est? |
|
179 |
// mejor hecho. |
|
180 |
/*code = crs.getAbrev(); |
|
181 |
|
|
182 |
data.put(code, crs);*/ |
|
183 |
|
|
184 |
return crs; |
|
185 |
} |
|
186 |
|
|
187 |
/** |
|
188 |
* |
|
189 |
* @param epsg_code |
|
190 |
* @param code |
|
191 |
* @param params |
|
192 |
* @return |
|
193 |
* @throws CrsException |
|
194 |
*/ |
|
195 |
public ICrs getCRS(int epsg_code, String code, String params) throws CrsException { |
|
196 |
/*if (data.containsKey(code)) |
|
197 |
return (Crs) data.get(code);*/ |
|
198 |
|
|
199 |
Crs crs = new Crs(epsg_code, code,params); |
|
200 |
|
|
201 |
// LWS Esta l?nea sobra, cuando el cuadro de di?logo est? |
|
202 |
// mejor hecho. |
|
203 |
/*code = crs.getAbrev(); |
|
204 |
|
|
205 |
data.put(code, crs);*/ |
|
206 |
|
|
207 |
return crs; |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* |
|
212 |
*/ |
|
213 |
public IProjection get(String name) { |
|
214 |
// TODO Auto-generated method stub |
|
215 |
try { |
|
216 |
return getCRS(name); |
|
217 |
} catch (CrsException e) { |
|
218 |
// TODO Auto-generated catch block |
|
219 |
e.printStackTrace(); |
|
220 |
} |
|
221 |
return null; |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* |
|
226 |
*/ |
|
227 |
public boolean doesRigurousTransformations() { |
|
228 |
return true; |
|
229 |
} |
|
230 |
} |
|
0 | 231 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/EpsgRepositoryGT.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs.repository; |
|
42 |
|
|
43 |
import org.geotools.referencing.CRS; |
|
44 |
import org.gvsig.crs.CrsGT; |
|
45 |
import org.gvsig.crs.ICrs; |
|
46 |
import org.opengis.referencing.FactoryException; |
|
47 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
48 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
49 |
|
|
50 |
/** |
|
51 |
* Repositorio de CRSs de EPSG basado en Geotools. |
|
52 |
* |
|
53 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
|
54 |
* |
|
55 |
*/ |
|
56 |
|
|
57 |
public class EpsgRepositoryGT implements ICrsRepository { |
|
58 |
|
|
59 |
public ICrs getCrs(String code) { |
|
60 |
CrsGT crsGT = null; |
|
61 |
try { |
|
62 |
CoordinateReferenceSystem crs = CRS.decode("EPSG:"+code); |
|
63 |
crsGT = new CrsGT(crs); |
|
64 |
} catch (NoSuchAuthorityCodeException e) { |
|
65 |
// TODO Auto-generated catch block |
|
66 |
e.printStackTrace(); |
|
67 |
return null; |
|
68 |
} catch (FactoryException e) { |
|
69 |
// TODO Auto-generated catch block |
|
70 |
e.printStackTrace(); |
|
71 |
return null; |
|
72 |
} |
|
73 |
return crsGT; |
|
74 |
} |
|
75 |
|
|
76 |
} |
|
0 | 77 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/UsrRepository.java | ||
---|---|---|
1 |
package org.gvsig.crs.repository; |
|
2 |
|
|
3 |
import java.sql.ResultSet; |
|
4 |
import java.sql.SQLException; |
|
5 |
|
|
6 |
import org.gvsig.crs.Crs; |
|
7 |
import org.gvsig.crs.CrsException; |
|
8 |
import org.gvsig.crs.ICrs; |
|
9 |
|
|
10 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
11 |
import es.idr.teledeteccion.connection.Query; |
|
12 |
|
|
13 |
public class UsrRepository implements ICrsRepository { |
|
14 |
|
|
15 |
EpsgConnection connection; |
|
16 |
|
|
17 |
public UsrRepository() { |
|
18 |
super(); |
|
19 |
connection = new EpsgConnection(); |
|
20 |
} |
|
21 |
|
|
22 |
public ICrs getCrs(String code) { |
|
23 |
// TODO Auto-generated method stub |
|
24 |
String cadWKT = ""; |
|
25 |
Crs crs = null; |
|
26 |
|
|
27 |
String sentence = "SELECT usr_code, usr_wkt, usr_proj, usr_geog, usr_datum " + |
|
28 |
"FROM USR " + |
|
29 |
"WHERE usr_code = " + code; |
|
30 |
|
|
31 |
connection.setConnectionUsr(); |
|
32 |
ResultSet result = Query.select(sentence,connection.getConnection()); |
|
33 |
try { |
|
34 |
connection.shutdown(); |
|
35 |
} catch (SQLException e) { |
|
36 |
// TODO Auto-generated catch block |
|
37 |
e.printStackTrace(); |
|
38 |
} |
|
39 |
try { |
|
40 |
if (!result.next()) |
|
41 |
return null; |
|
42 |
cadWKT = result.getString("usr_wkt"); |
|
43 |
} catch (SQLException e1) { |
|
44 |
e1.printStackTrace(); |
|
45 |
} |
|
46 |
cadWKT = cadWKT.substring(0, cadWKT.length()-1) + ", AUTHORITY[\"USR\","+ Integer.parseInt(code)+"]]"; |
|
47 |
|
|
48 |
try { |
|
49 |
crs = new Crs(Integer.parseInt(code),cadWKT); |
|
50 |
} catch (CrsException e) { |
|
51 |
// TODO Auto-generated catch block |
|
52 |
e.printStackTrace(); |
|
53 |
} |
|
54 |
|
|
55 |
return crs; |
|
56 |
} |
|
57 |
|
|
58 |
} |
|
0 | 59 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/Iau2000RepositoryGT.java | ||
---|---|---|
1 |
package org.gvsig.crs.repository; |
|
2 |
|
|
3 |
import org.geotools.referencing.CRS; |
|
4 |
import org.gvsig.crs.CrsGT; |
|
5 |
import org.gvsig.crs.ICrs; |
|
6 |
import org.opengis.referencing.FactoryException; |
|
7 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
8 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
9 |
|
|
10 |
public class Iau2000RepositoryGT implements ICrsRepository { |
|
11 |
|
|
12 |
public ICrs getCrs(String code) { |
|
13 |
CrsGT crsGT = null; |
|
14 |
try { |
|
15 |
CoordinateReferenceSystem crs = CRS.decode("IAU2000:"+code); |
|
16 |
crsGT = new CrsGT(crs); |
|
17 |
} catch (NoSuchAuthorityCodeException e) { |
|
18 |
// TODO Auto-generated catch block |
|
19 |
e.printStackTrace(); |
|
20 |
return null; |
|
21 |
} catch (FactoryException e) { |
|
22 |
// TODO Auto-generated catch block |
|
23 |
e.printStackTrace(); |
|
24 |
return null; |
|
25 |
} |
|
26 |
return crsGT; |
|
27 |
} |
|
28 |
|
|
29 |
} |
|
0 | 30 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/EsriRepositoryGT.java | ||
---|---|---|
1 |
package org.gvsig.crs.repository; |
|
2 |
|
|
3 |
import org.geotools.referencing.CRS; |
|
4 |
import org.gvsig.crs.CrsGT; |
|
5 |
import org.gvsig.crs.ICrs; |
|
6 |
import org.opengis.referencing.FactoryException; |
|
7 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
8 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
9 |
|
|
10 |
public class EsriRepositoryGT implements ICrsRepository { |
|
11 |
|
|
12 |
public ICrs getCrs(String code) { |
|
13 |
CrsGT crsGT = null; |
|
14 |
try { |
|
15 |
CoordinateReferenceSystem crs = CRS.decode("ESRI:"+code); |
|
16 |
crsGT = new CrsGT(crs); |
|
17 |
} catch (NoSuchAuthorityCodeException e) { |
|
18 |
// TODO Auto-generated catch block |
|
19 |
e.printStackTrace(); |
|
20 |
return null; |
|
21 |
} catch (FactoryException e) { |
|
22 |
// TODO Auto-generated catch block |
|
23 |
e.printStackTrace(); |
|
24 |
return null; |
|
25 |
} |
|
26 |
return crsGT; |
|
27 |
} |
|
28 |
|
|
29 |
} |
|
0 | 30 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/EpsgRepository.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs.repository; |
|
42 |
|
|
43 |
import java.sql.ResultSet; |
|
44 |
import java.sql.SQLException; |
|
45 |
|
|
46 |
import org.gvsig.crs.Crs; |
|
47 |
import org.gvsig.crs.CrsException; |
|
48 |
import org.gvsig.crs.ICrs; |
|
49 |
import org.gvsig.crs.ogr.Epsg2wkt; |
|
50 |
import org.gvsig.crs.ogr.CrsEPSG; |
|
51 |
|
|
52 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
53 |
import es.idr.teledeteccion.connection.Query; |
|
54 |
|
|
55 |
/** |
|
56 |
* Repositorio de CRSs de EPSG |
|
57 |
* |
|
58 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
|
59 |
* |
|
60 |
*/ |
|
61 |
public class EpsgRepository implements ICrsRepository { |
|
62 |
|
|
63 |
public EpsgConnection connection = null; |
|
64 |
|
|
65 |
public EpsgRepository() { |
|
66 |
connection = new EpsgConnection(); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Obtiene un CRS a partir de su c?digo EPSG. |
|
71 |
* |
|
72 |
* @param code Codigo EPSG del CRS. |
|
73 |
* @return ICrs |
|
74 |
*/ |
|
75 |
public ICrs getCrs(String code) { |
|
76 |
int epsg_code = Integer.parseInt(code); |
|
77 |
boolean source_yn = false; |
|
78 |
int source_cod = 0; |
|
79 |
int datum_code = 0; |
|
80 |
int projection_conv_code = 0; |
|
81 |
String crs_kind = null; |
|
82 |
|
|
83 |
Epsg2wkt wkt = null; |
|
84 |
|
|
85 |
Crs crs = null; |
|
86 |
|
|
87 |
ResultSet result = null; |
|
88 |
String sentence = "SELECT source_geogcrs_code, projection_conv_code, " |
|
89 |
+ "coord_ref_sys_kind, datum_code " |
|
90 |
+ "FROM epsg_coordinatereferencesystem " |
|
91 |
+ "WHERE coord_ref_sys_code = " + code; |
|
92 |
|
|
93 |
connection.setConnectionEPSG(); |
|
94 |
result = Query.select(sentence,connection.getConnection()); |
|
95 |
|
|
96 |
/*try { |
|
97 |
connection.shutdown(); |
|
98 |
} catch (SQLException e) { |
|
99 |
// TODO Auto-generated catch block |
|
100 |
e.printStackTrace(); |
|
101 |
}*/ |
|
102 |
|
|
103 |
try { |
|
104 |
if (!result.next()) |
|
105 |
return null; |
|
106 |
source_cod = result.getInt("source_geogcrs_code"); |
|
107 |
projection_conv_code = result.getInt("projection_conv_code"); |
|
108 |
crs_kind = result.getString("coord_ref_sys_kind"); |
|
109 |
datum_code = result.getInt("datum_code"); |
|
110 |
} catch (SQLException e1) { |
|
111 |
e1.printStackTrace(); |
|
112 |
} |
|
113 |
|
|
114 |
if (datum_code != 0){ |
|
115 |
source_yn = true; |
|
116 |
} |
|
117 |
else if (source_cod != 0){ |
|
118 |
source_yn = false; |
|
119 |
} |
|
120 |
else source_yn = true; |
|
121 |
|
|
122 |
CrsEPSG ep = new CrsEPSG(epsg_code, source_yn, source_cod, projection_conv_code, connection); |
|
123 |
|
|
124 |
if (crs_kind.equals("geographic 2D") || crs_kind.equals("geographic 3D")){ |
|
125 |
wkt = new Epsg2wkt(ep , "geog"); |
|
126 |
} |
|
127 |
else if (crs_kind.equals("projected")){ |
|
128 |
wkt = new Epsg2wkt(ep, "proj"); |
|
129 |
} |
|
130 |
else if (crs_kind.equals("compound")){ |
|
131 |
wkt = new Epsg2wkt(ep,"comp"); |
|
132 |
} |
|
133 |
else if (crs_kind.equals("geocentric")){ |
|
134 |
wkt = new Epsg2wkt(ep,"geoc"); |
|
135 |
} |
|
136 |
|
|
137 |
try { |
|
138 |
crs = new Crs(Integer.parseInt(code),wkt.getWKT()); |
|
139 |
} catch (CrsException e) { |
|
140 |
// TODO Auto-generated catch block |
|
141 |
e.printStackTrace(); |
|
142 |
} |
|
143 |
return crs; |
|
144 |
} |
|
145 |
} |
|
0 | 146 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/package.html | ||
---|---|---|
1 |
<html> |
|
2 |
<body>Clases relacionadas con los repositorios de la extensi?n CRS. |
|
3 |
</body> |
|
4 |
</html> |
|
0 | 5 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/ICrsRepository.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs.repository; |
|
42 |
|
|
43 |
import org.gvsig.crs.ICrs; |
|
44 |
|
|
45 |
/** |
|
46 |
* Interfaz para un repositorio de Sistemas de Referencia Coordenados (CRS) |
|
47 |
* |
|
48 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
|
49 |
* |
|
50 |
*/ |
|
51 |
public interface ICrsRepository { |
|
52 |
|
|
53 |
/** |
|
54 |
* Obtiene un CRS a partir del c?digo que lo identifica en el repositorio. |
|
55 |
* |
|
56 |
* @param code Codigo de CRS en el repositorio. |
|
57 |
* @return ICrs |
|
58 |
*/ |
|
59 |
public ICrs getCrs(String code); |
|
60 |
|
|
61 |
} |
|
0 | 62 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/Iau2000Repository.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
|
|
41 |
package org.gvsig.crs.repository; |
|
42 |
|
|
43 |
import java.sql.ResultSet; |
|
44 |
import java.sql.SQLException; |
|
45 |
|
|
46 |
import org.gvsig.crs.Crs; |
|
47 |
import org.gvsig.crs.CrsException; |
|
48 |
import org.gvsig.crs.ICrs; |
|
49 |
import org.gvsig.crs.ogr.Iau2wkt; |
|
50 |
|
|
51 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
52 |
import es.idr.teledeteccion.connection.Query; |
|
53 |
|
|
54 |
/** |
|
55 |
* Repositorio de CRSs de IAU2000 |
|
56 |
* |
|
57 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
|
58 |
* |
|
59 |
*/ |
|
60 |
public class Iau2000Repository implements ICrsRepository { |
|
61 |
|
|
62 |
EpsgConnection connection = null; |
|
63 |
|
|
64 |
public Iau2000Repository() { |
|
65 |
connection = new EpsgConnection(); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Obtiene un CRS a partir de su c?digo IAU2000. |
|
70 |
* |
|
71 |
* @param code Codigo IAU2000 del CRS. |
|
72 |
* @return ICrs |
|
73 |
*/ |
|
74 |
public ICrs getCrs(String code) { |
|
75 |
String cadWKT = ""; |
|
76 |
Crs crs = null; |
|
77 |
|
|
78 |
String sentence = "SELECT iau_code, iau_wkt, iau_proj, iau_geog, iau_datum " + |
|
79 |
"FROM IAU2000 " + |
|
80 |
"WHERE iau_code = " + code; |
|
81 |
|
|
82 |
connection.setConnectionIAU2000(); |
|
83 |
ResultSet result = Query.select(sentence,connection.getConnection()); |
|
84 |
try { |
|
85 |
connection.shutdown(); |
|
86 |
} catch (SQLException e) { |
|
87 |
// TODO Auto-generated catch block |
|
88 |
e.printStackTrace(); |
|
89 |
} |
|
90 |
try { |
|
91 |
if (!result.next()) |
|
92 |
return null; |
|
93 |
cadWKT = result.getString("iau_wkt"); |
|
94 |
} catch (SQLException e1) { |
|
95 |
e1.printStackTrace(); |
|
96 |
} |
|
97 |
cadWKT = cadWKT.substring(0, cadWKT.length()-1) + ", AUTHORITY[\"IAU2000\","+ Integer.parseInt(code)+"]]"; |
|
98 |
if (cadWKT.charAt(0) == 'P'){ |
|
99 |
Iau2wkt wk = new Iau2wkt(cadWKT); |
|
100 |
cadWKT = wk.getWkt(); |
|
101 |
} |
|
102 |
|
|
103 |
try { |
|
104 |
crs = new Crs(Integer.parseInt(code),cadWKT); |
|
105 |
} catch (CrsException e) { |
|
106 |
// TODO Auto-generated catch block |
|
107 |
e.printStackTrace(); |
|
108 |
} |
|
109 |
|
|
110 |
return crs; |
|
111 |
} |
|
112 |
} |
|
0 | 113 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/EsriRepository.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha |
|
34 |
* Campus Universitario s/n |
|
35 |
* 02071 Alabacete |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 967 599 200 |
|
39 |
*/ |
|
40 |
package org.gvsig.crs.repository; |
|
41 |
|
|
42 |
import java.sql.ResultSet; |
|
43 |
import java.sql.SQLException; |
|
44 |
|
|
45 |
import org.gvsig.crs.Crs; |
|
46 |
import org.gvsig.crs.CrsException; |
|
47 |
import org.gvsig.crs.ICrs; |
|
48 |
import org.gvsig.crs.ogr.Esri2wkt; |
|
49 |
|
|
50 |
import es.idr.teledeteccion.connection.EpsgConnection; |
|
51 |
import es.idr.teledeteccion.connection.Query; |
|
52 |
|
|
53 |
/** |
|
54 |
* Repositorio de CRSs de EPSG |
|
55 |
* |
|
56 |
* @author Jos? Luis G?mez Mart?nez (jolugomar@gmail.com) |
|
57 |
* |
|
58 |
*/ |
|
59 |
|
|
60 |
public class EsriRepository implements ICrsRepository { |
|
61 |
|
|
62 |
EpsgConnection connection = null; |
|
63 |
|
|
64 |
public EsriRepository() { |
|
65 |
connection = new EpsgConnection(); |
|
66 |
connection.setConnectionEsri(); |
|
67 |
} |
|
68 |
|
|
69 |
public ICrs getCrs(String code) { |
|
70 |
String cadWKT = ""; |
|
71 |
Crs crs = null; |
|
72 |
|
|
73 |
String sentence = "SELECT esri_code, esri_wkt, esri_proj, esri_geog, esri_datum " + |
|
74 |
"FROM ESRI " + |
|
75 |
"WHERE esri_code = " + code; |
|
76 |
|
|
77 |
ResultSet result = Query.select(sentence,connection.getConnection()); |
|
78 |
/*try { |
|
79 |
connection.shutdown(); |
|
80 |
} catch (SQLException e) { |
|
81 |
// TODO Auto-generated catch block |
|
82 |
e.printStackTrace(); |
|
83 |
}*/ |
|
84 |
try { |
|
85 |
if (!result.next()) |
|
86 |
return null; |
|
87 |
cadWKT = result.getString("esri_wkt"); |
|
88 |
} catch (SQLException e1) { |
|
89 |
e1.printStackTrace(); |
|
90 |
} |
|
91 |
cadWKT = cadWKT.substring(0, cadWKT.length()-1) + ", AUTHORITY[\"ESRI\","+ Integer.parseInt(code)+"]]"; |
|
92 |
if (cadWKT.charAt(0) == 'P'){ |
|
93 |
Esri2wkt wk = new Esri2wkt(cadWKT); |
|
94 |
cadWKT = wk.getWkt(); |
|
95 |
} |
|
96 |
|
|
97 |
try { |
|
98 |
crs = new Crs(Integer.parseInt(code),cadWKT); |
|
99 |
} catch (CrsException e) { |
|
100 |
// TODO Auto-generated catch block |
|
101 |
e.printStackTrace(); |
|
102 |
} |
|
103 |
|
|
104 |
return crs; |
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
} |
|
0 | 109 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/repository/UsrRepositoryGT.java | ||
---|---|---|
1 |
package org.gvsig.crs.repository; |
|
2 |
|
|
3 |
import org.geotools.referencing.CRS; |
|
4 |
import org.gvsig.crs.CrsGT; |
|
5 |
import org.gvsig.crs.ICrs; |
|
6 |
import org.opengis.referencing.FactoryException; |
|
7 |
import org.opengis.referencing.NoSuchAuthorityCodeException; |
|
8 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
|
9 |
|
|
10 |
public class UsrRepositoryGT implements ICrsRepository { |
|
11 |
|
|
12 |
public ICrs getCrs(String code) { |
|
13 |
CrsGT crsGT = null; |
|
14 |
try { |
|
15 |
CoordinateReferenceSystem crs = CRS.decode("USR:"+code); |
|
16 |
crsGT = new CrsGT(crs); |
|
17 |
} catch (NoSuchAuthorityCodeException e) { |
|
18 |
// TODO Auto-generated catch block |
|
19 |
e.printStackTrace(); |
|
20 |
return null; |
|
21 |
} catch (FactoryException e) { |
|
22 |
// TODO Auto-generated catch block |
|
23 |
e.printStackTrace(); |
|
24 |
return null; |
|
25 |
} |
|
26 |
return crsGT; |
|
27 |
} |
|
28 |
|
|
29 |
} |
|
0 | 30 |
tags/v1_11_0_Build_1306/libraries/libJCRS/src/org/gvsig/crs/ICrs.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
Also available in: Unified diff