Revision 4346
org.gvsig.raster.gdal/trunk/org.gvsig.raster.gdal/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/io/GdalProvider.java | ||
---|---|---|
50 | 50 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
51 | 51 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
52 | 52 |
import org.gvsig.fmap.dal.exception.OpenException; |
53 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
53 | 54 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
54 | 55 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
55 | 56 |
import org.gvsig.jgdal.GdalException; |
... | ... | |
111 | 112 |
public static final int BAND_HEIGHT = 64; |
112 | 113 |
protected GdalDataSource file = null; |
113 | 114 |
private Extent viewRequest = null; |
114 |
protected static String[] formatList = null; |
|
115 |
protected static String[][] formatList = null;
|
|
115 | 116 |
|
116 | 117 |
public static void register() { |
117 | 118 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
... | ... | |
137 | 138 |
} |
138 | 139 |
|
139 | 140 |
private static void registerFormats() { |
140 |
formatList = new String[] { |
|
141 |
"bmp", |
|
142 |
"gif", |
|
143 |
"tif", |
|
144 |
"tiff", |
|
145 |
"jpg", |
|
146 |
"jpeg", |
|
147 |
"png", |
|
148 |
"vrt", |
|
149 |
"dat", // Envi |
|
150 |
"lan", // Erdas |
|
151 |
"gis", // Erdas |
|
152 |
"img", // Erdas |
|
153 |
"pix", // PCI Geomatics |
|
154 |
"aux", // PCI Geomatics |
|
155 |
"adf", // ESRI Grids |
|
156 |
"mpr", // Ilwis |
|
157 |
"mpl", // Ilwis |
|
158 |
"map", // PC Raster |
|
159 |
"asc", |
|
160 |
"pgm", //Ficheros PNM en escala de grises |
|
161 |
"ppm", //Ficheros PNM en RGB |
|
162 |
"rst", //IDRISIS |
|
163 |
"rmf", //Raster Matrix Format |
|
164 |
"nos", |
|
165 |
"kap", |
|
166 |
"hdr", |
|
167 |
"raw", |
|
168 |
"ers", |
|
169 |
"xml", |
|
170 |
"grd", |
|
171 |
"txt"/*, |
|
172 |
"jp2"*/}; |
|
141 |
formatList = new String[][] { |
|
142 |
new String[] {"bmp","image/bmp" }, |
|
143 |
new String[] {"gif","image/gif" }, |
|
144 |
new String[] {"tif","image/tiff" }, |
|
145 |
new String[] {"tiff","image/tiff" }, |
|
146 |
new String[] {"jpg","image/jpeg" }, |
|
147 |
new String[] {"jpeg","image/jpeg" }, |
|
148 |
new String[] {"png","image/png" }, |
|
149 |
new String[] {"vrt","image/vrt" }, |
|
150 |
new String[] {"dat","image/dat" }, // Envi |
|
151 |
new String[] {"lan","image/lan" }, // Erdas |
|
152 |
new String[] {"gis","image/gis" }, // Erdas |
|
153 |
new String[] {"img","image/img" }, // Erdas |
|
154 |
new String[] {"pix", "image/pix" },// PCI Geomatics |
|
155 |
new String[] {"aux","image/aux" }, // PCI Geomatics |
|
156 |
new String[] {"adf","image/adf" }, // ESRI Grids |
|
157 |
new String[] {"mpr","image/mpr" }, // Ilwis |
|
158 |
new String[] {"mpl","image/mpl" }, // Ilwis |
|
159 |
new String[] {"map", "image/map" },// PC Raster |
|
160 |
new String[] {"asc","image/asc" }, |
|
161 |
new String[] {"pgm", "image/pgn" },//Ficheros PNM en escala de grises |
|
162 |
new String[] {"ppm", "image/ppm" },//Ficheros PNM en RGB |
|
163 |
new String[] {"rst", "image/rst" },//IDRISIS |
|
164 |
new String[] {"rmf", "image/rmf" },//Raster Matrix Format |
|
165 |
new String[] {"nos","image/nos" }, |
|
166 |
new String[] {"kap","image/kap" }, |
|
167 |
new String[] {"hdr","image/hdr" }, |
|
168 |
new String[] {"raw","image/raw" }, |
|
169 |
new String[] {"ers","image/ers" }, |
|
170 |
new String[] {"xml","image/xml" }, |
|
171 |
new String[] {"grd","image/grd" }, |
|
172 |
/* |
|
173 |
new String[] {"jp2","image/jp2" }, |
|
174 |
new String[] {"mrsid","image/mrsid" }, |
|
175 |
new String[] {"ecw","image/ecw" }, |
|
176 |
*/ |
|
177 |
new String[] {"txt","image/txt" } |
|
178 |
}; |
|
173 | 179 |
for (int i = 0; i < formatList.length; i++) |
174 |
RasterLocator.getManager().getProviderServices().addFormat(formatList[i], GdalProvider.class); |
|
180 |
RasterLocator.getManager().getProviderServices().addFormat(formatList[i][0], GdalProvider.class);
|
|
175 | 181 |
} |
176 | 182 |
|
177 | 183 |
public String[] getFormatList() { |
178 |
return formatList; |
|
184 |
String[] fl = new String[formatList.length]; |
|
185 |
for( int i=0; i<fl.length; i++) { |
|
186 |
fl[i] = formatList[i][0]; |
|
187 |
} |
|
188 |
return fl; |
|
179 | 189 |
} |
180 | 190 |
|
181 | 191 |
/** |
... | ... | |
187 | 197 |
if(ext.indexOf(".") != -1) |
188 | 198 |
ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length()); |
189 | 199 |
for (int i = 0; i < formatList.length; i++) { |
190 |
if(formatList[i].compareTo(ext) == 0) |
|
200 |
if(formatList[i][0].compareTo(ext) == 0)
|
|
191 | 201 |
return true; |
192 | 202 |
} |
193 | 203 |
return false; |
... | ... | |
201 | 211 |
|
202 | 212 |
/** |
203 | 213 |
* Constructor. Abre el dataset. |
204 |
* @param proj Proyecci?n |
|
205 |
* @param fName Nombre del fichero |
|
214 |
* @param params |
|
206 | 215 |
* @throws NotSupportedExtensionException |
207 | 216 |
* @throws OpenException |
208 | 217 |
* @deprecated use {@link #GdalProvider(URI)}, this constructor will be removed in gvSIG 2.5 |
... | ... | |
229 | 238 |
|
230 | 239 |
/** |
231 | 240 |
* Constructor. Abre el dataset. |
232 |
* @param proj Proyecci?n |
|
233 |
* @param fName Nombre del fichero |
|
241 |
* @param uri |
|
234 | 242 |
* @throws NotSupportedExtensionException |
235 | 243 |
*/ |
236 | 244 |
public GdalProvider(URI uri) throws NotSupportedExtensionException { |
... | ... | |
262 | 270 |
/** |
263 | 271 |
* Creates file references and loads structures with the information and metadata |
264 | 272 |
* @param params load parameters |
273 |
* @param storeServices |
|
265 | 274 |
* @throws NotSupportedExtensionException |
266 | 275 |
*/ |
267 | 276 |
public void init (AbstractRasterDataParameters params, |
... | ... | |
318 | 327 |
} |
319 | 328 |
} |
320 | 329 |
|
330 |
public String getMimeType() { |
|
331 |
try { |
|
332 |
File f = ((FilesystemStoreParameters) (this.getDataStoreParameters())).getFile(); |
|
333 |
String ext = FilenameUtils.getExtension(f.getName()); |
|
334 |
for (int i = 0; i < formatList.length; i++) { |
|
335 |
if (ext.equalsIgnoreCase(formatList[i][0])) { |
|
336 |
return formatList[i][1]; |
|
337 |
} |
|
338 |
} |
|
339 |
} catch (Exception ex) { |
|
340 |
logger.warn("Can't get mime type for GDAL archive.",ex); |
|
341 |
} |
|
342 |
return "image"; |
|
343 |
} |
|
344 |
|
|
321 | 345 |
/** |
322 | 346 |
* Comprueba si el fichero abierto es un RasterMetaFile o una imagen |
323 | 347 |
* raster. |
... | ... | |
366 | 390 |
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci?n |
367 | 391 |
* de la vista asignada ya que la petici?n viene en coordenadas del fichero .rmf y la vista (v) |
368 | 392 |
* ha de estar en coordenadas del fichero. |
393 |
* @param e |
|
369 | 394 |
*/ |
370 | 395 |
public void setView(Extent e) { |
371 | 396 |
viewRequest = new ExtentImpl(e); |
... | ... | |
483 | 508 |
return false; |
484 | 509 |
} |
485 | 510 |
|
486 |
public GdalDataSource getNative(){
|
|
511 |
protected GdalDataSource getNative(){
|
|
487 | 512 |
return file; |
488 | 513 |
} |
489 | 514 |
|
Also available in: Unified diff