Revision 2305
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/ColorInterpretation.java | ||
---|---|---|
53 | 53 |
public int length(); |
54 | 54 |
|
55 | 55 |
/** |
56 |
* Returns true if the color interpretation is BGR |
|
57 |
* @return |
|
58 |
*/ |
|
59 |
public boolean isBGR(); |
|
60 |
|
|
61 |
/** |
|
56 | 62 |
* Returns true if the color interpretation is RGB |
57 | 63 |
* @return |
58 | 64 |
*/ |
... | ... | |
104 | 110 |
public boolean hasAlphaBand(); |
105 | 111 |
|
106 | 112 |
/** |
113 |
* Returns the number of band with the label "Alpha" |
|
114 |
* @return |
|
115 |
*/ |
|
116 |
public int getAlphaBand(); |
|
117 |
|
|
118 |
/** |
|
107 | 119 |
* A?ade un objeto DatasetColorInterpretation al actual. El resultado es la suma |
108 | 120 |
* de ambos. |
109 | 121 |
* @param ci |
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 | ||
---|---|---|
80 | 80 |
if(store.getColorInterpretation().hasAlphaBand()) |
81 | 81 |
alphaBand = true; |
82 | 82 |
|
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(isInternalTile(newBufWidth, newBufHeight)) { |
|
83 |
//A partir de ahora todos los tiles RGB llevan banda de transparencia, por eso eliminamos este c?digo. Esto es para que |
|
84 |
//las capas tileadas puedan aparecer con banda transparente en el cuadro de propiedades. Si no da problemas la |
|
85 |
//modificaci?n eliminarlo permanentemente dentro de un par de versiones (19/11/2013 BN2207) |
|
86 |
|
|
87 |
/*if(isInternalTile(newBufWidth, newBufHeight)) { |
|
85 | 88 |
bufResult = readSupersampledBuffer(tileExtent, this.tilePxWidth, this.tilePxHeight, false); |
86 | 89 |
if(bufResult == null) { |
87 | 90 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
... | ... | |
90 | 93 |
q.setAdjustToExtent(true); |
91 | 94 |
bufResult = store.query(q); |
92 | 95 |
} |
93 |
} else { |
|
94 |
//Hay parte del tile que cae fuera de la imagen |
|
95 |
if(store.getDataType()[0] == Buffer.TYPE_BYTE) { |
|
96 |
//Para imagenes byte se crea una banda de transparencia |
|
97 |
alphaBand = true; |
|
98 |
if(!store.getColorInterpretation().hasAlphaBand()) |
|
99 |
nBandsBuffer ++; |
|
100 |
} |
|
101 |
|
|
102 |
Buffer smallBuf = readSupersampledBuffer(ex, newBufWidth, newBufHeight, alphaBand); |
|
103 |
|
|
104 |
if(smallBuf == null) { //No ha habido resampleo |
|
105 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
|
106 |
q.setAreaOfInterest(ex, newBufWidth, newBufHeight); |
|
107 |
q.setAllDrawableBands(); |
|
108 |
q.setAdjustToExtent(true); |
|
109 |
if(alphaBand) |
|
110 |
q.setAlphaBand(store.getBandCount() - 1); |
|
111 |
smallBuf = store.query(q); |
|
112 |
} |
|
113 |
|
|
114 |
bufResult = buildTileBuffer(nBandsBuffer, this.tilePxWidth, this.tilePxHeight); |
|
115 |
RasterLocator.getManager().getRasterUtils().copyToBuffer( |
|
116 |
bufResult, |
|
117 |
tileExtent, |
|
118 |
smallBuf, |
|
119 |
ex, |
|
120 |
pixelSize, |
|
121 |
store.getColorInterpretation().hasAlphaBand()); |
|
96 |
} else {*/ |
|
97 |
|
|
98 |
//Hay parte del tile que cae fuera de la imagen |
|
99 |
if(store.getDataType()[0] == Buffer.TYPE_BYTE) { |
|
100 |
//Para imagenes byte se crea una banda de transparencia |
|
101 |
alphaBand = true; |
|
102 |
if(!store.getColorInterpretation().hasAlphaBand()) |
|
103 |
nBandsBuffer ++; |
|
104 |
} |
|
105 |
|
|
106 |
Buffer smallBuf = readSupersampledBuffer(ex, newBufWidth, newBufHeight, alphaBand); |
|
107 |
|
|
108 |
if(smallBuf == null) { //No ha habido resampleo |
|
109 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
|
110 |
q.setAreaOfInterest(ex, newBufWidth, newBufHeight); |
|
111 |
q.setAllDrawableBands(); |
|
112 |
q.setAdjustToExtent(true); |
|
113 |
if(alphaBand) |
|
114 |
q.setAlphaBand(store.getBandCount() - 1); |
|
115 |
smallBuf = store.query(q); |
|
122 | 116 |
} |
123 |
|
|
117 |
|
|
118 |
bufResult = buildTileBuffer(nBandsBuffer, this.tilePxWidth, this.tilePxHeight); |
|
119 |
RasterLocator.getManager().getRasterUtils().copyToBuffer( |
|
120 |
bufResult, |
|
121 |
tileExtent, |
|
122 |
smallBuf, |
|
123 |
ex, |
|
124 |
pixelSize, |
|
125 |
store.getColorInterpretation().hasAlphaBand()); |
|
126 |
//} |
|
127 |
|
|
124 | 128 |
saveTile(bufResult, pixelSize, extension, alphaBand, tile, tileExtent, ci); |
125 | 129 |
//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para |
126 | 130 |
//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros |
127 | 131 |
//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf"); |
128 | 132 |
//if(rmf.exists()) |
129 |
//rmf.delete();
|
|
133 |
//rmf.delete(); |
|
130 | 134 |
} catch (ProcessInterruptedException e) { |
131 | 135 |
} catch (RasterDriverException e) { |
132 | 136 |
throw new TileGettingException(e); |
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_oldversion.java | ||
---|---|---|
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.impl.provider.tile; |
|
23 |
|
|
24 |
import java.io.IOException; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
27 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
29 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
30 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
31 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
|
32 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
33 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
34 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
|
35 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
36 |
import org.gvsig.raster.cache.tile.Tile; |
|
37 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
38 |
import org.gvsig.raster.cache.tile.provider.CacheStruct; |
|
39 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
40 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
41 |
|
|
42 |
/** |
|
43 |
* Tile getter |
|
44 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
45 |
*/ |
|
46 |
public class TileDownloaderForFiles_oldversion extends BaseTileDownloader { |
|
47 |
protected CacheStruct struct = null; |
|
48 |
protected String extension = null; |
|
49 |
|
|
50 |
public TileDownloaderForFiles_oldversion(RasterDataStore store, |
|
51 |
CacheStruct struct, |
|
52 |
int tileWidth, |
|
53 |
int tileHeight, |
|
54 |
String extension) { |
|
55 |
super(store, tileWidth, tileHeight); |
|
56 |
this.struct = struct; |
|
57 |
this.extension = extension; |
|
58 |
} |
|
59 |
|
|
60 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
|
61 |
Extent tileExtent = new ExtentImpl(tile.getUl(), tile.getLr()); |
|
62 |
ColorInterpretation ci = store.getColorInterpretation(); |
|
63 |
|
|
64 |
//Escribe todas las bandas a disco |
|
65 |
//BandList newBandList = store.getDefaultBandList();//createBandList(prov); |
|
66 |
|
|
67 |
Buffer bufResult = null; |
|
68 |
|
|
69 |
double pixelSize = struct.getPixelSizeByLevel(tile.getLevel()); |
|
70 |
|
|
71 |
try { |
|
72 |
Extent ex = store.getExtent().intersection(tileExtent); |
|
73 |
|
|
74 |
//newBuf ser?n distintas de tilePx cuando haya zonas con valores no data. Las de los bordes |
|
75 |
int newBufWidth = (int)Math.ceil((ex.width() * this.tilePxWidth) / tileExtent.width()); |
|
76 |
int newBufHeight = (int)Math.ceil((ex.height() * this.tilePxHeight) / tileExtent.height()); |
|
77 |
boolean alphaBand = false; |
|
78 |
int nBandsBuffer = store.getBandCount(); |
|
79 |
|
|
80 |
if(store.getColorInterpretation().hasAlphaBand()) |
|
81 |
alphaBand = true; |
|
82 |
|
|
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(isInternalTile(newBufWidth, newBufHeight)) { |
|
85 |
bufResult = readSupersampledBuffer(tileExtent, this.tilePxWidth, this.tilePxHeight, false); |
|
86 |
if(bufResult == null) { |
|
87 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
|
88 |
q.setAreaOfInterest(tileExtent, this.tilePxWidth, this.tilePxHeight); |
|
89 |
q.setAllDrawableBands(); |
|
90 |
q.setAdjustToExtent(true); |
|
91 |
bufResult = store.query(q); |
|
92 |
} |
|
93 |
} else { |
|
94 |
//Hay parte del tile que cae fuera de la imagen |
|
95 |
if(store.getDataType()[0] == Buffer.TYPE_BYTE) { |
|
96 |
//Para imagenes byte se crea una banda de transparencia |
|
97 |
alphaBand = true; |
|
98 |
if(!store.getColorInterpretation().hasAlphaBand()) |
|
99 |
nBandsBuffer ++; |
|
100 |
} |
|
101 |
|
|
102 |
Buffer smallBuf = readSupersampledBuffer(ex, newBufWidth, newBufHeight, alphaBand); |
|
103 |
|
|
104 |
if(smallBuf == null) { //No ha habido resampleo |
|
105 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
|
106 |
q.setAreaOfInterest(ex, newBufWidth, newBufHeight); |
|
107 |
q.setAllDrawableBands(); |
|
108 |
q.setAdjustToExtent(true); |
|
109 |
if(alphaBand) |
|
110 |
q.setAlphaBand(store.getBandCount() - 1); |
|
111 |
smallBuf = store.query(q); |
|
112 |
} |
|
113 |
|
|
114 |
bufResult = buildTileBuffer(nBandsBuffer, this.tilePxWidth, this.tilePxHeight); |
|
115 |
RasterLocator.getManager().getRasterUtils().copyToBuffer( |
|
116 |
bufResult, |
|
117 |
tileExtent, |
|
118 |
smallBuf, |
|
119 |
ex, |
|
120 |
pixelSize, |
|
121 |
store.getColorInterpretation().hasAlphaBand()); |
|
122 |
} |
|
123 |
|
|
124 |
saveTile(bufResult, pixelSize, extension, alphaBand, tile, tileExtent, ci); |
|
125 |
//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para |
|
126 |
//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros |
|
127 |
//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf"); |
|
128 |
//if(rmf.exists()) |
|
129 |
//rmf.delete(); |
|
130 |
} catch (ProcessInterruptedException e) { |
|
131 |
} catch (RasterDriverException e) { |
|
132 |
throw new TileGettingException(e); |
|
133 |
} catch (NotSupportedExtensionException e) { |
|
134 |
throw new TileGettingException(e); |
|
135 |
} catch (IOException e) { |
|
136 |
throw new TileGettingException(e); |
|
137 |
} catch (QueryException e) { |
|
138 |
throw new TileGettingException(e); |
|
139 |
} |
|
140 |
readTileFromDisk(tile); |
|
141 |
return tile; |
|
142 |
} |
|
143 |
|
|
144 |
public boolean isInternalTile(int bufWidth, int bufHeight) { |
|
145 |
return (bufHeight == this.tilePxHeight && bufWidth == this.tilePxWidth); |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* When the buffer of the request is greater than the original raster (> scale 1:1) then the request |
|
150 |
* has to be resampled. |
|
151 |
* @param tileExtent |
|
152 |
* @param newBandList |
|
153 |
* @param bufWidth |
|
154 |
* @param bufHeight |
|
155 |
* @param nBands |
|
156 |
* @return |
|
157 |
* @throws ProcessInterruptedException |
|
158 |
* @throws TileGettingException |
|
159 |
*/ |
|
160 |
protected Buffer readSupersampledBuffer(Extent tileExtent, int bufWidth, int bufHeight, boolean hasAlphaBand) throws ProcessInterruptedException, TileGettingException { |
|
161 |
int widthImgPx = (int)Math.abs(tileExtent.width() / store.getPixelSizeX()); |
|
162 |
int heightImgPx = (int)Math.abs(tileExtent.height() / store.getPixelSizeY()); |
|
163 |
boolean supersampling = ((bufWidth > widthImgPx) || (bufHeight > heightImgPx)) ? true : false; |
|
164 |
|
|
165 |
if(supersampling) { |
|
166 |
RasterQuery q = RasterLocator.getManager().createQuery(); |
|
167 |
q.setAreaOfInterest(tileExtent, widthImgPx, heightImgPx); |
|
168 |
q.setAllDrawableBands(); |
|
169 |
q.setAdjustToExtent(true); |
|
170 |
if(hasAlphaBand) |
|
171 |
q.setAlphaBand(store.getBandCount() - 1); |
|
172 |
Buffer buf = null; |
|
173 |
try { |
|
174 |
buf = store.query(q); |
|
175 |
} catch (QueryException e) { |
|
176 |
throw new TileGettingException(e); |
|
177 |
} |
|
178 |
Buffer result = buf.getAdjustedWindow(bufWidth, bufHeight, Buffer.INTERPOLATION_NearestNeighbour); |
|
179 |
if(result != buf) |
|
180 |
buf.dispose(); |
|
181 |
return result; |
|
182 |
} |
|
183 |
return null; |
|
184 |
} |
|
185 |
|
|
186 |
/** |
|
187 |
* Builds a buffer using the specified number of bands and initialize it |
|
188 |
* @param nbands |
|
189 |
* @return |
|
190 |
*/ |
|
191 |
protected Buffer buildTileBuffer(int nbands, int w, int h) { |
|
192 |
Buffer bufResult = DefaultRasterManager.getInstance().createMemoryBuffer(store.getDataType()[0], w, h, nbands, true); |
|
193 |
if(store.getDataType()[0] != Buffer.TYPE_BYTE) { |
|
194 |
for (int i = 0; i < bufResult.getBandCount(); i++) { |
|
195 |
clearMaskBuffer(bufResult, i); |
|
196 |
} |
|
197 |
} else |
|
198 |
clearMaskBuffer(bufResult, nbands - 1); |
|
199 |
return bufResult; |
|
200 |
} |
|
201 |
} |
|
0 | 202 |
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/DataStoreColorInterpretation.java | ||
---|---|---|
114 | 114 |
colorInterpretation = new String[values]; |
115 | 115 |
} |
116 | 116 |
|
117 |
public boolean isBGR() { |
|
118 |
if(colorInterpretation != null) { |
|
119 |
if (colorInterpretation.length == 3 && |
|
120 |
colorInterpretation[0] == BLUE_BAND && |
|
121 |
colorInterpretation[1] == GREEN_BAND && |
|
122 |
colorInterpretation[2] == RED_BAND) |
|
123 |
return true; |
|
124 |
} |
|
125 |
return false; |
|
126 |
} |
|
127 |
|
|
117 | 128 |
public boolean isRGB() { |
118 | 129 |
if(colorInterpretation != null) { |
119 | 130 |
if (colorInterpretation.length == 3 && |
120 | 131 |
colorInterpretation[0] == RED_BAND && |
121 |
colorInterpretation[1] == BLUE_BAND &&
|
|
132 |
colorInterpretation[1] == GREEN_BAND &&
|
|
122 | 133 |
colorInterpretation[2] == BLUE_BAND) |
123 | 134 |
return true; |
124 | 135 |
} |
... | ... | |
130 | 141 |
if (colorInterpretation.length == 4 && |
131 | 142 |
colorInterpretation[0] == RED_BAND && |
132 | 143 |
colorInterpretation[1] == BLUE_BAND && |
133 |
colorInterpretation[2] == BLUE_BAND &&
|
|
144 |
colorInterpretation[2] == GREEN_BAND &&
|
|
134 | 145 |
colorInterpretation[3] == ALPHA_BAND) |
135 | 146 |
return true; |
136 | 147 |
} |
137 | 148 |
return false; |
138 | 149 |
} |
139 | 150 |
|
151 |
public int getAlphaBand() { |
|
152 |
String[] values = getValues(); |
|
153 |
for (int i = 0; i < values.length; i++) { |
|
154 |
if(values[i] != null && values[i].equals("Alpha")) |
|
155 |
return i; |
|
156 |
} |
|
157 |
return -1; |
|
158 |
} |
|
159 |
|
|
140 | 160 |
public String[] getValues() { |
141 | 161 |
return colorInterpretation; |
142 | 162 |
} |
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 | ||
---|---|---|
180 | 180 |
return reprojectionOnTheFly != null; |
181 | 181 |
} |
182 | 182 |
|
183 |
/* |
|
184 |
* (non-Javadoc) |
|
185 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#getDataStore() |
|
186 |
*/ |
|
187 | 183 |
public RasterDataStore getDataStore() { |
188 | 184 |
return this.dataStore; |
189 | 185 |
} |
190 | 186 |
|
191 |
/* |
|
192 |
* (non-Javadoc) |
|
193 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#setDataStore(org.gvsig.fmap.dal.coverage.store.RasterDataStore) |
|
194 |
*/ |
|
195 | 187 |
public void setDataStore(RasterDataStore dataStore) { |
196 | 188 |
this.dataStore = dataStore; |
197 | 189 |
init(); |
... | ... | |
323 | 315 |
|
324 | 316 |
if (dataStore != null) { |
325 | 317 |
//TODO:Eliminado pq parece que machaca lo que ha puesto BandSelectorPropertiesListener y no hace caso al selector de bandas. |
326 |
if(getLastTransparency().getAlphaBandNumber() == -1) |
|
327 |
getLastTransparency().setTransparencyBand(dataStore.getTransparency().getAlphaBandNumber()); |
|
318 |
//if(getLastTransparency().getAlphaBandNumber() == -1)
|
|
319 |
//getLastTransparency().setTransparencyBand(dataStore.getTransparency().getAlphaBandNumber());
|
|
328 | 320 |
|
329 | 321 |
lastAlphaBand = getLastTransparency().getAlphaBandNumber(); |
330 | 322 |
|
... | ... | |
518 | 510 |
} |
519 | 511 |
|
520 | 512 |
if(tiling == null || tiling.booleanValue()) { |
521 |
//if(lastTransparency.getAlphaBandNumber() != -1) { |
|
513 |
if(lastTransparency.getAlphaBandNumber() == -1) |
|
514 |
lastTransparency.setAlphaBand(null); |
|
515 |
else |
|
522 | 516 |
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 |
//} |
|
517 |
Grid grid = null; |
|
518 |
try { |
|
519 |
grid = bufferPreprocessing(buf, lastTransparency); |
|
520 |
} catch (ProcessInterruptedException e3) { |
|
521 |
return; |
|
522 |
} |
|
523 |
buf = grid.getRasterBuf(); |
|
531 | 524 |
} |
532 |
|
|
525 |
|
|
533 | 526 |
if(tiling == null || tiling.booleanValue()) { |
534 | 527 |
//Reescalado de los tiles. El tama?o en pixels de un tile no tiene pq coincidir con el de la vista. |
535 | 528 |
double w = lastViewPortData.getWidth(); |
... | ... | |
673 | 666 |
}*/ |
674 | 667 |
} |
675 | 668 |
|
676 |
/* |
|
677 |
* (non-Javadoc) |
|
678 |
* @see org.gvsig.raster.impl.grid.render.TileListener#endReading() |
|
679 |
*/ |
|
680 | 669 |
public void endReading() { |
681 | 670 |
isDrawing = false; |
682 | 671 |
} |
683 | 672 |
|
684 |
/* |
|
685 |
* (non-Javadoc) |
|
686 |
* @see org.gvsig.raster.impl.grid.render.TileListener#isReading() |
|
687 |
*/ |
|
688 | 673 |
public boolean isReading() { |
689 | 674 |
return isDrawing; |
690 | 675 |
} |
691 | 676 |
|
692 |
/* |
|
693 |
* (non-Javadoc) |
|
694 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#setReading(boolean) |
|
695 |
*/ |
|
696 | 677 |
public void setReading(boolean reading) { |
697 | 678 |
isDrawing = reading; |
698 | 679 |
} |
... | ... | |
759 | 740 |
return adjustedRotedExtent; |
760 | 741 |
} |
761 | 742 |
|
762 |
/* |
|
763 |
* (non-Javadoc) |
|
764 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#getRenderBands() |
|
765 |
*/ |
|
766 | 743 |
public int[] getRenderBands() { |
767 | 744 |
return renderBands; |
768 | 745 |
} |
769 | 746 |
|
770 |
/* |
|
771 |
* (non-Javadoc) |
|
772 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#isRenderingAsGray() |
|
773 |
*/ |
|
774 | 747 |
public boolean isRenderingAsGray() { |
775 | 748 |
int[] renderBands = getRenderBands(); |
776 | 749 |
if ((renderBands != null) && (renderBands.length == 3) && (renderBands[0] >= 0) && |
... | ... | |
843 | 816 |
return lastTransparency; |
844 | 817 |
} |
845 | 818 |
|
846 |
/* |
|
847 |
* (non-Javadoc) |
|
848 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#getLastAlphaBandNumber() |
|
849 |
*/ |
|
850 | 819 |
public int getLastAlphaBandNumber() { |
851 | 820 |
return lastAlphaBand; |
852 | 821 |
} |
853 | 822 |
|
854 |
/* |
|
855 |
* (non-Javadoc) |
|
856 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#setLastTransparency(org.gvsig.fmap.dal.coverage.store.props.Transparency) |
|
857 |
*/ |
|
858 | 823 |
public void setLastTransparency(Transparency lastTransparency) { |
859 | 824 |
this.lastTransparency = lastTransparency; |
860 | 825 |
if(this.lastTransparency != null) |
861 | 826 |
this.lastTransparency.addPropertyListener(this); |
862 | 827 |
} |
863 | 828 |
|
864 |
/* |
|
865 |
* (non-Javadoc) |
|
866 |
* @see org.gvsig.fmap.dal.coverage.grid.Render#getFilterList() |
|
867 |
*/ |
|
868 | 829 |
public RasterFilterList getFilterList() { |
869 | 830 |
return filterList; |
870 | 831 |
} |
871 | 832 |
|
872 |
/* |
|
873 |
* (non-Javadoc) |
|
874 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#setFilterList(org.gvsig.fmap.dal.coverage.grid.RasterFilterList) |
|
875 |
*/ |
|
876 | 833 |
public void setFilterList(RasterFilterList filterList) { |
877 | 834 |
this.filterList = filterList; |
878 | 835 |
this.filterList.addFilterListListener(this); |
879 | 836 |
} |
880 | 837 |
|
881 |
/* |
|
882 |
* (non-Javadoc) |
|
883 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#existColorTable() |
|
884 |
*/ |
|
885 | 838 |
public boolean existColorTable() { |
886 | 839 |
return (filterList.getFilterByBaseClass(ColorTableFilter.class) != null); |
887 | 840 |
} |
888 | 841 |
|
889 |
/* |
|
890 |
* (non-Javadoc) |
|
891 |
* @see org.gvsig.fmap.dal.coverage.grid.render.Render#getColorTable() |
|
892 |
*/ |
|
893 | 842 |
public ColorTable getColorTable() { |
894 | 843 |
if(existColorTable()) { |
895 | 844 |
RasterFilter f = filterList.getFilterByBaseClass(ColorTableFilter.class); |
... | ... | |
928 | 877 |
callVisualPropertyChanged(new VisualPropertyEvent(e.getSource())); |
929 | 878 |
} |
930 | 879 |
|
931 |
/* |
|
932 |
* (non-Javadoc) |
|
933 |
* @see org.gvsig.tools.persistence.Persistent#loadFromState(org.gvsig.tools.persistence.PersistentState) |
|
934 |
*/ |
|
935 | 880 |
public void loadFromState(PersistentState state) |
936 | 881 |
throws PersistenceException { |
937 | 882 |
lastTransparency = (Transparency)state.get("lastTransparency"); |
... | ... | |
939 | 884 |
//setFilterList((RasterFilterList)state.get("filterList")); |
940 | 885 |
} |
941 | 886 |
|
942 |
/* |
|
943 |
* (non-Javadoc) |
|
944 |
* @see org.gvsig.tools.persistence.Persistent#saveToState(org.gvsig.tools.persistence.PersistentState) |
|
945 |
*/ |
|
946 | 887 |
public void saveToState(PersistentState state) throws PersistenceException { |
947 | 888 |
state.set("lastTransparency", lastTransparency); |
948 | 889 |
state.set("renderBands", renderBands); |
... | ... | |
979 | 920 |
} |
980 | 921 |
} |
981 | 922 |
|
982 |
/* |
|
983 |
* (non-Javadoc) |
|
984 |
* @see java.lang.Object#finalize() |
|
985 |
*/ |
|
986 | 923 |
protected void finalize() throws Throwable { |
987 | 924 |
grid = null; |
988 | 925 |
dataStore = 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 | ||
---|---|---|
1193 | 1193 |
dataType[iBand]); |
1194 | 1194 |
int lineInputWindow = 0; |
1195 | 1195 |
if(dataType[iBand] == Gdal.GDT_Byte) { |
1196 |
for (int line = stepBuffer[1]; line < stepBuffer[3]/*buf.getHeight()*/; line++) {
|
|
1196 |
for (int line = stepBuffer[1]; line < stepBuffer[3]; line++) { |
|
1197 | 1197 |
pos = (int)((bufWidth * (lineInputWindow - stepBuffer[0])) + init); |
1198 |
for (int col = stepBuffer[0]; col < stepBuffer[2]/*buf.getWidth()*/; col ++) {
|
|
1198 |
for (int col = stepBuffer[0]; col < stepBuffer[2]; col ++) { |
|
1199 | 1199 |
for (int i = 0; i < drawableBands.length; i++) |
1200 | 1200 |
buf.setElem(line, col, drawableBands[i], gdalBuf.buffByte[pos]); |
1201 | 1201 |
pos ++; |
org.gvsig.raster.tilecache/branches/org.gvsig.raster.tilecache_dataaccess_refactoring/org.gvsig.raster.tilecache.io/src/main/java/org/gvsig/raster/tilecache/io/TileProvider.java | ||
---|---|---|
37 | 37 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
38 | 38 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
39 | 39 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
40 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
41 | 40 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
42 | 41 |
import org.gvsig.fmap.dal.exception.InitializeException; |
43 | 42 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
... | ... | |
68 | 67 |
import org.gvsig.raster.impl.provider.RemoteRasterProvider; |
69 | 68 |
import org.gvsig.raster.impl.provider.TiledRasterProvider; |
70 | 69 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
70 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
71 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
|
71 | 72 |
import org.gvsig.raster.impl.store.properties.RemoteDataStoreStatistics; |
72 | 73 |
import org.gvsig.tools.ToolsLocator; |
73 | 74 |
import org.gvsig.tools.locator.LocatorException; |
... | ... | |
300 | 301 |
DataStoreProviderServices storeServices) throws InitializeException { |
301 | 302 |
setParam(storeServices, params); |
302 | 303 |
open = true; |
303 |
setDataType(provider.getDataType()); |
|
304 |
bandCount = provider.getBandCount(); |
|
305 |
//if(getColorInterpretation() == null) |
|
306 |
setColorInterpretation(provider.getColorInterpretation()); |
|
307 |
/*else |
|
308 |
getColorInterpretation().addColorInterpretation(provider.getColorInterpretation());*/ |
|
304 |
calculateDataType(); |
|
305 |
calculateBandCount(); |
|
306 |
calculateColorInterpretation(); |
|
307 |
calculateTransparency(); |
|
309 | 308 |
setColorTable(provider.getColorTable()); |
310 | 309 |
noData = provider.getNoDataValue(); |
311 | 310 |
setFName(provider.getURIOfFirstProvider()); |
... | ... | |
330 | 329 |
if(provider instanceof RemoteRasterProvider) |
331 | 330 |
stats = new RemoteDataStoreStatistics(provider); |
332 | 331 |
} |
332 |
|
|
333 |
/** |
|
334 |
* Calculates the data type of this provider |
|
335 |
* @return |
|
336 |
*/ |
|
337 |
public void calculateDataType() { |
|
338 |
int[] datatype = null; |
|
339 |
if(provider.getDataType()[0] == Buffer.TYPE_BYTE && provider.getBandCount() == 3) |
|
340 |
datatype = new int[provider.getBandCount() + 1]; |
|
341 |
else |
|
342 |
datatype = new int[provider.getBandCount()]; |
|
343 |
for (int i = 0; i < provider.getDataType().length; i++) { |
|
344 |
datatype[i] = provider.getDataType()[i]; |
|
345 |
} |
|
346 |
if(provider.getDataType()[0] == Buffer.TYPE_BYTE && provider.getBandCount() == 3) |
|
347 |
datatype[datatype.length - 1] = Buffer.TYPE_BYTE; |
|
348 |
setDataType(datatype); |
|
349 |
} |
|
333 | 350 |
|
334 | 351 |
/** |
352 |
* Calculates the number of bands |
|
353 |
*/ |
|
354 |
public void calculateBandCount() { |
|
355 |
bandCount = provider.getBandCount(); |
|
356 |
if(provider.getDataType()[0] == Buffer.TYPE_BYTE && provider.getBandCount() == 3) |
|
357 |
bandCount ++; |
|
358 |
} |
|
359 |
|
|
360 |
/** |
|
361 |
* Calculates the color interpretation |
|
362 |
*/ |
|
363 |
public void calculateColorInterpretation() { |
|
364 |
ColorInterpretation ci = provider.getColorInterpretation(); |
|
365 |
if(ci != null) { |
|
366 |
if(ci.isRGB() || ci.isBGR()) { |
|
367 |
ci = DataStoreColorInterpretation.createARGBInterpretation(); |
|
368 |
} else |
|
369 |
ci = ci.cloneColorInterpretation(); |
|
370 |
super.setColorInterpretation(ci); |
|
371 |
} |
|
372 |
|
|
373 |
if(ci == null) { |
|
374 |
if(provider.getDataType()[0] == Buffer.TYPE_BYTE) { |
|
375 |
if(provider.getBandCount() == 3) |
|
376 |
ci = DataStoreColorInterpretation.createARGBInterpretation(); |
|
377 |
else |
|
378 |
ci = DataStoreColorInterpretation.createDefaultInterpretation(getBandCount()); |
|
379 |
} else { |
|
380 |
if(getBandCount() == 1) |
|
381 |
ci = DataStoreColorInterpretation.createGrayInterpretation(); |
|
382 |
else |
|
383 |
ci = DataStoreColorInterpretation.createDefaultInterpretation(getBandCount()); |
|
384 |
} |
|
385 |
} |
|
386 |
|
|
387 |
setColorInterpretation(ci); |
|
388 |
} |
|
389 |
|
|
390 |
|
|
391 |
public void calculateTransparency() { |
|
392 |
if(provider.getTransparency() != null) |
|
393 |
transparency = provider.getTransparency().cloneTransparency(); |
|
394 |
else |
|
395 |
transparency = new DataStoreTransparency(); |
|
396 |
if(getColorInterpretation() != null) |
|
397 |
transparency.setTransparencyBand(getColorInterpretation().getAlphaBand()); |
|
398 |
} |
|
399 |
|
|
400 |
/** |
|
335 | 401 |
* Creates a new tiled layer if this hasn't been created yet or the ID has changed. |
336 | 402 |
* An ID could changed because the file type has changed when the user uses WMTS properties. |
337 | 403 |
*/ |
... | ... | |
425 | 491 |
} |
426 | 492 |
|
427 | 493 |
/** |
428 |
* Obtiene el objeto que contiene el estado de la transparencia |
|
429 |
*/ |
|
430 |
public Transparency getTransparency() { |
|
431 |
return provider.getTransparency(); |
|
432 |
} |
|
433 |
|
|
434 |
/** |
|
435 | 494 |
* Gets the bounding box in world coordinates. If the layer has grid subsets (TileMatrixLimits) then |
436 | 495 |
* this will have a only extent but if the layer doesn't have grid subsets then this will have a different |
437 | 496 |
* extent in each level resolution. In this case we need to know the extent for each level. |
... | ... | |
746 | 805 |
return "Not implemented"; |
747 | 806 |
} |
748 | 807 |
|
749 |
public ColorInterpretation getColorInterpretation() { |
|
750 |
return provider.getColorInterpretation(); |
|
751 |
} |
|
752 |
|
|
753 | 808 |
/** |
754 | 809 |
* Asigna el objeto que contiene que contiene la interpretaci?n de |
755 | 810 |
* color por banda |
Also available in: Unified diff