gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / provider / DefaultRasterProvider.java @ 937
History | View | Annotate | Download (43.8 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.raster.impl.provider; |
23 |
|
24 |
import java.awt.geom.AffineTransform; |
25 |
import java.awt.geom.NoninvertibleTransformException; |
26 |
import java.awt.geom.Point2D; |
27 |
import java.io.File; |
28 |
import java.util.ArrayList; |
29 |
import java.util.Collection; |
30 |
import java.util.Date; |
31 |
import java.util.Iterator; |
32 |
|
33 |
import org.cresques.cts.IProjection; |
34 |
import org.gvsig.compat.net.ICancellable; |
35 |
import org.gvsig.fmap.dal.DALLocator; |
36 |
import org.gvsig.fmap.dal.DataServerExplorer; |
37 |
import org.gvsig.fmap.dal.DataStoreParameters; |
38 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
39 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
40 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
41 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
42 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
43 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
44 |
import org.gvsig.fmap.dal.coverage.exception.CloneException; |
45 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
46 |
import org.gvsig.fmap.dal.coverage.exception.HistogramException; |
47 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
48 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
49 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException; |
50 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
51 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
52 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
53 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
54 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
55 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
56 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterFileStoreParameters; |
57 |
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters; |
58 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
59 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
60 |
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer; |
61 |
import org.gvsig.fmap.dal.coverage.store.props.Metadata; |
62 |
import org.gvsig.fmap.dal.coverage.store.props.Statistics; |
63 |
import org.gvsig.fmap.dal.coverage.store.props.TimeSeries; |
64 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
65 |
import org.gvsig.fmap.dal.coverage.util.FileUtils; |
66 |
import org.gvsig.fmap.dal.coverage.util.RasterUtils; |
67 |
import org.gvsig.fmap.dal.exception.InitializeException; |
68 |
import org.gvsig.fmap.dal.exception.OpenException; |
69 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
70 |
import org.gvsig.fmap.dal.exception.ReadException; |
71 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
72 |
import org.gvsig.fmap.dal.raster.spi.AbstractCoverageStoreProvider; |
73 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
74 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
75 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
76 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
77 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
78 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
79 |
import org.gvsig.raster.cache.tile.provider.TileListener; |
80 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
81 |
import org.gvsig.raster.impl.datastruct.DefaultNoData; |
82 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
83 |
import org.gvsig.raster.impl.datastruct.serializer.ColorTableRmfSerializer; |
84 |
import org.gvsig.raster.impl.datastruct.serializer.NoDataRmfSerializer; |
85 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
86 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
87 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
88 |
import org.gvsig.raster.impl.store.properties.SimpleProviderHistogramComputer; |
89 |
import org.gvsig.raster.impl.store.properties.SimpleProviderStatistics; |
90 |
import org.gvsig.raster.impl.store.rmf.ClassSerializer; |
91 |
import org.gvsig.raster.impl.store.rmf.RmfBlocksManager; |
92 |
import org.gvsig.raster.impl.store.serializer.ColorInterpretationRmfSerializer; |
93 |
import org.gvsig.raster.impl.store.serializer.GeoInfoRmfSerializer; |
94 |
import org.gvsig.raster.impl.store.serializer.ProjectionRmfSerializer; |
95 |
import org.gvsig.raster.impl.store.serializer.StatisticsRmfSerializer; |
96 |
import org.gvsig.raster.util.DefaultProviderServices; |
97 |
import org.gvsig.timesupport.Interval; |
98 |
import org.gvsig.timesupport.Time; |
99 |
import org.gvsig.tools.dynobject.DynObject; |
100 |
|
101 |
/**
|
102 |
* Base class for all raster providers.
|
103 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
104 |
*/
|
105 |
public abstract class DefaultRasterProvider extends AbstractCoverageStoreProvider implements RasterProvider { |
106 |
/**
|
107 |
* Flags que representan a las bandas visualizables
|
108 |
*/
|
109 |
public static final int RED_BAND = 0x01; |
110 |
public static final int GREEN_BAND = 0x02; |
111 |
public static final int BLUE_BAND = 0x04; |
112 |
public static final int ALPHA_BAND = 0x08; |
113 |
|
114 |
protected int bandCount = 1; |
115 |
private int[] dataType = null; |
116 |
protected NoData noData = null; |
117 |
protected String wktProjection = ""; |
118 |
|
119 |
protected Statistics stats = null; |
120 |
protected HistogramComputer histogram = null; |
121 |
protected DataStoreParameters param = null; |
122 |
protected DataStoreProviderServices storeServices = null; |
123 |
protected RmfBlocksManager rmfBlocksManager = null; |
124 |
protected ColorTable colorTable = null; |
125 |
private ColorInterpretation colorInterpretation = null; |
126 |
protected TimeSeries serialInfo = null; |
127 |
protected Transparency transparency = null; |
128 |
protected TileServer tileServer = null; |
129 |
|
130 |
protected FileUtils fileUtil = RasterLocator.getManager().getFileUtils();
|
131 |
protected RasterUtils rasterUtil = RasterLocator.getManager().getRasterUtils();
|
132 |
|
133 |
protected IProjection proj = null; |
134 |
protected long fileSize = 0; |
135 |
protected long bytesReaded = 0; |
136 |
protected long lineCnt = 0; |
137 |
protected String uri; |
138 |
protected String selectedSubdatasetID = null; |
139 |
|
140 |
/**
|
141 |
* Transformaci?n creada a partir de la informaci?n de georreferencia de la
|
142 |
* propia imagen. Esta informaci?n est? en la cabecera o en ficheros
|
143 |
* worldfile.
|
144 |
*/
|
145 |
protected AffineTransform ownTransformation = null; |
146 |
/**
|
147 |
* Transformaci?n asignada de forma externa, bien desde el fichero rmf o
|
148 |
* asignada directamente por el usuario.
|
149 |
*/
|
150 |
protected AffineTransform externalTransformation = null; |
151 |
|
152 |
public DefaultRasterProvider(AbstractRasterDataParameters params,
|
153 |
DataStoreProviderServices storeServices, DynObject metadata) { |
154 |
super(params, storeServices, metadata);
|
155 |
if(params.getURI() != null) { |
156 |
File f = new File(params.getURI()); |
157 |
if(f.exists())
|
158 |
setFileSize(f.length()); |
159 |
} |
160 |
|
161 |
if(params.getURI() != null) |
162 |
uri = translateFileName(params.getURI()); |
163 |
|
164 |
ownTransformation = new AffineTransform(); |
165 |
externalTransformation = new AffineTransform(); |
166 |
} |
167 |
|
168 |
public DefaultRasterProvider(DataStoreParameters params,
|
169 |
DataStoreProviderServices storeServices, DynObject metadata) { |
170 |
super(params, storeServices, metadata);
|
171 |
if(((RasterDataParameters)params).getURI() != null) { |
172 |
File f = new File(((RasterDataParameters)params).getURI()); |
173 |
if(f.exists())
|
174 |
setFileSize(f.length()); |
175 |
if(params instanceof RemoteStoreParameters) |
176 |
uri = translateFileName(((RasterDataParameters)params).getURI()); |
177 |
} |
178 |
|
179 |
ownTransformation = new AffineTransform(); |
180 |
externalTransformation = new AffineTransform(); |
181 |
} |
182 |
|
183 |
public DefaultRasterProvider(String params) { |
184 |
super();
|
185 |
} |
186 |
|
187 |
public DefaultRasterProvider() {
|
188 |
super(null, null, null); |
189 |
} |
190 |
|
191 |
public String getFullName() { |
192 |
return getName();
|
193 |
} |
194 |
|
195 |
public String getProviderName() { |
196 |
return getName();
|
197 |
} |
198 |
|
199 |
/*
|
200 |
* (non-Javadoc)
|
201 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getFormatList()
|
202 |
*/
|
203 |
public String[] getFormatList() { |
204 |
return null; |
205 |
} |
206 |
|
207 |
/**
|
208 |
* Acciones de inicilizaci?n comunes a todos los drivers.
|
209 |
* Este m?todo debe ser llamado explicitamente por el constructor de cada driver.
|
210 |
* Estas son acciones de inicializaci?n que se ejecutan despu?s del constructor de cada driver.
|
211 |
* Las acciones que hayan de ser realizadas antes se definen en el constructor de RasterDataset.
|
212 |
*/
|
213 |
protected void init() { |
214 |
} |
215 |
|
216 |
/*
|
217 |
* (non-Javadoc)
|
218 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isTiled()
|
219 |
*/
|
220 |
public boolean isTiled() { |
221 |
return false; |
222 |
} |
223 |
|
224 |
/*
|
225 |
* (non-Javadoc)
|
226 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isTimeSupported()
|
227 |
*/
|
228 |
public boolean isTimeSupported() { |
229 |
return false; |
230 |
} |
231 |
|
232 |
/*
|
233 |
* (non-Javadoc)
|
234 |
* @see java.lang.Object#clone()
|
235 |
*/
|
236 |
public RasterProvider cloneProvider() throws CloneException { |
237 |
try {
|
238 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
239 |
DefaultRasterProvider provider = (DefaultRasterProvider)dataManager.createProvider(storeServices, param); |
240 |
//DefaultRasterProvider provider = singleDatasetInstance(storeServices, param);
|
241 |
// Estas van por referencia
|
242 |
provider.histogram = histogram; |
243 |
provider.stats = stats; |
244 |
return provider;
|
245 |
} catch (ProviderNotRegisteredException e) {
|
246 |
e.printStackTrace(); |
247 |
} catch (InitializeException e) {
|
248 |
e.printStackTrace(); |
249 |
} |
250 |
return null; |
251 |
} |
252 |
|
253 |
/**
|
254 |
* Factoria para abrir distintos tipos de raster.
|
255 |
* @param fName Nombre del fichero.
|
256 |
*
|
257 |
* @return SingleDataset, o null si hay problemas.
|
258 |
*/
|
259 |
/*public static DefaultRasterProvider singleDatasetInstance(DataStoreProviderServices storeServices, DataStoreParameters param) throws RasterDriverException {
|
260 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
|
261 |
try {
|
262 |
return (DefaultRasterProvider)dataManager.createProvider(storeServices, param);
|
263 |
} catch (InitializeException e) {
|
264 |
throw new RasterDriverException("Error initializing provider", e);
|
265 |
} catch (ProviderNotRegisteredException e) {
|
266 |
throw new RasterDriverException("Provider not register error", e);
|
267 |
}
|
268 |
}*/
|
269 |
|
270 |
/**
|
271 |
* Factoria para abrir distintos tipos de raster.
|
272 |
* @param fName Nombre del fichero.
|
273 |
*
|
274 |
* @return SingleDataset, o null si hay problemas.
|
275 |
*/
|
276 |
public static DefaultRasterProvider singleDatasetInstance(DataStoreProviderServices storeServices, String param) throws RasterDriverException { |
277 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager(); |
278 |
//We have to locate a provider's name which manages the selected file
|
279 |
//A FilesystemServerExplorer will give a getProviderNames service
|
280 |
|
281 |
FilesystemServerExplorer serverExplorer = null;
|
282 |
try {
|
283 |
FilesystemServerExplorerParameters paramsExplorer = (FilesystemServerExplorerParameters)dataManager.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
284 |
paramsExplorer.setRoot(File.separator);
|
285 |
serverExplorer = (FilesystemServerExplorer)dataManager.openServerExplorer(FilesystemServerExplorer.NAME, paramsExplorer); |
286 |
} catch (ValidateDataParametersException e) {
|
287 |
throw new RasterDriverException("Error validating parameters", e); |
288 |
} catch (InitializeException e) {
|
289 |
throw new RasterDriverException("Error creating a server explorer ", e); |
290 |
} catch (ProviderNotRegisteredException e) {
|
291 |
throw new RasterDriverException("Provider not registered", e); |
292 |
} |
293 |
|
294 |
//Gets the list of provider's name to manage the file
|
295 |
File file = new File(param); |
296 |
ArrayList<String> provName = serverExplorer.getProviderNameList(file); |
297 |
if(provName.size() > 0) { |
298 |
for (int i = 0; i < provName.size(); i++) { |
299 |
//Gets the first provider what is not a TileProvider
|
300 |
if(provName.get(i).compareTo("Tile Store") != 0) { |
301 |
DataStoreParameters newparams; |
302 |
try {
|
303 |
newparams = dataManager.createStoreParameters(provName.get(i)); |
304 |
((FilesystemStoreParameters)newparams).setFile(file); |
305 |
if(storeServices == null) |
306 |
storeServices = new DefaultRasterStore();
|
307 |
return (DefaultRasterProvider)dataManager.createProvider(storeServices, newparams);
|
308 |
} catch (InitializeException e) {
|
309 |
throw new RasterDriverException("Error creating a server explorer ", e); |
310 |
} catch (ProviderNotRegisteredException e) {
|
311 |
throw new RasterDriverException("Provider not registered", e); |
312 |
} |
313 |
} |
314 |
} |
315 |
} |
316 |
return null; |
317 |
} |
318 |
|
319 |
/**
|
320 |
* Carga un fichero raster. Puede usarse para calcular el extent e instanciar
|
321 |
* un objeto de este tipo.
|
322 |
*/
|
323 |
abstract public RasterProvider load(); |
324 |
|
325 |
/**
|
326 |
* Cierra el fichero y libera los recursos.
|
327 |
*/
|
328 |
abstract public void close(); |
329 |
|
330 |
/**
|
331 |
* Obtiene el ancho de la imagen
|
332 |
* @return Ancho de la imagen
|
333 |
*/
|
334 |
abstract public double getWidth(); |
335 |
|
336 |
/**
|
337 |
* Obtiene el ancho de la imagen
|
338 |
* @return Ancho de la imagen
|
339 |
*/
|
340 |
abstract public double getHeight(); |
341 |
|
342 |
/**
|
343 |
* Asigna un nuevo Extent
|
344 |
* @param e Extent
|
345 |
*/
|
346 |
public abstract void setView(Extent e); |
347 |
|
348 |
/**
|
349 |
* Obtiene el extent asignado
|
350 |
* @return Extent
|
351 |
*/
|
352 |
public abstract Extent getView(); |
353 |
|
354 |
/**
|
355 |
* Obtiene el valor del raster en la coordenada que se le pasa.
|
356 |
* El valor ser? Double, Int, Byte, etc. dependiendo del tipo de
|
357 |
* raster.
|
358 |
* @param x coordenada X
|
359 |
* @param y coordenada Y
|
360 |
* @return
|
361 |
*/
|
362 |
abstract public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException; |
363 |
|
364 |
/**
|
365 |
* Gets a window of data from the source. The result of this operation could be a list of tiles
|
366 |
* that are sent through the listener.
|
367 |
* @param ex
|
368 |
* @param bufWidth
|
369 |
* @param bufHeight
|
370 |
* @param bandList
|
371 |
* @param listener
|
372 |
* @throws ProcessInterruptedException
|
373 |
* @throws RasterDriverException
|
374 |
*/
|
375 |
abstract public void getWindow(Extent ex, int bufWidth, int bufHeight, |
376 |
BandList bandList, TileListener listener) throws ProcessInterruptedException, RasterDriverException;
|
377 |
|
378 |
/**
|
379 |
* Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
|
380 |
* No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama?o a los
|
381 |
* pixeles de disco.
|
382 |
* @param ulx Posici?n X superior izquierda
|
383 |
* @param uly Posici?n Y superior izquierda
|
384 |
* @param lrx Posici?n X inferior derecha
|
385 |
* @param lry Posici?n Y inferior derecha
|
386 |
* @param rasterBuf Buffer de datos
|
387 |
* @param bandList
|
388 |
* @return Buffer de datos
|
389 |
*/
|
390 |
abstract public Buffer getWindow(Extent extent, BandList bandList, Buffer rasterBuf) |
391 |
throws ProcessInterruptedException, RasterDriverException;
|
392 |
|
393 |
/**
|
394 |
* Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
|
395 |
* No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama?o a los
|
396 |
* pixeles de disco.
|
397 |
* @param x Posici?n X superior izquierda
|
398 |
* @param y Posici?n Y superior izquierda
|
399 |
* @param w Ancho en coordenadas reales
|
400 |
* @param h Alto en coordenadas reales
|
401 |
* @param rasterBuf Buffer de datos
|
402 |
* @param bandList
|
403 |
* @param adjustToExtent Flag que dice si el extent solicitado debe ajustarse al extent del raster o no.
|
404 |
* @return Buffer de datos
|
405 |
*/
|
406 |
abstract public Buffer getWindow(double x, double y, double w, double h, |
407 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException; |
408 |
|
409 |
/**
|
410 |
* Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
|
411 |
* Se aplica supersampleo o subsampleo dependiendo del tama?o del buffer especificado.
|
412 |
*
|
413 |
* @param minX Posici?n m?nima X superior izquierda
|
414 |
* @param minY Posici?n m?nima Y superior izquierda
|
415 |
* @param maxX Posici?n m?xima X inferior derecha
|
416 |
* @param maxY Posici?n m?xima Y inferior derecha
|
417 |
* @param bufWidth Ancho del buffer de datos
|
418 |
* @param bufHeight Alto del buffer de datos
|
419 |
* @param rasterBuf Buffer de datos
|
420 |
* @param adjustToExtent Flag que dice si el extent solicitado debe ajustarse al extent del raster o no.
|
421 |
* @param bandList
|
422 |
* @return Buffer de datos
|
423 |
*/
|
424 |
abstract public Buffer getWindow(Extent extent, |
425 |
int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException; |
426 |
|
427 |
/**
|
428 |
* Obtiene una ventana de datos de la imagen a partir de coordenadas pixel.
|
429 |
* No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama?o a los
|
430 |
* pixeles de disco.
|
431 |
* @param x Posici?n X superior izquierda
|
432 |
* @param y Posici?n Y superior izquierda
|
433 |
* @param w Ancho en coordenadas reales
|
434 |
* @param h Alto en coordenadas reales
|
435 |
* @param rasterBuf Buffer de datos
|
436 |
* @param bandList
|
437 |
* @return Buffer de datos
|
438 |
*/
|
439 |
abstract public Buffer getWindow(int x, int y, |
440 |
BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException; |
441 |
|
442 |
/**
|
443 |
* Obtiene una ventana de datos de la imagen a partir de coordenadas pixel.
|
444 |
* Se aplica supersampleo o subsampleo dependiendo del tama?o del buffer especificado.
|
445 |
*
|
446 |
* @param x Posici?n X superior izquierda
|
447 |
* @param y Posici?n Y superior izquierda
|
448 |
* @param w Ancho en coordenadas reales
|
449 |
* @param h Alto en coordenadas reales
|
450 |
* @param bufWidth Ancho del buffer de datos
|
451 |
* @param bufHeight Alto del buffer de datos
|
452 |
* @param rasterBuf Buffer de datos
|
453 |
* @param bandList
|
454 |
* @return Buffer de datos
|
455 |
*/
|
456 |
abstract public Buffer getWindow(int x, int y, int w, int h, int bufWidth, int bufHeight, |
457 |
BandList bandList, Buffer rasterBuf)throws ProcessInterruptedException, RasterDriverException; |
458 |
|
459 |
abstract public int getBlockSize(); |
460 |
|
461 |
/*
|
462 |
* (non-Javadoc)
|
463 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewHeight(int, int)
|
464 |
*/
|
465 |
abstract public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException; |
466 |
|
467 |
/**
|
468 |
* Informa de si el dataset soporta overviews o no.
|
469 |
* @return true si soporta overviews y false si no las soporta.
|
470 |
*/
|
471 |
abstract public boolean isOverviewsSupported(); |
472 |
|
473 |
/**
|
474 |
* Returns true if supersampling operation is supported by this provider, i.e if
|
475 |
* a request greater than 1:1 will have a response.
|
476 |
* @return
|
477 |
*/
|
478 |
public boolean isSupersamplingSupported() { |
479 |
return true; |
480 |
} |
481 |
|
482 |
/**
|
483 |
* Carga metadatos desde el fichero Rmf si estos existen
|
484 |
* @param fName Nombre del fichero
|
485 |
* @throws ParsingException
|
486 |
*/
|
487 |
protected void loadFromRmf(RmfBlocksManager manager) throws ParsingException { |
488 |
if (!manager.checkRmf())
|
489 |
return;
|
490 |
|
491 |
if (!new File(manager.getPath()).exists()) |
492 |
return;
|
493 |
|
494 |
GeoInfoRmfSerializer geoInfoSerializer = new GeoInfoRmfSerializer(this); |
495 |
ColorTableRmfSerializer colorTableSerializer = new ColorTableRmfSerializer();
|
496 |
NoDataRmfSerializer noDataSerializer = null;
|
497 |
if(noData == null) |
498 |
noData = new DefaultNoData(null, null, manager.getPath(), getBandCount()); |
499 |
noDataSerializer = new NoDataRmfSerializer((DefaultNoData)noData);
|
500 |
ColorInterpretationRmfSerializer colorInterpSerializer = new ColorInterpretationRmfSerializer();
|
501 |
ProjectionRmfSerializer projectionRmfSerializer = new ProjectionRmfSerializer();
|
502 |
StatisticsRmfSerializer statsRmfSerializer = new StatisticsRmfSerializer(getStatistics());
|
503 |
|
504 |
manager.addClient(geoInfoSerializer); |
505 |
manager.addClient(colorTableSerializer); |
506 |
manager.addClient(noDataSerializer); |
507 |
manager.addClient(colorInterpSerializer); |
508 |
manager.addClient(projectionRmfSerializer); |
509 |
manager.addClient(statsRmfSerializer); |
510 |
|
511 |
manager.read(null);
|
512 |
|
513 |
manager.removeAllClients(); |
514 |
|
515 |
if (colorTableSerializer.getResult() != null) |
516 |
setColorTable((ColorTable) colorTableSerializer.getResult()); |
517 |
|
518 |
if (colorInterpSerializer.getResult() != null) { |
519 |
DataStoreColorInterpretation ci = (DataStoreColorInterpretation) colorInterpSerializer.getResult(); |
520 |
setColorInterpretation(ci); |
521 |
if (ci.getBand(DataStoreColorInterpretation.ALPHA_BAND) != -1) |
522 |
getTransparency().setTransparencyBand(ci.getBand(DataStoreColorInterpretation.ALPHA_BAND)); |
523 |
} |
524 |
|
525 |
if (projectionRmfSerializer.getResult() != null) |
526 |
wktProjection = RasterLocator.getManager().getCRSUtils().convertIProjectionToWkt((IProjection) projectionRmfSerializer.getResult()); |
527 |
} |
528 |
|
529 |
/**
|
530 |
* Obtiene el n?nero de bandas del fichero
|
531 |
* @return Entero que representa el n?mero de bandas
|
532 |
*/
|
533 |
public int getBandCount() { |
534 |
return bandCount;
|
535 |
} |
536 |
|
537 |
/**
|
538 |
* @return Returns the dataType.
|
539 |
*/
|
540 |
public int[] getDataType() { |
541 |
return dataType;
|
542 |
} |
543 |
|
544 |
/**
|
545 |
* @param dataType The dataType to set.
|
546 |
*/
|
547 |
public void setDataType(int[] dataType) { |
548 |
this.dataType = dataType;
|
549 |
} |
550 |
|
551 |
/*
|
552 |
* (non-Javadoc)
|
553 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeX()
|
554 |
*/
|
555 |
public double getPixelSizeX() { |
556 |
return externalTransformation.getScaleX();
|
557 |
} |
558 |
|
559 |
/*
|
560 |
* (non-Javadoc)
|
561 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeY()
|
562 |
*/
|
563 |
public double getPixelSizeY() { |
564 |
return externalTransformation.getScaleY();
|
565 |
} |
566 |
|
567 |
/*
|
568 |
* (non-Javadoc)
|
569 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getNoDataValue()
|
570 |
*/
|
571 |
public NoData getNoDataValue() {
|
572 |
if(noData == null) { |
573 |
noData = RasterLocator.getManager().getDataStructFactory().createNoData(null, null, getRMFFile(), getBandCount()); |
574 |
noData.setDataType(getDataType()[0]);
|
575 |
} |
576 |
return noData;
|
577 |
} |
578 |
|
579 |
/*
|
580 |
* (non-Javadoc)
|
581 |
* @see org.gvsig.raster.impl.provider.RasterProvider#setNoDataValue(org.gvsig.fmap.dal.coverage.datastruct.NoData)
|
582 |
*/
|
583 |
public void setNoDataValue(NoData value) { |
584 |
this.noData = value;
|
585 |
} |
586 |
|
587 |
/**
|
588 |
* Dice si el fichero tiene georreferenciaci?n o no.
|
589 |
* @return true si tiene georreferenciaci?n y false si no la tiene
|
590 |
*/
|
591 |
public boolean isGeoreferenced() { |
592 |
return true; |
593 |
} |
594 |
|
595 |
/**
|
596 |
* Dado unas coordenadas reales, un tama?o de buffer y un tama?o de raster.
|
597 |
* Si el buffer es de mayor tama?o que el raster (supersampleo) quiere decir que
|
598 |
* por cada pixel de buffer se repiten varios del raster. Esta funci?n calcula el
|
599 |
* n?mero de pixels de desplazamiento en X e Y que corresponden al primer pixel del
|
600 |
* buffer en la esquina superior izquierda. Esto es necesario porque la coordenada
|
601 |
* solicitada es real y puede no caer sobre un pixel completo. Este calculo es
|
602 |
* util cuando un cliente quiere supersamplear sobre un buffer y que no se lo haga
|
603 |
* el driver autom?ticamente.
|
604 |
* @param dWorldTLX Coordenada real X superior izquierda
|
605 |
* @param dWorldTLY Coordenada real Y superior izquierda
|
606 |
* @param dWorldBRX Coordenada real X inferior derecha
|
607 |
* @param dWorldBRY Coordenada real Y inferior derecha
|
608 |
* @param nWidth Ancho del raster
|
609 |
* @param nHeight Alto del raster
|
610 |
* @param bufWidth Ancho del buffer
|
611 |
* @param bufHeight Alto del buffer
|
612 |
* @return Array de dos elementos con el desplazamiento en X e Y.
|
613 |
*/
|
614 |
public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY, |
615 |
double nWidth, double nHeight, int bufWidth, int bufHeight) { |
616 |
|
617 |
Point2D p1 = new Point2D.Double(dWorldTLX, dWorldTLY); |
618 |
Point2D p2 = new Point2D.Double(dWorldBRX, dWorldBRY); |
619 |
|
620 |
Point2D tl = worldToRaster(new Point2D.Double(p1.getX(), p1.getY())); |
621 |
Point2D br = worldToRaster(new Point2D.Double(p2.getX(), p2.getY())); |
622 |
|
623 |
double wPx = (bufWidth / Math.abs(br.getX() - tl.getX())); |
624 |
double hPx = (bufHeight / Math.abs(br.getY() - tl.getY())); |
625 |
|
626 |
int x = (int)((tl.getX() > br.getX()) ? Math.floor(br.getX()) : Math.floor(tl.getX())); |
627 |
int y = (int)((tl.getY() > br.getY()) ? Math.floor(br.getY()) : Math.floor(tl.getY())); |
628 |
|
629 |
double a = (tl.getX() > br.getX()) ? (Math.abs(br.getX() - x)) : (Math.abs(tl.getX() - x)); |
630 |
double b = (tl.getY() > br.getY()) ? (Math.abs(br.getY() - y)) : (Math.abs(tl.getY() - y)); |
631 |
|
632 |
double stpX = (int)((a * bufWidth) / Math.abs(br.getX() - tl.getX())); |
633 |
double stpY = (int)((b * bufHeight) / Math.abs(br.getY() - tl.getY())); |
634 |
|
635 |
return new double[]{stpX, stpY, wPx, hPx}; |
636 |
} |
637 |
|
638 |
/**
|
639 |
* Convierte un punto desde coordenadas pixel a coordenadas del mundo.
|
640 |
* @param pt Punto a transformar
|
641 |
* @return punto transformado en coordenadas del mundo
|
642 |
*/
|
643 |
public Point2D rasterToWorld(Point2D pt) { |
644 |
Point2D p = new Point2D.Double(); |
645 |
externalTransformation.transform(pt, p); |
646 |
return p;
|
647 |
} |
648 |
|
649 |
/**
|
650 |
* Convierte un punto desde del mundo a coordenadas pixel.
|
651 |
* @param pt Punto a transformar
|
652 |
* @return punto transformado en coordenadas pixel
|
653 |
*/
|
654 |
public Point2D worldToRaster(Point2D pt) { |
655 |
Point2D p = new Point2D.Double(); |
656 |
try {
|
657 |
externalTransformation.inverseTransform(pt, p); |
658 |
} catch (NoninvertibleTransformException e) { |
659 |
return pt;
|
660 |
} |
661 |
return p;
|
662 |
} |
663 |
|
664 |
/**
|
665 |
* Calcula el extent en coordenadas del mundo real
|
666 |
* @return Extent
|
667 |
*/
|
668 |
public Extent getExtent() {
|
669 |
return new ExtentImpl( rasterToWorld(new Point2D.Double(0, 0)), |
670 |
rasterToWorld(new Point2D.Double(getWidth(), getHeight())), |
671 |
rasterToWorld(new Point2D.Double(getWidth(), 0)), |
672 |
rasterToWorld(new Point2D.Double(0, getHeight()))); |
673 |
} |
674 |
|
675 |
/**
|
676 |
* Calcula el extent en coordenadas del mundo real sin rotaci?n. Solo coordenadas y tama?o de pixel
|
677 |
* @return Extent
|
678 |
*/
|
679 |
public Extent getExtentWithoutRot() {
|
680 |
AffineTransform at = new AffineTransform( externalTransformation.getScaleX(), 0, |
681 |
0, externalTransformation.getScaleY(),
|
682 |
externalTransformation.getTranslateX(), externalTransformation.getTranslateY()); |
683 |
Point2D p1 = new Point2D.Double(0, 0); |
684 |
Point2D p2 = new Point2D.Double(getWidth(), getHeight()); |
685 |
at.transform(p1, p1); |
686 |
at.transform(p2, p2); |
687 |
return new ExtentImpl(p1, p2); |
688 |
} |
689 |
|
690 |
/**
|
691 |
* ASigna el par?metro de inicializaci?n del driver.
|
692 |
*/
|
693 |
public void setParam(DataStoreProviderServices provServices, DataStoreParameters param) { |
694 |
if(param instanceof RasterDataParameters) |
695 |
this.uri = ((RasterDataParameters)param).getURI();
|
696 |
this.param = param;
|
697 |
this.storeServices = provServices;
|
698 |
} |
699 |
|
700 |
/*
|
701 |
* (non-Javadoc)
|
702 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewWidth(int, int)
|
703 |
*/
|
704 |
abstract public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException; |
705 |
|
706 |
/*
|
707 |
* (non-Javadoc)
|
708 |
* @see org.gvsig.raster.impl.provider.RasterProvider#selectSubdataset()
|
709 |
*/
|
710 |
public void selectSubdataset() {} |
711 |
|
712 |
/**
|
713 |
* Selects the subdataset. This method will select
|
714 |
* the rmf file.
|
715 |
*/
|
716 |
protected void selectSubdataset(String subdataset) { |
717 |
selectedSubdatasetID = subdataset; |
718 |
getRmfBlocksManager().setPath(getRMFFile()); |
719 |
} |
720 |
|
721 |
/**
|
722 |
* Obtiene el gestor de ficheros RMF
|
723 |
* @return RmfBloksManager
|
724 |
*/
|
725 |
public RmfBlocksManager getRmfBlocksManager() {
|
726 |
String fileRMF = getRMFFile();
|
727 |
if(fileRMF != null) { |
728 |
if (rmfBlocksManager == null || fileRMF.compareTo(rmfBlocksManager.getPath()) != 0) { |
729 |
rmfBlocksManager = new RmfBlocksManager(fileRMF);
|
730 |
} |
731 |
} |
732 |
return rmfBlocksManager;
|
733 |
} |
734 |
|
735 |
/*
|
736 |
* (non-Javadoc)
|
737 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getRMFFile()
|
738 |
*/
|
739 |
public String getRMFFile() { |
740 |
String tail = selectedSubdatasetID == null ? ".rmf" : "-sd" + selectedSubdatasetID + ".rmf"; |
741 |
return fileUtil.getNameWithoutExtension(getURI()) + tail;
|
742 |
} |
743 |
|
744 |
/*
|
745 |
* (non-Javadoc)
|
746 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isInside(java.awt.geom.Point2D)
|
747 |
*/
|
748 |
public boolean isInside(Point2D p){ |
749 |
//Realizamos los calculos solo si el punto est? dentro del extent de la imagen rotada, as? nos ahorramos los calculos
|
750 |
//cuando el puntero est? fuera
|
751 |
|
752 |
Point2D pt = new Point2D.Double(); |
753 |
try {
|
754 |
|
755 |
getAffineTransform().inverseTransform(p, pt); |
756 |
if( pt.getX() >= 0 && pt.getX() < getWidth() && |
757 |
pt.getY() >= 0 && pt.getY() < getHeight())
|
758 |
return true; |
759 |
} catch (NoninvertibleTransformException e) { |
760 |
return false; |
761 |
} |
762 |
|
763 |
return false; |
764 |
} |
765 |
|
766 |
/**
|
767 |
* Consulta de si un raster tiene rotaci?n o no.
|
768 |
* @return true si tiene rotaci?n y false si no la tiene.
|
769 |
*/
|
770 |
public boolean isRotated() { |
771 |
if(externalTransformation.getShearX() != 0 || externalTransformation.getShearY() != 0) |
772 |
return true; |
773 |
return false; |
774 |
} |
775 |
|
776 |
/*
|
777 |
* (non-Javadoc)
|
778 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isMultiFile()
|
779 |
*/
|
780 |
public boolean isMultiFile() { |
781 |
return false; |
782 |
} |
783 |
|
784 |
/*
|
785 |
* (non-Javadoc)
|
786 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isMosaic()
|
787 |
*/
|
788 |
public boolean isMosaic() { |
789 |
return false; |
790 |
} |
791 |
|
792 |
/**
|
793 |
* Devuelve si el Dataset es reproyectable
|
794 |
* @return
|
795 |
*/
|
796 |
public boolean isReproyectable() { |
797 |
return false; |
798 |
} |
799 |
|
800 |
public String getWktProjection() { |
801 |
return wktProjection;
|
802 |
} |
803 |
|
804 |
/*
|
805 |
* (non-Javadoc)
|
806 |
* @see org.gvsig.raster.impl.dataset.RasterProvider#saveObjectToRmf(java.lang.Class, java.lang.Object)
|
807 |
*/
|
808 |
@SuppressWarnings("unchecked") |
809 |
public void saveObjectToRmf(Class class1, Object value) throws RmfSerializerException { |
810 |
((DefaultProviderServices)RasterLocator.getManager().getProviderServices()).saveObjectToRmfFile(getRmfBlocksManager(), class1, value); |
811 |
} |
812 |
|
813 |
/**
|
814 |
* Carga un objecto desde un serializador del tipo class1. Usa value para iniciar dicho
|
815 |
* serializador
|
816 |
*
|
817 |
* @param class1
|
818 |
* @param value
|
819 |
* @return
|
820 |
* @throws RmfSerializerException
|
821 |
*/
|
822 |
@SuppressWarnings("unchecked") |
823 |
private static Object loadObjectFromRmfFile(RmfBlocksManager blocksManager, Class class1, Object value) throws RmfSerializerException { |
824 |
ClassSerializer serializerObject = ((DefaultProviderServices)RasterLocator.getManager().getProviderServices()).getSerializerObject(class1, value); |
825 |
|
826 |
if (serializerObject == null) |
827 |
throw new RmfSerializerException("No se ha podido encontrar el serializador para el Rmf"); |
828 |
|
829 |
if (!blocksManager.checkRmf())
|
830 |
throw new RmfSerializerException("Error al comprobar el fichero Rmf"); |
831 |
|
832 |
blocksManager.addClient(serializerObject); |
833 |
try {
|
834 |
blocksManager.read(null);
|
835 |
} catch (ParsingException e) {
|
836 |
throw new RmfSerializerException("Error al leer el fichero Rmf", e); |
837 |
} |
838 |
blocksManager.removeAllClients(); |
839 |
|
840 |
return serializerObject.getResult();
|
841 |
} |
842 |
|
843 |
/*
|
844 |
* (non-Javadoc)
|
845 |
* @see org.gvsig.raster.impl.dataset.RasterProvider#loadObjectFromRmf(java.lang.Class, java.lang.Object)
|
846 |
*/
|
847 |
@SuppressWarnings("unchecked") |
848 |
public Object loadObjectFromRmf(Class class1, Object value) throws RmfSerializerException { |
849 |
return loadObjectFromRmfFile(getRmfBlocksManager(), class1, value);
|
850 |
} |
851 |
|
852 |
/**
|
853 |
* Carga un objeto del fichero RMF especificado por parametro
|
854 |
* @param file
|
855 |
* @param class1
|
856 |
* @param value
|
857 |
* @return
|
858 |
* @throws RmfSerializerException
|
859 |
*/
|
860 |
@SuppressWarnings("unchecked") |
861 |
public static Object loadObjectFromRmfFile(String file, Class class1, Object value) throws RmfSerializerException { |
862 |
String fileRMF = RasterLocator.getManager().getFileUtils().getNameWithoutExtension(file) + ".rmf"; |
863 |
RmfBlocksManager blocksManager = new RmfBlocksManager(fileRMF);
|
864 |
return loadObjectFromRmfFile(blocksManager, class1, value);
|
865 |
} |
866 |
|
867 |
/**
|
868 |
* Guarda en el RMF el objecto actual en caso de que exista un serializador para el
|
869 |
* @param value
|
870 |
* @throws RmfSerializerException
|
871 |
*/
|
872 |
public void saveObjectToRmf(Object value) throws RmfSerializerException { |
873 |
saveObjectToRmf(value.getClass(), value); |
874 |
} |
875 |
|
876 |
/**
|
877 |
* Carga un objecto desde un serializador usando el tipo del mismo objeto pasado por parametro.
|
878 |
* Usa value para iniciar dicho serializador
|
879 |
* @param value
|
880 |
* @return
|
881 |
* @throws RmfSerializerException
|
882 |
*/
|
883 |
public Object loadObjectFromRmf(Object value) throws RmfSerializerException { |
884 |
return loadObjectFromRmf(value.getClass(), value);
|
885 |
} |
886 |
|
887 |
|
888 |
public double getCellSize() { |
889 |
try {
|
890 |
Extent e = getExtent(); |
891 |
double dCellsize = (e.getMax().getX() - e.getMin().getX() ) / getWidth();
|
892 |
return dCellsize;
|
893 |
} catch (NullPointerException e) { |
894 |
return 1; |
895 |
} |
896 |
} |
897 |
|
898 |
|
899 |
public RasterProvider newProvider() {
|
900 |
return null; |
901 |
} |
902 |
|
903 |
/*
|
904 |
* (non-Javadoc)
|
905 |
* @see org.gvsig.raster.impl.dataset.RasterProvider#getColorTable()
|
906 |
*/
|
907 |
public ColorTable getColorTable() {
|
908 |
return colorTable;
|
909 |
} |
910 |
|
911 |
/*
|
912 |
* (non-Javadoc)
|
913 |
* @see org.gvsig.raster.impl.provider.RasterProvider#setColorTable(org.gvsig.fmap.dal.coverage.store.props.ColorTable)
|
914 |
*/
|
915 |
public void setColorTable(ColorTable value) { |
916 |
colorTable = value; |
917 |
} |
918 |
|
919 |
/*
|
920 |
* (non-Javadoc)
|
921 |
* @see org.gvsig.raster.impl.dataset.RasterProvider#getTransparency()
|
922 |
*/
|
923 |
public Transparency getTransparency() { |
924 |
return transparency;
|
925 |
} |
926 |
|
927 |
/*
|
928 |
* (non-Javadoc)
|
929 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getMetadata()
|
930 |
*/
|
931 |
public Metadata getMetadata() {
|
932 |
return null; |
933 |
} |
934 |
|
935 |
/*
|
936 |
* (non-Javadoc)
|
937 |
* @see org.gvsig.raster.impl.dataset.RasterProvider#getColorInterpretation()
|
938 |
*/
|
939 |
public ColorInterpretation getColorInterpretation() {
|
940 |
return this.colorInterpretation; |
941 |
} |
942 |
|
943 |
/**
|
944 |
* Asigna el objeto que contiene que contiene la interpretaci?n de
|
945 |
* color por banda
|
946 |
* @param DataStoreColorInterpretation
|
947 |
*/
|
948 |
public void setColorInterpretation(ColorInterpretation colorInterpretation) { |
949 |
this.colorInterpretation = colorInterpretation;
|
950 |
} |
951 |
|
952 |
/*
|
953 |
* (non-Javadoc)
|
954 |
* @see org.gvsig.raster.impl.dataset.RasterProvider#getStatistics()
|
955 |
*/
|
956 |
public Statistics getStatistics() {
|
957 |
if(stats == null) { |
958 |
stats = new SimpleProviderStatistics(this); |
959 |
} |
960 |
return stats;
|
961 |
} |
962 |
|
963 |
/*
|
964 |
* (non-Javadoc)
|
965 |
* @see org.gvsig.raster.impl.provider.RasterProvider#setStatistics(org.gvsig.fmap.dal.coverage.store.props.Statistics)
|
966 |
*/
|
967 |
public void setStatistics(Statistics stats) { |
968 |
this.stats = stats;
|
969 |
} |
970 |
|
971 |
/*
|
972 |
* (non-Javadoc)
|
973 |
* @see org.gvsig.fmap.dal.coverage.store.props.Histogramable#getHistogramComputer()
|
974 |
*/
|
975 |
public HistogramComputer getHistogramComputer() throws HistogramException, InterruptedException { |
976 |
if (histogram == null) |
977 |
histogram = new SimpleProviderHistogramComputer(this); |
978 |
return histogram;
|
979 |
} |
980 |
|
981 |
//****************************************************
|
982 |
//*********Implementing Disposable methods************
|
983 |
//****************************************************
|
984 |
|
985 |
/*
|
986 |
* (non-Javadoc)
|
987 |
* @see org.gvsig.tools.dispose.impl.AbstractDisposable#doDispose()
|
988 |
*/
|
989 |
public void doDispose() { |
990 |
|
991 |
} |
992 |
|
993 |
//****************************************************
|
994 |
//*****Implementing DataStoreProvider methods*********
|
995 |
//****************************************************
|
996 |
|
997 |
/**
|
998 |
* Gets the specific parameter. All of them inherit from RasterStoreParameters
|
999 |
*/
|
1000 |
//public abstract RasterStoreParameters getRasterParameters();
|
1001 |
|
1002 |
@Override
|
1003 |
public DataServerExplorer getExplorer() throws ReadException, |
1004 |
ValidateDataParametersException { |
1005 |
/*DataManager manager = DALLocator.getDataManager();
|
1006 |
FilesystemServerExplorerParameters params;
|
1007 |
try {
|
1008 |
params = (FilesystemServerExplorerParameters) manager
|
1009 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME);
|
1010 |
params.setRoot(((AbstractRasterStoreParameters)this.getDataParameters()).getFile().getParent());
|
1011 |
return manager.createServerExplorer(params);
|
1012 |
} catch (DataException e) {
|
1013 |
throw new ReadException(this.getName(), e);
|
1014 |
}*/
|
1015 |
return null; |
1016 |
} |
1017 |
|
1018 |
|
1019 |
/**
|
1020 |
* Returs the DataParameters
|
1021 |
* @return
|
1022 |
*/
|
1023 |
public RasterDataParameters getDataParameters() {
|
1024 |
if(getDataStoreParameters() instanceof RasterDataParameters) |
1025 |
return (RasterDataParameters)getDataStoreParameters();
|
1026 |
return null; |
1027 |
} |
1028 |
|
1029 |
/*
|
1030 |
* (non-Javadoc)
|
1031 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#getChilds()
|
1032 |
*/
|
1033 |
@SuppressWarnings("unchecked") |
1034 |
public Iterator getChilds() { |
1035 |
return null; |
1036 |
} |
1037 |
|
1038 |
/*
|
1039 |
* (non-Javadoc)
|
1040 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#getResource()
|
1041 |
*/
|
1042 |
public ResourceProvider getResource() {
|
1043 |
return null; |
1044 |
} |
1045 |
|
1046 |
/*
|
1047 |
* (non-Javadoc)
|
1048 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#getSourceId()
|
1049 |
*/
|
1050 |
public Object getSourceId() { |
1051 |
if( this.getDataParameters() instanceof RasterFileStoreParameters) |
1052 |
return ((RasterFileStoreParameters)this.getDataParameters()).getFile(); |
1053 |
else
|
1054 |
return this.getDataParameters().getURI(); |
1055 |
} |
1056 |
|
1057 |
/*
|
1058 |
* (non-Javadoc)
|
1059 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#open()
|
1060 |
*/
|
1061 |
public void open() throws OpenException { |
1062 |
} |
1063 |
|
1064 |
/**
|
1065 |
* Traduce el nombre del fichero por un alias asignado por el propio driver.
|
1066 |
* Cuando es traducido por un alias el driver intentar? abrir el alias y no el
|
1067 |
* fichero. Esto es util porque algunos formatos tienen la extensi?n en el
|
1068 |
* fichero de cabecera pero lo que se abre realmente es el fichero de datos.
|
1069 |
* @param fileName
|
1070 |
* @return
|
1071 |
*/
|
1072 |
public String translateFileName(String fileName) { |
1073 |
return fileName;
|
1074 |
} |
1075 |
|
1076 |
/*
|
1077 |
* (non-Javadoc)
|
1078 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getFileSuffix()
|
1079 |
*/
|
1080 |
public String getFileSuffix() { |
1081 |
return getURIOfFirstProvider().substring(getURIOfFirstProvider().lastIndexOf(".") + 1, getURIOfFirstProvider().length()); |
1082 |
} |
1083 |
|
1084 |
/*
|
1085 |
* (non-Javadoc)
|
1086 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getURIOfFirstProvider()
|
1087 |
*/
|
1088 |
public String getURIOfFirstProvider() { |
1089 |
return RasterLocator.getManager().getFileUtils().getFormatedRasterFileName(uri);
|
1090 |
} |
1091 |
|
1092 |
/*
|
1093 |
* (non-Javadoc)
|
1094 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getURI()
|
1095 |
*/
|
1096 |
public String getURI() { |
1097 |
return uri;
|
1098 |
} |
1099 |
|
1100 |
public void setFName(String n) { |
1101 |
uri = n; |
1102 |
} |
1103 |
|
1104 |
public long getFileSize() { |
1105 |
return fileSize;
|
1106 |
} |
1107 |
|
1108 |
public void setFileSize(long sz) { |
1109 |
fileSize = sz; |
1110 |
} |
1111 |
|
1112 |
/*
|
1113 |
* (non-Javadoc)
|
1114 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getProjection()
|
1115 |
*/
|
1116 |
public IProjection getProjection() {
|
1117 |
return proj;
|
1118 |
} |
1119 |
|
1120 |
public void setProjection(IProjection p) { |
1121 |
proj = p; |
1122 |
} |
1123 |
|
1124 |
protected long getTime() { |
1125 |
return (new Date()).getTime(); |
1126 |
} |
1127 |
|
1128 |
/*
|
1129 |
* (non-Javadoc)
|
1130 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#setAffineTransform(java.awt.geom.AffineTransform)
|
1131 |
*/
|
1132 |
public void setAffineTransform(AffineTransform t) { |
1133 |
externalTransformation = (AffineTransform) t.clone();
|
1134 |
} |
1135 |
|
1136 |
/*
|
1137 |
* (non-Javadoc)
|
1138 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getAffineTransform()
|
1139 |
*/
|
1140 |
public AffineTransform getAffineTransform() { |
1141 |
return externalTransformation;
|
1142 |
} |
1143 |
|
1144 |
/**
|
1145 |
* Elimina la matriz de transformaci?n asociada al raster y que se tiene en
|
1146 |
* cuenta para el setView. Este reseteo tendr? en cuenta que si el raster
|
1147 |
* tiene asociado un rmf esta transformaci?n no ser? eliminada sino que se
|
1148 |
* asignar? la correspondiente al rmf existente.
|
1149 |
* @return devuelve true si tiene fichero rmf asociado y false si no lo tiene.
|
1150 |
*/
|
1151 |
public void resetAffineTransform() { |
1152 |
externalTransformation.setToIdentity(); |
1153 |
} |
1154 |
|
1155 |
/*
|
1156 |
* (non-Javadoc)
|
1157 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getOwnAffineTransform()
|
1158 |
*/
|
1159 |
public AffineTransform getOwnAffineTransform() { |
1160 |
return ownTransformation;
|
1161 |
} |
1162 |
|
1163 |
/*
|
1164 |
* (non-Javadoc)
|
1165 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getInfoByPoint(double, double)
|
1166 |
*/
|
1167 |
public String getInfoByPoint(double x, double y, ICancellable cancellable) throws RemoteServiceException { |
1168 |
return null; |
1169 |
} |
1170 |
|
1171 |
/*
|
1172 |
* (non-Javadoc)
|
1173 |
* @see org.gvsig.raster.impl.provider.RasterProvider#setTileServer(java.lang.Class)
|
1174 |
*/
|
1175 |
public void setTileServer(Class<?> tileServer) { |
1176 |
|
1177 |
} |
1178 |
|
1179 |
/*
|
1180 |
* (non-Javadoc)
|
1181 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getTileSize()
|
1182 |
*/
|
1183 |
public int[] getTileSize(int level) { |
1184 |
return new int[]{0, 0}; |
1185 |
} |
1186 |
|
1187 |
/*
|
1188 |
* (non-Javadoc)
|
1189 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isRasterEnclosed()
|
1190 |
*/
|
1191 |
public boolean isRasterEnclosed() { |
1192 |
return false; |
1193 |
} |
1194 |
|
1195 |
/*
|
1196 |
* (non-Javadoc)
|
1197 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getSourceType()
|
1198 |
*/
|
1199 |
public int getSourceType() { |
1200 |
if(getURI().startsWith("PG:host")) |
1201 |
return RasterDataStore.POSTGIS;
|
1202 |
if(getURI().startsWith("http:") || getURI().startsWith("https:")) |
1203 |
return RasterDataStore.REMOTE;
|
1204 |
return RasterDataStore.FILE;
|
1205 |
} |
1206 |
|
1207 |
/**
|
1208 |
* Most of providers don't need tiles. It those cases this method
|
1209 |
* won't execute anything. Only providers that use tile cache will need
|
1210 |
* implement this function, for instance TileProvider and MosaicProvider.
|
1211 |
*/
|
1212 |
public void deleteLayerFromCache() { |
1213 |
|
1214 |
} |
1215 |
|
1216 |
/*
|
1217 |
* (non-Javadoc)
|
1218 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getTimeSerials()
|
1219 |
*/
|
1220 |
public TimeSeries getTimeSerials() throws RmfSerializerException { |
1221 |
if(serialInfo == null) { |
1222 |
serialInfo = new DefaultTimeSerials();
|
1223 |
loadObjectFromRmf(TimeSeries.class, serialInfo); |
1224 |
//Seleccionamos la primera serie por defecto. El usuario seleccionar? otra si la necesita
|
1225 |
serialInfo.selectSerial(0);
|
1226 |
} |
1227 |
return serialInfo;
|
1228 |
} |
1229 |
|
1230 |
/*
|
1231 |
* (non-Javadoc)
|
1232 |
* @see org.gvsig.raster.impl.provider.RasterProvider#setTimeSerials(org.gvsig.fmap.dal.coverage.store.props.TimeSerials)
|
1233 |
*/
|
1234 |
public void setTimeSerials(TimeSeries serialInfo) throws RmfSerializerException { |
1235 |
this.serialInfo = serialInfo;
|
1236 |
saveObjectToRmf(TimeSeries.class, serialInfo); |
1237 |
} |
1238 |
|
1239 |
/*
|
1240 |
* (non-Javadoc)
|
1241 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getFileSizeByProvider()
|
1242 |
*/
|
1243 |
public long[] getFileSizeByProvider() { |
1244 |
return new long[]{getFileSize()}; |
1245 |
} |
1246 |
|
1247 |
/*
|
1248 |
* (non-Javadoc)
|
1249 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getFileNameByProvider()
|
1250 |
*/
|
1251 |
public String[] getURIByProvider() { |
1252 |
//For providers with one file
|
1253 |
return new String[]{getURIOfFirstProvider()}; |
1254 |
} |
1255 |
|
1256 |
/*
|
1257 |
* (non-Javadoc)
|
1258 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getBandCountByProvider()
|
1259 |
*/
|
1260 |
public int[] getBandCountByProvider() { |
1261 |
return new int[]{getBandCount()}; |
1262 |
} |
1263 |
|
1264 |
/*
|
1265 |
* (non-Javadoc)
|
1266 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getInternalProviderCount()
|
1267 |
*/
|
1268 |
public int getInternalProviderCount() { |
1269 |
return 1; |
1270 |
} |
1271 |
|
1272 |
/*
|
1273 |
* (non-Javadoc)
|
1274 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getInternalProvider(int)
|
1275 |
*/
|
1276 |
public RasterProvider getInternalProvider(int i) { |
1277 |
return this; |
1278 |
} |
1279 |
|
1280 |
/*
|
1281 |
* (non-Javadoc)
|
1282 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getURIByBand(int)
|
1283 |
*/
|
1284 |
public String getURIByBand(int band) { |
1285 |
//No matter which band be selected. In providers with one file is always the first URI
|
1286 |
return getURIOfFirstProvider();
|
1287 |
} |
1288 |
|
1289 |
/*
|
1290 |
* (non-Javadoc)
|
1291 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getBandPositionByProvider(int)
|
1292 |
*/
|
1293 |
public int getBandPositionByProvider(int band) { |
1294 |
return band;
|
1295 |
} |
1296 |
|
1297 |
/*
|
1298 |
* (non-Javadoc)
|
1299 |
* @see org.gvsig.raster.impl.provider.RasterProvider#addFile(java.lang.String)
|
1300 |
*/
|
1301 |
public void addFile(String file) throws InvalidSourceException { |
1302 |
//Do nothing
|
1303 |
} |
1304 |
|
1305 |
/*
|
1306 |
* (non-Javadoc)
|
1307 |
* @see org.gvsig.raster.impl.provider.RasterProvider#removeFile(java.lang.String)
|
1308 |
*/
|
1309 |
public void removeFile(String file) { |
1310 |
//Do nothing
|
1311 |
} |
1312 |
|
1313 |
/*
|
1314 |
* (non-Javadoc)
|
1315 |
* @see org.gvsig.raster.impl.provider.RasterProvider#needEnhanced()
|
1316 |
*/
|
1317 |
public boolean needEnhanced() { |
1318 |
return false; |
1319 |
} |
1320 |
|
1321 |
/**
|
1322 |
* Gets the {@link Interval} of the store, that means the temporal
|
1323 |
* interval where the store has valid data.
|
1324 |
* In raster this method has sense in a mosaic. Therefore this has to be implemented
|
1325 |
* by the provider.
|
1326 |
* @return
|
1327 |
* a time interval or null if there is not time support
|
1328 |
*/
|
1329 |
public Interval getInterval() {
|
1330 |
return null; |
1331 |
} |
1332 |
|
1333 |
/**
|
1334 |
* Gets all the possible values of time for which the store has data.
|
1335 |
* In raster this method has sense in a mosaic. Therefore this has to be implemented
|
1336 |
* by the provider.
|
1337 |
* @return
|
1338 |
* a collection of {@link Time} objects.
|
1339 |
*/
|
1340 |
@SuppressWarnings("unchecked") |
1341 |
public Collection getTimes() { |
1342 |
return null; |
1343 |
} |
1344 |
|
1345 |
/**
|
1346 |
* Gets all the possible values of time for which the store has data
|
1347 |
* and intersects with an interval.
|
1348 |
* In raster this method has sense in a mosaic. Therefore this has to be implemented
|
1349 |
* by the provider.
|
1350 |
* @param interval
|
1351 |
* the interval of time
|
1352 |
* @return
|
1353 |
* a collection of {@link Time} objects.
|
1354 |
*/
|
1355 |
@SuppressWarnings("unchecked") |
1356 |
public Collection getTimes(Interval interval) { |
1357 |
return null; |
1358 |
} |
1359 |
} |