Revision 11981
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/features/HFAFeatures.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.dataset.io.features; |
|
20 |
|
|
21 |
import org.gvsig.raster.dataset.Params; |
|
22 |
import org.gvsig.raster.dataset.io.GdalWriter; |
|
23 |
|
|
24 |
/** |
|
25 |
* Caracteristicas del formato HFA (.img) de Erdas para escritura. |
|
26 |
* Soporta enteros de 8, 16 y 32 bits y datos en coma flotante de 32 y 64 bits |
|
27 |
* con cualquier n?mero de bandas. |
|
28 |
* |
|
29 |
* @version 04/06/2007 |
|
30 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
31 |
* |
|
32 |
*/ |
|
33 |
//TODO: Mirar si se pueden generar con piramides |
|
34 |
public class HFAFeatures extends WriteFileFormatFeatures { |
|
35 |
|
|
36 |
public HFAFeatures() { |
|
37 |
super("HFA", "img", -1, new int[]{0, 1, 2, 3, 4, 5}, GdalWriter.class); |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* Carga los par?metros de este driver. |
|
42 |
*/ |
|
43 |
public void loadParams() { |
|
44 |
super.loadParams(); |
|
45 |
|
|
46 |
driverParams.setParam( "rrd", |
|
47 |
"NO", |
|
48 |
Params.CHOICE, |
|
49 |
new String[]{ "YES", "NO"}); |
|
50 |
|
|
51 |
driverParams.setParam( "compress", |
|
52 |
"NO", |
|
53 |
Params.CHOICE, |
|
54 |
new String[]{"YES", "NO"}); |
|
55 |
} |
|
56 |
} |
|
0 | 57 |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/features/GTiffFeatures.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.dataset.io.features; |
|
20 |
|
|
21 |
import org.gvsig.raster.dataset.Params; |
|
22 |
import org.gvsig.raster.dataset.io.GdalWriter; |
|
23 |
|
|
24 |
/** |
|
25 |
* Caracteristicas del formato GeoTiff para escritura. |
|
26 |
* |
|
27 |
* @version 04/06/2007 |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class GTiffFeatures extends WriteFileFormatFeatures { |
|
32 |
|
|
33 |
public GTiffFeatures() { |
|
34 |
super("GTiff", "tif", -1, new int[]{0, 1, 2, 3, 4, 5}, GdalWriter.class); |
|
35 |
} |
|
36 |
|
|
37 |
/** |
|
38 |
* Carga los par?metros de este driver. |
|
39 |
*/ |
|
40 |
public void loadParams() { |
|
41 |
super.loadParams(); |
|
42 |
|
|
43 |
driverParams.setParam( "photometric", |
|
44 |
"RGB", |
|
45 |
Params.CHOICE, |
|
46 |
new String[]{"YCBR", "MINISBLACK", "MINISWHITE", "RGB", "CMYK", "CIELAB", "ICCLAB", "ITULAB", "CBCR"}); |
|
47 |
|
|
48 |
driverParams.setParam( "interleave", |
|
49 |
"BAND", |
|
50 |
Params.CHOICE, |
|
51 |
new String[]{ "BAND", "PIXEL"}); |
|
52 |
|
|
53 |
driverParams.setParam( "compression", |
|
54 |
"NONE", |
|
55 |
Params.CHOICE, |
|
56 |
new String[]{"LZW", "PACKBITS", "DEFLATE", "NONE"}); |
|
57 |
|
|
58 |
driverParams.setParam( "tfw", |
|
59 |
"false", |
|
60 |
Params.CHECK, |
|
61 |
null); |
|
62 |
} |
|
63 |
} |
|
0 | 64 |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/features/WriteFileFormatFeatures.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.dataset.io.features; |
|
20 |
|
|
21 |
import org.gvsig.raster.RasterLibrary; |
|
22 |
import org.gvsig.raster.dataset.IBuffer; |
|
23 |
import org.gvsig.raster.dataset.Params; |
|
24 |
|
|
25 |
/** |
|
26 |
* Caracteristicas de un formato de fichero utilizado para escritura. El contenido |
|
27 |
* de esta clase es utilizado por el driver para informar de las caracteristicas de cada |
|
28 |
* formato. |
|
29 |
* |
|
30 |
* 02-jun-2007 |
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
32 |
*/ |
|
33 |
public class WriteFileFormatFeatures { |
|
34 |
private String driverName = null; |
|
35 |
private String ext = null; |
|
36 |
private int nBandsSupported = -1; |
|
37 |
private int[] dataTypesSupported = new int[]{IBuffer.TYPE_BYTE}; |
|
38 |
private Class driver = null; |
|
39 |
protected Params driverParams = new Params(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Constructor. |
|
43 |
* Asigna las caracteristicas del formato de escritura. El tipo de dato se inicializa por |
|
44 |
* defecto a solo byte. Si recibe como parametro un null el formato acepta por defecto el tipo |
|
45 |
* byte. |
|
46 |
* @param name Nombre del driver. En el caso de gdal debe coincidir con el nombre de driver de gdal |
|
47 |
* @param ext Extensi?n del fichero |
|
48 |
* @param bands N?mero de bandas m?ximas soportadas en la escritura. Si el valor es menor que 1 soporta cualquier n?mero. |
|
49 |
* @param dataTypes Array con el tipo de datos que soporta. Cada posici?n del array contiene un entero |
|
50 |
* que corresponde con un tipo de dato soportado. Los tipo de datos posibles est?n listados como constante |
|
51 |
* en la clase IBuffer |
|
52 |
* @param driver Clase con el driver de la libreria de raster que gestiona el formato. |
|
53 |
*/ |
|
54 |
public WriteFileFormatFeatures(String name, String ext, int bands, int[] dataTypes, Class driver) { |
|
55 |
this.driverName = name; |
|
56 |
this.ext = ext; |
|
57 |
this.nBandsSupported = bands; |
|
58 |
if(dataTypes != null) |
|
59 |
this.dataTypesSupported = dataTypes; |
|
60 |
this.driver = driver; |
|
61 |
} |
|
62 |
|
|
63 |
public WriteFileFormatFeatures() { |
|
64 |
|
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Carga los par?metros comunes a todos los drivers en el objeto WriterParams. |
|
69 |
*/ |
|
70 |
public void loadParams() { |
|
71 |
driverParams.clear(); |
|
72 |
|
|
73 |
driverParams.setParam( "blocksize", |
|
74 |
String.valueOf(RasterLibrary.blockHeight), |
|
75 |
Params.CHOICE, |
|
76 |
new String[]{ "1", "8", "16", "32", "64", "128", "256", "512", "1024"}); |
|
77 |
|
|
78 |
driverParams.setParam( "georef", |
|
79 |
"true", |
|
80 |
Params.CHECK, |
|
81 |
null); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Obtiene los par?metros del driver. |
|
86 |
* @return WriterParams |
|
87 |
*/ |
|
88 |
public Params getParams() { |
|
89 |
return driverParams; |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* Asigna los par?metros del driver modificados por el cliente. |
|
94 |
* @param Params |
|
95 |
*/ |
|
96 |
public void setParams(Params params) { |
|
97 |
this.driverParams = params; |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Obtiene la clase del driver que gestiona la escritura de ese tipo de formato |
|
102 |
* @return Clase del driver |
|
103 |
*/ |
|
104 |
public Class getDriver() { |
|
105 |
return driver; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Asigna la clase del driver que gestiona la escritura de ese tipo de formato |
|
110 |
* @param Clase del driver |
|
111 |
*/ |
|
112 |
public void setDriver(Class driver) { |
|
113 |
this.driver = driver; |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Obtiene una lista de los tipos de datos soportados. Estos est?n definidos como |
|
118 |
* constantes en IBuffer. |
|
119 |
* @return Lista con los tipos de datos soportados |
|
120 |
*/ |
|
121 |
public int[] getDataTypesSupported() { |
|
122 |
return dataTypesSupported; |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Asigna una lista de los tipos de datos soportados. Estos est?n definidos como |
|
127 |
* constantes en IBuffer. |
|
128 |
* @param Lista con los tipos de datos soportados |
|
129 |
*/ |
|
130 |
public void setDataTypesSupported(int[] dataTypesSupported) { |
|
131 |
this.dataTypesSupported = dataTypesSupported; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Obtiene el nombre del driver. En el caso de gdal debe coincidir con el nombre de driver de gdal. |
|
136 |
* @return Nombre del driver |
|
137 |
*/ |
|
138 |
public String getDriverName() { |
|
139 |
return driverName; |
|
140 |
} |
|
141 |
|
|
142 |
/** |
|
143 |
* Asigna el nombre del driver. En el caso de gdal debe coincidir con el nombre de driver de gdal. |
|
144 |
* @return Nombre del driver |
|
145 |
*/ |
|
146 |
public void setDriverName(String driverName) { |
|
147 |
this.driverName = driverName; |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* Obtiene la extensi?n del formato |
|
152 |
* @return Cadena con la extensi?n del formato |
|
153 |
*/ |
|
154 |
public String getExt() { |
|
155 |
return ext; |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* Asigna la extensi?n del formato |
|
160 |
* @param ext Cadena con la extensi?n del formato |
|
161 |
*/ |
|
162 |
public void setExt(String ext) { |
|
163 |
this.ext = ext; |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* Obtiene el n?mero de bandas soportadas o -1 si es cualquier n?mero de ellas |
|
168 |
* @return N?mero de bandas soportadas |
|
169 |
*/ |
|
170 |
public int getNBandsSupported() { |
|
171 |
return nBandsSupported; |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Asigna el n?mero de bandas soportadas o -1 si es cualquier n?mero de ellas |
|
176 |
* @param N?mero de bandas soportadas |
|
177 |
*/ |
|
178 |
public void setNBandsSupported(int bandsSupported) { |
|
179 |
nBandsSupported = bandsSupported; |
|
180 |
} |
|
181 |
} |
|
0 | 182 |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/GdalWriter.java | ||
---|---|---|
19 | 19 |
package org.gvsig.raster.dataset.io; |
20 | 20 |
|
21 | 21 |
import java.io.IOException; |
22 |
import java.util.ArrayList; |
|
22 | 23 |
|
23 | 24 |
import org.cresques.cts.IProjection; |
24 | 25 |
import org.gvsig.raster.buffer.RasterBuffer; |
25 | 26 |
import org.gvsig.raster.dataset.GeoRasterWriter; |
26 |
import org.gvsig.raster.dataset.IBuffer; |
|
27 | 27 |
import org.gvsig.raster.dataset.IDataWriter; |
28 | 28 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
29 | 29 |
import org.gvsig.raster.dataset.Params; |
30 |
import org.gvsig.raster.dataset.properties.WriteFileFormatFeatures; |
|
30 |
import org.gvsig.raster.dataset.Params.Param; |
|
31 |
import org.gvsig.raster.dataset.io.features.GTiffFeatures; |
|
32 |
import org.gvsig.raster.dataset.io.features.HFAFeatures; |
|
33 |
import org.gvsig.raster.dataset.io.features.WriteFileFormatFeatures; |
|
31 | 34 |
import org.gvsig.raster.shared.Extent; |
32 | 35 |
import org.gvsig.raster.util.RasterUtilities; |
33 | 36 |
import org.gvsig.raster.util.extensionPoints.ExtensionPoints; |
... | ... | |
60 | 63 |
|
61 | 64 |
static { |
62 | 65 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
63 |
WriteFileFormatFeatures features = null; |
|
64 | 66 |
|
65 |
features = new WriteFileFormatFeatures("GTiff", "tif", -1, new int[]{0, 1, 2, 3, 4, 5}, GdalWriter.class); |
|
66 | 67 |
extensionPoints.add("RasterWriter", "tif", GdalWriter.class); |
67 |
fileFeature.put("tif", features);
|
|
68 |
fileFeature.put("tif", new GTiffFeatures());
|
|
68 | 69 |
|
69 |
features = new WriteFileFormatFeatures("HFA", "img", -1, new int[]{0, 1, 2, 3, 4, 5}, GdalWriter.class); |
|
70 | 70 |
extensionPoints.add("RasterWriter", "img", GdalWriter.class); |
71 |
fileFeature.put("img", features); |
|
71 |
fileFeature.put("img", new HFAFeatures()); |
|
72 |
|
|
73 |
//Imagenes 1 banda (monocromo) o 3 (RGB) en 8 bits. Georef = .wld |
|
74 |
/*features = new WriteFileFormatFeatures("BMP", "bmp", -1, null, GdalWriter.class); |
|
75 |
extensionPoints.add("RasterWriter", "bmp", GdalWriter.class); |
|
76 |
fileFeature.put("bmp", features);*/ |
|
72 | 77 |
} |
73 | 78 |
|
74 |
private es.gva.cit.jgdal.GdalDriver drv; |
|
79 |
private es.gva.cit.jgdal.GdalDriver drv;
|
|
75 | 80 |
private Gdal dset_destino = null; |
76 |
private GdalRasterBand rband = null; |
|
81 |
private GdalRasterBand rband = null;
|
|
77 | 82 |
private GeoTransform geot = null; //Datos de georeferenciaci?n |
78 | 83 |
//private OGRSpatialReference oSRS; //Datos de proyecci?n |
79 | 84 |
private GdalBuffer[] bufBands = null; |
80 | 85 |
private int nBlocks = 0; //N?mero de bloques en Y en el que se divide la imagen para escribir |
81 | 86 |
private int anchoResto = 0; //Tama?o del ?ltimo bloque de la imagen. |
82 |
private String[] params = null; //Par?metros de creaci?n del dataset. |
|
83 |
private boolean consulta = false; |
|
84 |
private boolean write = true; //Cuando est? a true se puede escribir en la imagen de salida. Si est? a false el proceso es interrumpido |
|
87 |
private boolean write = true; //Cuando est? a true se puede escribir en la imagen de salida. Si est? a false el proceso es interrumpido |
|
85 | 88 |
private int dataType = RasterBuffer.TYPE_UNDEFINED; |
86 | 89 |
|
87 | 90 |
/** |
88 | 91 |
* Carga los par?metros de este driver. |
89 | 92 |
*/ |
90 |
public void loadParams() { |
|
91 |
super.loadParams(); |
|
92 |
|
|
93 |
driverParams.setParam( "photometric", |
|
94 |
"RGB", |
|
95 |
Params.CHOICE, |
|
96 |
new String[]{"YCBR", "MINISBLACK", "MINISWHITE", "RGB", "CMYK", "CIELAB", "ICCLAB", "ITULAB", "CBCR"}); |
|
97 |
|
|
98 |
driverParams.setParam( "interleave", |
|
99 |
"BAND", |
|
100 |
Params.CHOICE, |
|
101 |
new String[]{ "BAND", "PIXEL"}); |
|
102 |
|
|
103 |
driverParams.setParam( "compression", |
|
104 |
"NONE", |
|
105 |
Params.CHOICE, |
|
106 |
new String[]{"LZW", "PACKBITS", "DEFLATE", "NONE"}); |
|
107 |
|
|
108 |
driverParams.setParam( "tfw", |
|
109 |
"false", |
|
110 |
Params.CHECK, |
|
111 |
null); |
|
93 |
public void loadParams(String ident) { |
|
94 |
WriteFileFormatFeatures wfff = (WriteFileFormatFeatures)fileFeature.get(ident); |
|
95 |
wfff.loadParams(); |
|
96 |
driverParams = wfff.getParams(); |
|
112 | 97 |
} |
113 | 98 |
|
114 | 99 |
/** |
... | ... | |
119 | 104 |
ident = RasterUtilities.getExtensionFromFileName(fileName); |
120 | 105 |
driver = ((WriteFileFormatFeatures)fileFeature.get(ident)).getDriverName(); |
121 | 106 |
|
122 |
loadParams(); |
|
123 |
|
|
124 |
consulta = true; |
|
107 |
loadParams(ident); |
|
125 | 108 |
} |
126 | 109 |
|
127 | 110 |
/** |
... | ... | |
177 | 160 |
geot.adfgeotransform[5] = (double) ((minY - maxY) / outSizeY.intValue()); //pixelSizeY; |
178 | 161 |
|
179 | 162 |
if(params == null) |
180 |
loadParams(); |
|
163 |
loadParams(ident);
|
|
181 | 164 |
else |
182 | 165 |
this.driverParams = params; |
183 | 166 |
|
... | ... | |
210 | 193 |
okdrvtype = true; |
211 | 194 |
|
212 | 195 |
if (okdrvtype == false) |
213 |
throw new GdalException("El tipo de driver "+driver+" no est? soportado por GdalWriter.");
|
|
196 |
throw new GdalException("El tipo de driver " + driver + " no est? soportado por GdalWriter.");
|
|
214 | 197 |
|
215 | 198 |
//Obtenemos el driver y creamos el dataset del destino |
216 | 199 |
drv = Gdal.getDriverByName(driver); |
... | ... | |
221 | 204 |
} |
222 | 205 |
|
223 | 206 |
dset_destino = drv.create(outFileName, sizeWindowX, sizeWindowY, |
224 |
nBands, RasterUtilities.getGdalTypeFromRasterBufType(dataType), params);
|
|
207 |
nBands, RasterUtilities.getGdalTypeFromRasterBufType(dataType), gdalParamsFromRasterParams(driverParams));
|
|
225 | 208 |
|
226 | 209 |
dset_destino.setGeoTransform(geot); |
227 | 210 |
|
... | ... | |
238 | 221 |
|
239 | 222 |
public void anotherFile(String fileName)throws GdalException { |
240 | 223 |
dset_destino = drv.create(fileName, sizeWindowX, sizeWindowY, |
241 |
nBands, RasterUtilities.getGdalTypeFromRasterBufType(dataType), params);
|
|
224 |
nBands, RasterUtilities.getGdalTypeFromRasterBufType(dataType), gdalParamsFromRasterParams(driverParams));
|
|
242 | 225 |
} |
243 | 226 |
|
244 | 227 |
/** |
228 |
* Convierte los par?metros obtenidos desde el objeto params a parametros |
|
229 |
* comprensibles por la librer?a gdal |
|
230 |
* @param p Params |
|
231 |
* @return Array de par?metros |
|
232 |
*/ |
|
233 |
private String[] gdalParamsFromRasterParams(Params p) { |
|
234 |
if(p == null) |
|
235 |
return null; |
|
236 |
ArrayList paramList = new ArrayList(); |
|
237 |
Param phot = (Param)p.getParamById("photometric"); |
|
238 |
if(phot != null) |
|
239 |
paramList.add("PHOTOMETRIC=" + phot.defaultValue); |
|
240 |
Param inter = (Param)p.getParamById("interleave"); |
|
241 |
if(inter != null) |
|
242 |
paramList.add("INTERLEAVE=" + inter.defaultValue); |
|
243 |
Param comp = (Param)p.getParamById("compression"); |
|
244 |
if(comp != null) |
|
245 |
paramList.add("COMPRESS=" + comp.defaultValue); |
|
246 |
Param comp1 = (Param)p.getParamById("compress"); |
|
247 |
if(comp1 != null) |
|
248 |
paramList.add("COMPRESS=" + comp1.defaultValue); |
|
249 |
Param rrd = (Param)p.getParamById("rrd"); |
|
250 |
if(rrd != null) |
|
251 |
paramList.add("HFA_USE_RRD=" + rrd.defaultValue); |
|
252 |
|
|
253 |
String[] result = new String[paramList.size()]; |
|
254 |
for (int i = 0; i < result.length; i++) |
|
255 |
result[i] = (String)paramList.get(i); |
|
256 |
return result; |
|
257 |
} |
|
258 |
|
|
259 |
/** |
|
245 | 260 |
* A partir de un elemento que contiene una propiedad y un valor |
246 | 261 |
* lo parsea y asigna el valor a su variable. |
247 | 262 |
* @param propValue elemento con la forma propiedad=valor |
248 | 263 |
*/ |
249 |
private void readProperty(String propValue) { |
|
264 |
/* private void readProperty(String propValue) {
|
|
250 | 265 |
String prop = propValue.substring(0, propValue.indexOf("=")); |
251 | 266 |
|
252 | 267 |
if (propValue.startsWith(prop)) { |
... | ... | |
265 | 280 |
driverParams.changeParamValue("tfw", value); |
266 | 281 |
} |
267 | 282 |
} |
268 |
} |
|
283 |
}*/
|
|
269 | 284 |
|
270 | 285 |
/** |
271 | 286 |
* Asigna propiedades al driver a partir de un vector de |
... | ... | |
273 | 288 |
* propiedad=valor. |
274 | 289 |
* @param props Propiedades |
275 | 290 |
*/ |
276 |
public void setProps(String[] props) { |
|
291 |
/*public void setProps(String[] props) {
|
|
277 | 292 |
for (int iProps = 0; iProps < props.length; iProps++) |
278 | 293 |
readProperty(props[iProps]); |
279 | 294 |
|
... | ... | |
285 | 300 |
} catch (GdalException e) { |
286 | 301 |
e.printStackTrace(); |
287 | 302 |
} |
288 |
} |
|
303 |
}*/
|
|
289 | 304 |
|
290 | 305 |
/** |
291 | 306 |
* Escritura de datos tipo Byte. |
... | ... | |
602 | 617 |
|
603 | 618 |
write(GeoRasterWriter.MODE_DATAWRITE); |
604 | 619 |
|
605 |
if(driverParams.getParamById("tfw").defaultValue.equals("true")) { |
|
620 |
if(driverParams.getParamById("tfw") != null && driverParams.getParamById("tfw").defaultValue.equals("true")) {
|
|
606 | 621 |
if(extent != null) |
607 | 622 |
RasterUtilities.createWorldFile(this.outFileName, extent, sizeWindowX, sizeWindowY); |
608 | 623 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/ErmapperWriter.java | ||
---|---|---|
26 | 26 |
import org.gvsig.raster.dataset.IDataWriter; |
27 | 27 |
import org.gvsig.raster.dataset.Params; |
28 | 28 |
import org.gvsig.raster.dataset.Params.Param; |
29 |
import org.gvsig.raster.dataset.properties.WriteFileFormatFeatures;
|
|
29 |
import org.gvsig.raster.dataset.io.features.WriteFileFormatFeatures;
|
|
30 | 30 |
import org.gvsig.raster.shared.Extent; |
31 | 31 |
import org.gvsig.raster.util.RasterUtilities; |
32 | 32 |
import org.gvsig.raster.util.extensionPoints.ExtensionPoints; |
... | ... | |
87 | 87 |
* Carga los par?metros de este driver. |
88 | 88 |
*/ |
89 | 89 |
public void loadParams() { |
90 |
super.loadParams(); |
|
90 |
WriteFileFormatFeatures wfff = new WriteFileFormatFeatures(); |
|
91 |
wfff.loadParams(); |
|
92 |
driverParams = wfff.getParams(); |
|
91 | 93 |
|
92 | 94 |
driverParams.setParam( "compression", |
93 | 95 |
"10", |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/GeoRasterWriter.java | ||
---|---|---|
28 | 28 |
import java.util.TreeMap; |
29 | 29 |
|
30 | 30 |
import org.gvsig.raster.RasterLibrary; |
31 |
import org.gvsig.raster.dataset.properties.WriteFileFormatFeatures;
|
|
31 |
import org.gvsig.raster.dataset.io.features.WriteFileFormatFeatures;
|
|
32 | 32 |
import org.gvsig.raster.shared.Extent; |
33 | 33 |
import org.gvsig.raster.util.RasterUtilities; |
34 | 34 |
import org.gvsig.raster.util.extensionPoints.ExtensionPoint; |
... | ... | |
59 | 59 |
protected int nBands = 0; |
60 | 60 |
protected String ident = null; |
61 | 61 |
protected String driver = null; |
62 |
protected Params driverParams = new Params();
|
|
62 |
protected Params driverParams = null;
|
|
63 | 63 |
protected Extent extent = null; |
64 | 64 |
protected int percent = 0; |
65 | 65 |
protected int dataType = IBuffer.TYPE_BYTE; |
... | ... | |
67 | 67 |
/** |
68 | 68 |
* Carga los par?metros comunes a todos los drivers en el objeto WriterParams. |
69 | 69 |
*/ |
70 |
public void loadParams() { |
|
70 |
/*public void loadParams() {
|
|
71 | 71 |
driverParams.clear(); |
72 | 72 |
|
73 | 73 |
driverParams.setParam( "blocksize", |
... | ... | |
79 | 79 |
"true", |
80 | 80 |
Params.CHECK, |
81 | 81 |
null); |
82 |
} |
|
82 |
}*/
|
|
83 | 83 |
|
84 | 84 |
/** |
85 | 85 |
* Obtiene la lista de extensiones registradas |
... | ... | |
337 | 337 |
* propiedad=valor. |
338 | 338 |
* @param props Propiedades |
339 | 339 |
*/ |
340 |
public abstract void setProps(String[] props); |
|
340 |
//public abstract void setProps(String[] props);
|
|
341 | 341 |
|
342 | 342 |
/** |
343 | 343 |
* Realiza la funci?n de compresi?n a partir de un GeoRasterFile. |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/properties/WriteFileFormatFeatures.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
*/ |
|
19 |
package org.gvsig.raster.dataset.properties; |
|
20 |
|
|
21 |
import org.gvsig.raster.dataset.IBuffer; |
|
22 |
|
|
23 |
/** |
|
24 |
* Caracteristicas de un formato de fichero utilizado para escritura. El contenido |
|
25 |
* de esta clase es utilizado por el driver para informar de las caracteristicas de cada |
|
26 |
* formato. |
|
27 |
* |
|
28 |
* 02-jun-2007 |
|
29 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
30 |
*/ |
|
31 |
public class WriteFileFormatFeatures { |
|
32 |
private String driverName = null; |
|
33 |
private String ext = null; |
|
34 |
private int nBandsSupported = -1; |
|
35 |
private int[] dataTypesSupported = new int[]{IBuffer.TYPE_BYTE}; |
|
36 |
private Class driver = null; |
|
37 |
|
|
38 |
/** |
|
39 |
* Constructor. |
|
40 |
* Asigna las caracteristicas del formato de escritura. El tipo de dato se inicializa por |
|
41 |
* defecto a solo byte. Si recibe como parametro un null el formato acepta por defecto el tipo |
|
42 |
* byte. |
|
43 |
* @param name Nombre del driver. En el caso de gdal debe coincidir con el nombre de driver de gdal |
|
44 |
* @param ext Extensi?n del fichero |
|
45 |
* @param bands N?mero de bandas m?ximas soportadas en la escritura. Si el valor es menor que 1 soporta cualquier n?mero. |
|
46 |
* @param dataTypes Array con el tipo de datos que soporta. Cada posici?n del array contiene un entero |
|
47 |
* que corresponde con un tipo de dato soportado. Los tipo de datos posibles est?n listados como constante |
|
48 |
* en la clase IBuffer |
|
49 |
* @param driver Clase con el driver de la libreria de raster que gestiona el formato. |
|
50 |
*/ |
|
51 |
public WriteFileFormatFeatures(String name, String ext, int bands, int[] dataTypes, Class driver) { |
|
52 |
this.driverName = name; |
|
53 |
this.ext = ext; |
|
54 |
this.nBandsSupported = bands; |
|
55 |
if(dataTypes != null) |
|
56 |
this.dataTypesSupported = dataTypes; |
|
57 |
this.driver = driver; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Obtiene la clase del driver que gestiona la escritura de ese tipo de formato |
|
62 |
* @return Clase del driver |
|
63 |
*/ |
|
64 |
public Class getDriver() { |
|
65 |
return driver; |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Asigna la clase del driver que gestiona la escritura de ese tipo de formato |
|
70 |
* @param Clase del driver |
|
71 |
*/ |
|
72 |
public void setDriver(Class driver) { |
|
73 |
this.driver = driver; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Obtiene una lista de los tipos de datos soportados. Estos est?n definidos como |
|
78 |
* constantes en IBuffer. |
|
79 |
* @return Lista con los tipos de datos soportados |
|
80 |
*/ |
|
81 |
public int[] getDataTypesSupported() { |
|
82 |
return dataTypesSupported; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* Asigna una lista de los tipos de datos soportados. Estos est?n definidos como |
|
87 |
* constantes en IBuffer. |
|
88 |
* @param Lista con los tipos de datos soportados |
|
89 |
*/ |
|
90 |
public void setDataTypesSupported(int[] dataTypesSupported) { |
|
91 |
this.dataTypesSupported = dataTypesSupported; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* Obtiene el nombre del driver. En el caso de gdal debe coincidir con el nombre de driver de gdal. |
|
96 |
* @return Nombre del driver |
|
97 |
*/ |
|
98 |
public String getDriverName() { |
|
99 |
return driverName; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Asigna el nombre del driver. En el caso de gdal debe coincidir con el nombre de driver de gdal. |
|
104 |
* @return Nombre del driver |
|
105 |
*/ |
|
106 |
public void setDriverName(String driverName) { |
|
107 |
this.driverName = driverName; |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* Obtiene la extensi?n del formato |
|
112 |
* @return Cadena con la extensi?n del formato |
|
113 |
*/ |
|
114 |
public String getExt() { |
|
115 |
return ext; |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* Asigna la extensi?n del formato |
|
120 |
* @param ext Cadena con la extensi?n del formato |
|
121 |
*/ |
|
122 |
public void setExt(String ext) { |
|
123 |
this.ext = ext; |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* Obtiene el n?mero de bandas soportadas o -1 si es cualquier n?mero de ellas |
|
128 |
* @return N?mero de bandas soportadas |
|
129 |
*/ |
|
130 |
public int getNBandsSupported() { |
|
131 |
return nBandsSupported; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Asigna el n?mero de bandas soportadas o -1 si es cualquier n?mero de ellas |
|
136 |
* @param N?mero de bandas soportadas |
|
137 |
*/ |
|
138 |
public void setNBandsSupported(int bandsSupported) { |
|
139 |
nBandsSupported = bandsSupported; |
|
140 |
} |
|
141 |
} |
Also available in: Unified diff