Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1014 / libraries / libJCRS / src / org / gvsig / crs / ogr / CrsOgr.java @ 13593

History | View | Annotate | Download (5.1 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.ogr;
42

    
43
/**
44
 * 
45
 * @author Miguel Garc?a Jim?nez (garciajimenez.miguel@gmail.com)
46
 *
47
 */
48
public class CrsOgr extends JNIBaseCRS
49
{
50
        public static String exportToWkt(OGRSpatialReference ORGSpace)throws CrsOgrException, crsgdalException
51
        {
52
                String result = exportToWktNat(ORGSpace.getPtr());
53
                if(result.length() == 0) throw new CrsOgrException(ORGSpace);
54
                return result;
55
        }
56
        
57
        public static int importFromWkt(OGRSpatialReference ORGSpace, String cadenas) throws crsgdalException, CrsOgrException, OGRException
58
        {
59
                int result = importFromWktNat(ORGSpace.getPtr(), cadenas);
60
                if(result != 0) throw new OGRException(result,"Error en Wkt().La creacion del objeto no tuvo exito. ",ORGSpace);
61
                return result;
62
        }
63
        
64
        public static int setUTM(OGRSpatialReference ORGSpace ,int zona, boolean norte_sur)throws OGRException, crsgdalException, CrsOgrException{
65
                
66
                if(ORGSpace.getPtr() <= 0)
67
                        throw new OGRException("Error en setUTM(). La llamada de creaci?n de objeto no tuvo exito.");
68
                
69
                int ns=-1;
70
                if(norte_sur)ns=1;
71
                else ns=0;
72
                
73
                int res = setUTMNat(ORGSpace.getPtr(), zona, ns);
74
                
75
                if(res != 0)
76
                        throw new OGRException(res,"Error en setUTM(). No se ha podido asignar la zona especificada. ",ORGSpace);
77
                return res;
78
        }
79
        
80
        public static int setWellKnownGeogCS(OGRSpatialReference ORGSpace, String cs)throws OGRException, crsgdalException, CrsOgrException{
81
                
82
                if(ORGSpace.getPtr() <= 0)
83
                        throw new OGRException("Error en setWellKnownGeogCS(). La llamada de creaci?n de objeto no tuvo exito.");
84
                
85
                int res = setWellKnownGeogCSNat(ORGSpace.getPtr(), cs);
86
                
87
                if(res != 0)
88
                        throw new OGRException(res,"Error en setWellKnownGeoCS(). No se ha podido asignar el sistema de coordenadas especificado. ",ORGSpace);
89
                return res;
90
        }
91
        
92
        public static int importFromEPSG(OGRSpatialReference ORGSpace, int cod) throws OGRException, crsgdalException, CrsOgrException
93
        {
94
                int result = importFromEPSGNat(ORGSpace.getPtr(), cod);
95
                if(result != 0) throw new OGRException(result,"Error en EPSG().La creacion del objeto no tuvo exito. ",ORGSpace);
96
                return result;
97
        }
98
        
99
        public static int importFromProj4(OGRSpatialReference ORGSpace, String cs)throws OGRException, crsgdalException, CrsOgrException{
100
                
101
                if(ORGSpace.getPtr() <= 0)
102
                        throw new OGRException("Error en Proj4(). La llamada de creaci?n de objeto no tuvo exito.");
103
                
104
                int res = importFromProj4Nat(ORGSpace.getPtr(), cs);
105
                
106
                if(res != 0)
107
                        throw new OGRException(res, "Error en Proj4(). No se ha podido asignar el sistema de coordenadas especificado. ", ORGSpace);
108
                
109
                return res;
110
                
111
        }
112
        
113
        public static String exportToProj4(OGRSpatialReference ORGSpace)throws CrsOgrException, crsgdalException
114
        {
115
                String result = exportToProj4Nat(ORGSpace.getPtr());
116
                if(result.length() == 0) throw new CrsOgrException(ORGSpace);
117
                return result;
118
        }
119
        
120
        public static int importFromPCI(OGRSpatialReference ORGSpace,String cod, String cs, double[] coord)throws CrsOgrException, crsgdalException, OGRException
121
        {
122
                int result = importFromPCINat(ORGSpace.getPtr(),cod, cs, coord);
123
                if(result != 0) throw new OGRException(result,"Error en PCI().La creacion del objeto no tuvo exito. ",ORGSpace);
124
                return result;
125
        }
126
        
127
        public static int importFromUSGS(OGRSpatialReference ORGSpace, long code, long zone, double[] params, long datum) throws crsgdalException, OGRException, CrsOgrException
128
        {
129
                int result = importFromUSGSNat(ORGSpace.getPtr(),code, zone, params, datum);
130
                if(result != 0) throw new OGRException(result,"Error en USGS().La creacion del objeto no tuvo exito. ",ORGSpace);
131
                return result;        
132
                
133
        }
134
        
135
        public static int importFromESRI(OGRSpatialReference ORGSpace, String cadenas) throws crsgdalException, CrsOgrException, OGRException
136
        {
137
                int result = importFromESRINat(ORGSpace.getPtr(), cadenas);
138
                if(result != 0) throw new OGRException(result,"Error en ESRI().La creacion del objeto no tuvo exito. ",ORGSpace);
139
                return result;
140
        }
141
}
142