Revision 162 org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/DefaultMosaicRasterStore.java
DefaultMosaicRasterStore.java | ||
---|---|---|
34 | 34 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
35 | 35 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
36 | 36 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
37 |
import org.gvsig.fmap.dal.coverage.exception.FileNotFoundInListException; |
|
38 | 37 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
39 | 38 |
import org.gvsig.fmap.dal.coverage.exception.HistogramException; |
40 | 39 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
41 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
42 | 40 |
import org.gvsig.fmap.dal.coverage.exception.MosaicNotValidException; |
43 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
44 |
import org.gvsig.fmap.dal.coverage.exception.OperationNotSupportedException; |
|
45 | 41 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
46 | 42 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
47 | 43 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
48 | 44 |
import org.gvsig.fmap.dal.coverage.store.MosaicRasterStore; |
49 |
import org.gvsig.fmap.dal.coverage.store.MultiRasterStore; |
|
50 | 45 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
46 |
import org.gvsig.fmap.dal.coverage.store.RasterStoreParameters; |
|
51 | 47 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
52 | 48 |
import org.gvsig.fmap.dal.coverage.store.props.Histogram; |
53 | 49 |
import org.gvsig.fmap.dal.coverage.store.props.Metadata; |
50 |
import org.gvsig.fmap.dal.coverage.store.props.SerialInfo; |
|
54 | 51 |
import org.gvsig.fmap.dal.coverage.store.props.Statistics; |
55 | 52 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
56 | 53 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
... | ... | |
61 | 58 |
import org.gvsig.raster.impl.datastruct.BandListImpl; |
62 | 59 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
63 | 60 |
import org.gvsig.raster.impl.provider.RasterProvider; |
64 |
import org.gvsig.raster.impl.store.properties.DatasetColorInterpretation; |
|
65 |
import org.gvsig.raster.impl.store.properties.DatasetTransparency; |
|
66 |
import org.gvsig.raster.impl.store.properties.MosaicDatasetHistogram; |
|
67 |
import org.gvsig.raster.impl.store.properties.MosaicDatasetStatistics; |
|
68 |
import org.gvsig.raster.impl.store.properties.MultiDatasetHistogram; |
|
61 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
62 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
|
63 |
import org.gvsig.raster.impl.store.properties.MosaicDataStoreHistogram; |
|
64 |
import org.gvsig.raster.impl.store.properties.MosaicDataStoreStatistics; |
|
69 | 65 |
/** |
70 | 66 |
* Esta clase est? compuestas de multiples datasets formando una rejilla de NxM |
71 | 67 |
* rasters. Un cliente de esta clase debe tener una visi?n de la rejilla como si |
... | ... | |
76 | 72 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
77 | 73 |
*/ |
78 | 74 |
public class DefaultMosaicRasterStore extends AbstractRasterDataStore implements MosaicRasterStore { |
79 |
private MultiRasterStore[][] mosaic = null;
|
|
75 |
private RasterDataStore[][] mosaic = null;
|
|
80 | 76 |
private Statistics stats = null; |
81 | 77 |
private BandListImpl bandList = null; |
82 | 78 |
private boolean readOnly = false; |
... | ... | |
101 | 97 |
* @param n N?mero de filas |
102 | 98 |
* @param m N?mero de columnas |
103 | 99 |
*/ |
104 |
public DefaultMosaicRasterStore(MultiRasterStore[][] mos) throws MosaicNotValidException {
|
|
100 |
public DefaultMosaicRasterStore(RasterDataStore[][] mos) throws MosaicNotValidException {
|
|
105 | 101 |
bandList = new BandListImpl(); |
106 | 102 |
this.mosaic = deleteNullValues(mos); |
107 | 103 |
//this.mosaic = mos; |
... | ... | |
119 | 115 |
* @param values |
120 | 116 |
* @return MultiRasterDataset |
121 | 117 |
*/ |
122 |
private MultiRasterStore[][] deleteNullValues(MultiRasterStore[][] values) {
|
|
118 |
private RasterDataStore[][] deleteNullValues(RasterDataStore[][] values) {
|
|
123 | 119 |
int n = values.length; |
124 | 120 |
int m = values[0].length; |
125 | 121 |
int posInitX = 0; |
... | ... | |
158 | 154 |
nCols --; |
159 | 155 |
} |
160 | 156 |
//Copia de datos |
161 |
MultiRasterStore[][] result = new DefaultMultiRasterStore[nRows][nCols];
|
|
157 |
RasterDataStore[][] result = new DefaultMultiRasterStore[nRows][nCols];
|
|
162 | 158 |
|
163 | 159 |
for (int row = 0; row < result.length; row++) |
164 | 160 |
for (int col = 0; col < result[row].length; col++) |
... | ... | |
265 | 261 |
* (non-Javadoc) |
266 | 262 |
* @see org.gvsig.raster.dataset.IRasterDataSource#addDataset(org.gvsig.raster.dataset.RasterDataset[]) |
267 | 263 |
*/ |
268 |
public void addDataset(RasterDataStore[] f) throws FileNotFoundInListException, OperationNotSupportedException, InvalidSourceException { |
|
264 |
/*public void addDataset(RasterDataStore[] f) throws FileNotFoundInListException, OperationNotSupportedException, InvalidSourceException {
|
|
269 | 265 |
if(mosaic != null) { |
270 | 266 |
int n = mosaic.length; |
271 | 267 |
int m = mosaic[0].length; |
... | ... | |
277 | 273 |
} |
278 | 274 |
init(); |
279 | 275 |
} |
280 |
} |
|
276 |
}*/
|
|
281 | 277 |
|
282 | 278 |
/* |
283 | 279 |
* (non-Javadoc) |
284 | 280 |
* @see org.gvsig.raster.dataset.IRasterDataSource#addDataset(java.lang.String[]) |
285 | 281 |
*/ |
286 |
public void addDataset(String[] fileName) throws FileNotFoundInListException, NotSupportedExtensionException, RasterDriverException, OperationNotSupportedException { |
|
282 |
/*public void addDataset(String[] fileName) throws FileNotFoundInListException, NotSupportedExtensionException, RasterDriverException, OperationNotSupportedException {
|
|
287 | 283 |
if(mosaic != null) { |
288 | 284 |
int n = mosaic.length; |
289 | 285 |
int m = mosaic[0].length; |
... | ... | |
298 | 294 |
} |
299 | 295 |
init(); |
300 | 296 |
} |
301 |
} |
|
297 |
}*/
|
|
302 | 298 |
|
303 | 299 |
/** |
304 | 300 |
* Acciones de inicializaci?n cuando se crea el objeto o se |
305 | 301 |
* a?aden nuevos dataset a este |
306 | 302 |
*/ |
307 | 303 |
private void init() { |
308 |
stats = new MosaicDatasetStatistics(mosaic);
|
|
304 |
stats = new MosaicDataStoreStatistics(mosaic);
|
|
309 | 305 |
|
310 | 306 |
//Creamos la lista de bandas |
311 | 307 |
bandList = (BandListImpl)((BandListImpl)mosaic[0][0].getBands()).clone(); |
... | ... | |
332 | 328 |
for (int i = 0; i < s.length; i++) |
333 | 329 |
for (int j = 0; j < s[i].length; j++) |
334 | 330 |
if(mosaic[i][j] != null) |
335 |
s[i][j] = mosaic[i][j].getDataStore(0).getName();
|
|
331 |
s[i][j] = ((RasterStoreParameters)mosaic[i][j].getParameters()).getFileName();
|
|
336 | 332 |
return s; |
337 | 333 |
} |
338 | 334 |
|
... | ... | |
342 | 338 |
*/ |
343 | 339 |
public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY, double nWidth, double nHeight, int bufWidth, int bufHeight) { |
344 | 340 |
if(mosaic != null) |
345 |
return mosaic[0][0].calcSteps(dWorldTLX, dWorldTLY, dWorldBRX, dWorldBRY, nWidth, nHeight, bufWidth, bufHeight);
|
|
341 |
return ((QueryableRaster)mosaic[0][0]).calcSteps(dWorldTLX, dWorldTLY, dWorldBRX, dWorldBRY, nWidth, nHeight, bufWidth, bufHeight);
|
|
346 | 342 |
return null; |
347 | 343 |
} |
348 | 344 |
|
... | ... | |
371 | 367 |
public RasterDataStore newDataStore() { |
372 | 368 |
int n = mosaic.length; |
373 | 369 |
int m = mosaic[0].length; |
374 |
MultiRasterStore[][] mrd = new DefaultMultiRasterStore[n][m];
|
|
370 |
RasterDataStore[][] mrd = new RasterDataStore[n][m];
|
|
375 | 371 |
for (int row = 0; row < n; row++) |
376 | 372 |
for (int col = 0; col < m; col++) |
377 | 373 |
if(mosaic[row][col] != null) |
378 |
mrd[row][col] = (MultiRasterStore)mosaic[row][col].newDataStore();
|
|
374 |
mrd[row][col] = mosaic[row][col].newDataStore(); |
|
379 | 375 |
|
380 | 376 |
try { |
381 | 377 |
return new DefaultMosaicRasterStore(mrd); |
... | ... | |
547 | 543 |
* @return MultiRasterDataset[][][] |
548 | 544 |
* @throws NoninvertibleTransformException |
549 | 545 |
*/ |
550 |
private MultiRasterStore[][] getDatasetListInArea(double ulx, double uly, double lrx, double lry) throws NoninvertibleTransformException {
|
|
546 |
private QueryableRaster[][] getDatasetListInArea(double ulx, double uly, double lrx, double lry) throws NoninvertibleTransformException {
|
|
551 | 547 |
RasterUtils util = RasterLocator.getManager().getRasterUtils(); |
552 | 548 |
int n = mosaic.length; |
553 | 549 |
int m = mosaic[0].length; |
554 | 550 |
|
555 |
MultiRasterStore[][] result = new DefaultMultiRasterStore[n][m];
|
|
551 |
QueryableRaster[][] result = new QueryableRaster[n][m];
|
|
556 | 552 |
|
557 | 553 |
for (int row = 0; row < n; row++) |
558 | 554 |
for (int col = 0; col < m; col++) |
559 | 555 |
if(mosaic[row][col] != null && |
560 | 556 |
util.intersects(new ExtentImpl(ulx, uly, lrx, lry), mosaic[row][col].getExtent(), mosaic[row][col].getAffineTransform())) |
561 | 557 |
for (int k = 0; k < mosaic.length; k++) |
562 |
result[row][col] = mosaic[row][col]; |
|
558 |
result[row][col] = (QueryableRaster)mosaic[row][col];
|
|
563 | 559 |
return result; |
564 | 560 |
} |
565 | 561 |
|
... | ... | |
618 | 614 |
* (non-Javadoc) |
619 | 615 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getDataset(int) |
620 | 616 |
*/ |
621 |
public RasterDataStore[] getDataset(int i) { |
|
617 |
/*public RasterDataStore[] getDataset(int i) {
|
|
622 | 618 |
RasterDataStore[] d = new RasterDataStore[mosaic.length * mosaic[0].length]; |
623 | 619 |
int count = 0; |
624 | 620 |
for (int row = 0; row < mosaic.length; row++) |
... | ... | |
626 | 622 |
if(mosaic[row][col] != null) |
627 | 623 |
d[count] = mosaic[row][col].getDataStore(i); |
628 | 624 |
return d; |
629 |
} |
|
625 |
}*/
|
|
630 | 626 |
|
631 | 627 |
/* |
632 | 628 |
* (non-Javadoc) |
... | ... | |
733 | 729 |
public Buffer getWindowRaster(double ulx, double uly, double lrx, double lry) |
734 | 730 |
throws InvalidSetViewException, ProcessInterruptedException, RasterDriverException { |
735 | 731 |
try { |
736 |
MultiRasterStore[][] datasetList = getDatasetListInArea(ulx, uly, lrx, lry);
|
|
732 |
QueryableRaster[][] datasetList = getDatasetListInArea(ulx, uly, lrx, lry);
|
|
737 | 733 |
int n = mosaic.length; |
738 | 734 |
int m = mosaic[0].length; |
739 | 735 |
Buffer[][] bufferList = new Buffer[n][m]; |
... | ... | |
772 | 768 |
try { |
773 | 769 |
Point2D p1 = new Point2D.Double(ulx, uly); |
774 | 770 |
Point2D p2 = new Point2D.Double(lrx, lry); |
775 |
MultiRasterStore[][] datasetList = getDatasetListInArea(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
|
771 |
QueryableRaster[][] datasetList = getDatasetListInArea(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
|
776 | 772 |
Point2D px1 = mosaic[0][0].worldToRaster(p1); |
777 | 773 |
Point2D px2 = mosaic[0][0].worldToRaster(p2); |
778 | 774 |
int n = mosaic.length; |
... | ... | |
810 | 806 |
try { |
811 | 807 |
Point2D p1 = mosaic[0][0].rasterToWorld(new Point2D.Double(x, y)); |
812 | 808 |
Point2D p2 = mosaic[0][0].rasterToWorld(new Point2D.Double(x + w, y + h)); |
813 |
MultiRasterStore[][] datasetList = getDatasetListInArea(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
|
809 |
QueryableRaster[][] datasetList = getDatasetListInArea(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
|
814 | 810 |
int n = mosaic.length; |
815 | 811 |
int m = mosaic[0].length; |
816 | 812 |
Buffer[][] bufferList = new Buffer[n][m]; |
... | ... | |
843 | 839 |
try { |
844 | 840 |
Point2D p1 = mosaic[0][0].rasterToWorld(new Point2D.Double(x, y)); |
845 | 841 |
Point2D p2 = mosaic[0][0].rasterToWorld(new Point2D.Double(x + w, y + h)); |
846 |
MultiRasterStore[][] datasetList = getDatasetListInArea(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
|
842 |
QueryableRaster[][] datasetList = getDatasetListInArea(p1.getX(), p1.getY(), p2.getX(), p2.getY());
|
|
847 | 843 |
int n = mosaic.length; |
848 | 844 |
int m = mosaic[0].length; |
849 | 845 |
Buffer[][] bufferList = new Buffer[n][m]; |
... | ... | |
1085 | 1081 |
public Transparency getTransparency() { |
1086 | 1082 |
if(mosaic != null && mosaic[0][0] != null) |
1087 | 1083 |
return mosaic[0][0].getTransparency(); |
1088 |
return new DatasetTransparency();
|
|
1084 |
return new DataStoreTransparency();
|
|
1089 | 1085 |
} |
1090 | 1086 |
|
1091 | 1087 |
/* |
... | ... | |
1103 | 1099 |
* @see org.gvsig.raster.hierarchy.IHistogramable#getHistogram() |
1104 | 1100 |
*/ |
1105 | 1101 |
public Histogram getHistogram() throws HistogramException { |
1106 |
MultiDatasetHistogram[] histogram = new MultiDatasetHistogram[mosaic.length * mosaic[0].length];
|
|
1102 |
Histogram[] histogram = new Histogram[mosaic.length * mosaic[0].length];
|
|
1107 | 1103 |
int cont = 0; |
1108 | 1104 |
for (int i = 0; i < mosaic.length; i++) { |
1109 | 1105 |
for (int j = 0; j < mosaic[0].length; j++) { |
1110 |
histogram[cont] = new MultiDatasetHistogram(mosaic[i][j]);
|
|
1106 |
histogram[cont] = mosaic[i][j].getHistogram();
|
|
1111 | 1107 |
} |
1112 | 1108 |
} |
1113 |
MosaicDatasetHistogram histRes = new MosaicDatasetHistogram(histogram, this);
|
|
1109 |
MosaicDataStoreHistogram histRes = new MosaicDataStoreHistogram(histogram, this);
|
|
1114 | 1110 |
return histRes; |
1115 | 1111 |
} |
1116 | 1112 |
|
... | ... | |
1120 | 1116 |
* @return Paleta asociada a este o null si no tiene |
1121 | 1117 |
*/ |
1122 | 1118 |
public ColorTable getColorTable(int i){ |
1123 |
return (mosaic != null) ? mosaic[0][0].getColorTable(i) : null;
|
|
1119 |
return (mosaic != null) ? ((QueryableRaster)mosaic[0][0]).getColorTable(i) : null;
|
|
1124 | 1120 |
} |
1125 | 1121 |
|
1126 | 1122 |
/** |
... | ... | |
1129 | 1125 |
* @return Paleta o null si no la tiene |
1130 | 1126 |
*/ |
1131 | 1127 |
public ColorTable getColorTable(String fileName){ |
1132 |
return (mosaic != null) ? mosaic[0][0].getColorTable(fileName) : null;
|
|
1128 |
return (mosaic != null) ? ((QueryableRaster)mosaic[0][0]).getColorTable(fileName) : null;
|
|
1133 | 1129 |
} |
1134 | 1130 |
|
1135 | 1131 |
/* |
... | ... | |
1139 | 1135 |
public Object getData(int x, int y, int band) throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
1140 | 1136 |
int[] posTile = getTileFromPixelPoint(x, y); |
1141 | 1137 |
if(posTile != null) { |
1142 |
MultiRasterStore dataset = (MultiRasterStore)mosaic[posTile[0]][posTile[1]].getDataStore(0);
|
|
1138 |
QueryableRaster dataset = (QueryableRaster)mosaic[posTile[0]][posTile[1]];
|
|
1143 | 1139 |
Point2D localPixel = getLocalPixel(x, y); |
1144 | 1140 |
return ((DefaultMultiRasterStore)dataset).getData((int)localPixel.getX(), (int)localPixel.getY(), band); |
1145 | 1141 |
} |
... | ... | |
1355 | 1351 |
* (non-Javadoc) |
1356 | 1352 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getColorInterpretation() |
1357 | 1353 |
*/ |
1358 |
public DatasetColorInterpretation getColorInterpretation() {
|
|
1354 |
public DataStoreColorInterpretation getColorInterpretation() {
|
|
1359 | 1355 |
return null; |
1360 | 1356 |
} |
1361 | 1357 |
|
... | ... | |
1373 | 1369 |
*/ |
1374 | 1370 |
public RasterDataStore getTile(int row, int col) { |
1375 | 1371 |
if(row < mosaic.length && col < mosaic[0].length) |
1376 |
return mosaic[row][col]; |
|
1372 |
return (RasterDataStore)mosaic[row][col];
|
|
1377 | 1373 |
return null; |
1378 | 1374 |
} |
1379 | 1375 |
|
... | ... | |
1382 | 1378 |
* @see org.gvsig.fmap.dal.coverage.store.MosaicRasterStore#getTile(int) |
1383 | 1379 |
*/ |
1384 | 1380 |
public RasterDataStore getTile(int i) { |
1385 |
return mosaic[i / mosaic.length][i % mosaic.length]; |
|
1381 |
return (RasterDataStore)mosaic[i / mosaic.length][i % mosaic.length];
|
|
1386 | 1382 |
} |
1387 | 1383 |
|
1388 | 1384 |
/* |
... | ... | |
1481 | 1477 |
int n = mosaic.length; |
1482 | 1478 |
int m = mosaic[0].length; |
1483 | 1479 |
|
1484 |
MultiRasterStore[][] mos = new MultiRasterStore[n][m];
|
|
1480 |
RasterDataStore[][] mos = new RasterDataStore[n][m];
|
|
1485 | 1481 |
for (int row = 0; row < n; row++) { |
1486 | 1482 |
for (int col = 0; col < m; col++) { |
1487 |
mos[row][col] = (MultiRasterStore)mosaic[row][col].cloneDataStore();
|
|
1483 |
mos[row][col] = mosaic[row][col].cloneDataStore(); |
|
1488 | 1484 |
} |
1489 | 1485 |
} |
1490 | 1486 |
DefaultMosaicRasterStore result = null; |
... | ... | |
1509 | 1505 |
} |
1510 | 1506 |
return null; |
1511 | 1507 |
} |
1508 |
|
|
1509 |
/* |
|
1510 |
* (non-Javadoc) |
|
1511 |
* @see org.gvsig.fmap.dal.coverage.store.RasterDataStore#saveSerialInfoToRmf(org.gvsig.fmap.dal.coverage.store.props.SerialInfo) |
|
1512 |
*/ |
|
1513 |
public void saveSerialInfoToRmf(SerialInfo serialInfo) throws RmfSerializerException { |
|
1514 |
int n = mosaic.length; |
|
1515 |
int m = mosaic[0].length; |
|
1516 |
for (int row = 0; row < n; row++) { |
|
1517 |
for (int col = 0; col < m; col++) { |
|
1518 |
((AbstractRasterDataStore)mosaic[row][col]).saveSerialInfoToRmf(serialInfo); |
|
1519 |
} |
|
1520 |
} |
|
1521 |
} |
|
1522 |
|
|
1523 |
/* |
|
1524 |
* (non-Javadoc) |
|
1525 |
* @see org.gvsig.fmap.dal.coverage.store.RasterDataStore#loadSerialInfoFromRmf(org.gvsig.fmap.dal.coverage.store.props.SerialInfo) |
|
1526 |
*/ |
|
1527 |
public boolean loadSerialInfoFromRmf(SerialInfo serialInfo) { |
|
1528 |
int n = mosaic.length; |
|
1529 |
int m = mosaic[0].length; |
|
1530 |
for (int row = 0; row < n; row++) { |
|
1531 |
for (int col = 0; col < m; col++) { |
|
1532 |
if(((AbstractRasterDataStore)mosaic[row][col]).loadSerialInfoFromRmf(serialInfo)) |
|
1533 |
return true; |
|
1534 |
} |
|
1535 |
} |
|
1536 |
return false; |
|
1537 |
} |
|
1512 | 1538 |
|
1513 | 1539 |
public void removeDataset(String fileName) {} |
1514 | 1540 |
public void removeDataset(RasterDataStore file) {} |
Also available in: Unified diff