gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.io / resources / TemplateRasterProvider.java @ 510
History | View | Annotate | Download (15.1 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.fmap.dal.coverage.dataset.io.netcdf; |
23 |
|
24 |
import java.awt.geom.AffineTransform; |
25 |
|
26 |
import org.gvsig.fmap.dal.DALFileLocator; |
27 |
import org.gvsig.fmap.dal.DALLocator; |
28 |
import org.gvsig.fmap.dal.DataStore; |
29 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
30 |
import org.gvsig.fmap.dal.coverage.dataset.io.tile.downloader.FileTileServer; |
31 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
32 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
33 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
34 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
35 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
36 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
37 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException; |
38 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
39 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
40 |
import org.gvsig.fmap.dal.coverage.store.RasterFileStoreParameters; |
41 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
42 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
43 |
import org.gvsig.metadata.MetadataLocator; |
44 |
import org.gvsig.raster.cache.tile.provider.TileListener; |
45 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
46 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
47 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
48 |
import org.gvsig.raster.impl.provider.RasterProvider; |
49 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
50 |
import org.gvsig.raster.impl.store.AbstractRasterDataStore; |
51 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
52 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
53 |
import org.gvsig.raster.impl.store.properties.DataStoreMetadata; |
54 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
55 |
import org.gvsig.tools.ToolsLocator; |
56 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
57 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
58 |
/**
|
59 |
* Data provider for ...
|
60 |
*
|
61 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
62 |
*/
|
63 |
public class NetCDFProvider extends DefaultRasterProvider { |
64 |
public static String NAME = "Template Store"; |
65 |
public static String DESCRIPTION = "Template Raster file"; |
66 |
public final String METADATA_DEFINITION_NAME = "TemplateStore"; |
67 |
|
68 |
private static String[] formatList = new String[]{"*"}; |
69 |
|
70 |
private Extent viewRequest = null; |
71 |
private TileServer tileServer = null; |
72 |
private boolean open = false; |
73 |
|
74 |
public static void register() { |
75 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
76 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) { |
77 |
dataman.registerStoreProvider(NAME, |
78 |
NetCDFProvider.class, NetCDFDataParameters.class); |
79 |
} |
80 |
|
81 |
if(DALFileLocator.getFilesystemServerExplorerManager() != null) |
82 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
83 |
NAME, DESCRIPTION, |
84 |
NetCDFFilesystemServerExplorer.class); |
85 |
|
86 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class); |
87 |
} |
88 |
|
89 |
|
90 |
/**
|
91 |
* Returns true if the extension is supported and false if doesn't
|
92 |
* @param ext
|
93 |
* @return
|
94 |
*/
|
95 |
public static boolean isExtensionSupported(String ext) { |
96 |
for (int i = 0; i < formatList.length; i++) { |
97 |
if(formatList[i].compareTo(ext) == 0) |
98 |
return true; |
99 |
} |
100 |
return false; |
101 |
} |
102 |
|
103 |
/**
|
104 |
* Constructor. Abre el dataset.
|
105 |
* @param proj Proyecci?n
|
106 |
* @param fName Nombre del fichero
|
107 |
* @throws NotSupportedExtensionException
|
108 |
*/
|
109 |
public NetCDFProvider(String params) throws NotSupportedExtensionException { |
110 |
super(params);
|
111 |
if(params instanceof String) { |
112 |
NetCDFDataParameters p = new NetCDFDataParameters();
|
113 |
p.setURI((String)params);
|
114 |
super.init(p, null, ToolsLocator.getDynObjectManager() |
115 |
.createDynObject( |
116 |
MetadataLocator.getMetadataManager().getDefinition( |
117 |
DataStore.METADATA_DEFINITION_NAME))); |
118 |
init(p, null);
|
119 |
} |
120 |
} |
121 |
|
122 |
public NetCDFProvider (NetCDFDataParameters params,
|
123 |
AbstractRasterDataStore storeServices) throws NotSupportedExtensionException {
|
124 |
super(params, storeServices, ToolsLocator.getDynObjectManager()
|
125 |
.createDynObject( |
126 |
MetadataLocator.getMetadataManager().getDefinition( |
127 |
DataStore.METADATA_DEFINITION_NAME))); |
128 |
init(params, storeServices); |
129 |
} |
130 |
|
131 |
/**
|
132 |
* Crea las referencias al fichero y carga
|
133 |
* las estructuras con la informaci?n y los metadatos.
|
134 |
* @param proj Proyecci?n
|
135 |
* @param param Parametros de carga
|
136 |
* @throws NotSupportedExtensionException
|
137 |
*/
|
138 |
public void init (AbstractRasterDataParameters params, |
139 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
|
140 |
//TODO:
|
141 |
|
142 |
if(((RasterFileStoreParameters)params).getFile().exists()) {
|
143 |
setParam(params); |
144 |
colorTable = null;
|
145 |
noData = 0;
|
146 |
wktProjection = null;
|
147 |
//CrsWkt crs = new CrsWkt(wktProjection);
|
148 |
//IProjection proj = CRSFactory.getCRS("EPSG:23030");
|
149 |
noDataEnabled = true;
|
150 |
ownTransformation = null;
|
151 |
externalTransformation = (AffineTransform)ownTransformation.clone();
|
152 |
load(); |
153 |
} else
|
154 |
setParam(params); |
155 |
bandCount = 0;
|
156 |
setDataType(null);
|
157 |
super.init();
|
158 |
|
159 |
try {
|
160 |
loadFromRmf(getRmfBlocksManager()); |
161 |
} catch (ParsingException e) {
|
162 |
//No lee desde rmf
|
163 |
} |
164 |
} |
165 |
|
166 |
/*
|
167 |
* (non-Javadoc)
|
168 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#load()
|
169 |
*/
|
170 |
public RasterProvider load() {
|
171 |
return this; |
172 |
} |
173 |
|
174 |
/*
|
175 |
* (non-Javadoc)
|
176 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isOpen()
|
177 |
*/
|
178 |
public boolean isOpen() { |
179 |
return open;
|
180 |
} |
181 |
|
182 |
/*
|
183 |
* (non-Javadoc)
|
184 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#close()
|
185 |
*/
|
186 |
public void close() { |
187 |
//TODO:
|
188 |
} |
189 |
|
190 |
/*
|
191 |
* (non-Javadoc)
|
192 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#translateFileName(java.lang.String)
|
193 |
*/
|
194 |
public String translateFileName(String fileName) { |
195 |
return fileName;
|
196 |
} |
197 |
|
198 |
/**
|
199 |
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci?n
|
200 |
* de la vista asignada ya que la petici?n viene en coordenadas del fichero .rmf y la vista (v)
|
201 |
* ha de estar en coordenadas del fichero.
|
202 |
*/
|
203 |
public void setView(Extent e) { |
204 |
viewRequest = new ExtentImpl(e);
|
205 |
} |
206 |
|
207 |
/*
|
208 |
* (non-Javadoc)
|
209 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getView()
|
210 |
*/
|
211 |
public Extent getView() {
|
212 |
return viewRequest;
|
213 |
} |
214 |
|
215 |
/*
|
216 |
* (non-Javadoc)
|
217 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWidth()
|
218 |
*/
|
219 |
public double getWidth() { |
220 |
//TODO:
|
221 |
return 0; |
222 |
} |
223 |
|
224 |
/*
|
225 |
* (non-Javadoc)
|
226 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getHeight()
|
227 |
*/
|
228 |
public double getHeight() { |
229 |
//TODO:
|
230 |
return 0; |
231 |
} |
232 |
|
233 |
/**
|
234 |
* Read a line from the file
|
235 |
* @param line
|
236 |
* @param band
|
237 |
* @return
|
238 |
* @throws InvalidSetViewException
|
239 |
* @throws FileNotOpenException
|
240 |
* @throws RasterDriverException
|
241 |
* @Deprecated This operation is deprecated because is not useful and in the future
|
242 |
* it will not be maintained. The abstract operation has dissapear
|
243 |
*/
|
244 |
public Object readCompleteLine(int line, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
245 |
if(line > this.getHeight() || band > this.getBandCount()) |
246 |
throw new InvalidSetViewException("Request out of grid"); |
247 |
|
248 |
//TODO:
|
249 |
return null; |
250 |
} |
251 |
|
252 |
/*
|
253 |
* (non-Javadoc)
|
254 |
* @see org.gvsig.raster.dataset.RasterDataset#readBlock(int, int)
|
255 |
*/
|
256 |
public Object readBlock(int pos, int blockHeight) |
257 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
|
258 |
if(pos < 0) |
259 |
throw new InvalidSetViewException("Request out of grid"); |
260 |
|
261 |
if((pos + blockHeight) > getHeight())
|
262 |
blockHeight = Math.abs(((int)getHeight()) - pos); |
263 |
|
264 |
//TODO:
|
265 |
return null; |
266 |
} |
267 |
|
268 |
/*
|
269 |
* (non-Javadoc)
|
270 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getData(int, int, int)
|
271 |
*/
|
272 |
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
273 |
if(x < 0 || y < 0 || x >= getWidth() || y >= getHeight()) |
274 |
throw new InvalidSetViewException("Request out of grid"); |
275 |
|
276 |
//TODO
|
277 |
return null; |
278 |
} |
279 |
|
280 |
/*
|
281 |
* (non-Javadoc)
|
282 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.raster.cache.tile.provider.TileListener)
|
283 |
*/
|
284 |
public void getWindow(Extent ex, int bufWidth, int bufHeight, |
285 |
BandList bandList, TileListener listener) throws ProcessInterruptedException, RasterDriverException {
|
286 |
//TODO
|
287 |
} |
288 |
|
289 |
/*
|
290 |
* (non-Javadoc)
|
291 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(org.gvsig.fmap.dal.coverage.datastruct.Extent, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer)
|
292 |
*/
|
293 |
public Buffer getWindow(Extent ex, BandList bandList, Buffer rasterBuf) |
294 |
throws ProcessInterruptedException, RasterDriverException {
|
295 |
//TODO
|
296 |
|
297 |
return rasterBuf;
|
298 |
} |
299 |
|
300 |
/*
|
301 |
* (non-Javadoc)
|
302 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer, boolean)
|
303 |
*/
|
304 |
public Buffer getWindow(double ulx, double uly, double w, double h, |
305 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException { |
306 |
//TODO
|
307 |
|
308 |
return rasterBuf;
|
309 |
} |
310 |
|
311 |
/*
|
312 |
* (non-Javadoc)
|
313 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer, boolean)
|
314 |
*/
|
315 |
public Buffer getWindow(Extent extent, |
316 |
int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException { |
317 |
//TODO
|
318 |
|
319 |
return rasterBuf;
|
320 |
} |
321 |
|
322 |
/*
|
323 |
* (non-Javadoc)
|
324 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(int, int, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer)
|
325 |
*/
|
326 |
public Buffer getWindow(int x, int y, int w, int h, |
327 |
BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException { |
328 |
//TODO
|
329 |
|
330 |
return rasterBuf;
|
331 |
} |
332 |
|
333 |
/*
|
334 |
* (non-Javadoc)
|
335 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(int, int, int, int, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer)
|
336 |
*/
|
337 |
public Buffer getWindow(int x, int y, int w, int h, |
338 |
int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException { |
339 |
//TODO
|
340 |
|
341 |
return rasterBuf;
|
342 |
} |
343 |
|
344 |
/*
|
345 |
* (non-Javadoc)
|
346 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getBlockSize()
|
347 |
*/
|
348 |
public int getBlockSize(){ |
349 |
//TODO
|
350 |
|
351 |
return 0; |
352 |
} |
353 |
|
354 |
/*
|
355 |
* (non-Javadoc)
|
356 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getMetadata()
|
357 |
*/
|
358 |
public DataStoreMetadata getMetadata() {
|
359 |
//TODO
|
360 |
|
361 |
return null; |
362 |
} |
363 |
|
364 |
/*
|
365 |
* (non-Javadoc)
|
366 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getColorInterpretation()
|
367 |
*/
|
368 |
public DataStoreColorInterpretation getColorInterpretation(){
|
369 |
//TODO
|
370 |
|
371 |
return null; |
372 |
} |
373 |
|
374 |
/*
|
375 |
* (non-Javadoc)
|
376 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#setColorInterpretation(org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation)
|
377 |
*/
|
378 |
public void setColorInterpretation(DataStoreColorInterpretation colorInterpretation){ |
379 |
//TODO
|
380 |
} |
381 |
|
382 |
/*
|
383 |
* (non-Javadoc)
|
384 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getTransparency()
|
385 |
*/
|
386 |
public DataStoreTransparency getTransparency() {
|
387 |
//TODO
|
388 |
|
389 |
return null; |
390 |
} |
391 |
|
392 |
/*
|
393 |
* (non-Javadoc)
|
394 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isGeoreferenced()
|
395 |
*/
|
396 |
public boolean isGeoreferenced() { |
397 |
//TODO
|
398 |
|
399 |
return false; |
400 |
} |
401 |
|
402 |
/**
|
403 |
* Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el driver el que colocar?
|
404 |
* el valor de esta variable cada vez que dibuja.
|
405 |
* @return true si se ha supersampleado y false si no se ha hecho.
|
406 |
*/
|
407 |
public boolean isSupersampling() { |
408 |
//TODO
|
409 |
|
410 |
return false; |
411 |
} |
412 |
|
413 |
/*
|
414 |
* (non-Javadoc)
|
415 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#setAffineTransform(java.awt.geom.AffineTransform)
|
416 |
*/
|
417 |
public void setAffineTransform(AffineTransform t){ |
418 |
super.setAffineTransform(t);
|
419 |
} |
420 |
|
421 |
/*
|
422 |
* (non-Javadoc)
|
423 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewCount(int)
|
424 |
*/
|
425 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException { |
426 |
if(band >= getBandCount())
|
427 |
throw new BandAccessException("Wrong band"); |
428 |
//TODO
|
429 |
|
430 |
return 0; |
431 |
} |
432 |
|
433 |
/*
|
434 |
* (non-Javadoc)
|
435 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewWidth(int, int)
|
436 |
*/
|
437 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException { |
438 |
if (band >= getBandCount())
|
439 |
throw new BandAccessException("Wrong band"); |
440 |
//TODO
|
441 |
|
442 |
return 0; |
443 |
} |
444 |
|
445 |
/*
|
446 |
* (non-Javadoc)
|
447 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewHeight(int, int)
|
448 |
*/
|
449 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException { |
450 |
if (band >= getBandCount())
|
451 |
throw new BandAccessException("Wrong band"); |
452 |
//TODO
|
453 |
|
454 |
return 0; |
455 |
} |
456 |
|
457 |
/*
|
458 |
* (non-Javadoc)
|
459 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#overviewsSupport()
|
460 |
*/
|
461 |
public boolean overviewsSupport() { |
462 |
return true; |
463 |
} |
464 |
|
465 |
/*
|
466 |
* (non-Javadoc)
|
467 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isReproyectable()
|
468 |
*/
|
469 |
public boolean isReproyectable() { |
470 |
return true; |
471 |
} |
472 |
|
473 |
/*
|
474 |
* (non-Javadoc)
|
475 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#getName()
|
476 |
*/
|
477 |
public String getName() { |
478 |
return NAME;
|
479 |
} |
480 |
|
481 |
/*
|
482 |
* (non-Javadoc)
|
483 |
* @see org.gvsig.raster.impl.provider.RasterProvider#setStatus(org.gvsig.raster.impl.provider.RasterProvider)
|
484 |
*/
|
485 |
public void setStatus(RasterProvider provider) { |
486 |
if(provider instanceof NetCDFProvider) { |
487 |
//Not implemented yet
|
488 |
} |
489 |
} |
490 |
|
491 |
/*
|
492 |
* (non-Javadoc)
|
493 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getTileServer()
|
494 |
*/
|
495 |
public TileServer getTileServer() {
|
496 |
if(tileServer == null) |
497 |
tileServer = new FileTileServer(this); |
498 |
return tileServer;
|
499 |
} |
500 |
} |