Statistics
| Revision:

gvsig-geoprocess / org.gvsig.geoprocess / trunk / org.gvsig.geoprocess / org.gvsig.geoprocess.lib / org.gvsig.geoprocess.lib.sextante / src / main / java / org / gvsig / geoprocess / lib / sextante / dataObjects / BufferWriteOnlyIRasterLayer.java @ 242

History | View | Annotate | Download (4.66 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007,2012 gvSIG Association.
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
package org.gvsig.geoprocess.lib.sextante.dataObjects;
22

    
23
import java.awt.geom.Rectangle2D;
24

    
25
import es.unex.sextante.core.AnalysisExtent;
26
import es.unex.sextante.dataObjects.AbstractRasterLayer;
27
import es.unex.sextante.gui.core.SextanteGUI;
28
import es.unex.sextante.outputs.IOutputChannel;
29

    
30
import org.cresques.cts.IProjection;
31

    
32
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
33

    
34
/**
35
 * 
36
 * @author volaya, nacho brodin (nachobrodin@gmail.com)
37
 * 
38
 */
39
public class BufferWriteOnlyIRasterLayer
40
         extends
41
            AbstractRasterLayer {
42

    
43
   private String         m_sFilename;
44
   private IProjection    m_Projection;
45
   protected RasterDriver m_RasterDriver;
46

    
47

    
48
   public void create(final String sName,
49
                      final String sFilename,
50
                      final AnalysisExtent ae,
51
                      final int iDataType,
52
                      final int iNumBands,
53
                      final Object crs) {
54

    
55
      final RasterDriver rmd = new RasterDriver(ae, iDataType, iNumBands);
56
      rmd.setName(sName);
57
        rmd.setNoDataValue(SextanteGUI.getOutputFactory()
58
            .getDefaultNoDataValue());
59

    
60
      m_RasterDriver = rmd;
61
      m_sFilename = sFilename;
62
      m_Projection = (IProjection) crs;
63

    
64
   }
65

    
66

    
67
   public void create(final String sName,
68
                      final String sFilename,
69
                      final AnalysisExtent ge,
70
                      final int iDataType,
71
                      final Object crs) {
72

    
73
      create(sName, sFilename, ge, iDataType, 1, crs);
74

    
75
   }
76

    
77

    
78
   public int getDataType() {
79

    
80
      return m_RasterDriver.getRasterBuf().getDataType();
81

    
82
   }
83

    
84

    
85
   public void setCellValue(final int x,
86
                            final int y,
87
                            final int iBand,
88
                            final double dValue) {
89

    
90
      m_RasterDriver.setCellValue(x, y, iBand, dValue);
91

    
92
   }
93

    
94

    
95
   public void setNoDataValue(final double dNoDataValue) {
96

    
97
      m_RasterDriver.setNoDataValue(dNoDataValue);
98

    
99
   }
100

    
101

    
102
   @Override
103
   public void setNoData(final int x,
104
                         final int y) {
105

    
106
      m_RasterDriver.setNoData(x, y);
107

    
108
   }
109

    
110

    
111
   public double getNoDataValue() {
112

    
113
      return m_RasterDriver.getNoDataValue();
114

    
115
   }
116

    
117

    
118
   public double getCellValueInLayerCoords(final int x,
119
                                           final int y,
120
                                           final int band) {
121

    
122
      return m_RasterDriver.getCellValue(x, y, band);
123

    
124
   }
125

    
126

    
127
   public int getBandsCount() {
128

    
129
      return m_RasterDriver.getRasterBuf().getBandCount();
130

    
131
   }
132

    
133

    
134
   public String getName() {
135

    
136
      return m_RasterDriver.getName();
137

    
138
   }
139

    
140

    
141
   public void postProcess() {
142

    
143
      m_RasterDriver.export(m_sFilename, m_Projection);
144

    
145
   }
146

    
147

    
148
   public void open() {
149

    
150
   }
151

    
152

    
153
   public void close() {
154

    
155
      m_RasterDriver.free();
156

    
157
   }
158

    
159

    
160
   public Rectangle2D getFullExtent() {
161

    
162
      return m_RasterDriver.getGridExtent().getAsRectangle2D();
163

    
164
   }
165

    
166

    
167
   public AnalysisExtent getLayerGridExtent() {
168

    
169
      return m_RasterDriver.getGridExtent();
170

    
171
   }
172

    
173

    
174
   public double getLayerCellSize() {
175

    
176

    
177
      return m_RasterDriver.getGridExtent().getCellSize();
178

    
179

    
180
   }
181

    
182

    
183
   public String getFilename() {
184

    
185

    
186
      return m_sFilename;
187

    
188
   }
189

    
190

    
191
   public Object getCRS() {
192

    
193
      return m_Projection;
194

    
195
   }
196

    
197

    
198
   public void setName(final String name) {
199

    
200
      m_RasterDriver.setName(name);
201

    
202
   }
203

    
204

    
205
   public Object getBaseDataObject() {
206

    
207
      return m_RasterDriver;
208

    
209
   }
210

    
211

    
212
    public void free() {
213
        // TODO Auto-generated method stub
214

    
215
    }
216

    
217
    public IOutputChannel getOutputChannel() {
218
        // TODO Auto-generated method stub
219
        return null;
220
    }
221

    
222
    public Buffer getBuffer() {
223
        return m_RasterDriver.getRasterBuf();
224
    }
225

    
226
}