svn-gvsig-desktop / trunk / libraries / libjni-gdal / src / main / java / org / gvsig / jogr / OGRSFDriverRegistrar.java @ 21213
History | View | Annotate | Download (4.08 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: OGRSFDriverRegistrar.java 15690 2007-10-31 10:28:41Z nbrodin $
|
3 |
*
|
4 |
* Name: OGRSFDriverRegistrar.java
|
5 |
* Project: JGDAL. Interface java to gdal (Frank Warmerdam).
|
6 |
* Purpose:
|
7 |
* Author: Nacho Brodin, brodin_ign@gva.es
|
8 |
*
|
9 |
**********************************************************************/
|
10 |
/*Copyright (C) 2004 Nacho Brodin <brodin_ign@gva.es>
|
11 |
|
12 |
This program is free software; you can redistribute it and/or
|
13 |
modify it under the terms of the GNU General Public License
|
14 |
as published by the Free Software Foundation; either version 2
|
15 |
of the License, or (at your option) any later version.
|
16 |
|
17 |
This program is distributed in the hope that it will be useful,
|
18 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
GNU General Public License for more details.
|
21 |
|
22 |
You should have received a copy of the GNU General Public License
|
23 |
along with this program; if not, write to the Free Software
|
24 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
25 |
*/
|
26 |
|
27 |
package org.gvsig.jogr; |
28 |
|
29 |
|
30 |
/**
|
31 |
* Gestor de drivers
|
32 |
*
|
33 |
* @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
|
34 |
* @version 0.0
|
35 |
* @link http://www.gvsig.gva.es
|
36 |
*/
|
37 |
|
38 |
public class OGRSFDriverRegistrar extends JNIBase{ |
39 |
|
40 |
private long driver; |
41 |
private native long openNat(String fte, int bUpdate); |
42 |
private native long getRegistrarNat(); |
43 |
private native long getDriverNat(long cPtr, int i); |
44 |
private native void FreeOGRSFDriverRegistrarNat(long cPtr); |
45 |
|
46 |
private native int releaseDataSource( long cPtr, OGRDataSource ds ); //Excepciones |
47 |
private native void registerDriver( long cPtr, OGRSFDriver poDriver ); |
48 |
private native OGRSFDriver getDriverByName( long cPtr, String name ); |
49 |
private native OGRDataSource getOpenDS(long cPtr, int i ); |
50 |
|
51 |
/**
|
52 |
* Abre un fichero de im?gen
|
53 |
* @throws OGRException
|
54 |
* @param fte fichero fuente
|
55 |
* @param bUpdate
|
56 |
* @param pdriver
|
57 |
* @return OGRDataSource
|
58 |
*/
|
59 |
|
60 |
public OGRDataSource open(String fte, boolean bUpdate, OGRSFDriver pdriver)throws OGRException{ |
61 |
|
62 |
OGRDataSource ds; |
63 |
OGRSFDriver drv; |
64 |
driver = pdriver.getPtro(); |
65 |
int bU=0; |
66 |
|
67 |
if(bUpdate)bU=1; |
68 |
|
69 |
if (fte == null || fte.equals("")) |
70 |
throw new OGRException("Fallo en parametro de entrada de OGRDataSource.open"); |
71 |
|
72 |
long res = openNat(fte, bU);
|
73 |
|
74 |
if(res == 0 || driver == 0) |
75 |
throw new OGRException("Error en open(). No se ha podido abrir la im?gen."); |
76 |
else{
|
77 |
ds = new OGRDataSource(res);
|
78 |
drv = new OGRSFDriver(driver);
|
79 |
} |
80 |
|
81 |
pdriver=drv; |
82 |
return ds;
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* Obtiene el n?mero de drivers registrados en el gestor
|
87 |
* @throws OGRException
|
88 |
* @return N?mero de drivers
|
89 |
*/
|
90 |
|
91 |
public int getDriverCount()throws OGRException{ |
92 |
|
93 |
String msg1="Error en getDriverCount. . La llamada getRegistrar de OGR no tuvo exito"; |
94 |
String msg2="Error en la cuenta de drivers"; |
95 |
return baseSimpleFunctions(0,msg1,msg2); |
96 |
} |
97 |
|
98 |
/**
|
99 |
* Obtiene el driver indicado por el ?ndice
|
100 |
* @throws OGRException
|
101 |
* @return un driver
|
102 |
*/
|
103 |
|
104 |
public OGRSFDriver getDriver(int i)throws OGRException{ |
105 |
|
106 |
if(cPtr == 0) |
107 |
throw new OGRException("Fallo al acceder al dato."); |
108 |
|
109 |
long drv = getDriverNat(cPtr, i);
|
110 |
|
111 |
if(drv == 0) |
112 |
throw new OGRException("Error en getDriver(). No se ha podido obtener el driver indicado."); |
113 |
|
114 |
return new OGRSFDriver(drv); |
115 |
|
116 |
} |
117 |
|
118 |
/**
|
119 |
* Destructor
|
120 |
*/
|
121 |
|
122 |
protected void finalize() throws OGRFailureException{ |
123 |
if(cPtr == 0) |
124 |
throw new OGRFailureException("Fallo al acceder al dato."); |
125 |
|
126 |
FreeOGRSFDriverRegistrarNat(cPtr); |
127 |
} |
128 |
|
129 |
|
130 |
/**
|
131 |
*
|
132 |
*/
|
133 |
|
134 |
public void releaseDataSource( OGRDataSource ds )throws OGRException{ //Excepciones |
135 |
|
136 |
} |
137 |
|
138 |
/**
|
139 |
*
|
140 |
*/
|
141 |
|
142 |
public void registerDriver( OGRSFDriver poDriver )throws OGRException{ |
143 |
|
144 |
} |
145 |
|
146 |
/**
|
147 |
*
|
148 |
*/
|
149 |
|
150 |
public OGRSFDriver getDriverByName( String name )throws OGRException{ |
151 |
return null; |
152 |
} |
153 |
|
154 |
/**
|
155 |
*
|
156 |
*/
|
157 |
|
158 |
public int getOpenDSCount()throws OGRException{ |
159 |
return 0; |
160 |
} |
161 |
|
162 |
/**
|
163 |
*
|
164 |
*/
|
165 |
|
166 |
public OGRDataSource getOpenDS( int i )throws OGRException{ |
167 |
return null; |
168 |
} |
169 |
|
170 |
|
171 |
} |