ComposerRule.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 #ifndef __TERRALIB_RP_INTERNAL_COMPOSER_RULE_H
21 #define __TERRALIB_RP_INTERNAL_COMPOSER_RULE_H
22 
23 #include "Config.h"
24 #include "../raster/Raster.h"
25 #include "../raster/Interpolator.h"
26 #include "../geometry/MultiPolygon.h"
27 #include "../geometry/GeometricTransformation.h"
28 
29 #include <memory>
30 #include <vector>
31 
32 namespace te
33 {
34  namespace rp
35  {
36  class Composer;
37 
38  /*!
39  \class Composer Rule
40  \brief A rule used by the te::rst::Composer classe.
41  \ingroup rp_optical
42  */
44  {
45  public:
46 
47  virtual ~ComposerRule();
48 
49  /*!
50  \brief Return the current error message if there is any.
51 
52  \return Return the current error message if there is any.
53  */
54  const std::string& getErrorMessage() const;
55 
56  protected:
57 
58  friend class Composer;
59 
60  bool m_forceRaster1NoDataValue; //!< Use noDataValue as the input raster 1 no-data value (The original rasters no-data values will be ignored)
61  bool m_forceRaster2NoDataValue; //!< Use noDataValue as the input raster 2 no-data value (The original rasters no-data values will be ignored)
62  te::rst::Raster const * m_raster1Ptr; //!< Input raster 1.
63  te::rst::Raster const * m_raster2Ptr; //!< Input raster 2.
64  te::rst::Raster * m_raster3Ptr; //!< Input raster 3.
65  te::rst::Interpolator::Method m_interpMethod1; //!< The interpolation method to use when reading raster 1 data.
66  te::rst::Interpolator::Method m_interpMethod2; //!< The interpolation method to use when reading raster 2 data.
67  double m_outputNoDataValue; //!< The output raster no-data value.
68  std::vector< unsigned int > m_raster1Bands; //!< Input raster 1 band indexes to use.
69  std::vector< unsigned int > m_raster2Bands; //!< Input raster 2 band indexes to use.
70  std::vector< unsigned int > m_raster3Bands; //!< Input raster 3 band indexes to use.
71  std::vector< double > m_pixelOffsets1; //!< The values offset to be applied to raster 1 pixel values before the composed value calcule (one element for each used raster channel/band).
72  std::vector< double > m_pixelScales1; //!< The values scale to be applied to raster 1 pixel values before the composed value calcule (one element for each used raster channel/band).
73  std::vector< double > m_pixelOffsets2; //!< The values offset to be applied to raster 2 pixel values before the composed value calcule (one element for each used raster channel/band).
74  std::vector< double > m_pixelScales2; //!< The values scale to be applied to raster 2 pixel values before the composed value calcule (one element for each used raster channel/band).
75  std::string m_errorMessage; //!< Current error message.
76 
78 
79  ComposerRule( const ComposerRule& other );
80 
81  const ComposerRule& operator=( const ComposerRule& other );
82 
83  /*!
84  \brief Inititate the instance.
85  \param raster1 Raster 1.
86  \param raster1Bands Raster 1 band indexes to use.
87  \param raster2 Raster 2.
88  \param raster2Bands Raster 2 band indexes to use (this vector has the same size as raster1Bands).
89  \param raster3 Raster 3.
90  \param raster3Bands Raster 3 band indexes to use (this vector has the same size as raster1Bands).
91  \param interpMethod1 The interpolation method to use when reading raster 1 data.
92  \param interpMethod2 The interpolation method to use when reading raster 2 data.
93  \param noDataValue The value returned where there is no pixel data.
94  \param forceRaster1NoDataValue Use noDataValue as the input raster 1 no-data value (The original rasters no-data values will be ignored)
95  \param forceRaster2NoDataValue Use noDataValue as the input raster 1 no-data value (The original rasters no-data values will be ignored)
96  \param pixelOffsets1 The values offset to be applied to raster 1 pixel values before the composed value calcule (one element for each used raster channel/band).
97  \param pixelScales1 The values scale to be applied to raster 1 pixel values before the composed value calcule (one element for each used raster channel/band).
98  \param pixelOffsets2 The values offset to be applied to raster 2 pixel values before the composed value calcule (one element for each used raster channel/band).
99  \param pixelScales2 The values scale to be applied to raster 2 pixel values before the composed value calcule (one element for each used raster channel/band).
100  \return true if ok, false on errors
101  \note Aboute scale and offset parametrs: outValue = ( inputValue * scale ) + offset
102  */
103  virtual bool initialize(
104  const te::rst::Raster& raster1,
105  const std::vector< unsigned int >& raster1Bands,
106  const te::rst::Raster& raster2,
107  const std::vector< unsigned int >& raster2Bands,
108  te::rst::Raster& raster3,
109  const std::vector< unsigned int >& raster3Bands,
110  const te::rst::Interpolator::Method& interpMethod1,
111  const te::rst::Interpolator::Method& interpMethod2,
112  const double& noDataValue,
113  const bool forceRaster1NoDataValue,
114  const bool forceRaster2NoDataValue,
115  const std::vector< double >& pixelOffsets1,
116  const std::vector< double >& pixelScales1,
117  const std::vector< double >& pixelOffsets2,
118  const std::vector< double >& pixelScales2 );
119 
120  /*!
121  \brief Compose a pixel value using the current parameters.
122  \param line Line (raster 3 reference).
123  \param col Column (raster 3 reference).
124  \param composedValuesPtr A pointer to a pre-allocated vector where the composed values will be stored.
125  \note The caller of this method must be aware that the returned composed value may be outside the original input rasters valid values range.
126  \note Raster 1 values have precedence over raster 2 values (when applicable).
127  */
128  virtual void getComposedValues( const double& line, const double& col,
129  double* const composedValuesPtr ) const = 0;
130 
131  /*!
132  \brief Create a clone of this instance.
133  \return A clone of this instance.
134  \note The caller of this method must take othe owndershipd of the returned pointer.
135  */
136  virtual ComposerRule* clone() const = 0;
137 
138  /*!
139  \brief Set the current error message.
140 
141  \param newErrorMessage New error message;
142  */
143  void setErrorMessage( const std::string& newErrorMessage );
144 
145  void initState();
146 
147  void clear();
148 
149  private :
150 
151 
152  };
153 
154  } // end namespace rp
155 } // end namespace te
156 
157 #endif
158 
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::ComposerRule::m_pixelScales1
std::vector< double > m_pixelScales1
The values scale to be applied to raster 1 pixel values before the composed value calcule (one elemen...
Definition: ComposerRule.h:72
te::rp::ComposerRule::initState
void initState()
te::rp::ComposerRule::initialize
virtual bool initialize(const te::rst::Raster &raster1, const std::vector< unsigned int > &raster1Bands, const te::rst::Raster &raster2, const std::vector< unsigned int > &raster2Bands, te::rst::Raster &raster3, const std::vector< unsigned int > &raster3Bands, const te::rst::Interpolator::Method &interpMethod1, const te::rst::Interpolator::Method &interpMethod2, const double &noDataValue, const bool forceRaster1NoDataValue, const bool forceRaster2NoDataValue, const std::vector< double > &pixelOffsets1, const std::vector< double > &pixelScales1, const std::vector< double > &pixelOffsets2, const std::vector< double > &pixelScales2)
Inititate the instance.
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::rp::ComposerRule::setErrorMessage
void setErrorMessage(const std::string &newErrorMessage)
Set the current error message.
te::rp::ComposerRule::m_errorMessage
std::string m_errorMessage
Current error message.
Definition: ComposerRule.h:75
te::rp::ComposerRule::getComposedValues
virtual void getComposedValues(const double &line, const double &col, double *const composedValuesPtr) const =0
Compose a pixel value using the current parameters.
te::rp::Composer
Composed pixel value calculation for two overlaped rasters.
Definition: Composer.h:55
te::rp::ComposerRule::m_outputNoDataValue
double m_outputNoDataValue
The output raster no-data value.
Definition: ComposerRule.h:67
te::rp::ComposerRule::~ComposerRule
virtual ~ComposerRule()
te::rp::ComposerRule::m_pixelScales2
std::vector< double > m_pixelScales2
The values scale to be applied to raster 2 pixel values before the composed value calcule (one elemen...
Definition: ComposerRule.h:74
te::rp::ComposerRule::operator=
const ComposerRule & operator=(const ComposerRule &other)
te::rp::ComposerRule::m_interpMethod1
te::rst::Interpolator::Method m_interpMethod1
The interpolation method to use when reading raster 1 data.
Definition: ComposerRule.h:65
te::rp::ComposerRule::ComposerRule
ComposerRule()
te::rp::ComposerRule::m_interpMethod2
te::rst::Interpolator::Method m_interpMethod2
The interpolation method to use when reading raster 2 data.
Definition: ComposerRule.h:66
te::rp::ComposerRule::m_raster3Bands
std::vector< unsigned int > m_raster3Bands
Input raster 3 band indexes to use.
Definition: ComposerRule.h:70
te::rp::ComposerRule::m_raster2Ptr
te::rst::Raster const * m_raster2Ptr
Input raster 2.
Definition: ComposerRule.h:63
te::rst::InterpolationMethod
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
te::rp::ComposerRule::m_forceRaster2NoDataValue
bool m_forceRaster2NoDataValue
Use noDataValue as the input raster 2 no-data value (The original rasters no-data values will be igno...
Definition: ComposerRule.h:61
te::rp::ComposerRule::m_raster2Bands
std::vector< unsigned int > m_raster2Bands
Input raster 2 band indexes to use.
Definition: ComposerRule.h:69
TERPEXPORT
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
te::rp::ComposerRule::ComposerRule
ComposerRule(const ComposerRule &other)
te::rp::ComposerRule::clear
void clear()
te::rp::ComposerRule
Definition: ComposerRule.h:44
te::rp::ComposerRule::m_pixelOffsets1
std::vector< double > m_pixelOffsets1
The values offset to be applied to raster 1 pixel values before the composed value calcule (one eleme...
Definition: ComposerRule.h:71
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::rp::ComposerRule::m_forceRaster1NoDataValue
bool m_forceRaster1NoDataValue
Use noDataValue as the input raster 1 no-data value (The original rasters no-data values will be igno...
Definition: ComposerRule.h:60
te::rp::ComposerRule::m_pixelOffsets2
std::vector< double > m_pixelOffsets2
The values offset to be applied to raster 2 pixel values before the composed value calcule (one eleme...
Definition: ComposerRule.h:73
te::rp::ComposerRule::m_raster1Ptr
te::rst::Raster const * m_raster1Ptr
Input raster 1.
Definition: ComposerRule.h:62
te::rp::ComposerRule::m_raster1Bands
std::vector< unsigned int > m_raster1Bands
Input raster 1 band indexes to use.
Definition: ComposerRule.h:68
te::rp::ComposerRule::m_raster3Ptr
te::rst::Raster * m_raster3Ptr
Input raster 3.
Definition: ComposerRule.h:64
te::rp::ComposerRule::clone
virtual ComposerRule * clone() const =0
Create a clone of this instance.
te::rp::ComposerRule::getErrorMessage
const std::string & getErrorMessage() const
Return the current error message if there is any.