root / branches / v10 / libraries / libjni-gdal / src / es / gva / cit / jogr / OGRSFDriverRegistrar.java @ 7847
History | View | Annotate | Download (3.91 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: OGRSFDriverRegistrar.java 7847 2006-10-04 06:55:46Z nacho $
|
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 es.gva.cit.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=-1;
|
65 |
int bU=0; |
66 |
|
67 |
if(bUpdate)bU=1; |
68 |
|
69 |
long res = openNat(fte, bU);
|
70 |
|
71 |
if(res<=0 || driver<=0) |
72 |
throw new OGRException("Error en open(). No se ha podido abrir la im?gen."); |
73 |
else{
|
74 |
ds = new OGRDataSource(res);
|
75 |
drv = new OGRSFDriver(driver);
|
76 |
} |
77 |
|
78 |
pdriver=drv; |
79 |
return ds;
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* Obtiene el n?mero de drivers registrados en el gestor
|
84 |
* @throws OGRException
|
85 |
* @return N?mero de drivers
|
86 |
*/
|
87 |
|
88 |
public int getDriverCount()throws OGRException{ |
89 |
|
90 |
if(cPtr<=0)cPtr=getRegistrarNat(); |
91 |
|
92 |
String msg1="Error en getDriverCount. . La llamada getRegistrar de OGR no tuvo exito"; |
93 |
String msg2="Error en la cuenta de drivers"; |
94 |
return baseSimpleFunctions(0,msg1,msg2); |
95 |
} |
96 |
|
97 |
/**
|
98 |
* Obtiene el driver indicado por el ?ndice
|
99 |
* @throws OGRException
|
100 |
* @return un driver
|
101 |
*/
|
102 |
|
103 |
public OGRSFDriver getDriver(int i)throws OGRException{ |
104 |
|
105 |
if(cPtr<=0)cPtr=getRegistrarNat(); |
106 |
if(cPtr <= 0) |
107 |
throw new OGRException("Error en getDriver(). La llamada getRegistrar() no tuvo exito"); |
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(){ |
123 |
if(cPtr > 0) |
124 |
FreeOGRSFDriverRegistrarNat(cPtr); |
125 |
} |
126 |
|
127 |
|
128 |
/**
|
129 |
*
|
130 |
*/
|
131 |
|
132 |
public void releaseDataSource( OGRDataSource ds )throws OGRException{ //Excepciones |
133 |
|
134 |
} |
135 |
|
136 |
/**
|
137 |
*
|
138 |
*/
|
139 |
|
140 |
public void registerDriver( OGRSFDriver poDriver )throws OGRException{ |
141 |
|
142 |
} |
143 |
|
144 |
/**
|
145 |
*
|
146 |
*/
|
147 |
|
148 |
public OGRSFDriver getDriverByName( String name )throws OGRException{ |
149 |
return null; |
150 |
} |
151 |
|
152 |
/**
|
153 |
*
|
154 |
*/
|
155 |
|
156 |
public int getOpenDSCount()throws OGRException{ |
157 |
return 0; |
158 |
} |
159 |
|
160 |
/**
|
161 |
*
|
162 |
*/
|
163 |
|
164 |
public OGRDataSource getOpenDS( int i )throws OGRException{ |
165 |
return null; |
166 |
} |
167 |
|
168 |
|
169 |
} |