01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.gce.geotiff;
17:
18: import java.util.Locale;
19:
20: import javax.imageio.ImageWriteParam;
21:
22: import org.geotools.coverage.grid.io.imageio.GeoToolsWriteParams;
23:
24: import com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam;
25:
26: /**
27: * Subclass of {@link GeoToolsWriteParams} the allows the user to specify
28: * parameters to control the process of writing out a GeoTiff file through
29: * standards {@link ImageWriteParam} (with possible extensions).
30: *
31: * <p>
32: * This class allows the user to control the output tile size for the GeoTiff
33: * file we are going to create as well as the possible compression.
34: *
35: * <p>
36: * An example of usage of this parameters is as follows:
37: *
38: * <pre>
39: * <code>
40: * //getting a format
41: * final GeoTiffFormat format = new GeoTiffFormat();
42: *
43: * //getting the write parameters
44: * final GeoTiffWriteParams wp = new GeoTiffWriteParams();
45: *
46: * //setting compression to LZW
47: * wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
48: * wp.setCompressionType("LZW");
49: * wp.setCompressionQuality(0.75F);
50: *
51: * //setting the tile size to 256X256
52: * wp.setTilingMode(GeoToolsWriteParams.MODE_EXPLICIT);
53: * wp.setTiling(256, 256);
54: *
55: * //setting the write parameters for this geotiff
56: * final ParameterValueGroup params = format.getWriteParameters();
57: * params.parameter(
58: * AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString())
59: * .setValue(wp);
60: *
61: * //get a reader to the input File
62: * GridCoverageReader reader = new GeoTiffReader(inFile, null);
63: * GridCoverageWriter writer = null;
64: * GridCoverage2D gc = null;
65: * if (reader != null) {
66: *
67: * // reading the coverage
68: * gc = (GridCoverage2D) reader.read(null);
69: * if (gc != null) {
70: * final File writeFile = new File(new StringBuffer(writedir
71: * .getAbsolutePath()).append(File.separatorChar)
72: * .append(gc.getName().toString()).append(".tiff")
73: * .toString());
74: * writer = format.getWriter(writeFile);
75: * writer.write(gc, (GeneralParameterValue[]) params.values()
76: * .toArray(new GeneralParameterValue[1]));
77: * }
78: * </code>
79: * </pre>
80: *
81: * @author Simone Giannecchini
82: * @since 2.3.x
83: *
84: */
85: public final class GeoTiffWriteParams extends GeoToolsWriteParams {
86:
87: /**
88: * Default constructor.
89: */
90: public GeoTiffWriteParams() {
91: super (new TIFFImageWriteParam(Locale.getDefault()));
92: }
93:
94: }
|