Revision 15931
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/RasterDataset.java | ||
---|---|---|
539 | 539 |
* @param bufHeight Alto del buffer |
540 | 540 |
* @return Array de dos elementos con el desplazamiento en X e Y. |
541 | 541 |
*/ |
542 |
public int[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
|
|
542 |
public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
|
|
543 | 543 |
double nWidth, double nHeight, int bufWidth, int bufHeight){ |
544 | 544 |
|
545 | 545 |
Point2D p1 = new Point2D.Double(dWorldTLX, dWorldTLY); |
... | ... | |
551 | 551 |
int x = (int) tl.getX(); |
552 | 552 |
int y = (int) tl.getY(); |
553 | 553 |
|
554 |
int stpX = (int)(((tl.getX() - x) * bufWidth) / Math.abs(br.getX() - tl.getX())); |
|
555 |
int stpY = (int)(((tl.getY() - y) * bufHeight) / Math.abs(br.getY() - tl.getY())); |
|
556 |
|
|
557 |
return new int[]{stpX, stpY}; |
|
554 |
double stpX = (int)(((tl.getX() - x) * bufWidth) / Math.abs(br.getX() - tl.getX())); |
|
555 |
double stpY = (int)(((tl.getY() - y) * bufHeight) / Math.abs(br.getY() - tl.getY())); |
|
556 |
double wPx = (bufWidth / Math.abs(br.getX() - tl.getX())); |
|
557 |
double hPx = (bufHeight / Math.abs(br.getY() - tl.getY())); |
|
558 |
return new double[]{stpX, stpY, wPx, hPx}; |
|
558 | 559 |
} |
559 | 560 |
|
560 | 561 |
/** |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/CompositeDataset.java | ||
---|---|---|
247 | 247 |
* (non-Javadoc) |
248 | 248 |
* @see org.gvsig.raster.dataset.IRasterDataSource#calcSteps(double, double, double, double, double, double, int, int) |
249 | 249 |
*/ |
250 |
public int[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY, double nWidth, double nHeight, int bufWidth, int bufHeight) {
|
|
250 |
public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY, double nWidth, double nHeight, int bufWidth, int bufHeight) {
|
|
251 | 251 |
if(mosaic != null) |
252 | 252 |
return mosaic[0][0].calcSteps(dWorldTLX, dWorldTLY, dWorldBRX, dWorldBRY, nWidth, nHeight, bufWidth, bufHeight); |
253 | 253 |
return null; |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/MultiRasterDataset.java | ||
---|---|---|
947 | 947 |
* (non-Javadoc) |
948 | 948 |
* @see org.gvsig.raster.dataset.IRasterDataSource#calcSteps(double, double, double, double, double, double, int, int) |
949 | 949 |
*/ |
950 |
public int[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
|
|
950 |
public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
|
|
951 | 951 |
double nWidth, double nHeight, int bufWidth, int bufHeight){ |
952 | 952 |
return ((RasterDataset)files.get(0)).calcSteps(dWorldTLX, dWorldTLY, dWorldBRX, dWorldBRY, nWidth, nHeight, bufWidth, bufHeight); |
953 | 953 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/IRasterDataSource.java | ||
---|---|---|
335 | 335 |
* @param nHeight Alto del raster |
336 | 336 |
* @param bufWidth Ancho del buffer |
337 | 337 |
* @param bufHeight Alto del buffer |
338 |
* @return Array de dos elementos con el desplazamiento en X e Y. |
|
338 |
* @return Array de cuatro. Los dos primeros elementos son el desplazamiento en X e Y y los dos segundos |
|
339 |
* el tama?o en pixels de buffer de un pixel de la imagen en ancho y alto. |
|
339 | 340 |
*/ |
340 |
public int[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
|
|
341 |
public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
|
|
341 | 342 |
double nWidth, double nHeight, int bufWidth, int bufHeight); |
342 | 343 |
|
343 | 344 |
/** |
trunk/libraries/libRaster/src/org/gvsig/raster/grid/render/ImageDrawer.java | ||
---|---|---|
37 | 37 |
/** |
38 | 38 |
* Fuente de datos para el renderizado |
39 | 39 |
*/ |
40 |
private IBuffer rasterBuf = null;
|
|
41 |
private GridTransparency transparency = null;
|
|
42 |
private int[] step = null;
|
|
40 |
private IBuffer rasterBuf = null;
|
|
41 |
private GridTransparency transparency = null;
|
|
42 |
private double[] step = null;
|
|
43 | 43 |
/** |
44 | 44 |
* Ancho y alto del objeto image |
45 | 45 |
*/ |
46 |
private int width = 0; |
|
47 |
private int height = 0; |
|
48 |
/** |
|
49 |
* Ancho y alto en pixeles del ?ltimo buffer asignado |
|
50 |
*/ |
|
51 |
private double nWidth = 0; |
|
52 |
private double nHeight = 0; |
|
46 |
private int width = 0; |
|
47 |
private int height = 0; |
|
53 | 48 |
|
49 |
|
|
54 | 50 |
/** |
55 | 51 |
* Dibuja el buffer sobre un objeto Image de java.awt y devuelve el resultado. |
56 | 52 |
* |
... | ... | |
91 | 87 |
} |
92 | 88 |
|
93 | 89 |
/** |
94 |
* Calcula los vectores de desplazamiento en pixels en X e Y cuando se supersamplea.
|
|
90 |
* Calcula los vectores de desplazamiento en pixels en X e Y cuando se supersamplea. |
|
95 | 91 |
* @param r Array de desplazamientos para las filas. Debe tener espacio reservado |
96 |
* @param c Array de desplazamientos para las columnas. Debe tener espacio reservado |
|
97 |
* @param rel relaci?n entre el ancho o alto del objeto Image y el ancho o alto del buffer con los pixels |
|
92 |
* @param c Array de desplazamientos para las columnas. Debe tener espacio reservado |
|
98 | 93 |
* cargados. |
99 | 94 |
*/ |
100 |
private void calcSupersamplingStepsArrays(int[] r, int[] c, double relRow, double relCol) { |
|
101 |
for(int row = 0; row < r.length; row ++) |
|
102 |
r[row] = (int)((row + step[1]) / relRow); |
|
103 |
|
|
104 |
for(int col = 0; col < c.length; col ++) |
|
105 |
c[col] = (int)((col + step[0]) / relCol); |
|
95 |
private void calcSupersamplingStepsArrays(int[] r, int[] c) { |
|
96 |
double pos = step[1]; |
|
97 |
for(int row = 0; row < r.length; row ++) { |
|
98 |
r[row] = (int)(pos / step[3]); |
|
99 |
pos ++; |
|
100 |
} |
|
101 |
pos = step[0]; |
|
102 |
for(int col = 0; col < c.length; col ++) { |
|
103 |
c[col] = (int)(pos / step[2]); |
|
104 |
pos ++; |
|
105 |
} |
|
106 | 106 |
} |
107 | 107 |
|
108 | 108 |
/** |
... | ... | |
115 | 115 |
if(supersampling) { |
116 | 116 |
int[] r = new int[height]; |
117 | 117 |
int[] c = new int[width]; |
118 |
calcSupersamplingStepsArrays(r, c, (double)((double)height / (rasterBuf.getHeight() - 1)), (double)((double)width / (rasterBuf.getWidth() - 1)));
|
|
118 |
calcSupersamplingStepsArrays(r, c); |
|
119 | 119 |
for(int row = 0; row < height; row ++) { |
120 | 120 |
for(int col = 0; col < width; col ++) { |
121 | 121 |
try { |
... | ... | |
155 | 155 |
if(supersampling) { |
156 | 156 |
int[] r = new int[height]; |
157 | 157 |
int[] c = new int[width]; |
158 |
calcSupersamplingStepsArrays(r, c, (double)((double)height/ nHeight), (double)((double)width / nWidth));
|
|
158 |
calcSupersamplingStepsArrays(r, c); |
|
159 | 159 |
for(int row = 0; row < height; row ++) { |
160 | 160 |
for(int col = 0; col < width; col ++) { |
161 | 161 |
try{ |
... | ... | |
306 | 306 |
* a este buffer de datos leidos independientemente del zoom que tengamos. |
307 | 307 |
* @param step Desplazamiento |
308 | 308 |
*/ |
309 |
public void setStep(int[] step) {
|
|
309 |
public void setStep(double[] step) {
|
|
310 | 310 |
this.step = step; |
311 | 311 |
} |
312 | 312 |
|
... | ... | |
321 | 321 |
this.height = h; |
322 | 322 |
} |
323 | 323 |
|
324 |
/** |
|
325 |
* Asigna el ancho y el alto en pixeles a dibujar. Esto es util para cuando hay supersampling |
|
326 |
* ya que necesitamos saber la relaci?n entre el ancho o alto del objeto image y en ancho o alto en pixels |
|
327 |
* del buffer. No vale la informaci?n contenida en rasterBuf (ni rasterBuf.getWidth ni rasterBuf.getHeight) |
|
328 |
* ya que esta es entera y necesitamos el valor en double para mantener la precisi?n del calculo. |
|
329 |
* @param w Ancho |
|
330 |
* @param h Alto |
|
331 |
*/ |
|
332 |
public void setPixelsToDrawSize(double w, double h) { |
|
333 |
this.nWidth = w; |
|
334 |
this.nHeight = h; |
|
335 |
} |
|
336 |
|
|
337 | 324 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/grid/render/Rendering.java | ||
---|---|---|
205 | 205 |
if ((widthImage <= 0) || (heightImage <= 0)) |
206 | 206 |
return; |
207 | 207 |
|
208 |
int[] step = null;
|
|
208 |
double[] step = null;
|
|
209 | 209 |
|
210 | 210 |
if (bufferFactory != null) { |
211 | 211 |
if (lastTransparency == null) |
... | ... | |
246 | 246 |
drawer.setTransparency(lastTransparency); // Objeto con la info de transparencia |
247 | 247 |
drawer.setStep(step); // Desplazamiento para supersampleo |
248 | 248 |
drawer.setBufferSize((int)Math.round(widthImage), (int)Math.round(heightImage)); // Ancho y alto del buffer |
249 |
drawer.setPixelsToDrawSize(bufferFactory.getNWidth(), bufferFactory.getNHeight()); // Ancho y alto del buffer |
|
250 | 249 |
geoImage = drawer.drawBufferOverImageObject(replicateBand, getRenderBands()); // Acci?n de renderizado |
251 | 250 |
|
252 | 251 |
//En el caso de no tenga rotaci?n y el tama?o de pixel sea positivo en X y negativo en Y no aplicamos ninguna |
trunk/libraries/libRaster/src/org/gvsig/raster/buffer/BufferFactory.java | ||
---|---|---|
289 | 289 |
* @throws ArrayIndexOutOfBoundsException |
290 | 290 |
* @throws InvalidSetViewException |
291 | 291 |
*/ |
292 |
public int[] setAreaOfInterest(double ulx, double uly, double lrx, double lry, int bufWidth, int bufHeight)
|
|
292 |
public double[] setAreaOfInterest(double ulx, double uly, double lrx, double lry, int bufWidth, int bufHeight)
|
|
293 | 293 |
throws ArrayIndexOutOfBoundsException, InvalidSetViewException, InterruptedException { |
294 | 294 |
dataExtent = new Extent(ulx, uly, lrx, lry); |
295 | 295 |
Extent adjustedDataExtent = RasterUtilities.calculateAdjustedView(dataExtent, mDataset.getAffineTransform(), new Dimension((int)mDataset.getWidth(), (int)mDataset.getHeight())); |
... | ... | |
309 | 309 |
|
310 | 310 |
if(bufWidth > Math.ceil(nWidth) && bufHeight > Math.ceil(nHeight)) { |
311 | 311 |
rasterBuf = mDataset.getWindowRaster(adjustedDataExtent.getULX(), adjustedDataExtent.getULY(), adjustedDataExtent.getLRX(), adjustedDataExtent.getLRY()); |
312 |
int[] step = mDataset.calcSteps(adjustedDataExtent.getULX(), adjustedDataExtent.getULY(), adjustedDataExtent.getLRX(), adjustedDataExtent.getLRY(), nWidth, nHeight, bufWidth, bufHeight);
|
|
312 |
double[] step = mDataset.calcSteps(adjustedDataExtent.getULX(), adjustedDataExtent.getULY(), adjustedDataExtent.getLRX(), adjustedDataExtent.getLRY(), nWidth, nHeight, bufWidth, bufHeight);
|
|
313 | 313 |
return step; |
314 | 314 |
} |
315 | 315 |
} |
... | ... | |
325 | 325 |
* @param rasterBuf Buffer de salida. |
326 | 326 |
* @throws InvalidSetViewException |
327 | 327 |
*/ |
328 |
private int[] requestFillingWithNoData(Extent requestExtent, Extent fitExtent, int bufWidth, int bufHeight) throws InvalidSetViewException, InterruptedException {
|
|
328 |
private double[] requestFillingWithNoData(Extent requestExtent, Extent fitExtent, int bufWidth, int bufHeight) throws InvalidSetViewException, InterruptedException {
|
|
329 | 329 |
double error = 0.01; |
330 | 330 |
//Upper Left |
331 | 331 |
double distWcX = Math.abs(fitExtent.getMin().getX() - dataExtent.getMin().getX()); |
... | ... | |
433 | 433 |
* @param bufHeight Alto del buffer |
434 | 434 |
* @return Array de dos elementos con el desplazamiento en X e Y. |
435 | 435 |
*/ |
436 |
public int[] calcSteps(double ulx, double uly, double lrx, double lry,
|
|
436 |
public double[] calcSteps(double ulx, double uly, double lrx, double lry,
|
|
437 | 437 |
double nWidth, double nHeight, int bufWidth, int bufHeight) { |
438 | 438 |
Point2D p1 = mDataset.worldToRaster(new Point2D.Double(ulx, uly)); |
439 | 439 |
Point2D p2 = mDataset.worldToRaster(new Point2D.Double(lrx, lry)); |
Also available in: Unified diff