gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.io / src / test / resources / TemplateRasterProvider.java @ 393
History | View | Annotate | Download (15.6 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 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
76 |
ExtensionPoint point = extensionPoints.get("RasterReader");
|
77 |
addFormatsToRegistry(point, NetCDFProvider.class); |
78 |
|
79 |
point = extensionPoints.get("DefaultDriver");
|
80 |
point.append("reader", "", NetCDFProvider.class); |
81 |
|
82 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
83 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) { |
84 |
dataman.registerStoreProvider(NAME, |
85 |
NetCDFProvider.class, NetCDFDataParameters.class); |
86 |
} |
87 |
|
88 |
if(DALFileLocator.getFilesystemServerExplorerManager() != null) |
89 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
90 |
NAME, DESCRIPTION, |
91 |
NetCDFFilesystemServerExplorer.class); |
92 |
|
93 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class); |
94 |
} |
95 |
|
96 |
/**
|
97 |
* Adds the list format to the extension point
|
98 |
* @param point
|
99 |
*/
|
100 |
public static void addFormatsToRegistry(ExtensionPoint point, Class<?> c) { |
101 |
for (int i = 0; i < formatList.length; i++) { |
102 |
point.append(formatList[i], "", c);
|
103 |
} |
104 |
} |
105 |
|
106 |
/**
|
107 |
* Returns true if the extension is supported and false if doesn't
|
108 |
* @param ext
|
109 |
* @return
|
110 |
*/
|
111 |
public static boolean isExtensionSupported(String ext) { |
112 |
for (int i = 0; i < formatList.length; i++) { |
113 |
if(formatList[i].compareTo(ext) == 0) |
114 |
return true; |
115 |
} |
116 |
return false; |
117 |
} |
118 |
|
119 |
/**
|
120 |
* Constructor. Abre el dataset.
|
121 |
* @param proj Proyecci?n
|
122 |
* @param fName Nombre del fichero
|
123 |
* @throws NotSupportedExtensionException
|
124 |
*/
|
125 |
public NetCDFProvider(String params) throws NotSupportedExtensionException { |
126 |
super(params);
|
127 |
if(params instanceof String) { |
128 |
NetCDFDataParameters p = new NetCDFDataParameters();
|
129 |
p.setURI((String)params);
|
130 |
super.init(p, null, ToolsLocator.getDynObjectManager() |
131 |
.createDynObject( |
132 |
MetadataLocator.getMetadataManager().getDefinition( |
133 |
DataStore.METADATA_DEFINITION_NAME))); |
134 |
init(p, null);
|
135 |
} |
136 |
} |
137 |
|
138 |
public NetCDFProvider (NetCDFDataParameters params,
|
139 |
AbstractRasterDataStore storeServices) throws NotSupportedExtensionException {
|
140 |
super(params, storeServices, ToolsLocator.getDynObjectManager()
|
141 |
.createDynObject( |
142 |
MetadataLocator.getMetadataManager().getDefinition( |
143 |
DataStore.METADATA_DEFINITION_NAME))); |
144 |
init(params, storeServices); |
145 |
} |
146 |
|
147 |
/**
|
148 |
* Crea las referencias al fichero y carga
|
149 |
* las estructuras con la informaci?n y los metadatos.
|
150 |
* @param proj Proyecci?n
|
151 |
* @param param Parametros de carga
|
152 |
* @throws NotSupportedExtensionException
|
153 |
*/
|
154 |
public void init (AbstractRasterDataParameters params, |
155 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
|
156 |
//TODO:
|
157 |
|
158 |
if(((RasterFileStoreParameters)params).getFile().exists()) {
|
159 |
setParam(params); |
160 |
colorTable = null;
|
161 |
noData = 0;
|
162 |
wktProjection = null;
|
163 |
//CrsWkt crs = new CrsWkt(wktProjection);
|
164 |
//IProjection proj = CRSFactory.getCRS("EPSG:23030");
|
165 |
noDataEnabled = true;
|
166 |
ownTransformation = null;
|
167 |
externalTransformation = (AffineTransform)ownTransformation.clone();
|
168 |
load(); |
169 |
} else
|
170 |
setParam(params); |
171 |
bandCount = 0;
|
172 |
setDataType(null);
|
173 |
super.init();
|
174 |
|
175 |
try {
|
176 |
loadFromRmf(getRmfBlocksManager()); |
177 |
} catch (ParsingException e) {
|
178 |
//No lee desde rmf
|
179 |
} |
180 |
} |
181 |
|
182 |
/*
|
183 |
* (non-Javadoc)
|
184 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#load()
|
185 |
*/
|
186 |
public RasterProvider load() {
|
187 |
return this; |
188 |
} |
189 |
|
190 |
/*
|
191 |
* (non-Javadoc)
|
192 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isOpen()
|
193 |
*/
|
194 |
public boolean isOpen() { |
195 |
return open;
|
196 |
} |
197 |
|
198 |
/*
|
199 |
* (non-Javadoc)
|
200 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#close()
|
201 |
*/
|
202 |
public void close() { |
203 |
//TODO:
|
204 |
} |
205 |
|
206 |
/*
|
207 |
* (non-Javadoc)
|
208 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#translateFileName(java.lang.String)
|
209 |
*/
|
210 |
public String translateFileName(String fileName) { |
211 |
return fileName;
|
212 |
} |
213 |
|
214 |
/**
|
215 |
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci?n
|
216 |
* de la vista asignada ya que la petici?n viene en coordenadas del fichero .rmf y la vista (v)
|
217 |
* ha de estar en coordenadas del fichero.
|
218 |
*/
|
219 |
public void setView(Extent e) { |
220 |
viewRequest = new ExtentImpl(e);
|
221 |
} |
222 |
|
223 |
/*
|
224 |
* (non-Javadoc)
|
225 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getView()
|
226 |
*/
|
227 |
public Extent getView() {
|
228 |
return viewRequest;
|
229 |
} |
230 |
|
231 |
/*
|
232 |
* (non-Javadoc)
|
233 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWidth()
|
234 |
*/
|
235 |
public double getWidth() { |
236 |
//TODO:
|
237 |
return 0; |
238 |
} |
239 |
|
240 |
/*
|
241 |
* (non-Javadoc)
|
242 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getHeight()
|
243 |
*/
|
244 |
public double getHeight() { |
245 |
//TODO:
|
246 |
return 0; |
247 |
} |
248 |
|
249 |
/**
|
250 |
* Read a line from the file
|
251 |
* @param line
|
252 |
* @param band
|
253 |
* @return
|
254 |
* @throws InvalidSetViewException
|
255 |
* @throws FileNotOpenException
|
256 |
* @throws RasterDriverException
|
257 |
* @Deprecated This operation is deprecated because is not useful and in the future
|
258 |
* it will not be maintained. The abstract operation has dissapear
|
259 |
*/
|
260 |
public Object readCompleteLine(int line, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
261 |
if(line > this.getHeight() || band > this.getBandCount()) |
262 |
throw new InvalidSetViewException("Request out of grid"); |
263 |
|
264 |
//TODO:
|
265 |
return null; |
266 |
} |
267 |
|
268 |
/*
|
269 |
* (non-Javadoc)
|
270 |
* @see org.gvsig.raster.dataset.RasterDataset#readBlock(int, int)
|
271 |
*/
|
272 |
public Object readBlock(int pos, int blockHeight) |
273 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
|
274 |
if(pos < 0) |
275 |
throw new InvalidSetViewException("Request out of grid"); |
276 |
|
277 |
if((pos + blockHeight) > getHeight())
|
278 |
blockHeight = Math.abs(((int)getHeight()) - pos); |
279 |
|
280 |
//TODO:
|
281 |
return null; |
282 |
} |
283 |
|
284 |
/*
|
285 |
* (non-Javadoc)
|
286 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getData(int, int, int)
|
287 |
*/
|
288 |
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
289 |
if(x < 0 || y < 0 || x >= getWidth() || y >= getHeight()) |
290 |
throw new InvalidSetViewException("Request out of grid"); |
291 |
|
292 |
//TODO
|
293 |
return null; |
294 |
} |
295 |
|
296 |
/*
|
297 |
* (non-Javadoc)
|
298 |
* @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)
|
299 |
*/
|
300 |
public void getWindow(Extent ex, int bufWidth, int bufHeight, |
301 |
BandList bandList, TileListener listener) throws ProcessInterruptedException, RasterDriverException {
|
302 |
//TODO
|
303 |
} |
304 |
|
305 |
/*
|
306 |
* (non-Javadoc)
|
307 |
* @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)
|
308 |
*/
|
309 |
public Buffer getWindow(Extent ex, BandList bandList, Buffer rasterBuf) |
310 |
throws ProcessInterruptedException, RasterDriverException {
|
311 |
//TODO
|
312 |
|
313 |
return rasterBuf;
|
314 |
} |
315 |
|
316 |
/*
|
317 |
* (non-Javadoc)
|
318 |
* @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)
|
319 |
*/
|
320 |
public Buffer getWindow(double ulx, double uly, double w, double h, |
321 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException { |
322 |
//TODO
|
323 |
|
324 |
return rasterBuf;
|
325 |
} |
326 |
|
327 |
/*
|
328 |
* (non-Javadoc)
|
329 |
* @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)
|
330 |
*/
|
331 |
public Buffer getWindow(Extent extent, |
332 |
int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException { |
333 |
//TODO
|
334 |
|
335 |
return rasterBuf;
|
336 |
} |
337 |
|
338 |
/*
|
339 |
* (non-Javadoc)
|
340 |
* @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)
|
341 |
*/
|
342 |
public Buffer getWindow(int x, int y, int w, int h, |
343 |
BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException { |
344 |
//TODO
|
345 |
|
346 |
return rasterBuf;
|
347 |
} |
348 |
|
349 |
/*
|
350 |
* (non-Javadoc)
|
351 |
* @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)
|
352 |
*/
|
353 |
public Buffer getWindow(int x, int y, int w, int h, |
354 |
int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException { |
355 |
//TODO
|
356 |
|
357 |
return rasterBuf;
|
358 |
} |
359 |
|
360 |
/*
|
361 |
* (non-Javadoc)
|
362 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getBlockSize()
|
363 |
*/
|
364 |
public int getBlockSize(){ |
365 |
//TODO
|
366 |
|
367 |
return 0; |
368 |
} |
369 |
|
370 |
/*
|
371 |
* (non-Javadoc)
|
372 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getMetadata()
|
373 |
*/
|
374 |
public DataStoreMetadata getMetadata() {
|
375 |
//TODO
|
376 |
|
377 |
return null; |
378 |
} |
379 |
|
380 |
/*
|
381 |
* (non-Javadoc)
|
382 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getColorInterpretation()
|
383 |
*/
|
384 |
public DataStoreColorInterpretation getColorInterpretation(){
|
385 |
//TODO
|
386 |
|
387 |
return null; |
388 |
} |
389 |
|
390 |
/*
|
391 |
* (non-Javadoc)
|
392 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#setColorInterpretation(org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation)
|
393 |
*/
|
394 |
public void setColorInterpretation(DataStoreColorInterpretation colorInterpretation){ |
395 |
//TODO
|
396 |
} |
397 |
|
398 |
/*
|
399 |
* (non-Javadoc)
|
400 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getTransparency()
|
401 |
*/
|
402 |
public DataStoreTransparency getTransparency() {
|
403 |
//TODO
|
404 |
|
405 |
return null; |
406 |
} |
407 |
|
408 |
/*
|
409 |
* (non-Javadoc)
|
410 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isGeoreferenced()
|
411 |
*/
|
412 |
public boolean isGeoreferenced() { |
413 |
//TODO
|
414 |
|
415 |
return false; |
416 |
} |
417 |
|
418 |
/**
|
419 |
* Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el driver el que colocar?
|
420 |
* el valor de esta variable cada vez que dibuja.
|
421 |
* @return true si se ha supersampleado y false si no se ha hecho.
|
422 |
*/
|
423 |
public boolean isSupersampling() { |
424 |
//TODO
|
425 |
|
426 |
return false; |
427 |
} |
428 |
|
429 |
/*
|
430 |
* (non-Javadoc)
|
431 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#setAffineTransform(java.awt.geom.AffineTransform)
|
432 |
*/
|
433 |
public void setAffineTransform(AffineTransform t){ |
434 |
super.setAffineTransform(t);
|
435 |
} |
436 |
|
437 |
/*
|
438 |
* (non-Javadoc)
|
439 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewCount(int)
|
440 |
*/
|
441 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException { |
442 |
if(band >= getBandCount())
|
443 |
throw new BandAccessException("Wrong band"); |
444 |
//TODO
|
445 |
|
446 |
return 0; |
447 |
} |
448 |
|
449 |
/*
|
450 |
* (non-Javadoc)
|
451 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewWidth(int, int)
|
452 |
*/
|
453 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException { |
454 |
if (band >= getBandCount())
|
455 |
throw new BandAccessException("Wrong band"); |
456 |
//TODO
|
457 |
|
458 |
return 0; |
459 |
} |
460 |
|
461 |
/*
|
462 |
* (non-Javadoc)
|
463 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewHeight(int, int)
|
464 |
*/
|
465 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException { |
466 |
if (band >= getBandCount())
|
467 |
throw new BandAccessException("Wrong band"); |
468 |
//TODO
|
469 |
|
470 |
return 0; |
471 |
} |
472 |
|
473 |
/*
|
474 |
* (non-Javadoc)
|
475 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#overviewsSupport()
|
476 |
*/
|
477 |
public boolean overviewsSupport() { |
478 |
return true; |
479 |
} |
480 |
|
481 |
/*
|
482 |
* (non-Javadoc)
|
483 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isReproyectable()
|
484 |
*/
|
485 |
public boolean isReproyectable() { |
486 |
return true; |
487 |
} |
488 |
|
489 |
/*
|
490 |
* (non-Javadoc)
|
491 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#getName()
|
492 |
*/
|
493 |
public String getName() { |
494 |
return NAME;
|
495 |
} |
496 |
|
497 |
/*
|
498 |
* (non-Javadoc)
|
499 |
* @see org.gvsig.raster.impl.provider.RasterProvider#setStatus(org.gvsig.raster.impl.provider.RasterProvider)
|
500 |
*/
|
501 |
public void setStatus(RasterProvider provider) { |
502 |
if(provider instanceof NetCDFProvider) { |
503 |
//Not implemented yet
|
504 |
} |
505 |
} |
506 |
|
507 |
/*
|
508 |
* (non-Javadoc)
|
509 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getTileServer()
|
510 |
*/
|
511 |
public TileServer getTileServer() {
|
512 |
if(tileServer == null) |
513 |
tileServer = new FileTileServer(this); |
514 |
return tileServer;
|
515 |
} |
516 |
} |