svn-gvsig-desktop / trunk / libraries / libRaster / src / org / gvsig / raster / dataaccess / cache / WriterBufferServer.java @ 10756
History | View | Annotate | Download (3.58 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.raster.dataaccess.cache; |
20 |
|
21 |
import org.gvsig.raster.driver.IBuffer; |
22 |
import org.gvsig.raster.driver.IDataWriter; |
23 |
|
24 |
/**
|
25 |
* Sirve los datos desde un IBuffer para el driver de escritura de bloques de
|
26 |
* cach?. La altura servida ser? igual a la del bloque de cache.
|
27 |
*
|
28 |
* @deprecated Esta clase fue creada para que CacheDataServer salvara sus datos a tif.
|
29 |
* Se ha cambiado por la escritura de los bytes en disco porque era m?s ?ptimo.
|
30 |
*
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
32 |
*/
|
33 |
public class WriterBufferServer implements IDataWriter{ |
34 |
private IBuffer buffer = null; |
35 |
|
36 |
public WriterBufferServer(IBuffer buffer){
|
37 |
this.buffer = buffer;
|
38 |
} |
39 |
|
40 |
public int[] readARGBData(int sizeX, int sizeY, int nBand) { |
41 |
return null; |
42 |
} |
43 |
|
44 |
public byte[][] readByteData(int sizeX, int sizeY) { |
45 |
int len = buffer.getWidth() * buffer.getHeight();
|
46 |
byte[][] b = new byte[buffer.getBandCount()][len]; |
47 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
48 |
for(int j = 0; j < buffer.getHeight(); j ++) |
49 |
for(int i = 0; i < buffer.getWidth(); i ++) |
50 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemByte(j, i, iBand); |
51 |
return b;
|
52 |
} |
53 |
|
54 |
public short[][] readShortData(int sizeX, int sizeY) { |
55 |
int len = buffer.getWidth() * buffer.getHeight();
|
56 |
short[][] b = new short[buffer.getBandCount()][len]; |
57 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
58 |
for(int j = 0; j < buffer.getHeight(); j ++) |
59 |
for(int i = 0; i < buffer.getWidth(); i ++) |
60 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemShort(j, i, iBand); |
61 |
return b;
|
62 |
} |
63 |
|
64 |
public int[][] readIntData(int sizeX, int sizeY) { |
65 |
int len = buffer.getWidth() * buffer.getHeight();
|
66 |
int[][] b = new int[buffer.getBandCount()][len]; |
67 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
68 |
for(int j = 0; j < buffer.getHeight(); j ++) |
69 |
for(int i = 0; i < buffer.getWidth(); i ++) |
70 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemInt(j, i, iBand); |
71 |
return b;
|
72 |
} |
73 |
|
74 |
public float[][] readFloatData(int sizeX, int sizeY) { |
75 |
int len = buffer.getWidth() * buffer.getHeight();
|
76 |
float[][] b = new float[buffer.getBandCount()][len]; |
77 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
78 |
for(int j = 0; j < buffer.getHeight(); j ++) |
79 |
for(int i = 0; i < buffer.getWidth(); i ++) |
80 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemFloat(j, i, iBand); |
81 |
return b;
|
82 |
} |
83 |
|
84 |
public double[][] readDoubleData(int sizeX, int sizeY) { |
85 |
int len = buffer.getWidth() * buffer.getHeight();
|
86 |
double[][] b = new double[buffer.getBandCount()][len]; |
87 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
88 |
for(int j = 0; j < buffer.getHeight(); j ++) |
89 |
for(int i = 0; i < buffer.getWidth(); i ++) |
90 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemDouble(j, i, iBand); |
91 |
return b;
|
92 |
} |
93 |
} |