Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.algorithm / src / main / java / es / unex / sextante / gridTools / changeNoDataValue / ChangeNoDataValueAlgorithm.java @ 59

History | View | Annotate | Download (1.87 KB)

1

    
2

    
3
package es.unex.sextante.gridTools.changeNoDataValue;
4

    
5
import es.unex.sextante.additionalInfo.AdditionalInfoNumericalValue;
6
import es.unex.sextante.core.GeoAlgorithm;
7
import es.unex.sextante.core.Sextante;
8
import es.unex.sextante.dataObjects.IRasterLayer;
9
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException;
10
import es.unex.sextante.exceptions.RepeatedParameterNameException;
11

    
12

    
13
public class ChangeNoDataValueAlgorithm
14
         extends
15
            GeoAlgorithm {
16

    
17
   public static final String  RESULT        = "RESULT";
18
   public static final String  INPUT         = "INPUT";
19
   private static final String NO_DATA_VALUE = "NO_DATA_VALUE";
20

    
21

    
22
   @Override
23
   public void defineCharacteristics() {
24

    
25
      setName(Sextante.getText("ChangeNoDataValue"));
26
      setGroup(Sextante.getText("Basic_tools_for_raster_layers"));
27
      setUserCanDefineAnalysisExtent(false);
28

    
29
      try {
30
         m_Parameters.addInputRasterLayer(INPUT, Sextante.getText("Input_layer"), true);
31
         m_Parameters.addNumericalValue(NO_DATA_VALUE, Sextante.getText("NoDataValue"), -99999.,
32
                  AdditionalInfoNumericalValue.NUMERICAL_VALUE_DOUBLE);
33
         addOutputRasterLayer(RESULT, Sextante.getText("Result"));
34
      }
35
      catch (final RepeatedParameterNameException e) {
36
         Sextante.addErrorToLog(e);
37
      }
38

    
39
   }
40

    
41

    
42
   @Override
43
   public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
44

    
45
      final IRasterLayer layer = m_Parameters.getParameterValueAsRasterLayer(INPUT);
46
      final double dNoData = m_Parameters.getParameterValueAsDouble(NO_DATA_VALUE);
47

    
48
      layer.setFullExtent();
49
      final IRasterLayer result = getNewRasterLayer(RESULT, layer.getName(), layer.getDataType(), layer.getLayerGridExtent());
50
      result.assign(layer);
51
      result.setNoDataValue(dNoData);
52

    
53
      return !m_Task.isCanceled();
54

    
55
   }
56

    
57

    
58
}