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 @ 162
History | View | Annotate | Download (5.93 KB)
1 | 77 | nbrodin | /* 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 | 132 | nbrodin | import org.gvsig.fmap.dal.coverage.RasterLocator; |
29 | 77 | nbrodin | import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
30 | import org.gvsig.fmap.dal.coverage.datastruct.Params; |
||
31 | 90 | nbrodin | import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
32 | 77 | nbrodin | 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 | 132 | nbrodin | import org.gvsig.fmap.dal.coverage.util.FileUtils; |
37 | import org.gvsig.fmap.dal.coverage.util.RasterUtils; |
||
38 | 77 | nbrodin | import org.gvsig.raster.impl.store.ParamsImpl; |
39 | 162 | nbrodin | import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
40 | 135 | nbrodin | import org.gvsig.raster.util.DefaultProviderServices; |
41 | 77 | nbrodin | |
42 | import es.gva.cit.jgdal.GdalException; |
||
43 | |||
44 | /**
|
||
45 | * Clase abstracta de la que heredan los drivers de escritura. Tiene los m?todos
|
||
46 | * abstractos que debe implementar cualquier driver de escritura y las
|
||
47 | * funcionalidades y opciones soportadas comunes a todos ellos.
|
||
48 | *
|
||
49 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
50 | */
|
||
51 | 131 | nbrodin | public abstract class DefaultRasterWriter implements RasterWriter { |
52 | 77 | nbrodin | public static final int MODE_FILEWRITE = 1; |
53 | public static final int MODE_DATAWRITE = 2; |
||
54 | |||
55 | protected String outFileName = null; |
||
56 | protected String inFileName = null; |
||
57 | protected int sizeWindowX = 0; |
||
58 | protected int sizeWindowY = 0; |
||
59 | protected int ulX = 0; |
||
60 | protected int ulY = 0; |
||
61 | protected DataServerWriter dataWriter = null; |
||
62 | protected int nBands = 0; |
||
63 | protected String ident = null; |
||
64 | protected String driver = null; |
||
65 | protected Params driverParams = null; |
||
66 | protected AffineTransform at = null; |
||
67 | protected int percent = 0; |
||
68 | protected int dataType = Buffer.TYPE_BYTE; |
||
69 | protected IProjection proj = null; |
||
70 | 162 | nbrodin | protected DataStoreColorInterpretation colorInterp = null; |
71 | 77 | nbrodin | protected ExternalCancellable extCancellable = null; |
72 | 132 | nbrodin | protected FileUtils fileUtil = RasterLocator.getManager().getFileUtils();
|
73 | protected RasterUtils rasterUtil = RasterLocator.getManager().getRasterUtils();
|
||
74 | 135 | nbrodin | protected DefaultProviderServices pInfo = (DefaultProviderServices)RasterLocator.getManager().getProviderServices();
|
75 | 132 | nbrodin | |
76 | 77 | nbrodin | |
77 | /**
|
||
78 | * Devuelve el identificador del driver
|
||
79 | * @return Identificador del driver
|
||
80 | */
|
||
81 | public String getIdent() { |
||
82 | return ident;
|
||
83 | } |
||
84 | |||
85 | /**
|
||
86 | * Obtiene el nombre del driver.
|
||
87 | * @return Nombre del driver
|
||
88 | */
|
||
89 | public String getDriverName() { |
||
90 | return driver;
|
||
91 | } |
||
92 | |||
93 | /**
|
||
94 | * @return
|
||
95 | */
|
||
96 | public String getDriverType() { |
||
97 | return driver;
|
||
98 | } |
||
99 | |||
100 | /**
|
||
101 | * Asigna el porcentaje de incremento. Esto es usado por el driver para
|
||
102 | * actualizar la variable percent
|
||
103 | * @param percent
|
||
104 | */
|
||
105 | public void setPercent(int percent) { |
||
106 | this.percent = percent;
|
||
107 | } |
||
108 | |||
109 | 135 | nbrodin | /*
|
110 | * (non-Javadoc)
|
||
111 | * @see org.gvsig.fmap.dal.coverage.store.RasterWriter#getPercent()
|
||
112 | 77 | nbrodin | */
|
113 | public int getPercent() { |
||
114 | return percent;
|
||
115 | } |
||
116 | |||
117 | /**
|
||
118 | * Obtiene los par?metros del driver.
|
||
119 | * @return WriterParams
|
||
120 | */
|
||
121 | public Params getParams() {
|
||
122 | return driverParams;
|
||
123 | } |
||
124 | |||
125 | /**
|
||
126 | * Asigna los par?metros del driver modificados por el cliente.
|
||
127 | * @param Params
|
||
128 | */
|
||
129 | public void setParams(Params params) { |
||
130 | if(params instanceof ParamsImpl) |
||
131 | this.driverParams = (ParamsImpl)params;
|
||
132 | } |
||
133 | |||
134 | /**
|
||
135 | * Realiza la funci?n de compresi?n a partir de un GeoRasterFile.
|
||
136 | * @throws IOException
|
||
137 | */
|
||
138 | 90 | nbrodin | public abstract void fileWrite() throws IOException, ProcessInterruptedException; |
139 | 77 | nbrodin | |
140 | /**
|
||
141 | * Realiza la funci?n de compresi?n a partir de los datos pasados por el
|
||
142 | * cliente.
|
||
143 | * @throws IOException
|
||
144 | * @throws RmfSerializerException
|
||
145 | */
|
||
146 | 90 | nbrodin | public abstract void dataWrite() throws IOException, ProcessInterruptedException; |
147 | 77 | nbrodin | |
148 | /**
|
||
149 | * Cierra el driver
|
||
150 | */
|
||
151 | public abstract void writeClose(); |
||
152 | |||
153 | /**
|
||
154 | * Cancela el grabado de datos
|
||
155 | */
|
||
156 | public abstract void writeCancel(); |
||
157 | |||
158 | /**
|
||
159 | * A?ade la proyecci?n Wkt con la que salvar.
|
||
160 | * @param wkt
|
||
161 | * @throws GdalException
|
||
162 | */
|
||
163 | public abstract void setWkt(String wkt); |
||
164 | |||
165 | /**
|
||
166 | * Asigna la interpretaci?n de color para el fichero de salida.
|
||
167 | * @param colorInterp Interpretaci?n de color
|
||
168 | */
|
||
169 | public void setColorBandsInterpretation(String[] colorInterp) { |
||
170 | if (colorInterp != null) { |
||
171 | 162 | nbrodin | this.colorInterp = new DataStoreColorInterpretation(); |
172 | 77 | nbrodin | this.colorInterp.initColorInterpretation(colorInterp.length);
|
173 | for (int i = 0; i < colorInterp.length; i++) |
||
174 | this.colorInterp.setColorInterpValue(i, colorInterp[i]);
|
||
175 | } |
||
176 | } |
||
177 | |||
178 | /**
|
||
179 | * Assigns the object to be cancelled
|
||
180 | *
|
||
181 | * @param cancellable
|
||
182 | */
|
||
183 | public void setCancellableRasterDriver(ExternalCancellable cancellable) { |
||
184 | this.extCancellable = cancellable;
|
||
185 | } |
||
186 | } |