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 / DefaultRasterQuery.java @ 859

History | View | Annotate | Download (12 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;
23

    
24
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
25
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
26
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
27
import org.gvsig.raster.cache.tile.provider.CacheStruct;
28
import org.gvsig.raster.cache.tile.provider.TileListener;
29
import org.gvsig.timesupport.Time;
30
import org.gvsig.tools.persistence.PersistentState;
31
import org.gvsig.tools.persistence.exception.PersistenceException;
32

    
33
/**
34
 * Default implementation for RasterQuery
35
 * 
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 */
38
public class DefaultRasterQuery implements RasterQuery {
39
        public static final int  TYPE_ENTIRE                = 0;
40
        public static final int  TYPE_COORDS                = 1;
41
        public static final int  TYPE_COORDS_SIZE           = 2;
42
        public static final int  TYPE_PX                    = 3;
43
        public static final int  TYPE_PX_SIZE               = 4;
44
        public static final int  TYPE_COORDS_SIZE_TILED     = 5;
45
        public static final int  TYPE_ONE_TILE              = 6;
46
        
47
        private int              type                       = 0;
48
        
49
        private double           x                          = 0;
50
        private double           y                          = 0;
51
        private double           w                          = 0;
52
        private double           h                          = 0;
53
        
54
        private int              pixelX                     = 0;
55
        private int              pixelY                     = 0;
56
        private int              pixelW                     = 0;
57
        private int              pixelH                     = 0;
58
        
59
        private Extent           bbox                       = null;
60
        
61
        private int              bufWidth                   = 0;
62
        private int              bufHeight                  = 0;
63
        
64
        private boolean          adjustToExtent             = true;
65
        private int[]            drawableBands              = new int[]{0};
66
        private boolean          readOnly                   = false;
67
        private boolean          memoryBuffer               = false;
68
        private boolean          storeLastBuffer            = false;
69
        private Time             time                       = null;
70
        
71
        private int              resolutionLevel            = -1;
72
        
73
        /**
74
         * Activa o desactiva el supersampleo en la carga del buffer.
75
         */
76
        private boolean                         supersamplingLoadingBuffer = true;
77
        /**
78
         * Valor NoData con el que se rellenan las celdas cuando adjustToExtent es false
79
         */
80
        private NoData           noDataValueToFill          = null;
81
        
82
        private int              frameWidth                 = 0;
83
        private TileListener     listener                   = null;
84
        private int              alphaBandNumber            = -1;
85
        private int              tileRow                    = 0;
86
        private int              tileCol                    = 0;
87
        private CacheStruct      cacheStruct                = null;   
88
        
89
        /*
90
         * (non-Javadoc)
91
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest(double, double, double, double)
92
         */
93
        public void setAreaOfInterest(double x, double y, double w, double h) {
94
                this.x = x;
95
                this.y = y;
96
                this.w = w;
97
                this.h = h;
98
                this.type = TYPE_COORDS;
99
        }
100
        
101
        /*
102
         * (non-Javadoc)
103
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest(double, double, double, double, int, int)
104
         */
105
        public void setAreaOfInterest(Extent bbox, int bufWidth, int bufHeight) {
106
                this.bbox = bbox;
107
                this.bufWidth = bufWidth;
108
                this.bufHeight = bufHeight;
109
                this.type = TYPE_COORDS_SIZE;
110
        }
111
        
112
        /*
113
         * (non-Javadoc)
114
         * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setAreaOfInterest(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.grid.render.TileListener, int)
115
         */
116
        public void setAreaOfInterest(Extent bbox, 
117
                        int bufWidth, int bufHeight, TileListener listener) {
118
                this.bbox = bbox;;
119
                this.bufWidth = bufWidth;
120
                this.bufHeight = bufHeight;
121
                this.type = TYPE_COORDS_SIZE_TILED;
122
                this.listener = listener;
123
        }
124
        
125
        /*
126
         * (non-Javadoc)
127
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest(int, int, int, int)
128
         */
129
        public void setAreaOfInterest(int x, int y, int w, int h) {
130
                this.pixelX = x;
131
                this.pixelY = y;
132
                this.pixelW = w;
133
                this.pixelH = h;
134
                this.type = TYPE_PX;
135
        }
136
        
137
        /*
138
         * (non-Javadoc)
139
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest()
140
         */
141
        public void setAreaOfInterest() {
142
                this.type = TYPE_ENTIRE;
143
        }
144
        
145
        /*
146
         * (non-Javadoc)
147
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAreaOfInterest(int, int, int, int, int, int)
148
         */
149
        public void setAreaOfInterest(int x, int y, int w, int h, int bufWidth,
150
                        int bufHeight) {
151
                this.pixelX = x;
152
                this.pixelY = y;
153
                this.pixelW = w;
154
                this.pixelH = h;
155
                this.bufWidth = bufWidth;
156
                this.bufHeight = bufHeight;
157
                this.type = TYPE_PX_SIZE;
158
        }
159
        
160
        /*
161
         * (non-Javadoc)
162
         * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setTileParameters(int, int, int, org.gvsig.fmap.dal.coverage.datastruct.Extent, org.gvsig.raster.cache.tile.provider.CacheStruct)
163
         */
164
        public void setTileParameters(int level, int tileCol, int tileRow, Extent bbox, CacheStruct cacheStruct) {
165
                this.type = TYPE_ONE_TILE;
166
                this.bbox = bbox;
167
                this.resolutionLevel = level;
168
                this.tileRow = tileRow;
169
                this.tileCol = tileCol;
170
                this.cacheStruct = cacheStruct;
171
                int[] size = cacheStruct.getTileSizeByLevel(level);
172
                this.bufWidth = size[0];
173
                this.bufHeight = size[1];
174
        }
175
        
176
        /*
177
         * (non-Javadoc)
178
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#storeLastBuffer(boolean)
179
         */
180
        public void storeLastBuffer(boolean store) {
181
                this.storeLastBuffer = store;
182
        }
183
        
184
        /**
185
         * The user can told if the buffer will be stored or not in the RasterDatasource.
186
         * @return store
187
         */
188
        public boolean isStoredLastBuffer() {
189
                return storeLastBuffer;
190
        }
191

    
192
        /*
193
         * (non-Javadoc)
194
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAdjustToExtent(boolean)
195
         */
196
        public void setAdjustToExtent(boolean adjustToExtent) {
197
                this.adjustToExtent = adjustToExtent;
198
        }
199
        
200
        /*
201
         * (non-Javadoc)
202
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#isAdjustToExtent()
203
         */
204
        public boolean isAdjustToExtent() {
205
                return adjustToExtent;
206
        }
207
        
208
        /*
209
         * (non-Javadoc)
210
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#getDrawableBands()
211
         */
212
        public int[] getDrawableBands() {
213
                return drawableBands;
214
        }
215

    
216
        /*
217
         * (non-Javadoc)
218
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setAllDrawableBands()
219
         */
220
        public void setAllDrawableBands() {
221
                this.drawableBands = null;
222
        }
223

    
224
        /*
225
         * (non-Javadoc)
226
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setDrawableBands(int[])
227
         */
228
        public void setDrawableBands(int[] drawableBands) {
229
                this.drawableBands = drawableBands;
230
        }
231

    
232
        /*
233
         * (non-Javadoc)
234
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setReadOnly(boolean)
235
         */
236
        public void setReadOnly(boolean readOnly) {
237
                this.readOnly = readOnly;
238
        }
239
        
240
        /*
241
         * (non-Javadoc)
242
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#isSupersamplingLoadingBuffer()
243
         */
244
        public boolean isSupersamplingLoadingBuffer() {
245
                return supersamplingLoadingBuffer;
246
        }
247

    
248
        /*
249
         * (non-Javadoc)
250
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setSupersamplingLoadingBuffer(boolean)
251
         */
252
        public void setSupersamplingLoadingBuffer(boolean supersamplingLoadingBuffer) {
253
                this.supersamplingLoadingBuffer = supersamplingLoadingBuffer;
254
        }
255
        
256
        /*
257
         * (non-Javadoc)
258
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setMemoryBuffer(boolean)
259
         */
260
        public void setMemoryBuffer(boolean memoryBuffer) {
261
                this.memoryBuffer = memoryBuffer;
262
        }
263
        
264
        /**
265
         * Obtiene el flag que dice si la carga del siguiente buffer es en memoria
266
         * @return memory true si la siguiente carga de buffer se hace en memoria y false se deja decidir al dataset 
267
         * el tipo de buffer
268
         */
269
        public boolean isMemoryBuffer() {
270
                return memoryBuffer;
271
        }
272
        
273
        /*
274
         * (non-Javadoc)
275
         * @see org.gvsig.fmap.dal.coverage.buffer.RasterQuery#setNoDataToFill(double)
276
         */
277
        public void setNoDataToFill(NoData noData) {
278
                this.noDataValueToFill = noData;
279
        }
280
        
281
        /*
282
         * (non-Javadoc)
283
         * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setAlphaBand(int)
284
         */
285
        public void setAlphaBand(int bandNumber) {
286
                this.alphaBandNumber = bandNumber;
287
        }
288
        
289
        /*
290
         * (non-Javadoc)
291
         * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setFrameWidth(int)
292
         */
293
        public void setFrameWidth(int n) {
294
                this.frameWidth = n;
295
        }
296
        
297
        public int getAlphaBandNumber() {
298
                return alphaBandNumber;
299
        }
300
        
301
        public NoData getNoDataValueToFill() {
302
                return this.noDataValueToFill;
303
        }
304

    
305
        public int getType() {
306
                return type;
307
        }
308

    
309
        public double getX() {
310
                return x;
311
        }
312

    
313
        public double getY() {
314
                return y;
315
        }
316

    
317
        public double getW() {
318
                return w;
319
        }
320

    
321
        public double getH() {
322
                return h;
323
        }
324

    
325
        public int getPixelX() {
326
                return pixelX;
327
        }
328

    
329
        public int getPixelY() {
330
                return pixelY;
331
        }
332

    
333
        public int getPixelW() {
334
                return pixelW;
335
        }
336

    
337
        public int getPixelH() {
338
                return pixelH;
339
        }
340

    
341
        public Extent getBBox() {
342
                return bbox;
343
        }
344

    
345
        public int getBufWidth() {
346
                return bufWidth;
347
        }
348

    
349
        public int getBufHeight() {
350
                return bufHeight;
351
        }
352

    
353
        public boolean isReadOnly() {
354
                return readOnly;
355
        }
356
        
357
        public int getFrameWidth() {
358
                return frameWidth;
359
        }
360

    
361
        public TileListener getTileListener() {
362
                return listener;
363
        }
364
        
365
        /*
366
         * (non-Javadoc)
367
         * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#getTime()
368
         */
369
        public Time getTime() {
370
                return time;
371
        }
372

    
373
        /*
374
         * (non-Javadoc)
375
         * @see org.gvsig.fmap.dal.coverage.store.RasterQuery#setTime(org.gvsig.timesupport.Time)
376
         */
377
        public void setTime(Time time) {
378
                this.time = time;
379
        }
380
        
381
        public int getTileRow() {
382
                return tileRow;
383
        }
384

    
385
        public int getTileCol() {
386
                return tileCol;
387
        }
388

    
389
        public CacheStruct getCacheStruct() {
390
                return cacheStruct;
391
        }
392

    
393
        public int getResolutionLevel() {
394
                return resolutionLevel;
395
        }
396
        
397
        //****************************************************
398
        //*********Implementing DataQuery methods*************
399
        //****************************************************
400
        
401
        /*
402
         * (non-Javadoc)
403
         * @see org.gvsig.fmap.dal.DataQuery#getQueryParameter(java.lang.String)
404
         */
405
        public Object getQueryParameter(String name) {
406
                // TODO Auto-generated method stub
407
                return null;
408
        }
409

    
410
        /*
411
         * (non-Javadoc)
412
         * @see org.gvsig.fmap.dal.DataQuery#getScale()
413
         */
414
        public double getScale() {
415
                // TODO Auto-generated method stub
416
                return 0;
417
        }
418

    
419
        /*
420
         * (non-Javadoc)
421
         * @see org.gvsig.fmap.dal.DataQuery#setQueryParameter(java.lang.String, java.lang.Object)
422
         */
423
        public void setQueryParameter(String name, Object value) {
424
                // TODO Auto-generated method stub
425
                
426
        }
427

    
428
        /*
429
         * (non-Javadoc)
430
         * @see org.gvsig.fmap.dal.DataQuery#setScale(double)
431
         */
432
        public void setScale(double scale) {
433
                // TODO Auto-generated method stub
434
                
435
        }
436
        
437
        //****************************************************
438
        //*********Implementing Persistent methods************
439
        //****************************************************
440

    
441
        /*
442
         * (non-Javadoc)
443
         * @see org.gvsig.tools.persistence.Persistent#loadFromState(org.gvsig.tools.persistence.PersistentState)
444
         */
445
        public void loadFromState(PersistentState state)
446
                        throws PersistenceException {
447
                // TODO Auto-generated method stub
448
                
449
        }
450

    
451
        /*
452
         * (non-Javadoc)
453
         * @see org.gvsig.tools.persistence.Persistent#saveToState(org.gvsig.tools.persistence.PersistentState)
454
         */
455
        public void saveToState(PersistentState state) throws PersistenceException {
456
                // TODO Auto-generated method stub
457
                
458
        }
459
}