Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libRaster / src / org / gvsig / raster / buffer / cache / CacheDataFromDriverServer.java @ 11183

History | View | Annotate | Download (3.62 KB)

1

    
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 */
20
package org.gvsig.raster.buffer.cache;
21

    
22
import java.io.IOException;
23

    
24
import org.gvsig.raster.dataset.Band;
25
import org.gvsig.raster.dataset.BandFoundInListException;
26
import org.gvsig.raster.dataset.BandList;
27
import org.gvsig.raster.dataset.NotSupportedExtensionException;
28
import org.gvsig.raster.dataset.RasterDataset;
29
import org.gvsig.raster.dataset.RasterDriverException;
30
import org.gvsig.raster.shared.Extent;
31

    
32

    
33
/** 
34
 * Servidor de datos de cach?. Esta clase es la encargada de recuperar las p?ginas
35
 * cuando le son solicitadas. Implementar? el interfaz ICacheDataSource, aunque esta
36
 * clase se encargar? de servir p?ginas de solo lectura. Las p?ginas son servidas directamente desde
37
 * un RasterDataset y un objeto de este tipo representa a una sola p?gina, por lo que tendr? asociado
38
 * el extent correspondiente al trozo de p?gina que sirve.
39
 * 
40
 * @author Nacho Brodin (nachobrodin@gmail.com)
41
 *
42
 */
43
public class CacheDataFromDriverServer implements ICacheDataSource{
44
        
45
        private int                                        numPag = -1;
46
        private RasterDataset                        dataset = null;
47
        private Extent                                        pageExtent = null; 
48
        
49
        /**
50
         * Constructor. 
51
         * Crea el identificador para todos los trozos de cach? que se guardar?n en disco. 
52
         * @param id Identificador de fichero. Si este es null se calcula uno autom?ticamente
53
         * @param numBand N?mero de banda
54
         * @param numPag N?mero de p?gina
55
         * @throws RasterDriverException 
56
         * @throws NotSupportedExtensionException 
57
         */
58
        public CacheDataFromDriverServer(RasterDataset dataset, int numPag, Extent extent) {
59
                this.numPag = numPag;
60
                this.dataset = dataset;
61
                pageExtent = extent;
62
        }
63

    
64
        /* (non-Javadoc)
65
         * @see org.gvsig.fmap.dataaccess.cache.ICacheDataSource#loadPage(int, org.gvsig.fmap.dataaccess.cache.PageBuffer)
66
         */
67
        public void loadPage(PageBandBuffer pageBuffer) {
68
                //Creamos un BandList con todas las bandas del fichero
69
                BandList bandList = new BandList();
70
                for(int i = 0; i < dataset.getBandCount();i++){
71
                        try{
72
                                Band band = new Band(dataset.getFName(), i, dataset.getDataType());
73
                                bandList.addBand(band, i);
74
                        }catch(BandFoundInListException ex){
75
                                //No a?adimos la banda
76
                        }
77
                }
78
                dataset.getWindowRaster(pageExtent.getMin().getX(), pageExtent.getMax().getY(), pageExtent.width(), pageExtent.height(), bandList, pageBuffer, true);
79
        }
80

    
81
        /* (non-Javadoc)
82
         * @see org.gvsig.fmap.dataaccess.cache.ICacheDataSource#savePage(int, org.gvsig.fmap.dataaccess.cache.PageBuffer)
83
         */
84
        public void savePage(PageBandBuffer pageBuffer) throws IOException {
85
                //Read Only                
86
        }
87

    
88
        /*
89
         * (non-Javadoc)
90
         * @see org.gvsig.raster.dataaccess.cache.ICacheDataSource#delete()
91
         */
92
        public void delete() {
93
                //Read Only
94
        }
95
        
96
        /*
97
         *  (non-Javadoc)
98
         * @see org.gvsig.raster.dataaccess.cache.ICacheDataSource#getPath()
99
         */
100
        public String getPath() {
101
                if(dataset != null)
102
                        return dataset.getFName();
103
                return null;
104
        }
105
}
106