gvsig-raster / org.gvsig.raster.gdal / tags / pre-remove-jgdal / org.gvsig.raster.gdal / org.gvsig.raster.gdal.io / src / main / java / org / gvsig / jogr / OGRSFDriverRegistrar.java @ 3497
History | View | Annotate | Download (4.06 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 |
import org.gdal.ogr.DataSource; |
30 |
import org.gdal.ogr.Driver; |
31 |
import org.gdal.ogr.ogr; |
32 |
|
33 |
|
34 |
/**
|
35 |
* Gestor de drivers
|
36 |
*
|
37 |
* @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
|
38 |
* @version 0.0
|
39 |
* @link http://www.gvsig.gva.es
|
40 |
*/
|
41 |
|
42 |
public class OGRSFDriverRegistrar extends JNIBase{ |
43 |
|
44 |
private OGRSFDriver driver;
|
45 |
// private native long openNat(String fte, int bUpdate);
|
46 |
// private native long getRegistrarNat();
|
47 |
// private native long getDriverNat(long cPtr, int i);
|
48 |
// private native void FreeOGRSFDriverRegistrarNat(long cPtr);
|
49 |
//
|
50 |
// private native int releaseDataSource( long cPtr, OGRDataSource ds ); //Excepciones
|
51 |
// private native void registerDriver( long cPtr, OGRSFDriver poDriver );
|
52 |
// private native OGRSFDriver getDriverByName( long cPtr, String name );
|
53 |
// private native OGRDataSource getOpenDS(long cPtr, int i );
|
54 |
|
55 |
/**
|
56 |
* Abre un fichero de im?gen
|
57 |
* @throws OGRException
|
58 |
* @param fte fichero fuente
|
59 |
* @param bUpdate
|
60 |
* @param pdriver
|
61 |
* @return OGRDataSource
|
62 |
*/
|
63 |
|
64 |
public OGRDataSource open(String fte, boolean bUpdate, OGRSFDriver pdriver)throws OGRException{ |
65 |
|
66 |
OGRDataSource ds; |
67 |
OGRSFDriver drv; |
68 |
driver = pdriver; |
69 |
int bU=0; |
70 |
|
71 |
if(bUpdate)bU=1; |
72 |
|
73 |
if (fte == null || fte.equals("")) |
74 |
throw new OGRException("Fallo en parametro de entrada de OGRDataSource.open"); |
75 |
|
76 |
DataSource res = ogr.Open(fte, bU);
|
77 |
|
78 |
if(res == null || driver == null) |
79 |
throw new OGRException("Error en open(). No se ha podido abrir la im?gen."); |
80 |
else{
|
81 |
ds = (OGRDataSource)res; |
82 |
drv = driver; |
83 |
} |
84 |
|
85 |
pdriver=drv; |
86 |
return ds;
|
87 |
} |
88 |
|
89 |
/**
|
90 |
* Obtiene el n?mero de drivers registrados en el gestor
|
91 |
* @throws OGRException
|
92 |
* @return N?mero de drivers
|
93 |
*/
|
94 |
|
95 |
public int getDriverCount()throws OGRException{ |
96 |
return ogr.GetDriverCount();
|
97 |
} |
98 |
|
99 |
/**
|
100 |
* Obtiene el driver indicado por el ?ndice
|
101 |
* @throws OGRException
|
102 |
* @return un driver
|
103 |
*/
|
104 |
|
105 |
public OGRSFDriver getDriver(int i)throws OGRException{ |
106 |
|
107 |
if(cPtr == 0) |
108 |
throw new OGRException("Fallo al acceder al dato."); |
109 |
|
110 |
Driver drv = ogr.GetDriver(i);
|
111 |
|
112 |
if(drv == null) |
113 |
throw new OGRException("Error en getDriver(). No se ha podido obtener el driver indicado."); |
114 |
|
115 |
return (OGRSFDriver)drv;
|
116 |
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* Destructor
|
121 |
*/
|
122 |
|
123 |
protected void finalize() throws OGRFailureException{ |
124 |
// if(cPtr == 0)
|
125 |
// throw new OGRFailureException("Fallo al acceder al dato.");
|
126 |
//
|
127 |
// FreeOGRSFDriverRegistrarNat(cPtr);
|
128 |
delete_DataSource(this.cPtr);
|
129 |
} |
130 |
|
131 |
|
132 |
/**
|
133 |
*
|
134 |
*/
|
135 |
|
136 |
public void releaseDataSource( OGRDataSource ds )throws OGRException{ //Excepciones |
137 |
|
138 |
} |
139 |
|
140 |
/**
|
141 |
*
|
142 |
*/
|
143 |
|
144 |
public void registerDriver( OGRSFDriver poDriver )throws OGRException{ |
145 |
|
146 |
} |
147 |
|
148 |
/**
|
149 |
*
|
150 |
*/
|
151 |
|
152 |
public OGRSFDriver getDriverByName( String name )throws OGRException{ |
153 |
return null; |
154 |
} |
155 |
|
156 |
/**
|
157 |
*
|
158 |
*/
|
159 |
|
160 |
public int getOpenDSCount()throws OGRException{ |
161 |
return 0; |
162 |
} |
163 |
|
164 |
/**
|
165 |
*
|
166 |
*/
|
167 |
|
168 |
public OGRDataSource getOpenDS( int i )throws OGRException{ |
169 |
return null; |
170 |
} |
171 |
|
172 |
|
173 |
} |