root / tags / v1_1_Build_1007 / libraries / libCq_CMS_praster / src / org / cresques / io / data / WriterBufferServer.java @ 12478
History | View | Annotate | Download (3.36 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.cresques.io.data; |
20 |
|
21 |
import org.cresques.io.IDataWriter; |
22 |
|
23 |
/**
|
24 |
* Sirve los datos desde un RasterBuf para el driver de escritura de bloques de
|
25 |
* cach?. La altura servida ser? igual a la del bloque de cache.
|
26 |
*
|
27 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
28 |
*/
|
29 |
public class WriterBufferServer implements IDataWriter{ |
30 |
private RasterBuf buffer = null; |
31 |
|
32 |
public WriterBufferServer(RasterBuf buffer){
|
33 |
this.buffer = buffer;
|
34 |
} |
35 |
|
36 |
public int[] readARGBData(int sizeX, int sizeY, int nBand) { |
37 |
return null; |
38 |
} |
39 |
|
40 |
public byte[][] readByteData(int sizeX, int sizeY) { |
41 |
int len = buffer.getWidth() * buffer.getHeight();
|
42 |
byte[][] b = new byte[buffer.getBandCount()][len]; |
43 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
44 |
for(int j = 0; j < buffer.getHeight(); j ++) |
45 |
for(int i = 0; i < buffer.getWidth(); i ++) |
46 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemByte(j, i, iBand); |
47 |
return b;
|
48 |
} |
49 |
|
50 |
public short[][] readShortData(int sizeX, int sizeY) { |
51 |
int len = buffer.getWidth() * buffer.getHeight();
|
52 |
short[][] b = new short[buffer.getBandCount()][len]; |
53 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
54 |
for(int j = 0; j < buffer.getHeight(); j ++) |
55 |
for(int i = 0; i < buffer.getWidth(); i ++) |
56 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemShort(j, i, iBand); |
57 |
return b;
|
58 |
} |
59 |
|
60 |
public int[][] readIntData(int sizeX, int sizeY) { |
61 |
int len = buffer.getWidth() * buffer.getHeight();
|
62 |
int[][] b = new int[buffer.getBandCount()][len]; |
63 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
64 |
for(int j = 0; j < buffer.getHeight(); j ++) |
65 |
for(int i = 0; i < buffer.getWidth(); i ++) |
66 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemInt(j, i, iBand); |
67 |
return b;
|
68 |
} |
69 |
|
70 |
public float[][] readFloatData(int sizeX, int sizeY) { |
71 |
int len = buffer.getWidth() * buffer.getHeight();
|
72 |
float[][] b = new float[buffer.getBandCount()][len]; |
73 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
74 |
for(int j = 0; j < buffer.getHeight(); j ++) |
75 |
for(int i = 0; i < buffer.getWidth(); i ++) |
76 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemFloat(j, i, iBand); |
77 |
return b;
|
78 |
} |
79 |
|
80 |
public double[][] readDoubleData(int sizeX, int sizeY) { |
81 |
int len = buffer.getWidth() * buffer.getHeight();
|
82 |
double[][] b = new double[buffer.getBandCount()][len]; |
83 |
for(int iBand = 0; iBand < buffer.getBandCount(); iBand ++) |
84 |
for(int j = 0; j < buffer.getHeight(); j ++) |
85 |
for(int i = 0; i < buffer.getWidth(); i ++) |
86 |
b[iBand][j * buffer.getWidth() + i] = buffer.getElemDouble(j, i, iBand); |
87 |
return b;
|
88 |
} |
89 |
} |