Revision 2303
org.gvsig.raster.multifile/branches/org.gvsig.raster.multifile_dataaccess_refactoring/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/BandSelectorPropertiesListener.java | ||
---|---|---|
307 | 307 |
bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.GREEN_BAND), |
308 | 308 |
bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.BLUE_BAND)}); |
309 | 309 |
int alphaBand = bandSetupPanel.getColorInterpretationByColorBandBand(RasterDataStore.ALPHA_BAND); |
310 |
// Ultima transparencia aplicada en el renderizador |
|
311 | 310 |
Transparency gt = fLayer.getRender().getLastTransparency(); |
312 | 311 |
if(gt != null) |
313 | 312 |
gt.setTransparencyBand(alphaBand); |
314 |
|
|
315 |
// Transparencia del dataset |
|
316 |
/*if(fLayer.getDataStore() != null) { |
|
317 |
Transparency t = fLayer.getDataStore().getTransparency(); |
|
318 |
if(t != null) |
|
319 |
t.setTransparencyBand(alphaBand); |
|
320 |
}*/ |
|
321 | 313 |
fLayer.getMapContext().invalidate(); |
322 | 314 |
} |
323 | 315 |
} |
org.gvsig.raster.tools/branches/org.gvsig.raster.tools_dataaccess_refactoring/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/properties/panel/InfoPanel.java | ||
---|---|---|
315 | 315 |
|
316 | 316 |
String cabecera = setHTMLTitleTable(cabCoord, 2); |
317 | 317 |
|
318 |
double pixelSizeX = lyr.getDataStore().getAffineTransform().getScaleX(); |
|
319 |
double pixelSizeY = lyr.getDataStore().getAffineTransform().getScaleY(); |
|
320 |
|
|
318 | 321 |
Extent ext = lyr.getFullRasterExtent(); |
319 | 322 |
propiedades += setHTMLBasicProperty(Messages.getText("ul"), ext.getULX() + ", " + ext.getULY()); |
320 | 323 |
propiedades += setHTMLBasicProperty(Messages.getText("lr"), ext.getLRX() + ", " + ext.getLRY()); |
321 | 324 |
propiedades += setHTMLBasicProperty(Messages.getText("ur"), ext.getURX() + ", " + ext.getURY()); |
322 | 325 |
propiedades += setHTMLBasicProperty(Messages.getText("ll"), ext.getLLX() + ", " + ext.getLLY()); |
323 | 326 |
|
324 |
double pixelSizeX = lyr.getDataStore().getAffineTransform().getScaleX(); |
|
325 |
double pixelSizeY = lyr.getDataStore().getAffineTransform().getScaleY(); |
|
326 | 327 |
double rotX = lyr.getDataStore().getAffineTransform().getShearX(); |
327 | 328 |
double rotY = lyr.getDataStore().getAffineTransform().getShearY(); |
328 | 329 |
|
... | ... | |
333 | 334 |
|
334 | 335 |
return "<br>" + setHTMLTable(cabecera + propiedades); |
335 | 336 |
} |
336 |
|
|
337 |
|
|
337 | 338 |
/** |
338 | 339 |
* M?todo que crea la tabla de origen de datos dentro del panel |
339 | 340 |
* de Informaci?n. |
org.gvsig.raster.tools/branches/org.gvsig.raster.tools_dataaccess_refactoring/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/properties/control/TransparencyListener.java | ||
---|---|---|
169 | 169 |
restoreStatus(); |
170 | 170 |
} |
171 | 171 |
|
172 |
/* |
|
173 |
* (non-Javadoc) |
|
174 |
* @see org.gvsig.rastertools.properties.panels.TranspByPixelEventListener#actionPixelListChanged(java.util.EventObject) |
|
175 |
*/ |
|
176 | 172 |
public void actionPixelListChanged(EventObject e) { |
177 | 173 |
if (!RasterExtension.autoRefreshView) |
178 | 174 |
return; |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.api/src/main/java/org/gvsig/fmap/dal/coverage/store/props/Transparency.java | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.fmap.dal.coverage.store.props; |
23 | 23 |
|
24 |
import java.util.ArrayList;
|
|
24 |
import java.util.List; |
|
25 | 25 |
|
26 | 26 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
27 | 27 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
... | ... | |
120 | 120 |
* Obtiene los rangos de pixels que son transparentes en el raster. |
121 | 121 |
* @return Rangos de transparencias a aplicar |
122 | 122 |
*/ |
123 |
public ArrayList<TransparencyRange> getTransparencyRange();
|
|
123 |
public List<TransparencyRange> getTransparencyRange(); |
|
124 | 124 |
|
125 | 125 |
/** |
126 | 126 |
* Asigna la lista de rangos de transparencia |
127 | 127 |
* @param ranges |
128 | 128 |
*/ |
129 |
public void setTransparencyRangeList(ArrayList<TransparencyRange> ranges);
|
|
129 |
public void setTransparencyRangeList(List<TransparencyRange> ranges); |
|
130 | 130 |
|
131 | 131 |
/** |
132 | 132 |
* Obtiene el valor noData |
org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.api/src/main/java/org/gvsig/fmap/dal/coverage/store/RasterQuery.java | ||
---|---|---|
248 | 248 |
* @return |
249 | 249 |
*/ |
250 | 250 |
public void setBufferForProviders(Buffer buffer) throws QueryException; |
251 |
|
|
251 |
|
|
252 | 252 |
/** |
253 | 253 |
* Clones this RasterQuery |
254 | 254 |
* @return |
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/grid/render/DefaultRender.java | ||
---|---|---|
322 | 322 |
} |
323 | 323 |
|
324 | 324 |
if (dataStore != null) { |
325 |
//TODO:Eliminado pq parece que machaca lo que ha puesto BandSelectorPropertiesListener y no hace caso al selector de bandas. |
|
325 | 326 |
if(getLastTransparency().getAlphaBandNumber() == -1) |
326 | 327 |
getLastTransparency().setTransparencyBand(dataStore.getTransparency().getAlphaBandNumber()); |
327 | 328 |
|
... | ... | |
333 | 334 |
query.setTime(vp.getTime()); |
334 | 335 |
query.setSupersamplingOption(false); // Desactivamos el supersampleo en la carga del buffer. |
335 | 336 |
query.setDrawableBands(getRenderBands()); |
336 |
query.setAlphaBand(getLastTransparency().getAlphaBandNumber());
|
|
337 |
query.setAlphaBand(lastAlphaBand);
|
|
337 | 338 |
query.setAreaOfInterest(vp.getExtent(), |
338 | 339 |
(int)Math.round(vp.getWidth()), |
339 | 340 |
(int)Math.round(vp.getHeight()), this); |
... | ... | |
517 | 518 |
} |
518 | 519 |
|
519 | 520 |
if(tiling == null || tiling.booleanValue()) { |
520 |
lastTransparency.setAlphaBand(transparencyBuffer); |
|
521 |
Grid grid = null; |
|
522 |
try { |
|
523 |
grid = bufferPreprocessing(buf, lastTransparency); |
|
524 |
} catch (ProcessInterruptedException e3) { |
|
525 |
return; |
|
526 |
} |
|
527 |
buf = grid.getRasterBuf(); |
|
521 |
//if(lastTransparency.getAlphaBandNumber() != -1) { |
|
522 |
lastTransparency.setAlphaBand(transparencyBuffer); |
|
523 |
Grid grid = null; |
|
524 |
try { |
|
525 |
grid = bufferPreprocessing(buf, lastTransparency); |
|
526 |
} catch (ProcessInterruptedException e3) { |
|
527 |
return; |
|
528 |
} |
|
529 |
buf = grid.getRasterBuf(); |
|
530 |
//} |
|
528 | 531 |
} |
529 | 532 |
|
530 | 533 |
if(tiling == null || tiling.booleanValue()) { |
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/DefaultRasterQuery.java | ||
---|---|---|
103 | 103 |
|
104 | 104 |
private TileListener listener = null; |
105 | 105 |
private int alphaBandNumber = -1; |
106 |
private boolean dontBuildBuffer = false; |
|
106 | 107 |
private CacheStruct cacheStruct = null; |
107 | 108 |
private TaskStatus taskStatus = null; |
108 | 109 |
|
... | ... | |
319 | 320 |
|
320 | 321 |
//Bands and buffers |
321 | 322 |
buildDrawableBandList(store.getBands()); |
322 |
createBuffer(store); |
|
323 |
if(!dontBuildBuffer) |
|
324 |
createBuffer(store); |
|
323 | 325 |
} |
324 | 326 |
|
325 | 327 |
/** |
... | ... | |
615 | 617 |
//**************Getters and Setters******************* |
616 | 618 |
//**************************************************** |
617 | 619 |
|
620 |
public void dontBuildBuffer() { |
|
621 |
this.dontBuildBuffer = true; |
|
622 |
} |
|
623 |
|
|
618 | 624 |
public int getType() { |
619 | 625 |
return type; |
620 | 626 |
} |
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/SpiRasterQuery.java | ||
---|---|---|
109 | 109 |
|
110 | 110 |
public boolean requestIsTiled(); |
111 | 111 |
|
112 |
/** |
|
113 |
* The buffer won't be built internally when all parameters will be calculated. |
|
114 |
* Uses this call carefully. The provider must know that <code>getBufferForProviders</code> |
|
115 |
* will return null. |
|
116 |
*/ |
|
117 |
public void dontBuildBuffer(); |
|
118 |
|
|
112 | 119 |
public RasterQuery clone(); |
113 | 120 |
} |
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/fusion/FirstFusionMethod.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
9 | 9 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
10 |
import org.gvsig.raster.impl.provider.fusion.BufferListFusion.PixelSquareStructure; |
|
11 | 10 |
|
12 | 11 |
public class FirstFusionMethod extends AbstractFusionMethod { |
13 |
protected SubSquareList subSquareList = null; |
|
14 |
protected byte[] dataByte = null; |
|
15 |
protected short[] dataShort = null; |
|
16 |
protected int[] dataInt = null; |
|
17 |
protected float[] dataFloat = null; |
|
18 |
protected double[] dataDouble = null; |
|
12 |
protected SubSquareList subSquareList = null; |
|
13 |
private int bandCount = 0; |
|
19 | 14 |
|
15 |
private int[] lastPixelCoords = new int[]{-1, -1}; |
|
16 |
private byte[] dataByte = null; |
|
17 |
private short[] dataShort = null; |
|
18 |
private int[] dataInt = null; |
|
19 |
private float[] dataFloat = null; |
|
20 |
private double[] dataDouble = null; |
|
21 |
|
|
20 | 22 |
public class SubSquareList extends ArrayList<SubSquare> { |
21 | 23 |
private static final long serialVersionUID = 1L; |
24 |
private int bandCount = 0; |
|
22 | 25 |
|
23 |
public void getByteValue(int row, int col, byte[] data) { |
|
26 |
public SubSquareList(int bandCount) { |
|
27 |
this.bandCount = bandCount; |
|
28 |
} |
|
29 |
|
|
30 |
public byte[] getByteValue(int row, int col) { |
|
31 |
byte[] value = new byte[bandCount]; |
|
24 | 32 |
for (int i = 0; i < size(); i++) { |
25 | 33 |
Point2D coord = get(i).getLocalCoords(row, col); |
26 | 34 |
if(coord != null) { |
27 |
get(i).getBuffer().getElemByte((int)coord.getY(), (int)coord.getX(), data);
|
|
28 |
return; |
|
35 |
get(i).getBuffer().getElemByte((int)coord.getY(), (int)coord.getX(), value);
|
|
36 |
return value;
|
|
29 | 37 |
} |
30 | 38 |
} |
39 |
return null; |
|
31 | 40 |
} |
32 | 41 |
|
33 |
public void getFloatValue(int row, int col, float[] data) { |
|
42 |
public float[] getFloatValue(int row, int col) { |
|
43 |
float[] value = new float[bandCount]; |
|
34 | 44 |
for (int i = 0; i < size(); i++) { |
35 | 45 |
Point2D coord = get(i).getLocalCoords(row, col); |
36 | 46 |
if(coord != null) { |
37 |
get(i).getBuffer().getElemFloat((int)coord.getY(), (int)coord.getX(), data);
|
|
38 |
return; |
|
47 |
get(i).getBuffer().getElemFloat((int)coord.getY(), (int)coord.getX(), value);
|
|
48 |
return value;
|
|
39 | 49 |
} |
40 | 50 |
} |
51 |
return null; |
|
41 | 52 |
} |
42 | 53 |
} |
43 | 54 |
|
... | ... | |
63 | 74 |
break; |
64 | 75 |
} |
65 | 76 |
|
66 |
subSquareList = new SubSquareList(); |
|
67 | 77 |
for (int i = 0; i < bufferList.size(); i++) { |
78 |
bandCount = bufferList.get(i).getBandCount() > bandCount ? bufferList.get(i).getBandCount() : bandCount; |
|
79 |
} |
|
80 |
|
|
81 |
subSquareList = new SubSquareList(bandCount); |
|
82 |
for (int i = 0; i < bufferList.size(); i++) { |
|
68 | 83 |
SubSquare square = new SubSquare( |
69 | 84 |
pxSquare.bbox, |
70 | 85 |
new Rectangle2D.Double(0, 0, pxSquare.width, pxSquare.height), |
... | ... | |
75 | 90 |
} |
76 | 91 |
} |
77 | 92 |
|
78 |
public byte[] getByteValue(int row, int col) { |
|
79 |
for (int i = 0; i < dataByte.length; i++) { |
|
80 |
dataByte[i] = pxSquare.nodata.getValue().byteValue(); |
|
93 |
public Byte getByteValue(int row, int col, int band) { |
|
94 |
if(row != lastPixelCoords[0] || col != lastPixelCoords[1]) { |
|
95 |
//Lee todas las bandas de una y devuelve la que corresponda al par?metro band |
|
96 |
dataByte = subSquareList.getByteValue(row, col); |
|
97 |
lastPixelCoords[0] = row; |
|
98 |
lastPixelCoords[1] = col; |
|
81 | 99 |
} |
82 |
subSquareList.getByteValue(row, col, dataByte); |
|
83 |
return dataByte; |
|
100 |
if(dataByte != null) |
|
101 |
return dataByte[band]; |
|
102 |
return null; |
|
84 | 103 |
} |
85 | 104 |
|
86 |
public float[] getFloatValue(int row, int col) { |
|
87 |
for (int i = 0; i < dataFloat.length; i++) { |
|
88 |
dataFloat[i] = pxSquare.nodata.getValue().byteValue(); |
|
105 |
public Float getFloatValue(int row, int col, int band) { |
|
106 |
if(row == lastPixelCoords[0] && col == lastPixelCoords[1]) { |
|
107 |
dataFloat = subSquareList.getFloatValue(row, col); |
|
108 |
lastPixelCoords[0] = row; |
|
109 |
lastPixelCoords[1] = col; |
|
89 | 110 |
} |
90 |
subSquareList.getFloatValue(row, col, dataFloat); |
|
91 |
return dataFloat; |
|
111 |
if(dataFloat != null) |
|
112 |
return dataFloat[band]; |
|
113 |
return null; |
|
92 | 114 |
} |
115 |
|
|
116 |
public int getBandCount() { |
|
117 |
return bandCount; |
|
118 |
} |
|
93 | 119 |
|
94 | 120 |
} |
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/fusion/PixelSquareStructure.java | ||
---|---|---|
1 |
package org.gvsig.raster.impl.provider.fusion; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
4 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
5 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
6 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
7 |
|
|
8 |
/** |
|
9 |
* Structure which represents a bitmap |
|
10 |
* |
|
11 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
12 |
*/ |
|
13 |
public class PixelSquareStructure { |
|
14 |
public double pixelSize = 0; |
|
15 |
public int dataType = Buffer.TYPE_UNDEFINED; |
|
16 |
public int bandCount = 0; |
|
17 |
public int width = 0; |
|
18 |
public int height = 0; |
|
19 |
public Extent bbox = null; |
|
20 |
public NoData nodata = null; |
|
21 |
public Buffer buffer = null; |
|
22 |
|
|
23 |
public PixelSquareStructure( |
|
24 |
Buffer buf, |
|
25 |
Extent bbox, |
|
26 |
double pixelSize) { |
|
27 |
this.pixelSize = pixelSize; |
|
28 |
this.dataType = buf.getDataType(); |
|
29 |
this.bandCount = buf.getBandCount(); |
|
30 |
this.width = buf.getWidth(); |
|
31 |
this.height = buf.getHeight(); |
|
32 |
nodata = buf.getNoDataValue() != null ? |
|
33 |
buf.getNoDataValue() : |
|
34 |
RasterLocator.getManager().getDataStructFactory().createDefaultNoData(bandCount, dataType); |
|
35 |
this.bbox = bbox; |
|
36 |
this.buffer = buf; |
|
37 |
} |
|
38 |
|
|
39 |
public PixelSquareStructure( |
|
40 |
double pixelSize, |
|
41 |
int bandCount, |
|
42 |
int datatype) { |
|
43 |
this.pixelSize = pixelSize; |
|
44 |
this.dataType = datatype; |
|
45 |
this.bandCount = bandCount; |
|
46 |
this.width = (int)Math.ceil(bbox.width() * pixelSize); |
|
47 |
this.height = (int)Math.ceil(bbox.height() * pixelSize); |
|
48 |
nodata = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(bandCount, datatype); |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
0 | 52 |
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/fusion/AbstractFusionMethod.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
9 | 9 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
10 |
import org.gvsig.raster.impl.provider.fusion.BufferListFusion.PixelSquareStructure; |
|
11 | 10 |
|
12 | 11 |
public abstract class AbstractFusionMethod { |
13 | 12 |
protected PixelSquareStructure pxSquare = null; |
... | ... | |
76 | 75 |
this.pxSquare = pxSquare; |
77 | 76 |
} |
78 | 77 |
|
79 |
public abstract byte[] getByteValue(int row, int col);
|
|
78 |
public abstract Byte getByteValue(int row, int col, int band);
|
|
80 | 79 |
|
81 |
public abstract float[] getFloatValue(int row, int col); |
|
80 |
public abstract Float getFloatValue(int row, int col, int band); |
|
81 |
|
|
82 |
public abstract int getBandCount(); |
|
82 | 83 |
|
83 | 84 |
} |
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/fusion/BufferListFusion.java | ||
---|---|---|
3 | 3 |
import java.awt.geom.Rectangle2D; |
4 | 4 |
import java.util.List; |
5 | 5 |
|
6 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
7 | 6 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
8 | 7 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
9 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
10 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
11 | 8 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
12 | 9 |
|
13 | 10 |
/** |
... | ... | |
33 | 30 |
private List<Extent> bboxList = null; |
34 | 31 |
private PixelSquareStructure pxSquare = null; |
35 | 32 |
private AbstractFusionMethod fusion = null; |
33 |
private int alphaBandNumber = -1; |
|
36 | 34 |
|
37 |
public class PixelSquareStructure { |
|
38 |
public double pixelSize = 0; |
|
39 |
public int dataType = Buffer.TYPE_UNDEFINED; |
|
40 |
public int bandCount = 0; |
|
41 |
public int width = 0; |
|
42 |
public int height = 0; |
|
43 |
public Extent bbox = null; |
|
44 |
public NoData nodata = null; |
|
45 |
public Buffer buffer = null; |
|
46 |
|
|
47 |
public PixelSquareStructure( |
|
48 |
Buffer buf, |
|
49 |
Extent bbox, |
|
50 |
double pixelSize) { |
|
51 |
this.pixelSize = pixelSize; |
|
52 |
this.dataType = buf.getDataType(); |
|
53 |
this.bandCount = buf.getBandCount(); |
|
54 |
this.width = buf.getWidth(); |
|
55 |
this.height = buf.getHeight(); |
|
56 |
nodata = buf.getNoDataValue() != null ? |
|
57 |
buf.getNoDataValue() : |
|
58 |
RasterLocator.getManager().getDataStructFactory().createDefaultNoData(bandCount, dataType); |
|
59 |
this.bbox = bbox; |
|
60 |
this.buffer = buf; |
|
61 |
} |
|
62 |
|
|
63 |
public PixelSquareStructure( |
|
64 |
double pixelSize, |
|
65 |
int bandCount, |
|
66 |
int datatype) { |
|
67 |
this.pixelSize = pixelSize; |
|
68 |
this.dataType = datatype; |
|
69 |
this.bandCount = bandCount; |
|
70 |
this.width = (int)Math.ceil(bbox.width() * pixelSize); |
|
71 |
this.height = (int)Math.ceil(bbox.height() * pixelSize); |
|
72 |
nodata = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(bandCount, datatype); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
public static PixelSquareStructure buildPixelSquareStructure( |
|
77 |
Buffer buf, |
|
78 |
Extent bbox, |
|
79 |
double pixelSize) { |
|
80 |
return new BufferListFusion().new PixelSquareStructure(buf, bbox, pixelSize); |
|
81 |
} |
|
82 |
|
|
83 |
public static PixelSquareStructure buildPixelSquareStructure( |
|
84 |
double pixelSize, |
|
85 |
int bandCount, |
|
86 |
int datatype) { |
|
87 |
return new BufferListFusion().new PixelSquareStructure(pixelSize, bandCount, datatype); |
|
88 |
} |
|
89 |
|
|
90 |
public BufferListFusion() {} |
|
91 |
|
|
92 | 35 |
public BufferListFusion( |
93 | 36 |
List<Buffer> bufferList, |
94 | 37 |
PixelSquareStructure pxSquare, |
... | ... | |
112 | 55 |
* @return |
113 | 56 |
*/ |
114 | 57 |
public Buffer getWindow() { |
115 |
if(pxSquare.buffer == null) { |
|
116 |
pxSquare.buffer = DefaultRasterManager.getInstance().createBuffer( |
|
117 |
pxSquare.dataType, pxSquare.width, pxSquare.height, pxSquare.bandCount, true); |
|
118 |
} |
|
119 |
|
|
120 | 58 |
if(pxSquare.dataType == Buffer.TYPE_BYTE) { |
121 | 59 |
for (int row = 0; row < pxSquare.buffer.getHeight(); row++) { |
122 | 60 |
for (int col = 0; col < pxSquare.buffer.getWidth(); col++) { |
123 |
pxSquare.buffer.setElemByte(row, col, fusion.getByteValue(row, col)); |
|
61 |
boolean hasData = false; |
|
62 |
|
|
63 |
for (int band = 0; band < fusion.getBandCount(); band++) { |
|
64 |
Byte value = fusion.getByteValue(row, col, band); |
|
65 |
if(value != null) { |
|
66 |
pxSquare.buffer.setElem(row, col, band, value.byteValue()); |
|
67 |
hasData = true; |
|
68 |
value = null; |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
for (int band = fusion.getBandCount(); band < pxSquare.buffer.getBandCount(); band++) { |
|
73 |
pxSquare.buffer.setElem(row, col, band, (byte)255); |
|
74 |
} |
|
75 |
|
|
76 |
if(alphaBandNumber != -1 && alphaBandNumber < pxSquare.buffer.getBandCount()) |
|
77 |
if(hasData) //No data has been written |
|
78 |
pxSquare.buffer.setElem(row, col, alphaBandNumber, (byte)255); |
|
79 |
else |
|
80 |
pxSquare.buffer.setElem(row, col, alphaBandNumber, (byte)0); |
|
124 | 81 |
} |
125 | 82 |
} |
126 | 83 |
} |
... | ... | |
128 | 85 |
if(pxSquare.dataType == Buffer.TYPE_FLOAT) { |
129 | 86 |
for (int row = 0; row < pxSquare.buffer.getHeight(); row++) { |
130 | 87 |
for (int col = 0; col < pxSquare.buffer.getWidth(); col++) { |
131 |
pxSquare.buffer.setElemFloat(row, col, fusion.getFloatValue(row, col)); |
|
88 |
for (int band = 0; band < fusion.getBandCount(); band++) { |
|
89 |
pxSquare.buffer.setElem(row, col, band, fusion.getFloatValue(row, col, band)); |
|
90 |
} |
|
91 |
for (int band = fusion.getBandCount(); band < pxSquare.buffer.getBandCount(); band++) { |
|
92 |
pxSquare.buffer.setElem(row, col, band, 0F); |
|
93 |
} |
|
132 | 94 |
} |
133 | 95 |
} |
134 | 96 |
} |
... | ... | |
235 | 197 |
} |
236 | 198 |
bufferList.clear(); |
237 | 199 |
} |
200 |
|
|
201 |
public void setAlphaBand(int alphaBandNumber) { |
|
202 |
this.alphaBandNumber = alphaBandNumber; |
|
203 |
} |
|
238 | 204 |
|
239 | 205 |
/*public void setNoDataValue(int datatype) { |
240 | 206 |
NoData noData = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(bandCount, datatype); |
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/FileTileServer.java | ||
---|---|---|
38 | 38 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
39 | 39 |
*/ |
40 | 40 |
public class FileTileServer implements TileServer { |
41 |
private CacheStruct struct = null;
|
|
42 |
private Downloader downloader = null;
|
|
43 |
private RasterDataStore store = null;
|
|
44 |
private String suffix = "tif";
|
|
45 |
private boolean externalStruct = false;
|
|
41 |
protected CacheStruct struct = null;
|
|
42 |
protected Downloader downloader = null;
|
|
43 |
protected RasterDataStore store = null;
|
|
44 |
protected String suffix = "tif";
|
|
45 |
protected boolean externalStruct = false;
|
|
46 | 46 |
|
47 | 47 |
public FileTileServer(RasterDataStore store) { |
48 | 48 |
this.store = store; |
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/TileDownloaderForFiles.java | ||
---|---|---|
44 | 44 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
45 | 45 |
*/ |
46 | 46 |
public class TileDownloaderForFiles extends BaseTileDownloader { |
47 |
private CacheStruct struct = null;
|
|
48 |
private String extension = null;
|
|
47 |
protected CacheStruct struct = null;
|
|
48 |
protected String extension = null;
|
|
49 | 49 |
|
50 | 50 |
public TileDownloaderForFiles(RasterDataStore store, |
51 | 51 |
CacheStruct struct, |
... | ... | |
81 | 81 |
alphaBand = true; |
82 | 82 |
|
83 | 83 |
//Si no hay parte del tile que cae fuera de la imagen no se usa una nueva banda de transparencia ni valores nodata |
84 |
if(newBufHeight == this.tilePxHeight && newBufWidth == this.tilePxWidth) {
|
|
85 |
bufResult = readSupersampledBuffer(tileExtent, this.tilePxWidth, this.tilePxHeight, nBandsBuffer);
|
|
84 |
if(isInternalTile(newBufWidth, newBufHeight)) {
|
|
85 |
bufResult = readSupersampledBuffer(tileExtent, this.tilePxWidth, this.tilePxHeight, false);
|
|
86 | 86 |
if(bufResult == null) { |
87 | 87 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
88 | 88 |
q.setAreaOfInterest(tileExtent, this.tilePxWidth, this.tilePxHeight); |
... | ... | |
99 | 99 |
nBandsBuffer ++; |
100 | 100 |
} |
101 | 101 |
|
102 |
Buffer smallBuf = readSupersampledBuffer(ex, newBufWidth, newBufHeight, nBandsBuffer);
|
|
102 |
Buffer smallBuf = readSupersampledBuffer(ex, newBufWidth, newBufHeight, alphaBand);
|
|
103 | 103 |
|
104 | 104 |
if(smallBuf == null) { //No ha habido resampleo |
105 | 105 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
106 | 106 |
q.setAreaOfInterest(ex, newBufWidth, newBufHeight); |
107 | 107 |
q.setAllDrawableBands(); |
108 | 108 |
q.setAdjustToExtent(true); |
109 |
if(alphaBand) |
|
110 |
q.setAlphaBand(store.getBandCount() - 1); |
|
109 | 111 |
smallBuf = store.query(q); |
110 | 112 |
} |
111 | 113 |
|
... | ... | |
139 | 141 |
return tile; |
140 | 142 |
} |
141 | 143 |
|
144 |
public boolean isInternalTile(int bufWidth, int bufHeight) { |
|
145 |
return (bufHeight == this.tilePxHeight && bufWidth == this.tilePxWidth); |
|
146 |
} |
|
147 |
|
|
142 | 148 |
/** |
143 | 149 |
* When the buffer of the request is greater than the original raster (> scale 1:1) then the request |
144 | 150 |
* has to be resampled. |
... | ... | |
151 | 157 |
* @throws ProcessInterruptedException |
152 | 158 |
* @throws TileGettingException |
153 | 159 |
*/ |
154 |
private Buffer readSupersampledBuffer(Extent tileExtent, int bufWidth, int bufHeight, int nBands) throws ProcessInterruptedException, TileGettingException {
|
|
160 |
protected Buffer readSupersampledBuffer(Extent tileExtent, int bufWidth, int bufHeight, boolean hasAlphaBand) throws ProcessInterruptedException, TileGettingException {
|
|
155 | 161 |
int widthImgPx = (int)Math.abs(tileExtent.width() / store.getPixelSizeX()); |
156 | 162 |
int heightImgPx = (int)Math.abs(tileExtent.height() / store.getPixelSizeY()); |
157 | 163 |
boolean supersampling = ((bufWidth > widthImgPx) || (bufHeight > heightImgPx)) ? true : false; |
... | ... | |
161 | 167 |
q.setAreaOfInterest(tileExtent, widthImgPx, heightImgPx); |
162 | 168 |
q.setAllDrawableBands(); |
163 | 169 |
q.setAdjustToExtent(true); |
170 |
if(hasAlphaBand) |
|
171 |
q.setAlphaBand(store.getBandCount() - 1); |
|
164 | 172 |
Buffer buf = null; |
165 | 173 |
try { |
166 | 174 |
buf = store.query(q); |
... | ... | |
180 | 188 |
* @param nbands |
181 | 189 |
* @return |
182 | 190 |
*/ |
183 |
private Buffer buildTileBuffer(int nbands, int w, int h) {
|
|
191 |
protected Buffer buildTileBuffer(int nbands, int w, int h) {
|
|
184 | 192 |
Buffer bufResult = DefaultRasterManager.getInstance().createMemoryBuffer(store.getDataType()[0], w, h, nbands, true); |
185 | 193 |
if(store.getDataType()[0] != Buffer.TYPE_BYTE) { |
186 | 194 |
for (int i = 0; i < bufResult.getBandCount(); i++) { |
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/store/properties/DataStoreTransparency.java | ||
---|---|---|
98 | 98 |
/** |
99 | 99 |
* Rangos de transparencia aplicados. Lista de TransparencyRange |
100 | 100 |
*/ |
101 |
protected ArrayList<TransparencyRange>
|
|
101 |
protected List<TransparencyRange> |
|
102 | 102 |
transparencyRanges = new ArrayList<TransparencyRange>(); |
103 | 103 |
/** |
104 | 104 |
* Grado de opacidad de todo el raster |
... | ... | |
108 | 108 |
/** |
109 | 109 |
* Array de listeners que ser?n informados cuando cambia la propiedad de transparencia |
110 | 110 |
*/ |
111 |
private ArrayList<PropertyListener>
|
|
111 |
private List<PropertyListener> |
|
112 | 112 |
transparencyPropertyListener = new ArrayList<PropertyListener>(); |
113 | 113 |
/** |
114 | 114 |
* Flag de activaci?n de la transparencia cuando se visualiza o exporta. |
... | ... | |
133 | 133 |
return; |
134 | 134 |
|
135 | 135 |
//TODO: FUNCIONALIDAD: Falta asignar lo necesario para la transparencia por selecci?n |
136 |
this.transparencyRanges = (ArrayList<TransparencyRange>) t.getTransparencyRange().clone();
|
|
136 |
this.transparencyRanges = (List<TransparencyRange>) ((ArrayList<TransparencyRange>)t.getTransparencyRange()).clone();
|
|
137 | 137 |
if(this.mask != null) |
138 | 138 |
this.mask = t.getAlphaBand(); |
139 | 139 |
this.opacity = t.getOpacity(); |
... | ... | |
170 | 170 |
return mask; |
171 | 171 |
} |
172 | 172 |
|
173 |
/* |
|
174 |
* (non-Javadoc) |
|
175 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#setAlphaBand(org.gvsig.fmap.dal.coverage.dataset.Buffer) |
|
176 |
*/ |
|
177 | 173 |
public void setAlphaBand(Buffer b) { |
178 | 174 |
if(b == null && mask != null) { |
179 | 175 |
mask = b; |
... | ... | |
186 | 182 |
} |
187 | 183 |
} |
188 | 184 |
|
189 |
/* |
|
190 |
* (non-Javadoc) |
|
191 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#existAlphaBand() |
|
192 |
*/ |
|
193 | 185 |
public boolean existAlphaBand() { |
194 | 186 |
return (mask != null); |
195 | 187 |
} |
... | ... | |
203 | 195 |
return originalData; |
204 | 196 |
} |
205 | 197 |
|
206 |
/* |
|
207 |
* (non-Javadoc) |
|
208 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#setDataBuffer(org.gvsig.fmap.dal.coverage.dataset.Buffer) |
|
209 |
*/ |
|
210 | 198 |
public void setDataBuffer(Buffer b) { |
211 | 199 |
originalData = b; |
212 | 200 |
} |
... | ... | |
219 | 207 |
return noData; |
220 | 208 |
} |
221 | 209 |
|
222 |
/* |
|
223 |
* (non-Javadoc) |
|
224 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#setNoData(double) |
|
225 |
*/ |
|
226 | 210 |
public void setNoData(NoData noData) { |
227 | 211 |
if(this.noData != noData) |
228 | 212 |
callPropertyChanged(this); |
... | ... | |
233 | 217 |
* Obtiene los rangos de pixels que son transparentes en el raster. |
234 | 218 |
* @return Rangos de transparencias a aplicar |
235 | 219 |
*/ |
236 |
public ArrayList<TransparencyRange> getTransparencyRange() {
|
|
220 |
public List<TransparencyRange> getTransparencyRange() { |
|
237 | 221 |
return transparencyRanges; |
238 | 222 |
} |
239 | 223 |
|
240 |
/* |
|
241 |
* (non-Javadoc) |
|
242 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#setTransparencyRange(org.gvsig.fmap.dal.coverage.datastruct.TransparencyRange) |
|
243 |
*/ |
|
244 | 224 |
public void setTransparencyRange(TransparencyRange range) { |
245 | 225 |
this.transparencyRanges.add(range); |
246 | 226 |
callPropertyChanged(this); |
... | ... | |
250 | 230 |
* Asigna la lista de rangos de transparencia |
251 | 231 |
* @param ranges |
252 | 232 |
*/ |
253 |
public void setTransparencyRangeList(ArrayList<TransparencyRange> ranges) {
|
|
233 |
public void setTransparencyRangeList(List<TransparencyRange> ranges) { |
|
254 | 234 |
this.transparencyRanges = ranges; |
255 | 235 |
callPropertyChanged(this); |
256 | 236 |
} |
257 | 237 |
|
258 |
/* |
|
259 |
* (non-Javadoc) |
|
260 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#clearListOfTransparencyRange() |
|
261 |
*/ |
|
262 | 238 |
public void clearListOfTransparencyRange() { |
263 | 239 |
transparencyRanges.clear(); |
264 | 240 |
callPropertyChanged(this); |
... | ... | |
272 | 248 |
return opacity; |
273 | 249 |
} |
274 | 250 |
|
275 |
/* |
|
276 |
* (non-Javadoc) |
|
277 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#setOpacity(int) |
|
278 |
*/ |
|
279 | 251 |
public void setOpacity(int opacity) { |
280 | 252 |
if(opacity != this.opacity) |
281 | 253 |
callPropertyChanged(this); |
... | ... | |
332 | 304 |
t.setOpacity((int) (op1 * op2 * MAX_OPACITY)); |
333 | 305 |
|
334 | 306 |
// Mezclamos los rangos de transparencia |
335 |
ArrayList<TransparencyRange> tr = transp.getTransparencyRange();
|
|
307 |
List<TransparencyRange> tr = transp.getTransparencyRange(); |
|
336 | 308 |
for (int i = 0; i < tr.size(); i++) |
337 | 309 |
transparencyRanges.add(tr.get(i)); |
338 | 310 |
|
... | ... | |
419 | 391 |
return false; |
420 | 392 |
} |
421 | 393 |
|
422 |
/* |
|
423 |
* (non-Javadoc) |
|
424 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#activeTransparency() |
|
425 |
*/ |
|
426 | 394 |
public void activeTransparency() { |
427 | 395 |
if( existAlphaBand() || |
428 | 396 |
(getNoData() != null && getNoData().isDefined() && getNoData().isNoDataTransparent()) || |
... | ... | |
433 | 401 |
transparencyActive = false; |
434 | 402 |
} |
435 | 403 |
|
436 |
/* |
|
437 |
* (non-Javadoc) |
|
438 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#isTransparencyActive() |
|
439 |
*/ |
|
440 | 404 |
public boolean isTransparencyActive() { |
441 | 405 |
return transparencyActive; |
442 | 406 |
} |
... | ... | |
449 | 413 |
this.transparencyActive = transparencyActive; |
450 | 414 |
} |
451 | 415 |
|
452 |
/* |
|
453 |
* (non-Javadoc) |
|
454 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#processRGB(int, int, int, int, int) |
|
455 |
*/ |
|
456 | 416 |
public int processRGB(int r, int g, int b, int line, int col) { |
457 | 417 |
// Si el valor es noData se pone totalmente transparente y ya no se tiene en |
458 | 418 |
// cuenta nada m?s. |
... | ... | |
532 | 492 |
return 255; |
533 | 493 |
} |
534 | 494 |
|
535 |
/* |
|
536 |
* (non-Javadoc) |
|
537 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#cloneTransparency() |
|
538 |
*/ |
|
539 | 495 |
@SuppressWarnings("unchecked") |
540 | 496 |
public Transparency cloneTransparency() { |
541 | 497 |
DataStoreTransparency t = new DataStoreTransparency(); |
542 | 498 |
|
543 | 499 |
//TODO: FUNCIONALIDAD: Falta asignar lo necesario para la transparencia por selecci?n |
544 |
t.transparencyRanges = (ArrayList<TransparencyRange>) getTransparencyRange().clone();
|
|
500 |
t.transparencyRanges = (ArrayList<TransparencyRange>)((ArrayList<TransparencyRange>) getTransparencyRange()).clone();
|
|
545 | 501 |
t.mask = getAlphaBand(); |
546 | 502 |
t.opacity = getOpacity(); |
547 | 503 |
t.alphaBandNumber = alphaBandNumber; |
... | ... | |
552 | 508 |
return t; |
553 | 509 |
} |
554 | 510 |
|
555 |
/* |
|
556 |
* (non-Javadoc) |
|
557 |
* @see org.gvsig.tools.persistence.Persistent#loadFromState(org.gvsig.tools.persistence.PersistentState) |
|
558 |
*/ |
|
559 | 511 |
@SuppressWarnings("unchecked") |
560 | 512 |
public void loadFromState(PersistentState state) |
561 | 513 |
throws PersistenceException { |
... | ... | |
563 | 515 |
opacity = state.getInt("opacity"); |
564 | 516 |
} |
565 | 517 |
|
566 |
List tr = state.getList("transparencyRange"); |
|
518 |
List<TransparencyRange> tr = state.getList("transparencyRange");
|
|
567 | 519 |
if(tr != null) { |
568 | 520 |
transparencyRanges = new ArrayList<TransparencyRange>(tr); |
569 | 521 |
if (state.hasValue("bandnumber")) { |
... | ... | |
575 | 527 |
//this.noData = state.getDouble("noData"); |
576 | 528 |
} |
577 | 529 |
|
578 |
/* |
|
579 |
* (non-Javadoc) |
|
580 |
* @see org.gvsig.tools.persistence.Persistent#saveToState(org.gvsig.tools.persistence.PersistentState) |
|
581 |
*/ |
|
582 | 530 |
public void saveToState(PersistentState state) throws PersistenceException { |
583 | 531 |
if(getOpacity() != 255) { |
584 | 532 |
state.set("opacity", getOpacity()); |
... | ... | |
611 | 559 |
//definition.addDynFieldDouble("noData").setMandatory(false); |
612 | 560 |
} |
613 | 561 |
|
614 |
/* |
|
615 |
* (non-Javadoc) |
|
616 |
* @see org.gvsig.fmap.dal.coverage.store.props.Transparency#free() |
|
617 |
*/ |
|
618 | 562 |
public void dispose() { |
619 | 563 |
if (mask != null) |
620 | 564 |
mask.dispose(); |
... | ... | |
624 | 568 |
originalData = null; |
625 | 569 |
} |
626 | 570 |
|
627 |
/* |
|
628 |
* (non-Javadoc) |
|
629 |
* @see java.lang.Object#finalize() |
|
630 |
*/ |
|
631 | 571 |
protected void finalize() throws Throwable { |
632 | 572 |
noData = null; |
633 | 573 |
mask = null; |
org.gvsig.raster.gdal/branches/org.gvsig.raster.gdal_dataaccess_refactoring/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/io/GdalNative.java | ||
---|---|---|
225 | 225 |
isCorrect = true; |
226 | 226 |
if (!isCorrect) |
227 | 227 |
throw new GdalException(""); |
228 |
|
|
229 |
ownTransformation = new AffineTransform(trans.adfgeotransform[1], trans.adfgeotransform[4], trans.adfgeotransform[2], trans.adfgeotransform[5], trans.adfgeotransform[0], trans.adfgeotransform[3]); |
|
228 |
|
|
229 |
double psX = trans.adfgeotransform[1]; |
|
230 |
double psY = trans.adfgeotransform[5]; |
|
231 |
double rotX = trans.adfgeotransform[4]; |
|
232 |
double rotY = trans.adfgeotransform[2]; |
|
233 |
double offX = trans.adfgeotransform[0]; |
|
234 |
double offY = trans.adfgeotransform[3]; |
|
235 |
|
|
236 |
ownTransformation = new AffineTransform(psX, rotX, rotY, psY, offX, offY); |
|
237 |
//trans.adfgeotransform[1], trans.adfgeotransform[4], trans.adfgeotransform[2], trans.adfgeotransform[5], trans.adfgeotransform[0], trans.adfgeotransform[3]); |
|
230 | 238 |
externalTransformation = (AffineTransform) ownTransformation.clone(); |
231 | 239 |
overviewWidth = width; |
232 | 240 |
overviewHeight = height; |
org.gvsig.raster.mosaic/trunk/org.gvsig.raster.mosaic/org.gvsig.raster.mosaic.io/src/main/java/org/gvsig/raster/mosaic/io/MosaicProvider.java | ||
---|---|---|
82 | 82 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
83 | 83 |
import org.gvsig.raster.impl.provider.RasterProvider; |
84 | 84 |
import org.gvsig.raster.impl.provider.fusion.BufferListFusion; |
85 |
import org.gvsig.raster.impl.provider.fusion.BufferListFusion.PixelSquareStructure;
|
|
85 |
import org.gvsig.raster.impl.provider.fusion.PixelSquareStructure; |
|
86 | 86 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
87 | 87 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
88 | 88 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
... | ... | |
429 | 429 |
if(providerList.get(i).getBandCount() > bandCount) |
430 | 430 |
bandCount = providerList.get(i).getBandCount(); |
431 | 431 |
} |
432 |
if(providerList.get(0).getDataType()[0] == Buffer.TYPE_BYTE) |
|
433 |
bandCount ++; |
|
432 | 434 |
} |
433 | 435 |
return bandCount; |
434 | 436 |
} |
... | ... | |
680 | 682 |
return (c > 0.95 || c < 0.05) ? Math.round(c) : c; |
681 | 683 |
} |
682 | 684 |
|
683 |
private Buffer getBuffersFusion(SpiRasterQuery query, Buffer rasterBuf, int alphaBandNumber) throws RasterDriverException, ProcessInterruptedException { |
|
685 |
/** |
|
686 |
* Write the list of buffers in a single buffer using the fusion method selected |
|
687 |
* @param bufferList |
|
688 |
* @param rasterBuf |
|
689 |
* @param alphaBandNumber |
|
690 |
* @return |
|
691 |
* @throws RasterDriverException |
|
692 |
* @throws ProcessInterruptedException |
|
693 |
*/ |
|
694 |
private Buffer fuseBuffers(List<Buffer> bufferList, Buffer rasterBuf, int alphaBandNumber) throws RasterDriverException, ProcessInterruptedException { |
|
695 |
if(bufferList.size() == 0) |
|
696 |
return rasterBuf; |
|
684 | 697 |
|
698 |
PixelSquareStructure pxSquare = new PixelSquareStructure( |
|
699 |
rasterBuf, |
|
700 |
getView(), |
|
701 |
getCellSize()); |
|
702 |
BufferListFusion bufferFusion = new BufferListFusion(bufferList, pxSquare, BufferListFusion.FIRST); |
|
703 |
bufferFusion.setAlphaBand(alphaBandNumber); |
|
704 |
rasterBuf = bufferFusion.getWindow(); |
|
705 |
bufferFusion.dispose(); |
|
706 |
return rasterBuf; |
|
707 |
} |
|
708 |
|
|
709 |
/** |
|
710 |
* Reads the list of buffers from the providers |
|
711 |
* @param query |
|
712 |
* @return |
|
713 |
* @throws RasterDriverException |
|
714 |
* @throws ProcessInterruptedException |
|
715 |
*/ |
|
716 |
private List<Buffer> readBufferListFromProviders(SpiRasterQuery query) |
|
717 |
throws RasterDriverException, ProcessInterruptedException { |
|
685 | 718 |
List<Buffer> bufferList = new ArrayList<Buffer>(); |
686 | 719 |
|
687 | 720 |
for (int i = 0; i < providerList.size(); i++) { |
... | ... | |
691 | 724 |
if(extIntersection == null) |
692 | 725 |
continue; |
693 | 726 |
|
694 |
double relWidth = getView().width() / rasterBuf.getWidth();
|
|
695 |
double relHeight = getView().height() / rasterBuf.getHeight();
|
|
727 |
double relWidth = getView().width() / query.getBufWidth();
|
|
728 |
double relHeight = getView().height() / query.getBufHeight();
|
|
696 | 729 |
int w = (int)Math.ceil(adjustCoordinate(extIntersection.width() / relWidth)); |
697 | 730 |
int h = (int)Math.ceil(adjustCoordinate(extIntersection.height() / relHeight)); |
698 | 731 |
|
... | ... | |
710 | 743 |
} |
711 | 744 |
bufferList.add(buf); |
712 | 745 |
} |
713 |
|
|
714 |
if(bufferList.size() == 0) |
|
715 |
return rasterBuf; |
|
716 |
|
|
717 |
PixelSquareStructure pxSquare = BufferListFusion.buildPixelSquareStructure( |
|
718 |
rasterBuf, |
|
719 |
getView(), |
|
720 |
getCellSize(), |
|
721 |
getBandCount()); |
|
722 |
BufferListFusion bufferFusion = new BufferListFusion(bufferList, pxSquare, BufferListFusion.FIRST); |
|
723 |
bufferFusion.setAlphaBand(alphaBandNumber); |
|
724 |
rasterBuf = bufferFusion.getWindow(); |
|
725 |
bufferFusion.dispose(); |
|
726 |
return rasterBuf; |
|
746 |
return bufferList; |
|
727 | 747 |
} |
728 | 748 |
|
729 | 749 |
public void loadBuffer(SpiRasterQuery q) throws ProcessInterruptedException, RasterDriverException { |
730 | 750 |
if(getParameters().hasParamsChanged()) |
731 | 751 |
calcMetadataFromParams(); |
732 |
setView(q.getAdjustedRequestBoundingBox());
|
|
752 |
setView(q.getRequestBoundingBox()); |
|
733 | 753 |
|
734 | 754 |
int alphaBandNumber = q.getAlphaBandNumber(); |
755 |
//int numBandsBufferResult = q.getAlphaBandNumber() == -1 ? getBandCount() : getBandCount() + 1; |
|
735 | 756 |
if(q.getAlphaBandNumber() != -1) { |
736 |
alphaBandNumber ++;
|
|
757 |
alphaBandNumber = getBandCount() - 1;
|
|
737 | 758 |
} |
738 | 759 |
|
739 |
//La query no ha creado el buffer porque no sabe el n?mero de bandas. Lo calculamos aqu? |
|
760 |
List<Buffer> bufferList = readBufferListFromProviders(q); |
|
761 |
|
|
762 |
//La query no ha creado el buffer porque no sabe el n?mero de bandas. |
|
763 |
//Lo calculamos aqu? y debe de tener el tama?o de un tile completo, ya |
|
764 |
//que fuseBuffers escribe sobre el buffer de un tile |
|
740 | 765 |
BufferParam bufParam = RasterLocator.getManager().getBufferFactory().createBufferParams( |
741 | 766 |
q.getBufWidth(), |
742 | 767 |
q.getBufHeight(), |
743 |
q.getAlphaBandNumber() == -1 ? getBandCount() : getBandCount() + 1,
|
|
768 |
getBandCount(),
|
|
744 | 769 |
getDataType()[0], |
745 | 770 |
true); |
746 | 771 |
|
747 | 772 |
try { |
748 | 773 |
Buffer buf = RasterLocator.getManager().getBufferFactory().createBuffer(bufParam); |
749 | 774 |
buf.setDataExtent(q.getAdjustedRequestBoundingBox().toRectangle2D()); |
750 |
getBuffersFusion(q, buf, alphaBandNumber) ;
|
|
775 |
fuseBuffers(bufferList, buf, alphaBandNumber) ;
|
|
751 | 776 |
q.setBufferResult(buf); |
752 | 777 |
} catch (LocatorException e) { |
753 | 778 |
new RasterDriverException("Error locating the manager", e); |
org.gvsig.raster.mosaic/trunk/org.gvsig.raster.mosaic/org.gvsig.raster.mosaic.io/src/main/java/org/gvsig/raster/mosaic/io/downloader/TileDownloaderForMosaics.java | ||
---|---|---|
36 | 36 |
import org.gvsig.raster.cache.tile.Tile; |
37 | 37 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
38 | 38 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
39 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
40 | 39 |
import org.gvsig.raster.impl.buffer.SpiRasterQuery; |
41 | 40 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
42 | 41 |
import org.gvsig.raster.impl.provider.tile.TileDownloaderForFiles; |
... | ... | |
59 | 58 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
60 | 59 |
Extent tileExtent = new ExtentImpl(tile.getUl(), tile.getLr()); |
61 | 60 |
ColorInterpretation ci = store.getColorInterpretation(); |
62 |
Buffer bufResult = null; |
|
63 | 61 |
double pixelSize = struct.getPixelSizeByLevel(tile.getLevel()); |
64 | 62 |
|
65 | 63 |
try { |
66 |
Extent ex = store.getExtent().intersection(tileExtent); |
|
67 |
|
|
68 |
//newBuf ser?n distintas de tilePx cuando haya zonas con valores no data. Las de los bordes |
|
69 |
int newBufWidth = (int)Math.ceil((ex.width() * this.tilePxWidth) / tileExtent.width()); |
|
70 |
int newBufHeight = (int)Math.ceil((ex.height() * this.tilePxHeight) / tileExtent.height()); |
|
71 | 64 |
boolean alphaBand = false; |
72 | 65 |
int nBandsBuffer = store.getBandCount(); |
73 | 66 |
|
... | ... | |
81 | 74 |
nBandsBuffer ++; |
82 | 75 |
} |
83 | 76 |
|
84 |
Buffer smallBuf = readSupersampledBuffer(ex, newBufWidth, newBufHeight, alphaBand);
|
|
77 |
Buffer bufResult = readSupersampledBuffer(tileExtent, this.tilePxWidth, this.tilePxHeight, alphaBand);
|
|
85 | 78 |
|
86 |
if(smallBuf == null) { //No ha habido resampleo
|
|
79 |
if(bufResult == null) { //No ha habido resampleo
|
|
87 | 80 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
88 |
q.setAreaOfInterest(ex, newBufWidth, newBufHeight);
|
|
81 |
q.setAreaOfInterest(tileExtent, this.tilePxWidth, this.tilePxHeight);
|
|
89 | 82 |
q.setAllDrawableBands(); |
90 | 83 |
q.setAdjustToExtent(true); |
91 | 84 |
((SpiRasterQuery)q).dontBuildBuffer(); |
92 | 85 |
if(alphaBand) |
93 | 86 |
q.setAlphaBand(nBandsBuffer); |
94 |
smallBuf = store.query(q);
|
|
87 |
bufResult = store.query(q);
|
|
95 | 88 |
} |
96 | 89 |
|
97 |
bufResult = buildTileBuffer(nBandsBuffer, this.tilePxWidth, this.tilePxHeight, alphaBand); |
|
98 |
RasterLocator.getManager().getRasterUtils().copyToBuffer( |
|
99 |
bufResult, |
|
100 |
tileExtent, |
|
101 |
smallBuf, |
|
102 |
ex, |
|
103 |
pixelSize, |
|
104 |
store.getColorInterpretation().hasAlphaBand()); |
|
105 |
|
|
106 | 90 |
saveTile(bufResult, pixelSize, extension, alphaBand, tile, tileExtent, ci); |
107 | 91 |
} catch (ProcessInterruptedException e) { |
108 | 92 |
} catch (RasterDriverException e) { |
... | ... | |
119 | 103 |
} |
120 | 104 |
|
121 | 105 |
/** |
106 |
* When the buffer of the request is greater than the original raster (> scale 1:1) then the request |
|
107 |
* has to be resampled. |
|
108 |
* @param tileExtent |
|
109 |
* @param newBandList |
|
110 |
* @param bufWidth |
|
111 |
* @param bufHeight |
|
112 |
* @param nBands |
|
113 |
* @return |
|
114 |
* @throws ProcessInterruptedException |
|
115 |
* @throws TileGettingException |
|
116 |
*/ |
|
117 |
protected Buffer readSupersampledBuffer(Extent tileExtent, int bufWidth, int bufHeight, boolean hasAlphaBand) throws ProcessInterruptedException, TileGettingException { |
|
118 |
int widthImgPx = (int)Math.abs(tileExtent.width() / store.getPixelSizeX()); |
|
119 |
int heightImgPx = (int)Math.abs(tileExtent.height() / store.getPixelSizeY()); |
|
120 |
boolean supersampling = ((bufWidth > widthImgPx) || (bufHeight > heightImgPx)) ? true : false; |
|
121 |
|
|
122 |
if(supersampling) { |
|
123 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
|
124 |
q.setAreaOfInterest(tileExtent, widthImgPx, heightImgPx); |
|
125 |
q.setAllDrawableBands(); |
|
126 |
q.setAdjustToExtent(true); |
|
127 |
((SpiRasterQuery)q).dontBuildBuffer(); |
|
128 |
if(hasAlphaBand) |
|
129 |
q.setAlphaBand(store.getBandCount() - 1); |
|
130 |
Buffer buf = null; |
|
131 |
try { |
|
132 |
buf = store.query(q); |
|
133 |
} catch (QueryException e) { |
|
134 |
throw new TileGettingException(e); |
|
135 |
} |
|
136 |
Buffer result = buf.getAdjustedWindow(bufWidth, bufHeight, Buffer.INTERPOLATION_NearestNeighbour); |
|
137 |
if(result != buf) |
|
138 |
buf.dispose(); |
|
139 |
return result; |
|
140 |
} |
|
141 |
return null; |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
122 | 145 |
* Builds a buffer using the specified number of bands and initialize it |
123 | 146 |
* @param nbands |
124 | 147 |
* @return |
125 | 148 |
*/ |
126 |
protected Buffer buildTileBuffer(int nbands, int w, int h, boolean hasAlphaBand) {
|
|
149 |
/*private Buffer buildTileBuffer(int nbands, int w, int h, boolean hasAlphaBand) {
|
|
127 | 150 |
Buffer bufResult = DefaultRasterManager.getInstance().createMemoryBuffer(store.getDataType()[0], w, h, nbands, true); |
128 | 151 |
if(!hasAlphaBand) { |
129 | 152 |
for (int i = 0; i < bufResult.getBandCount(); i++) { |
... | ... | |
137 | 160 |
} |
138 | 161 |
} |
139 | 162 |
return bufResult; |
140 |
} |
|
163 |
}*/
|
|
141 | 164 |
} |
Also available in: Unified diff