gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.main / src / test / java / org / gvsig / fmap / dal / coverage / grid / filter / TestControlTypes.java @ 2443
History | View | Annotate | Download (4.23 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.fmap.dal.coverage.grid.filter; |
23 |
|
24 |
import org.gvsig.fmap.dal.coverage.BaseTestCase; |
25 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
26 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
27 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
28 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
29 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
30 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
31 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
32 |
import org.gvsig.raster.impl.DefaultRasterManager; |
33 |
import org.gvsig.raster.impl.grid.filter.DefaultRasterFilterList; |
34 |
import org.gvsig.raster.impl.grid.filter.RasterFilterListManagerImpl; |
35 |
import org.gvsig.raster.impl.grid.filter.enhancement.BrightnessContrastListManager; |
36 |
import org.gvsig.raster.impl.grid.filter.enhancement.EnhancementStretchListManager; |
37 |
import org.gvsig.raster.impl.grid.filter.enhancement.LinearStretchEnhancementFilter; |
38 |
import org.gvsig.raster.impl.grid.filter.enhancement.DefaultLinearStretchParams; |
39 |
/**
|
40 |
* Dada una pila de filtros con filtros de tipos heterogeneos. Elimina uno del
|
41 |
* medio y ejecuta controlTypes de RasterFilterListManager. Despu?s comprueba
|
42 |
* que los tipo siguen siendo correctos.
|
43 |
*
|
44 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
45 |
*
|
46 |
*/
|
47 |
public class TestControlTypes extends BaseTestCase { |
48 |
private RasterFilterList list = new DefaultRasterFilterList(); |
49 |
private String path1 = baseDir + "miniRaster28x25F32.tif"; |
50 |
private RasterDataStore f1 = null; |
51 |
|
52 |
protected void doSetUp() throws Exception { |
53 |
System.err.println("TestControlTypes running..."); |
54 |
|
55 |
try {
|
56 |
super.doSetUp();
|
57 |
} catch (Exception e) { |
58 |
e.printStackTrace(); |
59 |
} |
60 |
|
61 |
try {
|
62 |
f1 = manager.open(path1); |
63 |
} catch (NotSupportedExtensionException e) {
|
64 |
e.printStackTrace(); |
65 |
} catch (RasterDriverException e) {
|
66 |
e.printStackTrace(); |
67 |
} |
68 |
} |
69 |
|
70 |
public void start() throws Exception { |
71 |
this.setUp();
|
72 |
this.testStack();
|
73 |
} |
74 |
|
75 |
public void testStack() { |
76 |
Buffer buf = DefaultRasterManager.getInstance().createBuffer(Buffer.TYPE_DOUBLE, 10, 10, 3, true); |
77 |
list.setInitRasterBuf(buf); |
78 |
RasterFilterListManagerImpl fmanager = new RasterFilterListManagerImpl(list);
|
79 |
EnhancementStretchListManager m0 = (EnhancementStretchListManager) fmanager.getManagerByClass(EnhancementStretchListManager.class); |
80 |
BrightnessContrastListManager m1 = (BrightnessContrastListManager)fmanager.getManagerByClass(BrightnessContrastListManager.class); |
81 |
|
82 |
try {
|
83 |
// Metemos Short, Short, Byte, Byte
|
84 |
list.clear(); |
85 |
buf = DefaultRasterManager.getInstance().createBuffer(Buffer.TYPE_SHORT, 10, 10, 3, true); |
86 |
list.setInitRasterBuf(buf); |
87 |
m1.addContrastFilter(12);
|
88 |
m1.addBrightnessFilter(10);
|
89 |
try {
|
90 |
m0.addEnhancedStretchFilter(DefaultLinearStretchParams.createStandardParam(new int[] { 0, 1, 2 }, 0.0, f1.getStatistics(), true), f1.getStatistics(), new int[] { 0, 1, 2 }, false); |
91 |
} catch (FileNotOpenException e) {
|
92 |
e.printStackTrace(); |
93 |
} catch (RasterDriverException e) {
|
94 |
e.printStackTrace(); |
95 |
} |
96 |
m1.addBrightnessFilter(10);
|
97 |
|
98 |
// Eliminamos el filtro de realce
|
99 |
list.remove(LinearStretchEnhancementFilter.names[0]);
|
100 |
fmanager.controlTypes(); |
101 |
|
102 |
// Ahora los tres que quedan deben ser byte
|
103 |
for (int i = 0; i < list.lenght(); i++) |
104 |
assertEquals(list.getOutDataType(), Buffer.TYPE_BYTE);
|
105 |
} catch (FilterTypeException exc) {
|
106 |
|
107 |
} |
108 |
} |
109 |
} |