01: /*
02: * Geotools2 - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002, 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: */
17: package org.geotools.gce.ecw;
18:
19: import org.geotools.coverage.grid.GridCoverage2D;
20: import org.geotools.coverage.grid.GridGeometry2D;
21: import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
22: import org.geotools.coverage.grid.io.AbstractGridFormat;
23: import org.geotools.geometry.GeneralEnvelope;
24: import org.geotools.test.TestData;
25: import org.opengis.parameter.GeneralParameterValue;
26: import org.opengis.parameter.ParameterValue;
27:
28: /**
29: * @author Daniele Romagnoli, GeoSolutions
30: * @author Simone Giannecchini (simboss), GeoSolutions
31: *
32: * Testing {@link ECWReader}
33: */
34: public final class ECWTest extends AbstractECWTestCase {
35:
36: /**
37: * file name of a valid ECW sample data to be used for tests. All ECW sample
38: * data found are too large to be placed in the test-data folder by means of
39: * the SVN.
40: *
41: * We suggest to download a valid ECW sample file from this site:
42: * ftp://www.sjrwmd.com/2004_DOQQs/rgb_ecw/
43: *
44: * Any zipped file contains a .ECW file as well as a HTML file containing a
45: * "Spatial Reference Information" paragraph where to find useful
46: * information about Projection, in order to build a valid .prj file.
47: */
48: private final static String fileName = "sampledata.ecw";
49:
50: /**
51: * Creates a new instance of {@link ECWTest}
52: *
53: * @param name
54: */
55: public ECWTest(String name) {
56: super (name);
57: }
58:
59: public static final void main(String[] args) throws Exception {
60: junit.textui.TestRunner.run(ECWTest.class);
61: }
62:
63: public void testVisualization() throws Exception {
64: if (!testingEnabled())
65: return;
66:
67: // read in the grid coverage
68: if (fileName.equalsIgnoreCase("")) {
69: LOGGER
70: .info("==================================================================\n"
71: + " Warning! No valid test File has been specified.\n"
72: + " Please provide a valid sample in the source code and repeat this test!\n"
73: + "========================================================================");
74: return;
75: }
76: final AbstractGridCoverage2DReader reader = new ECWReader(
77: TestData.file(this , fileName));
78: final ParameterValue gg = (ParameterValue) ((AbstractGridFormat) reader
79: .getFormat()).READ_GRIDGEOMETRY2D.createValue();
80: final GeneralEnvelope oldEnvelope = reader
81: .getOriginalEnvelope();
82: gg.setValue(new GridGeometry2D(reader.getOriginalGridRange(),
83: oldEnvelope));
84: final GridCoverage2D gc = (GridCoverage2D) reader
85: .read(new GeneralParameterValue[] { gg });
86:
87: assertNotNull(gc);
88:
89: if (TestData.isInteractiveTest()) {
90: gc.show();
91: } else
92: gc.getRenderedImage().getData();
93: if (TestData.isInteractiveTest()) {
94: // printing CRS information
95: LOGGER.info(gc.getCoordinateReferenceSystem().toWKT());
96: LOGGER.info(gc.getEnvelope().toString());
97: }
98: }
99: }
|