|
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.multifile.io;
|
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform;
|
|
25 |
import java.awt.geom.Point2D;
|
|
26 |
import java.awt.geom.Rectangle2D;
|
|
27 |
import java.io.File;
|
|
28 |
import java.io.IOException;
|
|
29 |
import java.util.ArrayList;
|
|
30 |
import java.util.List;
|
|
31 |
|
|
32 |
import org.gvsig.fmap.dal.DALFileLocator;
|
|
33 |
import org.gvsig.fmap.dal.DALLocator;
|
|
34 |
import org.gvsig.fmap.dal.DataStore;
|
|
35 |
import org.gvsig.fmap.dal.DataStoreParameters;
|
|
36 |
import org.gvsig.fmap.dal.coverage.RasterLocator;
|
|
37 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
|
|
38 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
|
|
39 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
|
|
40 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
|
|
41 |
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException;
|
|
42 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
|
|
43 |
import org.gvsig.fmap.dal.coverage.exception.FileNotSupportedException;
|
|
44 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
|
|
45 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
|
|
46 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
|
|
47 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
|
|
48 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
|
|
49 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
|
|
50 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
|
|
51 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
|
|
52 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
|
|
53 |
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer;
|
|
54 |
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
|
|
55 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices;
|
|
56 |
import org.gvsig.fmap.dal.exception.CloseException;
|
|
57 |
import org.gvsig.fmap.dal.exception.InitializeException;
|
|
58 |
import org.gvsig.fmap.dal.exception.OpenException;
|
|
59 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
|
|
60 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
|
|
61 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
|
|
62 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
|
|
63 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
|
|
64 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
|
|
65 |
import org.gvsig.fmap.dal.spi.DataStoreProvider;
|
|
66 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
|
|
67 |
import org.gvsig.metadata.MetadataLocator;
|
|
68 |
import org.gvsig.raster.cache.tile.provider.TileListener;
|
|
69 |
import org.gvsig.raster.cache.tile.provider.TileServer;
|
|
70 |
import org.gvsig.raster.impl.buffer.DefaultRasterQuery;
|
|
71 |
import org.gvsig.raster.impl.datastruct.BandListImpl;
|
|
72 |
import org.gvsig.raster.impl.datastruct.DatasetBandImpl;
|
|
73 |
import org.gvsig.raster.impl.datastruct.ExtentImpl;
|
|
74 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider;
|
|
75 |
import org.gvsig.raster.impl.provider.RasterProvider;
|
|
76 |
import org.gvsig.raster.impl.provider.tile.FileTileServer;
|
|
77 |
import org.gvsig.raster.impl.store.DefaultStoreFactory;
|
|
78 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
|
|
79 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency;
|
|
80 |
import org.gvsig.raster.impl.store.properties.MultiProviderHistogramComputer;
|
|
81 |
import org.gvsig.raster.impl.store.properties.MultiProviderStatistics;
|
|
82 |
import org.gvsig.tools.ToolsLocator;
|
|
83 |
import org.gvsig.tools.locator.LocatorException;
|
|
84 |
import org.gvsig.tools.task.TaskStatus;
|
|
85 |
import org.slf4j.Logger;
|
|
86 |
import org.slf4j.LoggerFactory;
|
|
87 |
/**
|
|
88 |
* A data provider for a multiband image readed from different files
|
|
89 |
*
|
|
90 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
|
91 |
*/
|
|
92 |
public class MultiFileProvider extends DefaultRasterProvider {
|
|
93 |
public static String NAME = "Multifile Raster";
|
|
94 |
public static String DESCRIPTION = "Multifile Raster Support";
|
|
95 |
public final String METADATA_DEFINITION_NAME = NAME;
|
|
96 |
private Extent viewRequest = null;
|
|
97 |
private TileServer tileServer = null;
|
|
98 |
private boolean open = false;
|
|
99 |
|
|
100 |
private DataStoreTransparency fileTransparency = null;
|
|
101 |
private static final Logger logger = LoggerFactory.getLogger(MultiFileProvider.class);
|
|
102 |
protected static String[] formatList = null;
|
|
103 |
private ArrayList<RasterProvider> providerList = null;
|
|
104 |
|
|
105 |
public static void register() {
|
|
106 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
|
|
107 |
registerFormats();
|
|
108 |
|
|
109 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
|
|
110 |
dataman.registerStoreProvider(NAME,
|
|
111 |
MultiFileProvider.class, MultiFileDataParametersImpl.class);
|
|
112 |
}
|
|
113 |
|
|
114 |
if(DALFileLocator.getFilesystemServerExplorerManager() != null)
|
|
115 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider(
|
|
116 |
NAME, DESCRIPTION,
|
|
117 |
MultiFileServerExplorer.class);
|
|
118 |
|
|
119 |
if (!dataman.getExplorerProviders().contains(NAME)) {
|
|
120 |
dataman.registerExplorerProvider(NAME, MultiFileServerExplorer.class, MultiFileServerExplorerParameters.class);
|
|
121 |
}
|
|
122 |
|
|
123 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
|
|
124 |
}
|
|
125 |
|
|
126 |
private static void registerFormats() {
|
|
127 |
formatList = new String[] {
|
|
128 |
"mff"};
|
|
129 |
for (int i = 0; i < formatList.length; i++)
|
|
130 |
RasterLocator.getManager().getProviderServices().addFormat(
|
|
131 |
formatList[i],
|
|
132 |
MultiFileProvider.class);
|
|
133 |
}
|
|
134 |
|
|
135 |
public MultiFileProvider() {
|
|
136 |
}
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Opens the dataset.
|
|
140 |
* @param proj Projection
|
|
141 |
* @param fName File name
|
|
142 |
* @throws NotSupportedExtensionException
|
|
143 |
*/
|
|
144 |
public MultiFileProvider(String params) throws NotSupportedExtensionException, OpenException {
|
|
145 |
super(params);
|
|
146 |
if(params instanceof String) {
|
|
147 |
MultiFileDataParameters p = new MultiFileDataParametersImpl();
|
|
148 |
p.setURI((String)params);
|
|
149 |
super.init(p, null, ToolsLocator.getDynObjectManager()
|
|
150 |
.createDynObject(
|
|
151 |
MetadataLocator.getMetadataManager().getDefinition(
|
|
152 |
DataStore.METADATA_DEFINITION_NAME)));
|
|
153 |
init(p, null);
|
|
154 |
}
|
|
155 |
}
|
|
156 |
|
|
157 |
public MultiFileProvider(MultiFileDataParametersImpl params,
|
|
158 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException {
|
|
159 |
super(params, storeServices, ToolsLocator.getDynObjectManager()
|
|
160 |
.createDynObject(
|
|
161 |
MetadataLocator.getMetadataManager().getDefinition(
|
|
162 |
DataStore.METADATA_DEFINITION_NAME)));
|
|
163 |
init(params, storeServices);
|
|
164 |
}
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Build file references
|
|
168 |
* @param proj Projection
|
|
169 |
* @param param Load parameters
|
|
170 |
* @throws NotSupportedExtensionException
|
|
171 |
*/
|
|
172 |
public void init(MultiFileDataParameters params,
|
|
173 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException, OpenException {
|
|
174 |
|
|
175 |
openFromMff();
|
|
176 |
|
|
177 |
uri = getParameters().getURI();
|
|
178 |
providerList = getParameters().getProviders();
|
|
179 |
setParam(storeServices, params);
|
|
180 |
|
|
181 |
try {
|
|
182 |
setFirstProviderToNotTiled();
|
|
183 |
} catch (InvalidSourceException e1) {
|
|
184 |
throw new OpenException(e1.getMessage(), e1);
|
|
185 |
}
|
|
186 |
|
|
187 |
super.init();
|
|
188 |
|
|
189 |
try {
|
|
190 |
loadFromRmf(getRmfBlocksManager());
|
|
191 |
} catch (ParsingException e) {
|
|
192 |
logger.debug("Problems reading from RMF", e);
|
|
193 |
}
|
|
194 |
|
|
195 |
open = true;
|
|
196 |
}
|
|
197 |
|
|
198 |
/**
|
|
199 |
* Open from a .mff file.
|
|
200 |
* This method loads all providers and adds these to the parameters
|
|
201 |
* @throws OpenException
|
|
202 |
*/
|
|
203 |
private void openFromMff() throws OpenException {
|
|
204 |
if(getParameters().getURI() != null && new File(getParameters().getURI()).exists()) {
|
|
205 |
boolean loadedProviders = true;
|
|
206 |
if(getParameters().getProviders() != null) {
|
|
207 |
//solo se considera que est�n todos los providers cargados si existen y est�n open,
|
|
208 |
//sino se leeran de disco
|
|
209 |
for (int i = 0; i < getParameters().getProviders().size(); i++) {
|
|
210 |
if(!getParameters().getProviders().get(i).isOpen())
|
|
211 |
loadedProviders = false;
|
|
212 |
}
|
|
213 |
} else
|
|
214 |
loadedProviders = false;
|
|
215 |
|
|
216 |
if(loadedProviders)
|
|
217 |
return;
|
|
218 |
|
|
219 |
try {
|
|
220 |
if(getParameters().getProviders() != null)
|
|
221 |
getParameters().getProviders().clear();
|
|
222 |
MultiFileFormat multiFileFormat = new MultiFileFormat();
|
|
223 |
multiFileFormat = MultiFileFormatSerializer.read(multiFileFormat, getParameters().getURI());
|
|
224 |
for (int i = 0; i < multiFileFormat.getNumberOfFiles(); i++) {
|
|
225 |
try {
|
|
226 |
File file = new File(multiFileFormat.getPathToFile(i));
|
|
227 |
if(file.exists()) {
|
|
228 |
RasterProvider prov = loadProvider(multiFileFormat.getPathToFile(i), storeServices);
|
|
229 |
getParameters().addProvider(prov);
|
|
230 |
}
|
|
231 |
} catch (ProviderNotRegisteredException e) {
|
|
232 |
throw new OpenException("A provider can't be loaded", e);
|
|
233 |
} catch (InitializeException e) {
|
|
234 |
throw new OpenException("A provider can't be initialized", e);
|
|
235 |
}
|
|
236 |
}
|
|
237 |
} catch (IOException e1) {
|
|
238 |
throw new OpenException("File .mff can't be read", e1);
|
|
239 |
} catch (ParsingException e1) {
|
|
240 |
throw new OpenException("File .mff can't be parsed", e1);
|
|
241 |
}
|
|
242 |
}
|
|
243 |
}
|
|
244 |
|
|
245 |
/**
|
|
246 |
* Loads the specific provider
|
|
247 |
* @param file
|
|
248 |
* @return
|
|
249 |
* @throws NotSupportedExtensionException
|
|
250 |
* @throws FileNotSupportedException
|
|
251 |
*/
|
|
252 |
private RasterProvider loadProvider(String file, DataStoreProviderServices storeServices) throws ProviderNotRegisteredException, InitializeException {
|
|
253 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
|
|
254 |
DataStoreProvider prov = null;
|
|
255 |
|
|
256 |
if(file != null) {
|
|
257 |
//We have to locate a provider's name which manages the selected file
|
|
258 |
//A FilesystemServerExplorer will give a getProviderNames service
|
|
259 |
FilesystemServerExplorerParameters paramsExplorer = (FilesystemServerExplorerParameters)dataManager.createServerExplorerParameters(FilesystemServerExplorer.NAME);
|
|
260 |
FilesystemServerExplorer serverExplorer = null;
|
|
261 |
try {
|
|
262 |
paramsExplorer.setRoot(File.separator);
|
|
263 |
serverExplorer = (FilesystemServerExplorer)dataManager.openServerExplorer(FilesystemServerExplorer.NAME, paramsExplorer);
|
|
264 |
} catch (ValidateDataParametersException e) {
|
|
265 |
throw new InitializeException(e);
|
|
266 |
}
|
|
267 |
File f = new File(file);
|
|
268 |
//Gets the list of provider's name to manage the file
|
|
269 |
List<String> provName = serverExplorer.getProviderNameList(f);
|
|
270 |
if(provName.size() > 0) {
|
|
271 |
for (int i = 0; i < provName.size(); i++) {
|
|
272 |
//Gets the first provider what is not a TileProvider
|
|
273 |
if(provName.get(i).compareTo("Tile Store") != 0) {
|
|
274 |
DataStoreParameters newparams = dataManager.createStoreParameters(provName.get(i));
|
|
275 |
((FilesystemStoreParameters)newparams).setFile(f);
|
|
276 |
prov = dataManager.createProvider(storeServices, newparams);
|
|
277 |
}
|
|
278 |
}
|
|
279 |
}
|
|
280 |
}
|
|
281 |
|
|
282 |
if(prov != null && prov instanceof RasterProvider) {
|
|
283 |
if(((RasterProvider)prov).isRotated())
|
|
284 |
throw new InitializeException("Rotation not supported tiling files", new Throwable());
|
|
285 |
|
|
286 |
return (RasterProvider)prov;
|
|
287 |
}
|
|
288 |
|
|
289 |
return null;
|
|
290 |
}
|
|
291 |
|
|
292 |
/**
|
|
293 |
* Checks if the new file is compatible with the old one
|
|
294 |
* @param file
|
|
295 |
* @return
|
|
296 |
* @throws LocatorException
|
|
297 |
* @throws NotSupportedExtensionException
|
|
298 |
* @throws RasterDriverException
|
|
299 |
* @throws CloseException
|
|
300 |
*/
|
|
301 |
private boolean checkNewProvider(RasterProvider p) {
|
|
302 |
Rectangle2D extentOrigin = getExtent().toRectangle2D();
|
|
303 |
|
|
304 |
Extent extentNewFile = p.getExtent();
|
|
305 |
|
|
306 |
// Comprobamos que el extent y tama�o del fichero a�adido sea igual al
|
|
307 |
// fichero original. Si no es as� no abrimos la capa y mostramos un aviso
|
|
308 |
|
|
309 |
double widthNewFile = (extentNewFile.getMax().getX() - extentNewFile.getMin().getX());
|
|
310 |
double heightNewFile = (extentNewFile.getMax().getY() - extentNewFile.getMin().getY());
|
|
311 |
|
|
312 |
if ((widthNewFile - extentOrigin.getWidth()) > 1.0 || (widthNewFile - extentOrigin.getWidth()) < -1.0 || (heightNewFile - extentOrigin.getHeight()) > 1.0
|
|
313 |
|| (heightNewFile - extentOrigin.getHeight()) < -1.0) {
|
|
314 |
return false;
|
|
315 |
}
|
|
316 |
|
|
317 |
if ((extentNewFile.getMax().getX() - extentNewFile.getMin().getX()) != extentOrigin.getWidth()
|
|
318 |
|| (extentNewFile.getMax().getY() - extentNewFile.getMin().getY()) != extentOrigin.getHeight()) {
|
|
319 |
return false;
|
|
320 |
}
|
|
321 |
|
|
322 |
return true;
|
|
323 |
}
|
|
324 |
|
|
325 |
public MultiFileDataParameters getParameters() {
|
|
326 |
try {
|
|
327 |
return (MultiFileDataParameters)parameters;
|
|
328 |
} catch (ClassCastException e) {
|
|
329 |
return null;
|
|
330 |
}
|
|
331 |
}
|
|
332 |
|
|
333 |
/*
|
|
334 |
* (non-Javadoc)
|
|
335 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#load()
|
|
336 |
*/
|
|
337 |
public RasterProvider load() {
|
|
338 |
return this;
|
|
339 |
}
|
|
340 |
|
|
341 |
/*
|
|
342 |
* (non-Javadoc)
|
|
343 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getBandCount()
|
|
344 |
*/
|
|
345 |
public int getBandCount() {
|
|
346 |
providerList = getParameters().getProviders();
|
|
347 |
int bandCount = 0;
|
|
348 |
for (int i = 0; i < providerList.size(); i++) {
|
|
349 |
bandCount += providerList.get(i).getBandCount();
|
|
350 |
}
|
|
351 |
return bandCount;
|
|
352 |
}
|
|
353 |
|
|
354 |
/*
|
|
355 |
* (non-Javadoc)
|
|
356 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getDataType()
|
|
357 |
*/
|
|
358 |
public int[] getDataType() {
|
|
359 |
providerList = getParameters().getProviders();
|
|
360 |
int[] datatypes = new int[getBandCount()];
|
|
361 |
int k = 0;
|
|
362 |
for (int i = 0; i < providerList.size(); i++) {
|
|
363 |
int[] dtByProv = providerList.get(i).getDataType();
|
|
364 |
for (int j = 0; j < dtByProv.length; j++) {
|
|
365 |
datatypes[k] = dtByProv[j];
|
|
366 |
k++;
|
|
367 |
}
|
|
368 |
}
|
|
369 |
return datatypes;
|
|
370 |
}
|
|
371 |
|
|
372 |
/*
|
|
373 |
* (non-Javadoc)
|
|
374 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getURIByProvider()
|
|
375 |
*/
|
|
376 |
public String[] getURIByProvider() {
|
|
377 |
providerList = getParameters().getProviders();
|
|
378 |
String[] uris = new String[providerList.size()];
|
|
379 |
for (int i = 0; i < uris.length; i++) {
|
|
380 |
uris[i] = providerList.get(i).getURIOfFirstProvider();
|
|
381 |
}
|
|
382 |
return uris;
|
|
383 |
}
|
|
384 |
|
|
385 |
/*
|
|
386 |
* (non-Javadoc)
|
|
387 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getBandPositionByProvider(int)
|
|
388 |
*/
|
|
389 |
public int getBandPositionByProvider(int band) {
|
|
390 |
return getSubBandByBandNumber(band)[1];
|
|
391 |
}
|
|
392 |
|
|
393 |
/*
|
|
394 |
* (non-Javadoc)
|
|
395 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getURIOfFirstProvider()
|
|
396 |
*/
|
|
397 |
public String getURIOfFirstProvider() {
|
|
398 |
providerList = getParameters().getProviders();
|
|
399 |
return providerList.get(0).getURIOfFirstProvider();
|
|
400 |
}
|
|
401 |
|
|
402 |
|
|
403 |
/*
|
|
404 |
* (non-Javadoc)
|
|
405 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getExtent()
|
|
406 |
*/
|
|
407 |
public Extent getExtent() {
|
|
408 |
providerList = getParameters().getProviders();
|
|
409 |
if(providerList != null && providerList.size() > 0)
|
|
410 |
return providerList.get(0).getExtent();
|
|
411 |
return null;
|
|
412 |
}
|
|
413 |
|
|
414 |
/*
|
|
415 |
* (non-Javadoc)
|
|
416 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getAffineTransform()
|
|
417 |
*/
|
|
418 |
public AffineTransform getAffineTransform() {
|
|
419 |
providerList = getParameters().getProviders();
|
|
420 |
return providerList.get(0).getAffineTransform();
|
|
421 |
}
|
|
422 |
|
|
423 |
/*
|
|
424 |
* (non-Javadoc)
|
|
425 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#setAffineTransform(java.awt.geom.AffineTransform)
|
|
426 |
*/
|
|
427 |
public void setAffineTransform(AffineTransform t) {
|
|
428 |
providerList = getParameters().getProviders();
|
|
429 |
for (int i = 0; i < providerList.size(); i++) {
|
|
430 |
providerList.get(i).setAffineTransform(t);
|
|
431 |
}
|
|
432 |
}
|
|
433 |
|
|
434 |
/*
|
|
435 |
* (non-Javadoc)
|
|
436 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getInternalProviderCount()
|
|
437 |
*/
|
|
438 |
public int getInternalProviderCount() {
|
|
439 |
return providerList.size();
|
|
440 |
}
|
|
441 |
|
|
442 |
/*
|
|
443 |
* (non-Javadoc)
|
|
444 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getInternalProvider(int)
|
|
445 |
*/
|
|
446 |
public RasterProvider getInternalProvider(int i) {
|
|
447 |
return providerList.get(i);
|
|
448 |
}
|
|
449 |
|
|
450 |
/*
|
|
451 |
* (non-Javadoc)
|
|
452 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getBandCountByProvider()
|
|
453 |
*/
|
|
454 |
public int[] getBandCountByProvider() {
|
|
455 |
providerList = getParameters().getProviders();
|
|
456 |
int[] bc = new int[providerList.size()];
|
|
457 |
for (int i = 0; i < bc.length; i++) {
|
|
458 |
bc[i] = providerList.get(i).getBandCount();
|
|
459 |
}
|
|
460 |
return bc;
|
|
461 |
}
|
|
462 |
|
|
463 |
/*
|
|
464 |
* (non-Javadoc)
|
|
465 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getFileSizeByProvider()
|
|
466 |
*/
|
|
467 |
public long[] getFileSizeByProvider() {
|
|
468 |
providerList = getParameters().getProviders();
|
|
469 |
long[] fs = new long[providerList.size()];
|
|
470 |
for (int i = 0; i < fs.length; i++) {
|
|
471 |
fs[i] = ((DefaultRasterProvider)providerList.get(i)).getFileSize();
|
|
472 |
}
|
|
473 |
return fs;
|
|
474 |
}
|
|
475 |
|
|
476 |
/*
|
|
477 |
* (non-Javadoc)
|
|
478 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#rasterToWorld(java.awt.geom.Point2D)
|
|
479 |
*/
|
|
480 |
public Point2D rasterToWorld(Point2D pt) {
|
|
481 |
providerList = getParameters().getProviders();
|
|
482 |
return providerList.get(0).rasterToWorld(pt);
|
|
483 |
}
|
|
484 |
|
|
485 |
/*
|
|
486 |
* (non-Javadoc)
|
|
487 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#worldToRaster(java.awt.geom.Point2D)
|
|
488 |
*/
|
|
489 |
public Point2D worldToRaster(Point2D pt) {
|
|
490 |
providerList = getParameters().getProviders();
|
|
491 |
return providerList.get(0).worldToRaster(pt);
|
|
492 |
}
|
|
493 |
|
|
494 |
/*
|
|
495 |
* (non-Javadoc)
|
|
496 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isInside(java.awt.geom.Point2D)
|
|
497 |
*/
|
|
498 |
public boolean isInside(Point2D p){
|
|
499 |
providerList = getParameters().getProviders();
|
|
500 |
return providerList.get(0).isInside(p);
|
|
501 |
}
|
|
502 |
|
|
503 |
/*
|
|
504 |
* (non-Javadoc)
|
|
505 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getCellSize()
|
|
506 |
*/
|
|
507 |
public double getCellSize() {
|
|
508 |
providerList = getParameters().getProviders();
|
|
509 |
return providerList.get(0).getCellSize();
|
|
510 |
}
|
|
511 |
|
|
512 |
/*
|
|
513 |
* (non-Javadoc)
|
|
514 |
* @see org.gvsig.raster.impl.dataset.RasterProvider#getStatistics()
|
|
515 |
*/
|
|
516 |
public Statistics getStatistics() {
|
|
517 |
if(stats == null || (stats instanceof MultiProviderStatistics &&
|
|
518 |
((MultiProviderStatistics)stats).getNumberOfProviders() != providerList.size())) {
|
|
519 |
providerList = getParameters().getProviders();
|
|
520 |
stats = new MultiProviderStatistics(providerList);
|
|
521 |
}
|
|
522 |
|
|
523 |
return stats;
|
|
524 |
}
|
|
525 |
|
|
526 |
/*
|
|
527 |
* (non-Javadoc)
|
|
528 |
* @see org.gvsig.fmap.dal.coverage.store.props.Histogramable#getHistogramComputer()
|
|
529 |
*/
|
|
530 |
public HistogramComputer getHistogramComputer() {
|
|
531 |
if(histogram == null ||
|
|
532 |
(histogram instanceof MultiProviderHistogramComputer &&
|
|
533 |
((MultiProviderHistogramComputer)histogram).getNumberOfProviders() != providerList.size())) {
|
|
534 |
histogram = new MultiProviderHistogramComputer(this);
|
|
535 |
}
|
|
536 |
|
|
537 |
return histogram;
|
|
538 |
}
|
|
539 |
|
|
540 |
/**
|
|
541 |
* A multiband provider doesn't have a color table because this will have
|
|
542 |
* more than one band.
|
|
543 |
*/
|
|
544 |
public ColorTable getColorTable() {
|
|
545 |
return null;
|
|
546 |
}
|
|
547 |
|
|
548 |
/*
|
|
549 |
* (non-Javadoc)
|
|
550 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isOpen()
|
|
551 |
*/
|
|
552 |
public boolean isOpen() {
|
|
553 |
return open;
|
|
554 |
}
|
|
555 |
|
|
556 |
/*
|
|
557 |
* (non-Javadoc)
|
|
558 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#close()
|
|
559 |
*/
|
|
560 |
public void close() {
|
|
561 |
}
|
|
562 |
|
|
563 |
/*
|
|
564 |
* (non-Javadoc)
|
|
565 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#translateFileName(java.lang.String)
|
|
566 |
*/
|
|
567 |
public String translateFileName(String fileName) {
|
|
568 |
return fileName;
|
|
569 |
}
|
|
570 |
|
|
571 |
/**
|
|
572 |
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci�n
|
|
573 |
* de la vista asignada ya que la petici�n viene en coordenadas del fichero .rmf y la vista (v)
|
|
574 |
* ha de estar en coordenadas del fichero.
|
|
575 |
*/
|
|
576 |
public void setView(Extent e) {
|
|
577 |
viewRequest = new ExtentImpl(e);
|
|
578 |
}
|
|
579 |
|
|
580 |
/*
|
|
581 |
* (non-Javadoc)
|
|
582 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getView()
|
|
583 |
*/
|
|
584 |
public Extent getView() {
|
|
585 |
return viewRequest;
|
|
586 |
}
|
|
587 |
|
|
588 |
/*
|
|
589 |
* (non-Javadoc)
|
|
590 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWidth()
|
|
591 |
*/
|
|
592 |
public double getWidth() {
|
|
593 |
providerList = getParameters().getProviders();
|
|
594 |
if(providerList != null && providerList.size() > 0) {
|
|
595 |
return providerList.get(0).getWidth();
|
|
596 |
}
|
|
597 |
return 0;
|
|
598 |
}
|
|
599 |
|
|
600 |
/*
|
|
601 |
* (non-Javadoc)
|
|
602 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getHeight()
|
|
603 |
*/
|
|
604 |
public double getHeight() {
|
|
605 |
providerList = getParameters().getProviders();
|
|
606 |
if(providerList != null && providerList.size() > 0) {
|
|
607 |
return providerList.get(0).getHeight();
|
|
608 |
}
|
|
609 |
return 0;
|
|
610 |
|
|
611 |
}
|
|
612 |
|
|
613 |
/*
|
|
614 |
* (non-Javadoc)
|
|
615 |
* @see org.gvsig.raster.dataset.RasterDataset#readBlock(int, int, double)
|
|
616 |
*/
|
|
617 |
public Object readBlock(int pos, int blockHeight, double scale)
|
|
618 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException {
|
|
619 |
providerList = getParameters().getProviders();
|
|
620 |
return null;
|
|
621 |
}
|
|
622 |
|
|
623 |
/**
|
|
624 |
* Gets a number of provider and the band of this provider
|
|
625 |
* @param band
|
|
626 |
* @return
|
|
627 |
*/
|
|
628 |
private int[] getSubBandByBandNumber(int band) {
|
|
629 |
providerList = getParameters().getProviders();
|
|
630 |
int[] res = new int[2];
|
|
631 |
int acum = 0;
|
|
632 |
for (int i = 0; i < providerList.size(); i++) {
|
|
633 |
acum += providerList.get(i).getBandCount();
|
|
634 |
if(acum > band) {
|
|
635 |
res[0] = i;
|
|
636 |
int aux = (acum - providerList.get(i).getBandCount());
|
|
637 |
res[1] = band - aux;
|
|
638 |
return res;
|
|
639 |
}
|
|
640 |
}
|
|
641 |
return res;
|
|
642 |
}
|
|
643 |
|
|
644 |
/*
|
|
645 |
* (non-Javadoc)
|
|
646 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getData(int, int, int)
|
|
647 |
*/
|
|
648 |
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
|
649 |
int[] sub = getSubBandByBandNumber(band);
|
|
650 |
RasterProvider prov = providerList.get(sub[0]);
|
|
651 |
return prov.getData(x, y, sub[1]);
|
|
652 |
}
|
|
653 |
|
|
654 |
/*
|
|
655 |
* (non-Javadoc)
|
|
656 |
* @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)
|
|
657 |
*/
|
|
658 |
public void getWindow(Extent ex, int bufWidth, int bufHeight,
|
|
659 |
BandList bandList, TileListener listener, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
|
|
660 |
}
|
|
661 |
|
|
662 |
/*
|
|
663 |
* (non-Javadoc)
|
|
664 |
* @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)
|
|
665 |
*/
|
|
666 |
public Buffer getWindow(Extent extent, BandList bandList, Buffer rasterBuf, TaskStatus status)
|
|
667 |
throws ProcessInterruptedException, RasterDriverException {
|
|
668 |
providerList = getParameters().getProviders();
|
|
669 |
|
|
670 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
|
|
671 |
q.setAreaOfInterest(extent);
|
|
672 |
q.setBandList(bandList);
|
|
673 |
q.setBuffer(rasterBuf);
|
|
674 |
|
|
675 |
for (int i = 0; i < providerList.size(); i++) {
|
|
676 |
rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q);
|
|
677 |
}
|
|
678 |
return rasterBuf;
|
|
679 |
}
|
|
680 |
|
|
681 |
|
|
682 |
|
|
683 |
/*
|
|
684 |
* (non-Javadoc)
|
|
685 |
* @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)
|
|
686 |
*/
|
|
687 |
public Buffer getWindow(double ulx, double uly, double w, double h,
|
|
688 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
|
|
689 |
providerList = getParameters().getProviders();
|
|
690 |
|
|
691 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
|
|
692 |
q.setAreaOfInterest(ulx, uly, w, h);
|
|
693 |
q.setBandList(bandList);
|
|
694 |
q.setBuffer(rasterBuf);
|
|
695 |
q.setAdjustToExtent(adjustToExtent);
|
|
696 |
|
|
697 |
for (int i = 0; i < providerList.size(); i++) {
|
|
698 |
rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q);
|
|
699 |
}
|
|
700 |
return rasterBuf;
|
|
701 |
}
|
|
702 |
|
|
703 |
/*
|
|
704 |
* (non-Javadoc)
|
|
705 |
* @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)
|
|
706 |
*/
|
|
707 |
public Buffer getWindow(Extent extent, int bufWidth, int bufHeight,
|
|
708 |
BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
|
|
709 |
providerList = getParameters().getProviders();
|
|
710 |
|
|
711 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
|
|
712 |
q.setAreaOfInterest(extent, bufWidth, bufHeight);
|
|
713 |
q.setBuffer(rasterBuf);
|
|
714 |
q.setAdjustToExtent(adjustToExtent);
|
|
715 |
|
|
716 |
for (int i = 0; i < providerList.size(); i++) {
|
|
717 |
BandList bandListByFile = createBandListByProvider(bandList, providerList.get(i));
|
|
718 |
if(bandListByFile != null) {
|
|
719 |
q.setBandList(bandListByFile);
|
|
720 |
rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q);
|
|
721 |
}
|
|
722 |
}
|
|
723 |
return rasterBuf;
|
|
724 |
}
|
|
725 |
|
|
726 |
/**
|
|
727 |
* Creates a <code>BandList</code> for each provider of this <code>MultiFileProvider</code>.
|
|
728 |
* When a request is made, the <code>BandList</code> is global for all files. A specific
|
|
729 |
* <code>BandList</code> has to be built for each provider.
|
|
730 |
* @param globalBandList
|
|
731 |
* @param provider
|
|
732 |
* @return
|
|
733 |
*/
|
|
734 |
private BandList createBandListByProvider(BandList globalBandList, RasterProvider provider) {
|
|
735 |
if(provider.isTiled()) {
|
|
736 |
//Si los proveedores que hay por debajo son tileados estos crear�n su propio buffer para escribir
|
|
737 |
//cada tile. Por ello no usar� el buffer que viene del store. Esto quiere decir que el BandList ha
|
|
738 |
//de ser distinto para que escriba bien en su buffer
|
|
739 |
|
|
740 |
//TODO: De momento no se permiten MultiFiles con proveedores tileados. Esto es porque
|
|
741 |
//los tiles crean su propio buffer y no escriben en el buffer creado en el Store
|
|
742 |
|
|
743 |
} else {
|
|
744 |
BandList bandListByFile = new BandListImpl();
|
|
745 |
for (int i = 0; i < provider.getBandCount(); i++) {
|
|
746 |
try {
|
|
747 |
bandListByFile.addBand(new DatasetBandImpl(provider.getURI(), i, provider.getDataType()[0], provider.getBandCount()));
|
|
748 |
} catch (BandNotFoundInListException e1) {
|
|
749 |
}
|
|
750 |
}
|
|
751 |
|
|
752 |
boolean areThereBandsToDraw = false;
|
|
753 |
for (int i = 0; i < provider.getBandCount(); i++) {
|
|
754 |
int[] bandsToDrawByProviderBand = globalBandList.getBufferBandToDraw(provider.getURI(), i);
|
|
755 |
if(bandsToDrawByProviderBand != null) {
|
|
756 |
areThereBandsToDraw = true;
|
|
757 |
for (int j = 0; j < bandsToDrawByProviderBand.length; j++) {
|
|
758 |
bandListByFile.getBand(i).addPositionToDrawInBuffer(bandsToDrawByProviderBand[j]);
|
|
759 |
}
|
|
760 |
}
|
|
761 |
}
|
|
762 |
|
|
763 |
if(areThereBandsToDraw)
|
|
764 |
return bandListByFile;
|
|
765 |
}
|
|
766 |
return null;
|
|
767 |
}
|
|
768 |
|
|
769 |
/*
|
|
770 |
* (non-Javadoc)
|
|
771 |
* @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)
|
|
772 |
*/
|
|
773 |
public Buffer getWindow(int x, int y, int w, int h,
|
|
774 |
BandList bandList, Buffer rasterBuf, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
|
|
775 |
providerList = getParameters().getProviders();
|
|
776 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
|
|
777 |
q.setAreaOfInterest(x, y, w, h);
|
|
778 |
q.setBandList(bandList);
|
|
779 |
q.setBuffer(rasterBuf);
|
|
780 |
for (int i = 0; i < providerList.size(); i++) {
|
|
781 |
rasterBuf = ((DefaultRasterProvider)providerList.get(i)).getDataSet(q);
|
|
782 |
}
|
|
783 |
return rasterBuf;
|
|
784 |
}
|
|
785 |
|
|
786 |
/*
|
|
787 |
* (non-Javadoc)
|
|
788 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getBlockSize()
|
|
789 |
*/
|
|
790 |
public int getBlockSize() {
|
|
791 |
return 0;
|
|
792 |
}
|
|
793 |
|
|
794 |
/*
|
|
795 |
* (non-Javadoc)
|
|
796 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getColorInterpretation()
|
|
797 |
*/
|
|
798 |
public ColorInterpretation getColorInterpretation() {
|
|
799 |
if(super.getColorInterpretation() == null) {
|
|
800 |
String[] cis = new String[getBandCount()];
|
|
801 |
for (int i = 0; i < cis.length; i++) {
|
|
802 |
if(i == 0)
|
|
803 |
cis[i] = ColorInterpretation.GRAY_BAND;
|
|
804 |
else
|
|
805 |
cis[i] = ColorInterpretation.UNDEF_BAND;
|
|
806 |
}
|
|
807 |
setColorInterpretation(new DataStoreColorInterpretation(cis));
|
|
808 |
}
|
|
809 |
return super.getColorInterpretation();
|
|
810 |
}
|
|
811 |
|
|
812 |
/*
|
|
813 |
* (non-Javadoc)
|
|
814 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getTransparency()
|
|
815 |
*/
|
|
816 |
public DataStoreTransparency getTransparency() {
|
|
817 |
if(fileTransparency == null)
|
|
818 |
fileTransparency = new DataStoreTransparency();
|
|
819 |
return fileTransparency;
|
|
820 |
}
|
|
821 |
|
|
822 |
/**
|
|
823 |
* Informa de si el driver ha supersampleado en el �ltimo dibujado. Es el driver el que colocar�
|
|
824 |
* el valor de esta variable cada vez que dibuja.
|
|
825 |
* @return true si se ha supersampleado y false si no se ha hecho.
|
|
826 |
*/
|
|
827 |
public boolean isSupersampling() {
|
|
828 |
return false;
|
|
829 |
}
|
|
830 |
|
|
831 |
/*
|
|
832 |
* (non-Javadoc)
|
|
833 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewCount(int)
|
|
834 |
*/
|
|
835 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException {
|
|
836 |
if(band >= getBandCount())
|
|
837 |
throw new BandAccessException("Wrong band");
|
|
838 |
return 0;
|
|
839 |
}
|
|
840 |
|
|
841 |
/*
|
|
842 |
* (non-Javadoc)
|
|
843 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewWidth(int, int)
|
|
844 |
*/
|
|
845 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException {
|
|
846 |
if (band >= getBandCount())
|
|
847 |
throw new BandAccessException("Wrong band");
|
|
848 |
return 0;
|
|
849 |
}
|
|
850 |
|
|
851 |
/*
|
|
852 |
* (non-Javadoc)
|
|
853 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getOverviewHeight(int, int)
|
|
854 |
*/
|
|
855 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException {
|
|
856 |
if (band >= getBandCount())
|
|
857 |
throw new BandAccessException("Wrong band");
|
|
858 |
return 0;
|
|
859 |
}
|
|
860 |
|
|
861 |
/*
|
|
862 |
* (non-Javadoc)
|
|
863 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isMultiFile()
|
|
864 |
*/
|
|
865 |
public boolean isMultiFile() {
|
|
866 |
return true;
|
|
867 |
}
|
|
868 |
|
|
869 |
/*
|
|
870 |
* (non-Javadoc)
|
|
871 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isOverviewsSupported()
|
|
872 |
*/
|
|
873 |
public boolean isOverviewsSupported() {
|
|
874 |
return true;
|
|
875 |
}
|
|
876 |
|
|
877 |
/*
|
|
878 |
* (non-Javadoc)
|
|
879 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#isReproyectable()
|
|
880 |
*/
|
|
881 |
public boolean isReproyectable() {
|
|
882 |
return true;
|
|
883 |
}
|
|
884 |
|
|
885 |
/*
|
|
886 |
* (non-Javadoc)
|
|
887 |
* @see org.gvsig.fmap.dal.spi.DataStoreProvider#getName()
|
|
888 |
*/
|
|
889 |
public String getName() {
|
|
890 |
return NAME;
|
|
891 |
}
|
|
892 |
|
|
893 |
/*
|
|
894 |
* (non-Javadoc)
|
|
895 |
* @see org.gvsig.raster.impl.provider.RasterProvider#setStatus(org.gvsig.raster.impl.provider.RasterProvider)
|
|
896 |
*/
|
|
897 |
public void setStatus(RasterProvider provider) {
|
|
898 |
if(provider instanceof MultiFileProvider) {
|
|
899 |
//Not implemented yet
|
|
900 |
}
|
|
901 |
}
|
|
902 |
|
|
903 |
/*
|
|
904 |
* (non-Javadoc)
|
|
905 |
* @see org.gvsig.raster.impl.provider.RasterProvider#isTimeSupported()
|
|
906 |
*/
|
|
907 |
public boolean isTimeSupported() {
|
|
908 |
return true;
|
|
909 |
}
|
|
910 |
|
|
911 |
/*
|
|
912 |
* (non-Javadoc)
|
|
913 |
* @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getURIByBand(int)
|
|
914 |
*/
|
|
915 |
public String getURIByBand(int band) {
|
|
916 |
int[] sub = getSubBandByBandNumber(band);
|
|
917 |
RasterProvider prov = providerList.get(sub[0]);
|
|
918 |
return prov.getURIOfFirstProvider();
|
|
919 |
}
|
|
920 |
|
|
921 |
/*
|
|
922 |
* (non-Javadoc)
|
|
923 |
* @see org.gvsig.raster.impl.provider.RasterProvider#addFile(java.lang.String)
|
|
924 |
*/
|
|
925 |
public void addFile(String file) throws InvalidSourceException {
|
|
926 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices();
|
|
927 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
|
|
928 |
|
|
929 |
// if(providerList.size() > 0 && providerList.get(0).isTiled()) {
|
|
930 |
// //Comentado hasta que se puedan incorporar fuentes tileadas a aun MultiFile
|
|
931 |
// //en su lugar se sustituye el primer proveedor tileado por uno sin tilear
|
|
932 |
//
|
|
933 |
// RasterDataParameters storeParameters = provServ.createParametersForTiledFiled(file);
|
|
934 |
//
|
|
935 |
// try {
|
|
936 |
// RasterProvider newFileProv = (RasterProvider)dataManager.createProvider(storeServices, storeParameters);
|
|
937 |
// if(checkNewProvider(newFileProv)) {
|
|
938 |
// getParameters().addProvider(newFileProv);
|
|
939 |
// }
|
|
940 |
// } catch (InitializeException e) {
|
|
941 |
// throw new InvalidSourceException("", e);
|
|
942 |
// } catch (ProviderNotRegisteredException e) {
|
|
943 |
// throw new InvalidSourceException("", e);
|
|
944 |
// }
|
|
945 |
// }
|
|
946 |
|
|
947 |
setFirstProviderToNotTiled();
|
|
948 |
|
|
949 |
List<RasterDataParameters> storeParametersList = provServ.createParametersList(file);
|
|
950 |
|
|
951 |
for (int j = 0; j < storeParametersList.size(); j++) {
|
|
952 |
RasterProvider newFileProv;
|
|
953 |
try {
|
|
954 |
newFileProv = (RasterProvider)dataManager.createProvider(storeServices, storeParametersList.get(j));
|
|
955 |
if(!newFileProv.isTiled() && checkNewProvider(newFileProv)) {
|
|
956 |
getParameters().addProvider(newFileProv);
|
|
957 |
}
|
|
958 |
} catch (InitializeException e) {
|
|
959 |
throw new InvalidSourceException("", e);
|
|
960 |
} catch (ProviderNotRegisteredException e) {
|
|
961 |
throw new InvalidSourceException("", e);
|
|
962 |
}
|
|
963 |
}
|
|
964 |
}
|
|
965 |
|
|
966 |
private void setFirstProviderToNotTiled() throws InvalidSourceException {
|
|
967 |
if(providerList == null || providerList.size() <= 0 || !providerList.get(0).isTiled())
|
|
968 |
return;
|
|
969 |
|
|
970 |
//Si el primer proveedor es tileado se cambia a no tileado
|
|
971 |
DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
|
|
972 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices();
|
|
973 |
|
|
974 |
RasterDataParameters firstDataParameters = providerList.get(0).getDataParameters();
|
|
975 |
String uri = firstDataParameters.getURI();
|
|
976 |
|
|
977 |
List<RasterDataParameters> storeParametersList = provServ.createParametersList(uri);
|
|
978 |
|
|
979 |
for (int j = 0; j < storeParametersList.size(); j++) {
|
|
980 |
RasterProvider newFileProv;
|
|
981 |
try {
|
|
982 |
newFileProv = (RasterProvider)dataManager.createProvider(storeServices, storeParametersList.get(j));
|
|
983 |
if(!newFileProv.isTiled() && checkNewProvider(newFileProv)) {
|
|
984 |
getParameters().setFirstProvider(newFileProv);
|
|
985 |
}
|
|
986 |
} catch (InitializeException e) {
|
|
987 |
throw new InvalidSourceException("Error replacing the first provider", e);
|
|
988 |
} catch (ProviderNotRegisteredException e) {
|
|
989 |
throw new InvalidSourceException("Error replacing the first provider", e);
|
|
990 |
}
|
|
991 |
}
|
|
992 |
}
|
|
993 |
|
|
994 |
/*
|
|
995 |
* (non-Javadoc)
|
|
996 |
* @see org.gvsig.raster.impl.provider.RasterProvider#removeFile(java.lang.String)
|
|
997 |
*/
|
|
998 |
public void removeFile(String file) {
|
|
999 |
getParameters().removeProvider(file);
|
|
1000 |
}
|
|
1001 |
|
|
1002 |
/*
|
|
1003 |
* (non-Javadoc)
|
|
1004 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getTileServer()
|
|
1005 |
*/
|
|
1006 |
public TileServer getTileServer() {
|
|
1007 |
if(tileServer == null)
|
|
1008 |
tileServer = new FileTileServer(this);
|
|
1009 |
return tileServer;
|
|
1010 |
}
|
|
1011 |
}
|
0 |
1012 |
|