Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / buffer / cache / WriterBufferCompleteServer.java @ 2623

History | View | Annotate | Download (4.71 KB)

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.buffer.cache;
23

    
24
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
25
import org.gvsig.fmap.dal.coverage.store.DataServerWriter;
26

    
27
/**
28
 * Sirve los datos desde un Buffer para el driver de escritura de bloques de 
29
 * cach?. La altura servida ser? igual a la del bloque de cache.
30
 * 
31
 * @deprecated Esta clase fue creada para que CacheDataServer salvara sus datos a tif. 
32
 * Se ha cambiado por la escritura de los bytes en disco porque era m?s ?ptimo. 
33
 * 
34
 * NO DEBE BORRARSE porque se usa para test pero no deber?a utilizarse para el trabajo
35
 * normal de escritura.
36
 * 
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 */
39
public class WriterBufferCompleteServer implements DataServerWriter {
40
        private Buffer                 buffer = null;
41
        private int         nband  = -1;
42

    
43
        public WriterBufferCompleteServer(Buffer buffer){
44
                this.buffer = buffer;
45
        }
46

    
47
        public int[] readARGBData(int sizeX, int sizeY, int nBand) {
48
                return null;
49
        }
50

    
51
        public byte[][] readByteData(int sizeX, int sizeY) {
52
                int len = buffer.getWidth() * buffer.getHeight();
53
                byte[][] b = new byte[buffer.getBandCount()][len];
54
                int init = 0;
55
                int end = buffer.getBandCount();
56
                if(nband >= 0) {
57
                        init = nband;
58
                        end = nband + 1;
59
                }
60
                for(int iBand = init; iBand < end; iBand ++)
61
                        for(int j = 0; j < buffer.getHeight(); j ++)
62
                                for(int i = 0; i < buffer.getWidth(); i ++)
63
                                        b[iBand][j * buffer.getWidth() + i] = buffer.getElemByte(j, i, iBand);
64
                return b;
65
        }
66

    
67
        public short[][] readShortData(int sizeX, int sizeY) {
68
                int len = buffer.getWidth() * buffer.getHeight();
69
                short[][] b = new short[buffer.getBandCount()][len];
70
                int init = 0;
71
                int end = buffer.getBandCount();
72
                if(nband >= 0) {
73
                        init = nband;
74
                        end = nband + 1;
75
                }
76
                for(int iBand = init; iBand < end; iBand ++)
77
                        for(int j = 0; j < buffer.getHeight(); j ++)
78
                                for(int i = 0; i < buffer.getWidth(); i ++)
79
                                        b[iBand][j * buffer.getWidth() + i] = buffer.getElemShort(j, i, iBand);
80
                return b;
81
        }
82

    
83
        public int[][] readIntData(int sizeX, int sizeY) {
84
                int len = buffer.getWidth() * buffer.getHeight();
85
                int[][] b = new int[buffer.getBandCount()][len];
86
                int init = 0;
87
                int end = buffer.getBandCount();
88
                if(nband >= 0) {
89
                        init = nband;
90
                        end = nband + 1;
91
                }
92
                for(int iBand = init; iBand < end; iBand ++)
93
                        for(int j = 0; j < buffer.getHeight(); j ++)
94
                                for(int i = 0; i < buffer.getWidth(); i ++)
95
                                        b[iBand][j * buffer.getWidth() + i] = buffer.getElemInt(j, i, iBand);
96
                return b;
97
        }
98

    
99
        public float[][] readFloatData(int sizeX, int sizeY) {
100
                int len = buffer.getWidth() * buffer.getHeight();
101
                float[][] b = new float[buffer.getBandCount()][len];
102
                int init = 0;
103
                int end = buffer.getBandCount();
104
                if(nband >= 0) {
105
                        init = nband;
106
                        end = nband + 1;
107
                }
108
                for(int iBand = init; iBand < end; iBand ++)
109
                        for(int j = 0; j < buffer.getHeight(); j ++)
110
                                for(int i = 0; i < buffer.getWidth(); i ++)
111
                                        b[iBand][j * buffer.getWidth() + i] = buffer.getElemFloat(j, i, iBand);
112
                return b;
113
        }
114

    
115
        public double[][] readDoubleData(int sizeX, int sizeY) {
116
                int len = buffer.getWidth() * buffer.getHeight();
117
                double[][] b = new double[buffer.getBandCount()][len];
118
                int init = 0;
119
                int end = buffer.getBandCount();
120
                if(nband >= 0) {
121
                        init = nband;
122
                        end = nband + 1;
123
                }
124
                for(int iBand = init; iBand < end; iBand ++)
125
                        for(int j = 0; j < buffer.getHeight(); j ++)
126
                                for(int i = 0; i < buffer.getWidth(); i ++)
127
                                        b[iBand][j * buffer.getWidth() + i] = buffer.getElemDouble(j, i, iBand);
128
                return b;
129
        }
130

    
131
        public void setBuffer(Buffer buffer, int nband) {
132
                this.buffer = buffer;
133
                this.nband = nband;
134
        }
135
        
136
        public Buffer getBuffer() {
137
                return buffer;
138
        }
139
        
140
        public void setBand(int nband) {
141
                this.nband = nband;
142
        }
143
        
144
        public int getPercent() {
145
                return 0;
146
        }
147

    
148
        public void setAlphaBuffer(Buffer alphaBuffer) {
149
        }
150

    
151
        public void dispose() {
152
        }
153

    
154
        public Buffer getSource() {
155
                return buffer;
156
        }
157

    
158
        public void setPercent(int value) {
159
        }
160
}