Revision 2236 org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/provider/tile/BaseTileDownloader.java
BaseTileDownloader.java | ||
---|---|---|
41 | 41 |
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException; |
42 | 42 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
43 | 43 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
44 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
|
44 | 45 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
45 | 46 |
import org.gvsig.fmap.dal.coverage.store.DataServerWriter; |
46 | 47 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
48 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
|
47 | 49 |
import org.gvsig.fmap.dal.coverage.store.RasterWriter; |
48 | 50 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
49 | 51 |
import org.gvsig.fmap.dal.exception.InitializeException; |
... | ... | |
51 | 53 |
import org.gvsig.raster.cache.tile.Tile; |
52 | 54 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
53 | 55 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
54 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
55 | 56 |
import org.gvsig.raster.impl.RasterDefaultImplLibrary; |
56 | 57 |
import org.gvsig.raster.impl.buffer.DefaultRasterQuery; |
57 | 58 |
import org.gvsig.raster.impl.datastruct.BandListImpl; |
58 | 59 |
import org.gvsig.raster.impl.datastruct.DatasetBandImpl; |
59 | 60 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
60 | 61 |
import org.gvsig.raster.impl.provider.RasterProvider; |
62 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
|
61 | 63 |
import org.gvsig.raster.util.DefaultProviderServices; |
62 | 64 |
|
63 | 65 |
/** |
... | ... | |
175 | 177 |
} |
176 | 178 |
|
177 | 179 |
BandList bandList = (BandList)tile.getDownloaderParams("BandList"); |
178 |
for (int j = 0; j < bandList.getBandCount(); j++) { |
|
180 |
/*for (int j = 0; j < bandList.getBandCount(); j++) {
|
|
179 | 181 |
bandList.getBand(j).setFileName(tile.getFile().getAbsolutePath()); |
180 | 182 |
} |
181 | 183 |
|
... | ... | |
183 | 185 |
if(bandList.getDrawableBands() != null) |
184 | 186 |
mallocNBands = bandList.getDrawableBands().length; |
185 | 187 |
else |
186 |
mallocNBands = bandList.getDrawableBandsCount(); |
|
188 |
mallocNBands = bandList.getDrawableBandsCount();*/
|
|
187 | 189 |
|
188 | 190 |
try { |
189 |
AbstractRasterProvider provider = DefaultProviderServices.loadProvider(tile.getFile()); |
|
191 |
DefaultRasterStore tileStore = new DefaultRasterStore(); |
|
192 |
AbstractRasterProvider tileProvider = DefaultProviderServices.loadProvider(tile.getFile()); |
|
193 |
tileStore.setProvider(tileProvider); |
|
190 | 194 |
this.tilePxWidth = tile.getWidthPx(); |
191 | 195 |
this.tilePxHeight = tile.getHeightPx(); |
192 | 196 |
//int mallocNBands = prov.getDataType()[0] == Buffer.TYPE_BYTE ? provider.getBandCount() - 1 : provider.getBandCount(); |
193 |
Buffer buf = DefaultRasterManager.getInstance().createMemoryBuffer(store.getDataType()[0], this.tilePxWidth, this.tilePxHeight, mallocNBands, true); |
|
194 |
Buffer transparency = DefaultRasterManager.getInstance().createMemoryBuffer(store.getDataType()[0], this.tilePxWidth, this.tilePxHeight, 1, true); |
|
197 |
//Buffer buf = DefaultRasterManager.getInstance().createMemoryBuffer(store.getDataType()[0], this.tilePxWidth, this.tilePxHeight, mallocNBands, true);
|
|
198 |
//Buffer transparency = DefaultRasterManager.getInstance().createMemoryBuffer(store.getDataType()[0], this.tilePxWidth, this.tilePxHeight, 1, true);
|
|
195 | 199 |
|
196 | 200 |
//buf = provider.getWindow((int)0, (int)0, createBandListFromProvider(provider), buf); |
197 | 201 |
|
198 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
|
|
202 |
RasterQuery q = RasterLocator.getManager().createQuery();
|
|
199 | 203 |
|
200 |
q.setAreaOfInterest(new Rectangle((int)0, (int)0, buf.getWidth(), buf.getHeight())); |
|
201 |
q.setBandList(bandList); |
|
202 |
q.setBufferForProviders(buf); |
|
203 |
buf = provider.getDataSet(q); |
|
204 |
q.setAreaOfInterest(new Rectangle((int)0, (int)0, this.tilePxWidth, this.tilePxHeight)); |
|
205 |
q.setDrawableBands(bandList.getDrawableBands());//;.setBandList(bandList); |
|
206 |
Buffer buf = tileStore.query(q); |
|
204 | 207 |
|
205 |
if(provider.getTransparency().getAlphaBandNumber() >= 0) {
|
|
208 |
if(tileStore.getTransparency().getAlphaBandNumber() >= 0) {
|
|
206 | 209 |
//Lee la banda de transparencia para eliminar la zona del tile que est? fuera de la imagen |
207 |
BandList newBandList = new BandListImpl(tile.getFile().getAbsolutePath(), provider.getBandCount(), provider.getDataType()[0]);
|
|
208 |
newBandList.clearDrawableBands(); |
|
209 |
newBandList.addDrawableBand(0, provider.getBandCount() - 1);
|
|
210 |
//BandList newBandList = new BandListImpl(tile.getFile().getAbsolutePath(), tileStore.getBandCount(), tileStore.getDataType()[0]);
|
|
211 |
//newBandList.clearDrawableBands();
|
|
212 |
//newBandList.addDrawableBand(0, tileStore.getBandCount() - 1);
|
|
210 | 213 |
|
211 |
q = (DefaultRasterQuery)RasterLocator.getManager().createQuery(); |
|
212 |
q.setAreaOfInterest(new Rectangle((int)0, (int)0, transparency.getWidth(), transparency.getHeight())); |
|
213 |
q.setBandList(newBandList); |
|
214 |
q.setBufferForProviders(transparency); |
|
215 |
transparency = provider.getDataSet(q); |
|
214 |
q = RasterLocator.getManager().createQuery(); |
|
215 |
q.setAreaOfInterest(new Rectangle((int)0, (int)0, this.tilePxWidth, this.tilePxHeight)); |
|
216 |
q.setDrawableBands(new int[]{tileStore.getBandCount() - 1});//.setBandList(newBandList); |
|
217 |
Buffer transparency = tileStore.query(q); |
|
216 | 218 |
|
217 | 219 |
tile.setData(new Object[]{buf, transparency, null}); |
218 | 220 |
} else |
219 |
tile.setData(new Object[]{buf, null, provider.getColorTable()});
|
|
221 |
tile.setData(new Object[]{buf, null, tileStore.getColorTable()});
|
|
220 | 222 |
|
221 |
buf.setDataExtent(provider.getExtent().toRectangle2D());
|
|
222 |
provider.close();
|
|
223 |
buf.setDataExtent(tileStore.getExtent().toRectangle2D());
|
|
224 |
tileStore.close();
|
|
223 | 225 |
return tile; |
224 | 226 |
} catch (ProcessInterruptedException e) { |
225 | 227 |
throw new TileGettingException(e); |
226 |
} catch (RasterDriverException e) { |
|
227 |
throw new TileGettingException(e); |
|
228 | 228 |
} catch (ProviderNotRegisteredException e) { |
229 | 229 |
throw new TileGettingException(e); |
230 | 230 |
} catch (InitializeException e) { |
231 | 231 |
throw new TileGettingException(e); |
232 |
} catch (QueryException e) { |
|
233 |
throw new TileGettingException(e); |
|
232 | 234 |
} |
233 | 235 |
} |
234 | 236 |
|
Also available in: Unified diff