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/buffer/cache/CacheDataServer.java
CacheDataServer.java | ||
---|---|---|
36 | 36 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
37 | 37 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
38 | 38 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
39 |
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException; |
|
40 | 39 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
41 | 40 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
41 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
|
42 | 42 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
43 | 43 |
import org.gvsig.fmap.dal.coverage.store.DataServerWriter; |
44 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
|
44 | 45 |
import org.gvsig.fmap.dal.coverage.store.RasterWriter; |
45 | 46 |
import org.gvsig.fmap.dal.coverage.util.FileUtils; |
46 | 47 |
import org.gvsig.raster.impl.DefaultRasterManager; |
47 |
import org.gvsig.raster.impl.buffer.DefaultRasterQuery; |
|
48 |
import org.gvsig.raster.impl.datastruct.BandListImpl; |
|
49 |
import org.gvsig.raster.impl.datastruct.DatasetBandImpl; |
|
50 | 48 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
49 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
|
51 | 50 |
import org.gvsig.raster.impl.store.ParamImpl; |
52 | 51 |
|
53 | 52 |
/** |
... | ... | |
168 | 167 |
* @throws IOException |
169 | 168 |
* @throws RasterDriverException |
170 | 169 |
* @throws NotSupportedExtensionException |
170 |
* @throws QueryException |
|
171 | 171 |
*/ |
172 |
public void cachear(String fileName, int pageLines)throws IOException, NotSupportedExtensionException, RasterDriverException, ProcessInterruptedException{ |
|
172 |
public void cachear(String fileName, int pageLines) |
|
173 |
throws IOException, NotSupportedExtensionException, RasterDriverException, ProcessInterruptedException, QueryException { |
|
173 | 174 |
if (id == null) |
174 | 175 |
id = Long.toString(System.currentTimeMillis()); |
175 | 176 |
|
176 |
AbstractRasterProvider grf = AbstractRasterProvider.singleDatasetInstance(null, fileName);
|
|
177 |
AbstractRasterProvider provider = AbstractRasterProvider.singleDatasetInstance(null, fileName);
|
|
177 | 178 |
|
178 |
// Creamos un BandList con todas las bandas del fichero |
|
179 |
BandListImpl bandList = new BandListImpl(); |
|
180 |
for (int i = 0; i < grf.getBandCount(); i++) { |
|
181 |
try { |
|
182 |
DatasetBandImpl band = new DatasetBandImpl(grf.getURIByBand(i), i, grf.getDataType()[i], grf.getBandCount()); |
|
183 |
bandList.addBand(band, i); |
|
184 |
bandList.addDrawableBand(i, i); |
|
185 |
} catch (BandNotFoundInListException ex) { |
|
186 |
// No a?adimos la banda |
|
187 |
} |
|
188 |
} |
|
179 |
int pages = (int) Math.ceil(provider.getHeight() / pageLines); |
|
189 | 180 |
|
190 |
int pages = (int) Math.ceil(grf.getHeight() / pageLines); |
|
191 |
|
|
192 | 181 |
tempDirectoryPath = file.getTemporalPath(); |
193 | 182 |
|
194 |
PageBandBuffer pageBuffer = new PageBandBuffer(grf.getDataType()[0], (int)grf.getWidth(), pageLines, grf.getBandCount(), true, 0); |
|
183 |
//PageBandBuffer pageBuffer = new PageBandBuffer(provider.getDataType()[0], (int)provider.getWidth(), pageLines, provider.getBandCount(), true, 0); |
|
184 |
Buffer pageBuffer = null; |
|
185 |
DefaultRasterStore store = new DefaultRasterStore(); |
|
186 |
store.setProvider(provider); |
|
195 | 187 |
int y = 0; |
196 | 188 |
for (int i = 0; i < pages; i++) { |
197 |
DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery(); |
|
198 |
q.setAreaOfInterest(new Rectangle((int)0, y, pageBuffer.getWidth(), pageBuffer.getHeight())); |
|
199 |
q.setBandList(bandList); |
|
200 |
q.setBufferForProviders(pageBuffer); |
|
201 |
grf.getDataSet(q); |
|
189 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
|
190 |
q.setAreaOfInterest(new Rectangle((int)0, y, (int)provider.getWidth(), pageLines)); |
|
191 |
q.setAllDrawableBands(); |
|
192 |
pageBuffer = store.query(q); |
|
202 | 193 |
|
203 | 194 |
//grf.getWindow(0, y, pageBuffer.getWidth(), pageBuffer.getHeight(), bandList, pageBuffer); |
204 | 195 |
String outFileName = tempDirectoryPath + File.separator + id + "-" + i; |
... | ... | |
288 | 279 |
* @param pageBuffer PageBuffer |
289 | 280 |
* @throws IOException |
290 | 281 |
*/ |
291 |
private void save(DataOutputStream dos, PageBandBuffer pageBuffer) throws IOException {
|
|
282 |
private void save(DataOutputStream dos, Buffer pageBuffer) throws IOException { |
|
292 | 283 |
switch (pageBuffer.getDataType()) { |
293 | 284 |
case Buffer.TYPE_BYTE: |
294 | 285 |
for (int iBand = 0; iBand < pageBuffer.getBandCount(); iBand++) |
Also available in: Unified diff