root / org.gvsig.projection.jcrs / trunk / org.gvsig.projection.jcrs / org.gvsig.projection.jcrs.lib / src / main / java / org / gvsig / crs / repository / EpsgRepository.java @ 436
History | View | Annotate | Download (3.03 KB)
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 es.idr.teledeteccion.connection.EpsgConnection; |
47 |
import es.idr.teledeteccion.connection.Query; |
48 |
|
49 |
import java.util.logging.Level; |
50 |
|
51 |
import org.gdal.osr.SpatialReference; |
52 |
import org.slf4j.Logger; |
53 |
import org.slf4j.LoggerFactory; |
54 |
|
55 |
import org.gvsig.crs.Crs; |
56 |
import org.gvsig.crs.CrsException; |
57 |
import org.gvsig.crs.ICrs; |
58 |
import org.gvsig.crs.ogr.CrsEPSG; |
59 |
import org.gvsig.crs.ogr.Epsg2wkt; |
60 |
import org.gvsig.tools.dispose.Disposable; |
61 |
/**
|
62 |
* Repositorio de CRSs de EPSG
|
63 |
*
|
64 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
|
65 |
*
|
66 |
*/
|
67 |
public class EpsgRepository implements ICrsRepository { |
68 |
private static final Logger logger = |
69 |
LoggerFactory.getLogger(EpsgRepository.class); |
70 |
|
71 |
public EpsgConnection connection = null; |
72 |
|
73 |
public EpsgRepository() {
|
74 |
connection = new EpsgConnection();
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* Obtiene un CRS a partir de su c?digo EPSG.
|
79 |
*
|
80 |
* @param code Codigo EPSG del CRS.
|
81 |
* @return ICrs
|
82 |
*/
|
83 |
public ICrs getCrs(String code) { |
84 |
int epsg_code = Integer.parseInt(code); |
85 |
|
86 |
Crs crs; |
87 |
SpatialReference spatialReference = new SpatialReference();
|
88 |
try {
|
89 |
spatialReference.ImportFromEPSG(epsg_code); |
90 |
crs = new Crs(spatialReference);
|
91 |
} catch(RuntimeException e) { |
92 |
logger.warn("Can't create ESPG Crs from "+code+".", e); |
93 |
throw e;
|
94 |
} |
95 |
return crs;
|
96 |
} |
97 |
|
98 |
// public void dispose() {
|
99 |
// try {
|
100 |
// this.connection.close();
|
101 |
// this.connection = null;
|
102 |
// } catch (SQLException ex) {
|
103 |
// logger.warn("Can't shutdown the connection.",ex);
|
104 |
// }
|
105 |
// }
|
106 |
} |