Revision 18866
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.tasseledcap.TasseledCapSextanteLibrary |
|
0 | 2 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/resources/org/gvsig/raster/tasseledcap/sextante/i18n/text_en.properties | ||
---|---|---|
1 |
multispectral=Multispectral raster |
|
2 |
tasseledcab=Tasseled Cab |
|
3 |
tasseledcap=Tasseled Cab |
|
4 |
use_roi=Use regions of interest |
|
5 |
stadistics=Stadistics |
|
6 |
calculating=Calculating |
|
0 | 7 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/resources/org/gvsig/raster/tasseledcap/sextante/i18n/text.properties | ||
---|---|---|
1 |
multispectral=Raster multiespectral |
|
2 |
tasseledcab=Tasseled Cab |
|
3 |
tasseledcap=Tasseled Cab |
|
4 |
use_roi=Usar las regiones de inter?s |
|
5 |
stadistics=Estad?sticas |
|
6 |
calculating=Calculando |
|
0 | 7 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/resources/help/TasseledCapSextanteAlgorithm.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
|
2 |
<help> |
|
3 |
<element name="DESCRIPTION" |
|
4 |
text="" |
|
5 |
description="Descripción" type="0"> |
|
6 |
<image description="" file=""> |
|
7 |
</image> |
|
8 |
</element> |
|
9 |
<element name="ADDITIONAL_INFO" text="" |
|
10 |
description="Información adicional" type="0"> |
|
11 |
</element> |
|
12 |
<element name="EXTENSION_AUTHOR" text="" |
|
13 |
description="Algoritmo creado por" type="0"> |
|
14 |
</element> |
|
15 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" |
|
16 |
type="0"> |
|
17 |
</element> |
|
18 |
<element name="USER_NOTES" text="" description="Notas de usuario" |
|
19 |
type="0"> |
|
20 |
</element> |
|
21 |
</help> |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/resources/help/TasseledCapSextanteAlgorithm_en.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
|
2 |
<help> |
|
3 |
<element name="DESCRIPTION" |
|
4 |
text="" |
|
5 |
description="Descripción" type="0"> |
|
6 |
<image description="" file=""> |
|
7 |
</image> |
|
8 |
</element> |
|
9 |
<element name="ADDITIONAL_INFO" text="" |
|
10 |
description="Información adicional" type="0"> |
|
11 |
</element> |
|
12 |
<element name="EXTENSION_AUTHOR" text="" |
|
13 |
description="Algoritmo creado por" type="0"> |
|
14 |
</element> |
|
15 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" |
|
16 |
type="0"> |
|
17 |
</element> |
|
18 |
<element name="USER_NOTES" text="" description="Notas de usuario" |
|
19 |
type="0"> |
|
20 |
</element> |
|
21 |
</help> |
|
0 | 22 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/java/org/gvsig/raster/tasseledcap/TasseledCapSextanteLibrary.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap; |
|
2 |
|
|
3 |
import org.gvsig.geoprocess.algorithm.base.core.AlgorithmAbstractLibrary; |
|
4 |
import org.gvsig.i18n.Messages; |
|
5 |
import org.gvsig.tools.library.LibraryException; |
|
6 |
|
|
7 |
/** |
|
8 |
* Initialization of <code>PrincipalComponentsSextanteLibrary</code> library. |
|
9 |
*/ |
|
10 |
public class TasseledCapSextanteLibrary extends AlgorithmAbstractLibrary { |
|
11 |
|
|
12 |
@Override |
|
13 |
protected void doInitialize() throws LibraryException { |
|
14 |
// Nothing to do |
|
15 |
} |
|
16 |
|
|
17 |
@Override |
|
18 |
protected void doPostInitialize() throws LibraryException { |
|
19 |
Messages.addResourceFamily( |
|
20 |
"org.gvsig.raster.tasseledcap.sextante.i18n.text", TasseledCapSextanteLibrary.class |
|
21 |
.getClassLoader(), TasseledCapSextanteLibrary.class.getClass().getName()); |
|
22 |
registerGeoProcess(new TasseledCapSextanteAlgorithm()); |
|
23 |
} |
|
24 |
|
|
25 |
} |
|
0 | 26 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/java/org/gvsig/raster/tasseledcap/TasseledCapSextanteAlgorithm.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
6 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
7 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
8 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
9 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
10 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FLyrRasterIRasterLayer; |
|
11 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
12 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
13 |
import org.gvsig.raster.algorithm.process.IProcessActions; |
|
14 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
15 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
16 |
import org.gvsig.raster.tasseledcap.algorithm.TasseledCapAlgorithmLibrary; |
|
17 |
import org.gvsig.raster.tasseledcap.algorithm.TasseledCapProcess; |
|
18 |
|
|
19 |
import es.unex.sextante.core.AnalysisExtent; |
|
20 |
import es.unex.sextante.core.Sextante; |
|
21 |
import es.unex.sextante.dataObjects.IRasterLayer; |
|
22 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
23 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
24 |
|
|
25 |
/** |
|
26 |
* ... |
|
27 |
*/ |
|
28 |
public class TasseledCapSextanteAlgorithm extends AbstractSextanteGeoProcess implements IProcessActions { |
|
29 |
public static final String RESULT = "RESULT"; |
|
30 |
public static final String LAYER = TasseledCapProcess.RASTER_STORE; |
|
31 |
public static final String USE_ROI = "USE_ROI"; |
|
32 |
public static final String TYPE = "TYPE"; |
|
33 |
|
|
34 |
public static String[] LANDSAT_TYPES = new String[]{"Landsat MS" , "Landsat TM", "Landsat ETM"}; |
|
35 |
|
|
36 |
|
|
37 |
private boolean useROI = false; |
|
38 |
private DataProcess taskStats = null; |
|
39 |
private DataProcess taskPC = null; |
|
40 |
private int type = 0; |
|
41 |
|
|
42 |
|
|
43 |
public void defineCharacteristics() { |
|
44 |
setName(getTranslation("tasseled_cap")); |
|
45 |
setGroup(getTranslation("multispectral")); |
|
46 |
|
|
47 |
try { |
|
48 |
m_Parameters.addInputRasterLayer(LAYER, getTranslation("Input_layer"), true); |
|
49 |
m_Parameters.addBoolean(USE_ROI, getTranslation("use_roi"), false); |
|
50 |
m_Parameters.addSelection(TYPE, getTranslation("type"), LANDSAT_TYPES); |
|
51 |
} catch (RepeatedParameterNameException e) { |
|
52 |
Sextante.addErrorToLog(e); |
|
53 |
} |
|
54 |
addOutputRasterLayer(RESULT, getTranslation("tasseled_cap")); |
|
55 |
} |
|
56 |
|
|
57 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
|
58 |
|
|
59 |
if(existsOutPutFile(TasseledCapSextanteAlgorithm.RESULT, 0)) { |
|
60 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
61 |
} |
|
62 |
|
|
63 |
IRasterLayer input = m_Parameters.getParameterValueAsRasterLayer(LAYER); |
|
64 |
useROI = m_Parameters.getParameterValueAsBoolean(USE_ROI); |
|
65 |
String value = m_Parameters.getParameterValueAsString(TYPE); |
|
66 |
type = 0; |
|
67 |
for (int j = 0; j < LANDSAT_TYPES.length; j++) { |
|
68 |
if(LANDSAT_TYPES[j].equals(value)) |
|
69 |
type = j; |
|
70 |
} |
|
71 |
|
|
72 |
FLyrRaster lyrRaster = ((FLyrRaster)input.getBaseDataObject()); |
|
73 |
IRasterLayer output = null; |
|
74 |
|
|
75 |
output = getNewRORasterLayer( |
|
76 |
RESULT, |
|
77 |
Sextante.getText("tasseledcap_description"), |
|
78 |
input.getDataType(), |
|
79 |
input.getBandsCount()); |
|
80 |
|
|
81 |
String fileName = ((FLyrRasterIRasterLayer)output).getName(); |
|
82 |
|
|
83 |
try { |
|
84 |
setProgressText(getTranslation("calculating")); |
|
85 |
taskPC = createTasseledCapProcess(lyrRaster.getDataStore(), fileName, type); |
|
86 |
taskPC.execute(); |
|
87 |
((FLyrRasterIRasterLayer)output).setBaseDataObject(fileName); |
|
88 |
} catch (ProcessInterruptedException e) { |
|
89 |
Sextante.addErrorToLog(e); |
|
90 |
} catch (ProcessException e) { |
|
91 |
Sextante.addErrorToLog(e); |
|
92 |
} |
|
93 |
|
|
94 |
if(getTaskMonitor().isCanceled()) |
|
95 |
return false; |
|
96 |
|
|
97 |
return true; |
|
98 |
} |
|
99 |
|
|
100 |
private DataProcess createTasseledCapProcess(RasterDataStore inputStore, String fileName, int type) throws ProcessException { |
|
101 |
DataProcess taskPC = RasterBaseAlgorithmLibrary.getManager().createRasterTask(TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
102 |
taskPC.setActions(this); |
|
103 |
List<String> params = taskPC.getRasterTaskInputParameters(TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
104 |
for (int i = 0; i < params.size(); i++) { |
|
105 |
String paramName = params.get(i); |
|
106 |
Class<?> paramType = taskPC.getParameterTypeByProcess(TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL, paramName); |
|
107 |
if(paramType == RasterDataStore.class) { |
|
108 |
taskPC.addParam(paramName, (RasterDataStore)inputStore); |
|
109 |
} |
|
110 |
|
|
111 |
if(paramType == Boolean[].class) { |
|
112 |
boolean[] bands = new boolean[type == 0 ? 4 : 6]; |
|
113 |
for (int j = 0; j < bands.length; j++) { |
|
114 |
bands[j] = true; |
|
115 |
} |
|
116 |
taskPC.addParam(paramName, bands); |
|
117 |
} |
|
118 |
|
|
119 |
if(paramType == Integer.class) { |
|
120 |
taskPC.addParam(paramName, type); |
|
121 |
} |
|
122 |
|
|
123 |
if(paramName.equals("PATH")) { |
|
124 |
taskPC.addParam(paramName, fileName); |
|
125 |
} |
|
126 |
|
|
127 |
if(paramName.equals("ROI_EPSG") && useROI) { |
|
128 |
taskPC.addParam(paramName, "EPSG:4326"); |
|
129 |
} |
|
130 |
|
|
131 |
if(paramName.equals("WINDOW")) { |
|
132 |
AnalysisExtent ext = getAnalysisExtent(); |
|
133 |
Extent bbox = RasterLocator.getManager().getDataStructFactory().createExtent( |
|
134 |
ext.getXMin(), ext.getYMax(), ext.getXMax(), ext.getYMin()); |
|
135 |
Extent inputBbox = inputStore.getExtent(); |
|
136 |
if(bbox.getULX() != inputBbox.getULX() || |
|
137 |
bbox.getULY() != inputBbox.getULY() || |
|
138 |
bbox.getLRX() != inputBbox.getLRX() || |
|
139 |
bbox.getLRY() != inputBbox.getLRY()) { |
|
140 |
taskPC.addParam(paramName, bbox); |
|
141 |
} |
|
142 |
} |
|
143 |
} |
|
144 |
return taskPC; |
|
145 |
} |
|
146 |
|
|
147 |
public void interrupted() { |
|
148 |
|
|
149 |
} |
|
150 |
|
|
151 |
public void end(Object param) { |
|
152 |
|
|
153 |
} |
|
154 |
|
|
155 |
public void updateProgress(int current, int total) { |
|
156 |
boolean cancelled = setProgress(current, total); |
|
157 |
|
|
158 |
if(!cancelled) { |
|
159 |
if(taskStats != null) |
|
160 |
taskStats.actionCanceled(null); |
|
161 |
if(taskPC != null) |
|
162 |
taskPC.actionCanceled(null); |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
/* |
|
167 |
* TODO: Customized panels |
|
168 |
@Override |
|
169 |
public Class<? extends GeoAlgorithmParametersPanel> getCustomParametersPanelClass() { |
|
170 |
return PrincipalComponentsParametersPanel.class; |
|
171 |
}*/ |
|
172 |
} |
|
0 | 173 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/resources-plugin/org/gvsig/raster/tasseledcap/sextante/i18n/text.properties | ||
---|---|---|
1 |
multispectral=Raster multiespectral |
|
2 |
tasseledcab=Tasseled Cab |
|
3 |
use_roi=Usar las regiones de inter?s de la capa de entrada |
|
0 | 4 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/src/main/resources-plugin/org/gvsig/raster/tasseledcap/sextante/i18n/text_en.properties | ||
---|---|---|
1 |
multispectral=Multispectral raster |
|
2 |
tasseledcab=Tasseled Cab |
|
3 |
use_roi=Use regions of interest of the input layer |
|
0 | 4 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.toolbox.algorithm/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
|
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.raster.tasseledcap.toolbox.algorithm</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>org.gvsig.raster.tasseledcap.toolbox.algorithm</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.raster.tasseledcap</artifactId> |
|
11 |
<version>2.2.199</version> |
|
12 |
</parent> |
|
13 |
<dependencies> |
|
14 |
<dependency> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>org.gvsig.raster.algorithm</artifactId> |
|
17 |
<scope>compile</scope> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.geoprocess.algorithm.base</artifactId> |
|
22 |
<scope>compile</scope> |
|
23 |
</dependency> |
|
24 |
<dependency> |
|
25 |
<groupId>org.gvsig</groupId> |
|
26 |
<artifactId>org.gvsig.raster.tasseledcap.algorithm</artifactId> |
|
27 |
<scope>compile</scope> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<groupId>org.gvsig</groupId> |
|
31 |
<artifactId>org.gvsig.geoprocess.lib.sextante</artifactId> |
|
32 |
<scope>compile</scope> |
|
33 |
</dependency> |
|
34 |
<dependency> |
|
35 |
<groupId>org.gvsig</groupId> |
|
36 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
37 |
<scope>compile</scope> |
|
38 |
</dependency> |
|
39 |
<dependency> |
|
40 |
<groupId>org.gvsig</groupId> |
|
41 |
<artifactId>org.gvsig.ui</artifactId> |
|
42 |
<scope>compile</scope> |
|
43 |
</dependency> |
|
44 |
<dependency> |
|
45 |
<groupId>org.gvsig</groupId> |
|
46 |
<artifactId>org.gvsig.i18n</artifactId> |
|
47 |
<scope>compile</scope> |
|
48 |
</dependency> |
|
49 |
<dependency> |
|
50 |
<groupId>org.gvsig</groupId> |
|
51 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
52 |
<scope>compile</scope> |
|
53 |
</dependency> |
|
54 |
<dependency> |
|
55 |
<groupId>org.gvsig</groupId> |
|
56 |
<artifactId>org.gvsig.fmap.mapcontext.impl</artifactId> |
|
57 |
<scope>runtime</scope> |
|
58 |
</dependency> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
62 |
<scope>compile</scope> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.projection.cresques.impl</artifactId> |
|
67 |
<scope>runtime</scope> |
|
68 |
</dependency> |
|
69 |
<dependency> |
|
70 |
<groupId>org.gvsig</groupId> |
|
71 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
72 |
<scope>compile</scope> |
|
73 |
</dependency> |
|
74 |
</dependencies> |
|
75 |
</project> |
|
0 | 76 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.raster.tasseledcap</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<version>2.2.199</version> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<description /> |
|
9 |
<inceptionYear>2011</inceptionYear> |
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.desktop</artifactId> |
|
13 |
<version>2.0.390</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<properties> |
|
17 |
<!-- El plugin versions:use-latest-versions falla con scope import --> |
|
18 |
<!-- asi que toca usar el versions:update-properties que si que funciona --> |
|
19 |
<org.gvsig.raster.version>2.2.221</org.gvsig.raster.version> |
|
20 |
<org.gvsig.geoprocess.version>2.2.228</org.gvsig.geoprocess.version> |
|
21 |
</properties> |
|
22 |
|
|
23 |
<repositories> |
|
24 |
<repository> |
|
25 |
<id>gvsig-public-http-repository</id> |
|
26 |
<name>gvSIG maven public HTTP repository</name> |
|
27 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
28 |
<releases> |
|
29 |
<enabled>true</enabled> |
|
30 |
<updatePolicy>daily</updatePolicy> |
|
31 |
<checksumPolicy>warn</checksumPolicy> |
|
32 |
</releases> |
|
33 |
<snapshots> |
|
34 |
<enabled>true</enabled> |
|
35 |
<updatePolicy>daily</updatePolicy> |
|
36 |
<checksumPolicy>warn</checksumPolicy> |
|
37 |
</snapshots> |
|
38 |
</repository> |
|
39 |
</repositories> |
|
40 |
|
|
41 |
<scm> |
|
42 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199</connection> |
|
43 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199</developerConnection> |
|
44 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199</url> |
|
45 |
</scm> |
|
46 |
<build> |
|
47 |
<plugins> |
|
48 |
<plugin> |
|
49 |
<groupId>org.apache.maven.plugins</groupId> |
|
50 |
<artifactId>maven-release-plugin</artifactId> |
|
51 |
<configuration> |
|
52 |
<tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.tasseledcap/tags/</tagBase> |
|
53 |
<goals>deploy</goals> |
|
54 |
</configuration> |
|
55 |
</plugin> |
|
56 |
</plugins> |
|
57 |
</build> |
|
58 |
|
|
59 |
<dependencyManagement> |
|
60 |
<dependencies> |
|
61 |
<dependency> |
|
62 |
<groupId>org.gvsig</groupId> |
|
63 |
<artifactId>org.gvsig.raster</artifactId> |
|
64 |
<version>${org.gvsig.raster.version}</version> |
|
65 |
<type>pom</type> |
|
66 |
<scope>import</scope> |
|
67 |
</dependency> |
|
68 |
|
|
69 |
<dependency> |
|
70 |
<groupId>org.gvsig</groupId> |
|
71 |
<artifactId>org.gvsig.geoprocess</artifactId> |
|
72 |
<version>${org.gvsig.geoprocess.version}</version> |
|
73 |
<type>pom</type> |
|
74 |
<scope>import</scope> |
|
75 |
</dependency> |
|
76 |
|
|
77 |
|
|
78 |
<dependency> |
|
79 |
<groupId>org.gvsig.legacy</groupId> |
|
80 |
<artifactId>jama</artifactId> |
|
81 |
<version>1.0.3</version> |
|
82 |
</dependency> |
|
83 |
|
|
84 |
<dependency> |
|
85 |
<groupId>org.gvsig</groupId> |
|
86 |
<artifactId>org.gvsig.raster.tasseledcap.lib.api</artifactId> |
|
87 |
<version>2.2.1-SNAPSHOT</version> |
|
88 |
</dependency> |
|
89 |
<dependency> |
|
90 |
<groupId>org.gvsig</groupId> |
|
91 |
<artifactId>org.gvsig.raster.tasseledcap.lib.impl</artifactId> |
|
92 |
<version>2.2.1-SNAPSHOT</version> |
|
93 |
</dependency> |
|
94 |
<dependency> |
|
95 |
<groupId>org.gvsig</groupId> |
|
96 |
<artifactId>org.gvsig.raster.tasseledcap.swing.api</artifactId> |
|
97 |
<version>2.2.199</version> |
|
98 |
</dependency> |
|
99 |
<dependency> |
|
100 |
<groupId>org.gvsig</groupId> |
|
101 |
<artifactId>org.gvsig.raster.tasseledcap.swing.impl</artifactId> |
|
102 |
<version>2.2.199</version> |
|
103 |
</dependency> |
|
104 |
<dependency> |
|
105 |
<groupId>org.gvsig</groupId> |
|
106 |
<artifactId>org.gvsig.raster.tasseledcap.algorithm</artifactId> |
|
107 |
<version>2.2.199</version> |
|
108 |
</dependency> |
|
109 |
<dependency> |
|
110 |
<groupId>org.gvsig</groupId> |
|
111 |
<artifactId>org.gvsig.raster.tasseledcap.toolbox.algorithm</artifactId> |
|
112 |
<version>2.2.199</version> |
|
113 |
</dependency> |
|
114 |
|
|
115 |
</dependencies> |
|
116 |
</dependencyManagement> |
|
117 |
<modules> |
|
118 |
<module>org.gvsig.raster.tasseledcap.algorithm</module> |
|
119 |
<module>org.gvsig.raster.tasseledcap.toolbox.algorithm</module> |
|
120 |
<module>org.gvsig.raster.tasseledcap.swing</module> |
|
121 |
<module>org.gvsig.raster.tasseledcap.app.tasseledcapclient</module> |
|
122 |
</modules> |
|
123 |
</project> |
|
0 | 124 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.algorithm/src/main/java/org/gvsig/raster/tasseledcap/algorithm/TasseledCapAlgorithmLibrary.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap.algorithm; |
|
2 |
|
|
3 |
import org.gvsig.i18n.Messages; |
|
4 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
5 |
import org.gvsig.tools.library.AbstractLibrary; |
|
6 |
import org.gvsig.tools.library.LibraryException; |
|
7 |
|
|
8 |
/** |
|
9 |
* Initialization of PrincipalComponentsAlgorithmLibrary library. |
|
10 |
*/ |
|
11 |
public class TasseledCapAlgorithmLibrary extends AbstractLibrary { |
|
12 |
public static final String TASSELEDCAP_PROCESS_LABEL = "TasseledCapProcess"; |
|
13 |
|
|
14 |
@Override |
|
15 |
protected void doInitialize() throws LibraryException { |
|
16 |
// Nothing to do |
|
17 |
} |
|
18 |
|
|
19 |
@Override |
|
20 |
protected void doPostInitialize() throws LibraryException { |
|
21 |
//Registers the process and its parameters |
|
22 |
RasterBaseAlgorithmLibrary.register(TASSELEDCAP_PROCESS_LABEL, TasseledCapProcess.class); |
|
23 |
TasseledCapProcess.registerParameters(); |
|
24 |
|
|
25 |
Messages.addResourceFamily( |
|
26 |
"org.gvsig.raster.tasseledcap.algorithm", |
|
27 |
TasseledCapAlgorithmLibrary.class.getClassLoader(), |
|
28 |
TasseledCapAlgorithmLibrary.class.getClass().getName()); |
|
29 |
//registerGeoProcess(new RasterReprojectAlgorithmLibrary()); |
|
30 |
|
|
31 |
Messages.addResourceFamily("org.gvsig.raster.tasseledcap.algorithm.i18n.text", |
|
32 |
TasseledCapAlgorithmLibrary.class.getClassLoader(), |
|
33 |
TasseledCapAlgorithmLibrary.class.getClass().getName()); |
|
34 |
} |
|
35 |
} |
|
0 | 36 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.algorithm/src/main/java/org/gvsig/raster/tasseledcap/algorithm/TasseledCapException.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap.algorithm; |
|
2 |
|
|
3 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
4 |
|
|
5 |
|
|
6 |
/** |
|
7 |
* This exception is thrown if happen problems processing data with this algorithm. |
|
8 |
*/ |
|
9 |
public class TasseledCapException extends ProcessException { |
|
10 |
private static final long serialVersionUID = -3022090543908771484L; |
|
11 |
|
|
12 |
public TasseledCapException(String msg){ |
|
13 |
super(msg); |
|
14 |
} |
|
15 |
|
|
16 |
public TasseledCapException(String msg, Throwable e){ |
|
17 |
super(msg, e); |
|
18 |
} |
|
19 |
} |
|
0 | 20 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.algorithm/src/main/java/org/gvsig/raster/tasseledcap/algorithm/TasseledCapProcess.java | ||
---|---|---|
1 |
package org.gvsig.raster.tasseledcap.algorithm; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
7 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
8 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
9 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
10 |
import org.gvsig.fmap.dal.coverage.exception.CloneException; |
|
11 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
12 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
|
13 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
14 |
import org.gvsig.i18n.Messages; |
|
15 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
16 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
17 |
import org.gvsig.raster.roi.ROI; |
|
18 |
|
|
19 |
/** |
|
20 |
* Tasseled Cab Process |
|
21 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
22 |
*/ |
|
23 |
public class TasseledCapProcess extends DataProcess { |
|
24 |
public static int LANDSAT_MS = 0; |
|
25 |
public static int LANDSAT_TM = 1; |
|
26 |
public static int LANDSAT_ETM = 2; |
|
27 |
|
|
28 |
public static String RASTER_STORE = "RASTER_STORE"; |
|
29 |
public static String PATH = "PATH"; |
|
30 |
public static String FILENAME = "FILENAME"; |
|
31 |
public static String LANDSAT_TYPE = "LANDSAT_TYPE"; |
|
32 |
|
|
33 |
public static final String BUFFERS = "BUFFERS"; |
|
34 |
public static final String GRAPHIC_DATA = "GRAPHIC_DATA"; |
|
35 |
public static final String BANDS = "BANDS"; |
|
36 |
|
|
37 |
private RasterDataStore store = null; |
|
38 |
private String filename = null; |
|
39 |
|
|
40 |
private List<ROI> rois = null; |
|
41 |
private Extent extentResult = null; |
|
42 |
private boolean[] bands = null; |
|
43 |
private NoData nodata = null; |
|
44 |
private double matrixParams[][] = null; |
|
45 |
private int type = LANDSAT_MS; |
|
46 |
|
|
47 |
// MATRICES DE COEFICIENTES PARA CADA TRANSFORMACI?N |
|
48 |
double LandSatMS[][] = { |
|
49 |
/* Brillo de suelo */ {0.433, 0.632, 0.586, 0.264 }, |
|
50 |
/* Indice de Verdor */ {-0.290, -0.562, 0.600, 0.491 }, |
|
51 |
/* Indice de Senescencia */ {-0.829, 0.522, -0.039, 0.194}, |
|
52 |
/* Cuarta */ {0.223, 0.012, -0.543, 0.810} |
|
53 |
}; |
|
54 |
|
|
55 |
double LandSatTM[][] = { |
|
56 |
/* Brillo */ {0.33183, 0.33121, 0.55177, 0.42514, 0.48087, 0.25252 }, |
|
57 |
/* Verdor */ {-0.24717, -0.16263, -0.40639, 0.85468, 0.05493, -0.11749 }, |
|
58 |
/* Tercera */ {0.13929, 0.22490, 0.40359, 0.25178, -0.70133, -0.45732 }, |
|
59 |
}; |
|
60 |
|
|
61 |
double LandSatETM[][] = { |
|
62 |
/* Brightness */ {0.3561, 0.3972, 0.3904, 0.6966, 0.2286, 0.1596 }, |
|
63 |
/* Greenness */ {-0.3344, -0.3544, -0.4556, 0.6966, -0.0242, -0.2630}, |
|
64 |
/* Vetness */ {0.2626, 0.2141, 0.0926, 0.0656, -0.7629, -0.5388 }, |
|
65 |
/* Fourth */ {0.0805, -0.0498, 0.1950, -0.1327, 0.5752, -0.7775 }, |
|
66 |
/* Fifth */ {-0.7252, -0.0202, 0.6683, 0.0631, -0.1494, -0.0274 }, |
|
67 |
/* Sixth */ {0.4000, -0.8172, 0.3832, 0.0602, -0.1095, -0.0985 } |
|
68 |
}; |
|
69 |
|
|
70 |
|
|
71 |
public static void registerParameters() { |
|
72 |
registerInputParameter(RASTER_STORE, RasterDataStore.class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
73 |
registerInputParameter(PATH, String.class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
74 |
registerInputParameter(BANDS, Boolean[].class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
75 |
registerInputParameter(LANDSAT_TYPE, Integer.class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
76 |
|
|
77 |
registerOutputParameter(FILENAME, String.class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
78 |
registerOutputParameter(GRAPHIC_DATA, Double[].class, TasseledCapAlgorithmLibrary.TASSELEDCAP_PROCESS_LABEL); |
|
79 |
} |
|
80 |
|
|
81 |
public void init() { |
|
82 |
store = getParam(RASTER_STORE) != null ? (RasterDataStore)getParam(RASTER_STORE) : null; |
|
83 |
filename = getStringParam(PATH); |
|
84 |
bands = (boolean[]) getParam(BANDS); |
|
85 |
type = getIntParam(LANDSAT_TYPE); |
|
86 |
} |
|
87 |
|
|
88 |
private boolean loadCoefMatrix(int type) { |
|
89 |
switch (type) { |
|
90 |
case 0: |
|
91 |
matrixParams = LandSatMS; |
|
92 |
if(getNumberOfOutputBands(bands) != 4) { |
|
93 |
return false; |
|
94 |
} |
|
95 |
break; |
|
96 |
case 1: |
|
97 |
matrixParams = LandSatTM; |
|
98 |
if(getNumberOfOutputBands(bands) != 6) { |
|
99 |
return false; |
|
100 |
} |
|
101 |
break; |
|
102 |
case 2: |
|
103 |
matrixParams = LandSatETM; |
|
104 |
if(getNumberOfOutputBands(bands) != 6) { |
|
105 |
return false; |
|
106 |
} |
|
107 |
break; |
|
108 |
} |
|
109 |
return true; |
|
110 |
} |
|
111 |
|
|
112 |
public void process() throws ProcessInterruptedException, ProcessException { |
|
113 |
insertLineLog(Messages.getText("processing_tc")); |
|
114 |
if (store == null) { |
|
115 |
throw new TasseledCapException(Messages.getText("need_a_input")); |
|
116 |
} |
|
117 |
|
|
118 |
if(!loadCoefMatrix(type)) { |
|
119 |
throw new TasseledCapException(Messages.getText("wrong_number_of_bands")); |
|
120 |
} |
|
121 |
|
|
122 |
if(getROIEPSG() != null) { |
|
123 |
try { |
|
124 |
rois = store.getRois(getROIEPSG()); |
|
125 |
} catch (ROIException e2) { |
|
126 |
logger.error(Messages.getText("error_getting_rois"), e2); |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
try { |
|
131 |
store = ((RasterDataStore)store).cloneDataStore(); |
|
132 |
} catch (CloneException e) { |
|
133 |
new TasseledCapException("Error cloning the input DataStore", e); |
|
134 |
} |
|
135 |
|
|
136 |
extentResult = getExtentResult(getOutputWindow(), rois, store); |
|
137 |
Rectangle2D sourcePxBBox = getSourcePxBox(extentResult, store); |
|
138 |
|
|
139 |
double cellSize = store.getCellSize(); |
|
140 |
|
|
141 |
nodata = RasterLocator.getManager().getDataStructFactory().createDefaultNoData(1, Buffer.TYPE_DOUBLE); |
|
142 |
double nodataValue = nodata.getValue().doubleValue(); |
|
143 |
|
|
144 |
Buffer outputBuffer = createOutputBuffer((int)sourcePxBBox.getWidth(), (int)sourcePxBBox.getHeight(), matrixParams.length, Buffer.TYPE_FLOAT); |
|
145 |
Buffer sourceBuffer = createSourceBuffer(store, sourcePxBBox, bands); |
|
146 |
|
|
147 |
|
|
148 |
insertLineLog(Messages.getText("writting_in_buffer")); |
|
149 |
float resultValue = 0; |
|
150 |
|
|
151 |
for (int i = 0; i < sourceBuffer.getHeight(); i++) { |
|
152 |
for (int j = 0; j < sourceBuffer.getWidth(); j++) { |
|
153 |
if (isInsideOfROI(j, i, rois, extentResult)) { |
|
154 |
for (int coef = 0; coef < matrixParams.length; coef++) { |
|
155 |
for(int band = 0; band < matrixParams[0].length; band++) { |
|
156 |
resultValue += getValue(sourceBuffer, i, j, band, coef); |
|
157 |
} |
|
158 |
outputBuffer.setElem(i, j, coef, resultValue); |
|
159 |
resultValue = 0; |
|
160 |
} |
|
161 |
} else { |
|
162 |
for (int iBand = 0; iBand < outputBuffer.getBandCount(); iBand++) { |
|
163 |
outputBuffer.setElem(i, j, iBand, (float)nodataValue); |
|
164 |
} |
|
165 |
} |
|
166 |
} |
|
167 |
updatePercent((int)(i * 100 / sourcePxBBox.getHeight()), 100); |
|
168 |
} |
|
169 |
|
|
170 |
super.exportRaster(filename, outputBuffer, cellSize, extentResult.getULX(), |
|
171 |
extentResult.getULY(), nodata, store.getProjection()); |
|
172 |
|
|
173 |
addOutputValue(FILENAME, filename); |
|
174 |
addOutputValue(GRAPHIC_DATA, filename); |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Gets the number of the selected bands |
|
179 |
* @param bandsPCs |
|
180 |
* @return |
|
181 |
*/ |
|
182 |
private int getNumberOfOutputBands(boolean[] b) { |
|
183 |
int bandCount = 0; |
|
184 |
for (int i = 0; i < b.length; i++) { |
|
185 |
if(b[i]) |
|
186 |
bandCount++; |
|
187 |
} |
|
188 |
return bandCount; |
|
189 |
} |
|
190 |
|
|
191 |
private float getValue(Buffer sourceBuffer, int i, int j, int band, int coef) { |
|
192 |
if (sourceBuffer.getDataType() == Buffer.TYPE_BYTE) { |
|
193 |
return (float)((sourceBuffer.getElemByte(i, j, band) & 0xff) * matrixParams[coef][band]); |
|
194 |
} |
|
195 |
if (sourceBuffer.getDataType() == Buffer.TYPE_SHORT) { |
|
196 |
return (float)(sourceBuffer.getElemShort(i, j, band) * matrixParams[coef][band]); |
|
197 |
} |
|
198 |
if (sourceBuffer.getDataType() == Buffer.TYPE_INT) { |
|
199 |
return (float)(sourceBuffer.getElemInt(i, j, band) * matrixParams[coef][band]); |
|
200 |
} |
|
201 |
if (sourceBuffer.getDataType() == Buffer.TYPE_FLOAT) { |
|
202 |
return (float)(sourceBuffer.getElemFloat(i, j, band) * matrixParams[coef][band]); |
|
203 |
} |
|
204 |
if (sourceBuffer.getDataType() == Buffer.TYPE_DOUBLE) { |
|
205 |
return (float)(sourceBuffer.getElemDouble(i, j, band) * matrixParams[coef][band]); |
|
206 |
} |
|
207 |
return nodata.getValue().floatValue(); |
|
208 |
} |
|
209 |
|
|
210 |
public String getTitle() { |
|
211 |
return Messages.getText("tasseled_cap"); |
|
212 |
} |
|
213 |
} |
|
0 | 214 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.algorithm/src/main/resources-plugin/org/gvsig/raster/tasseledcap/algorithm/i18n/text.properties | ||
---|---|---|
1 |
layers_dont_intersect=Las capas no intersectan |
|
2 |
roi_not_inside=La zona de estudio no esta contenida en la extensi?n de las capas |
|
3 |
preparing_buffers=Preparando buffers |
|
0 | 4 |
org.gvsig.raster.tasseledcap/tags/org.gvsig.raster.tasseledcap-2.2.199/org.gvsig.raster.tasseledcap.algorithm/src/main/resources-plugin/org/gvsig/raster/tasseledcap/algorithm/i18n/text_en.properties | ||
---|---|---|
1 |
layers_dont_intersect=Layers do not intersect |
|
2 |
roi_not_inside=The region of interest are not inside the extension of the layers |
|
3 |
preparing_buffers=Preparing buffers |
|
0 | 4 |
Also available in: Unified diff