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 / store / writer / DefaultRasterWriter.java @ 2443

History | View | Annotate | Download (5.89 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.store.writer;
23

    
24
import java.awt.geom.AffineTransform;
25
import java.io.IOException;
26

    
27
import org.cresques.cts.IProjection;
28
import org.gvsig.fmap.dal.coverage.RasterLocator;
29
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
30
import org.gvsig.fmap.dal.coverage.datastruct.Params;
31
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
32
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
33
import org.gvsig.fmap.dal.coverage.store.DataServerWriter;
34
import org.gvsig.fmap.dal.coverage.store.ExternalCancellable;
35
import org.gvsig.fmap.dal.coverage.store.RasterWriter;
36
import org.gvsig.fmap.dal.coverage.util.FileUtils;
37
import org.gvsig.fmap.dal.coverage.util.RasterUtils;
38
import org.gvsig.raster.impl.store.ParamsImpl;
39
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
40
import org.gvsig.raster.util.DefaultProviderServices;
41

    
42
/**
43
 * Clase abstracta de la que heredan los drivers de escritura. Tiene los m?todos
44
 * abstractos que debe implementar cualquier driver de escritura y las
45
 * funcionalidades y opciones soportadas comunes a todos ellos.
46
 *
47
 * @author Nacho Brodin (nachobrodin@gmail.com)
48
 */
49
public abstract class DefaultRasterWriter implements RasterWriter {
50
        public static final int              MODE_FILEWRITE = 1;
51
        public static final int              MODE_DATAWRITE = 2;
52

    
53
        protected String                     outFileName    = null;
54
        protected String                     inFileName     = null;
55
        protected int                        sizeWindowX    = 0;
56
        protected int                        sizeWindowY    = 0;
57
        protected int                        ulX            = 0;
58
        protected int                        ulY            = 0;
59
        protected DataServerWriter           dataWriter     = null;
60
        protected int                        nBands         = 0;
61
        protected String                     ident          = null;
62
        protected String                     driver         = null;
63
        protected Params                     driverParams   = null;
64
        protected AffineTransform            at             = null;
65
        protected int                        percent        = 0;
66
        protected int                        dataType       = Buffer.TYPE_BYTE;
67
        protected IProjection                proj           = null;
68
        protected DataStoreColorInterpretation colorInterp    = null;
69
        protected ExternalCancellable        extCancellable = null;
70
        protected FileUtils                  fileUtil       = RasterLocator.getManager().getFileUtils();
71
        protected RasterUtils                rasterUtil     = RasterLocator.getManager().getRasterUtils();
72
        protected DefaultProviderServices    pInfo          = (DefaultProviderServices)RasterLocator.getManager().getProviderServices();
73
        
74

    
75
        /**
76
         * Devuelve el identificador del driver
77
         * @return Identificador del driver
78
         */
79
        public String getIdent() {
80
                return ident;
81
        }
82

    
83
        /**
84
         * Obtiene el nombre del driver.
85
         * @return Nombre del driver
86
         */
87
        public String getDriverName() {
88
                return driver;
89
        }
90

    
91
        /**
92
         * @return
93
         */
94
        public String getDriverType() {
95
                return driver;
96
        }
97

    
98
        /**
99
         * Asigna el porcentaje de incremento. Esto es usado por el driver para
100
         * actualizar la variable percent
101
         * @param percent
102
         */
103
        public void setPercent(int percent) {
104
                this.percent = percent;
105
        }
106

    
107
        /*
108
         * (non-Javadoc)
109
         * @see org.gvsig.fmap.dal.coverage.store.RasterWriter#getPercent()
110
         */
111
        public int getPercent() {
112
                return percent;
113
        }
114

    
115
        /**
116
         * Obtiene los par?metros del driver.
117
         * @return WriterParams
118
         */
119
        public Params getParams() {
120
                return driverParams;
121
        }
122

    
123
        /**
124
         * Asigna los par?metros del driver modificados por el cliente.
125
         * @param Params
126
         */
127
        public void setParams(Params params) {
128
                if(params instanceof ParamsImpl)
129
                        this.driverParams = (ParamsImpl)params;
130
        }
131

    
132
        /**
133
         * Realiza la funci?n de compresi?n a partir de un GeoRasterFile.
134
         * @throws IOException
135
         */
136
        public abstract void fileWrite() throws IOException, ProcessInterruptedException;
137

    
138
        /**
139
         * Realiza la funci?n de compresi?n a partir de los datos pasados por el
140
         * cliente.
141
         * @throws IOException
142
         * @throws RmfSerializerException
143
         */
144
        public abstract void dataWrite() throws IOException, ProcessInterruptedException;
145

    
146
        /**
147
         * Cierra el driver
148
         */
149
        public abstract void writeClose() throws IOException;
150

    
151
        /**
152
         * Cancela el grabado de datos
153
         */
154
        public abstract void writeCancel();
155

    
156
        /**
157
         * A?ade la proyecci?n Wkt con la que salvar.
158
         * @param wkt
159
         */
160
        public abstract void setWkt(String wkt);
161

    
162
        /**
163
         * Asigna la interpretaci?n de color para el fichero de salida.
164
         * @param colorInterp Interpretaci?n de color
165
         */
166
        public void setColorBandsInterpretation(String[] colorInterp) {
167
                if (colorInterp != null) {
168
                        this.colorInterp = new DataStoreColorInterpretation();
169
                        this.colorInterp.initColorInterpretation(colorInterp.length);
170
                        for (int i = 0; i < colorInterp.length; i++)
171
                                this.colorInterp.setColorInterpValue(i, colorInterp[i]);
172
                }
173
        }
174

    
175
        /**
176
         * Assigns the object to be cancelled
177
         *
178
         * @param cancellable
179
         */
180
        public void setCancellableRasterDriver(ExternalCancellable cancellable) {
181
                this.extCancellable = cancellable;
182
        }
183
}