Statistics
| Revision:

gvsig-geoprocess / org.gvsig.geoprocess / branches / refactor-2018 / org.gvsig.geoprocess / org.gvsig.geoprocess.lib / org.gvsig.geoprocess.lib.sextante / src / main / java / org / gvsig / geoprocess / lib / sextante / dataObjects / BufferWriteOnlyIRasterLayer.java @ 1057

History | View | Annotate | Download (5.18 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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.geoprocess.lib.sextante.dataObjects;
25

    
26
import java.awt.geom.Rectangle2D;
27

    
28
import es.unex.sextante.core.AnalysisExtent;
29
import es.unex.sextante.dataObjects.AbstractRasterLayer;
30
import es.unex.sextante.gui.core.SextanteGUI;
31
import es.unex.sextante.outputs.IOutputChannel;
32

    
33
import org.cresques.cts.IProjection;
34
import org.gvsig.raster.lib.buffer.api.Buffer;
35
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException;
36

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

    
46
   private String         m_sFilename;
47
   private IProjection    m_Projection;
48
   protected RasterDriver m_RasterDriver;
49

    
50

    
51
   public void create(final String sName,
52
                      final String sFilename,
53
                      final AnalysisExtent ae,
54
                      final int iDataType,
55
                      final int iNumBands,
56
                      final Object crs) throws BufferException {
57

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

    
62
      m_RasterDriver = rmd;
63
      m_sFilename = sFilename;
64
      m_Projection = (IProjection) crs;
65

    
66
   }
67

    
68

    
69
   public void create(final String sName,
70
                      final String sFilename,
71
                      final AnalysisExtent ge,
72
                      final int iDataType,
73
                      final Object crs) throws BufferException {
74

    
75
      create(sName, sFilename, ge, iDataType, 1, crs);
76

    
77
   }
78

    
79

    
80
   @Override
81
   public int getDataType() {
82

    
83
      return m_RasterDriver.getRasterBuf().getBand(0).getDataType();
84

    
85
   }
86

    
87

    
88
   @Override
89
   public void setCellValue(final int x,
90
                            final int y,
91
                            final int iBand,
92
                            final double dValue) {
93

    
94
      m_RasterDriver.setCellValue(x, y, iBand, dValue);
95

    
96
   }
97

    
98

    
99
   @Override
100
   public void setNoDataValue(final double dNoDataValue) {
101

    
102
      m_RasterDriver.setNoDataValue(dNoDataValue);
103

    
104
   }
105

    
106

    
107
   @Override
108
   public void setNoData(final int x,
109
                         final int y) {
110

    
111
      m_RasterDriver.setNoData(x, y);
112

    
113
   }
114

    
115

    
116
   @Override
117
   public double getNoDataValue() {
118

    
119
      return m_RasterDriver.getNoDataValue();
120

    
121
   }
122

    
123

    
124
   @Override
125
   public double getCellValueInLayerCoords(final int x,
126
                                           final int y,
127
                                           final int band) {
128

    
129
      return m_RasterDriver.getCellValue(x, y, band);
130

    
131
   }
132

    
133

    
134
   @Override
135
   public int getBandsCount() {
136

    
137
      return m_RasterDriver.getRasterBuf().getBandCount();
138

    
139
   }
140

    
141

    
142
   @Override
143
   public String getName() {
144

    
145
      return m_RasterDriver.getName();
146

    
147
   }
148

    
149

    
150
   @Override
151
   public void postProcess() {
152

    
153
      m_RasterDriver.export(m_sFilename, m_Projection);
154

    
155
   }
156

    
157

    
158
   @Override
159
   public void open() {
160

    
161
   }
162

    
163

    
164
   @Override
165
   public void close() {
166

    
167
      m_RasterDriver.free();
168

    
169
   }
170

    
171

    
172
   @Override
173
   public Rectangle2D getFullExtent() {
174

    
175
      return m_RasterDriver.getGridExtent().getAsRectangle2D();
176

    
177
   }
178

    
179

    
180
   @Override
181
   public AnalysisExtent getLayerGridExtent() {
182

    
183
      return m_RasterDriver.getGridExtent();
184

    
185
   }
186

    
187

    
188
   @Override
189
   public double getLayerCellSize() {
190

    
191

    
192
      return m_RasterDriver.getGridExtent().getCellSize();
193

    
194

    
195
   }
196

    
197
    /**
198
     *
199
     * @return
200
     */
201
    public String getFilename() {
202

    
203

    
204
      return m_sFilename;
205

    
206
   }
207

    
208

    
209
   @Override
210
   public Object getCRS() {
211

    
212
      return m_Projection;
213

    
214
   }
215

    
216

    
217
   @Override
218
   public void setName(final String name) {
219

    
220
      m_RasterDriver.setName(name);
221

    
222
   }
223

    
224

    
225
   @Override
226
   public Object getBaseDataObject() {
227

    
228
      return m_RasterDriver;
229

    
230
   }
231

    
232

    
233
   @Override
234
    public void free() {
235
        // TODO Auto-generated method stub
236

    
237
    }
238

    
239
   @Override
240
    public IOutputChannel getOutputChannel() {
241
        // TODO Auto-generated method stub
242
        return null;
243
    }
244

    
245
    public Buffer getBuffer() {
246
        return m_RasterDriver.getRasterBuf();
247
    }
248

    
249
}