ArithmeticOperations.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 /*!
21  \file terralib/rp/ArithmeticOperations.h
22  \brief Performs arithmetic operation over raster data.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_ARITHMETICOPERATIONS_H
26 #define __TERRALIB_RP_INTERNAL_ARITHMETICOPERATIONS_H
27 
28 #include "Algorithm.h"
29 #include "../raster/Grid.h"
30 #include "../raster/Interpolator.h"
31 #include "../common/progress/TaskProgress.h"
32 
33 #include <map>
34 #include <memory>
35 #include <stack>
36 #include <string>
37 #include <vector>
38 #include <cmath>
39 
40 namespace te
41 {
42  namespace rst
43  {
44  class Raster;
45  }
46 
47  namespace rp
48  {
49  /*!
50  \class ArithmeticOperations
51 
52  \brief Performs arithmetic operation over raster data.
53 
54  \details The expression (arithmetic stringIt) must be formed by a combination of the following elements,
55  separated by spaces:
56 
57  Operators:
58  +(Sum of Rasters or a raster and a real number),
59  -(Subtraction of Rasters or a raster and a real number),
60  *(Multiplication of Rasters or a raster and a real number),
61  /(Division of Rasters or a raster and a real number)
62  ^(Exponential of a raster and a real number)
63  sqrt() (Square root of a raster)
64  sin() (Sine of a raster)
65  asin() (Arc Sine of a raster)
66  cos() (Cosine of a raster)
67  acos() (Arc Cosine of a raster)
68  log() (Common (base-10) logarithm of a raster)
69  tan() (Tangent of a raster)
70  atan() (Arc tangent of a raster)
71  ln() (Natural (base e) logarithm of a raster)
72 
73  Real Numbers (negative numbers must follow the form "-1.0")
74 
75  Raster bands: R0:1, R0:1, R1:0, .... (R0:1 is a reference to the first raster - with index 0 - from feeder, second band - with index 1).
76 
77  \ingroup rp_gen
78  \note The first input raster properties will be taken as reference.
79  */
81  {
82  public:
83 
84  /*!
85  \class InputParameters
86  \brief ArithmeticOperations input parameters
87  */
89  {
90  public:
91 
92  std::vector< te::rst::Raster* > m_inputRasters; //!< Input rasters vector.
93 
94  std::string m_arithmeticString; //!< Arithmetic string.
95 
96  bool m_normalize; //!< Output values normalization will be performed to fit the first original input raster values range (default:true).
97 
98  bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
99 
100  te::rst::Interpolator::Method m_interpMethod; //!< The raster interpolator method (default:NearestNeighbor).
101 
103 
105 
107 
108  //overload
109  void reset() _NOEXCEPT_OP(false);
110 
111  //overload
112  const InputParameters& operator=( const InputParameters& params );
113 
114  //overload
115  AbstractParameters* clone() const;
116  };
117 
118  /*!
119  \class OutputParameters
120  \brief ArithmeticOperations output parameters
121  */
123  {
124  public:
125 
126  std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
127 
128  std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the output rasters (as described in te::raster::RasterFactory).
129 
130  std::unique_ptr< te::rst::Raster > m_outputRasterPtr; //!< The generated output registered raster.
131 
133 
135 
137 
138  //overload
139  void reset() _NOEXCEPT_OP(false);
140 
141  //overload
142  const OutputParameters& operator=( const OutputParameters& params );
143 
144  //overload
145  AbstractParameters* clone() const;
146  };
147 
149 
151 
152  //overload
153  bool execute( AlgorithmOutputParameters& outputParams ) _NOEXCEPT_OP(false);
154 
155  //overload
156  void reset() _NOEXCEPT_OP(false);
157 
158  //overload
159  bool initialize( const AlgorithmInputParameters& inputParams ) _NOEXCEPT_OP(false);
160 
161  bool isInitialized() const;
162 
163  protected:
164 
165  /*!
166  \class ExecStackElement
167  \brief Execution stack element.
168  */
170  {
171  public :
172 
173  bool m_isRaster; //!< true if this is a raster pointer element.
174 
175  bool m_isRealNumber; //!< true if this is a real number element.
176 
177  bool m_isBinaryOp; //!< true if this is a binary operator pointer element.
178 
179  bool m_isUnaryOp; //!< true if this is a unary operator pointer element.
180 
181  double m_realNumberValue; //!< Real number value.
182 
183  unsigned int m_rasterBand; //!< Raster band index.
184 
185  te::rst::Raster* m_rasterNPtr; //!< Raster pointer.
186 
187  std::string m_binaryOp; //!< Binary operator.
188 
189  std::string m_unaryOp; //!< Unary operator.
190 
191  mutable std::unique_ptr< te::rst::Raster > m_rasterHandler; //!< Raster handler.
192 
194  : m_isRaster(false), m_isRealNumber(false), m_isBinaryOp(false), m_isUnaryOp(false),
195  m_realNumberValue(0), m_rasterBand(0), m_rasterNPtr(0), m_binaryOp(""), m_unaryOp("")
196  {
197  operator=( rhs );
198  }
199 
201  : m_isRaster(false), m_isRealNumber(false), m_isBinaryOp(false), m_isUnaryOp(false),
202  m_realNumberValue(0), m_rasterBand(0), m_rasterNPtr(0), m_binaryOp(""), m_unaryOp("")
203  {}
204 
206  {
207  m_isRaster = rhs.m_isRaster;
208  m_isRealNumber = rhs.m_isRealNumber;
209  m_isBinaryOp = rhs.m_isBinaryOp;
210  m_isUnaryOp = rhs.m_isUnaryOp;
211  m_realNumberValue = rhs.m_realNumberValue;
212  m_rasterBand = rhs.m_rasterBand;
213  m_rasterNPtr = rhs.m_rasterNPtr;
214  m_binaryOp = rhs.m_binaryOp;
215  m_unaryOp = rhs.m_unaryOp;
216  m_rasterHandler.reset( rhs.m_rasterHandler.release() );
217 
218  return *this;
219  }
220 
222  };
223 
224  typedef std::stack< ExecStackElement > ExecStackT; //!< Execution stack type definition.
225 
226  /*!
227  \brief Type definition for a operation function pointer.
228  */
229  typedef void (ArithmeticOperations::*BinOpFuncPtrT)( const double& inputValue1, const double& inputValue2,
230  double& outputValue ) const;
231 
232  typedef void (ArithmeticOperations::*UnaryOpFuncPtrT)(const double& inputValue1, double& outputValue) const;
233 
235 
236  bool m_isInitialized; //!< Tells if this instance is initialized.
237 
238  /*!
239  \brief Addition binary operator function.
240  */
241  inline void additionBinOp( const double& inputValue1, const double& inputValue2,
242  double& outputValue ) const { outputValue = inputValue1 + inputValue2; }
243 
244  /*!
245  \brief Subtraction binary operator function.
246  */
247  inline void subtractionBinOp( const double& inputValue1, const double& inputValue2,
248  double& outputValue ) const { outputValue = inputValue1 - inputValue2; }
249 
250  /*!
251  \brief Multiplication binary operator function.
252  */
253  inline void multiplicationBinOp( const double& inputValue1, const double& inputValue2,
254  double& outputValue ) const { outputValue = inputValue1 * inputValue2; }
255 
256  /*!
257  \brief Division binary operator function.
258  */
259  inline void divisionBinOp( const double& inputValue1, const double& inputValue2,
260  double& outputValue ) const {
261  ( inputValue2 == 0.0 ) ? ( outputValue = 0 )
262  : ( outputValue = inputValue1 / inputValue2 );
263  }
264 
265  /*!
266  \brief Exponencial binary operator function.
267  */
268  inline void exponencialBinOp( const double& inputValue1, const double& inputValue2,
269  double& outputValue ) const { outputValue = pow(inputValue1, inputValue2); }
270 
271  /*!
272  \brief Square root unary operator function.
273  */
274  inline void sqrtUnaryOp(const double& inputValue,
275  double& outputValue) const { outputValue = sqrt(inputValue); }
276 
277  /*!
278  \brief Sine unary operator function.
279  */
280  inline void sinUnaryOp(const double& inputValue,
281  double& outputValue) const { outputValue = sin(inputValue); }
282 
283  /*!
284  \brief Arc sine unary operator function.
285  */
286  inline void asinUnaryOp(const double& inputValue,
287  double& outputValue) const { outputValue = asin(inputValue); }
288 
289  /*!
290  \brief Cosine unary operator function.
291  */
292  inline void cosUnaryOp(const double& inputValue,
293  double& outputValue) const { outputValue = cos(inputValue); }
294 
295  /*!
296  \brief Arc cosine unary operator function.
297  */
298  inline void acosUnaryOp(const double& inputValue,
299  double& outputValue) const { outputValue = acos(inputValue); }
300 
301  /*!
302  \brief Common logarithm unary operator function.
303  */
304  inline void logUnaryOp(const double& inputValue,
305  double& outputValue) const { outputValue = log10(inputValue); }
306 
307  /*!
308  \brief Tangent unary operator function.
309  */
310  inline void tanUnaryOp(const double& inputValue,
311  double& outputValue) const { outputValue = tan(inputValue); }
312 
313  /*!
314  \brief Arc Tangent unary operator function.
315  */
316  inline void atanUnaryOp(const double& inputValue,
317  double& outputValue) const { outputValue = atan(inputValue); }
318 
319  /*!
320  \brief unary operator function.
321  */
322  inline void lnUnaryOp(const double& inputValue,
323  double& outputValue) const { outputValue = log(inputValue); }
324 
325  /*!
326  \brief Execute the automata parsing the given input string.
327  \param aStr The input arithmetic expression string.
328  \param inRasters Input rasters pointers.
329  \param outRaster Output raster pointer (pre-initiated).
330  \param generateOutput If true, the output raster data will be generated, if false only the automata execution will be performed..
331  \param progressPtr A pointer to a progress interface to be pulsed on each operation or a null pointer.
332  */
333  bool executeString( const std::string& aStr,
334  const std::vector< te::rst::Raster* >& inRasters,
335  std::unique_ptr<te::rst::Raster>& outRaster,
336  bool generateOutput,
337  te::common::TaskProgress* const progressPtr ) const;
338 
339  /*!
340  \brief Convert the input tokens vector from the infix notation to postfix notation.
341  \param input The input tokens vector.
342  \param output The output tokens vector.
343  */
344  void inFix2PostFix( const std::vector< std::string >& input,
345  std::vector< std::string >& output ) const;
346 
347  /*!
348  \brief Print tokens to stout.
349  \param input The input tokens vector.
350  */
351  void printTokens( const std::vector< std::string >& input ) const;
352 
353  /*!
354  \brief Returns true if the given token is an operator.
355  \param inputToken Input token.
356  \return Returns true if the given token is an operator.
357  */
358  bool isOperator( const std::string& inputToken ) const;
359 
360  /*!
361  \brief Returns true if the given token is a binary operator.
362  \param inputToken Input token.
363  \return Returns true if the given token is a binary operator.
364  */
365  bool isBinaryOperator( const std::string& inputToken ) const;
366 
367  /*!
368  \brief Returns true if the given token is a unary operator.
369  \param inputToken Input token.
370  \return Returns true if the given token is a unary operator.
371  */
372  bool isUnaryOperator( const std::string& inputToken ) const;
373 
374  /*!
375  \brief Returns true if operator1 has greater of equal precedence over operator2.
376  \param operator1 Operator1 input token.
377  \param operator2 Operator2 input token.
378  \return Returns true if operator1 has greater of equal precedence over operator2.
379  */
380  bool op1HasGreaterOrEqualPrecedence( const std::string& operator1,
381  const std::string& operator2 ) const;
382 
383  /*!
384  \brief Returns true if the given token is a raster data token.
385  \param token Input token.
386  \param rasterIdx The output converted raster index value.
387  \param bandIdx The output converted band index value.
388  \return Returns true if the given token is a raster data token.
389  */
390  bool isRasterBandToken( const std::string& token, unsigned int& rasterIdx,
391  unsigned int& bandIdx ) const;
392 
393  /*!
394  \brief Execute the given binary operator using the current given execution stack.
395  \param token Operator token.
396  \param execStack Execution stack.
397  \param generateOutput if true the execution will generate valid output data, if false only dummy stack elements will be generated.
398  \return true if OK, false on errors..
399  */
400  bool execBinaryOperator( const std::string& token, ExecStackT&
401  execStack, bool generateOutput ) const;
402 
403  /*!
404  \brief Execute the given binary operator using the given input rasters
405  \param inRaster1 Input raster 1.
406  \param band1 Input raster 1 band.
407  \param inRaster2 Input raster 2.
408  \param band2 Input raster 2 band.
409  \param binOptFunctPtr The binary operation function pointer.
410  \param outRasterPtr The generated output raster.
411  \return true if OK, false on errors..
412  */
414  const unsigned int band1, const te::rst::Raster& inRaster2,
415  const unsigned int band2,
416  const BinOpFuncPtrT binOptFunctPtr,
417  std::unique_ptr<te::rst::Raster>& outRasterPtr ) const;
418 
419  /*!
420  \brief Execute the given binary operator using the given input raster and a real number
421  \param inRaster Input raster.
422  \param bandIdx Input raster band.
423  \param binOptFunctPtr The binary operation function pointer.
424  \param outRasterPtr The generated output raster.
425  \param realNumberIsRigthtTerm true if the real number is the right term.
426  \return true if OK, false on errors..
427  */
429  const unsigned int bandIdx, const double value,
430  const BinOpFuncPtrT binOptFunctPtr,
431  std::unique_ptr<te::rst::Raster>& outRasterPtr,
432  const bool realNumberIsRigthtTerm ) const;
433 
434  /*!
435  \brief Execute the given unary operator using the current given execution stack.
436  \param token Operator token.
437  \param execStack Execution stack.
438  \param generateOutput if true the execution will generate valid output data, if false only dummy stack elements will be generated.
439  \return true if OK, false on errors..
440  */
441  bool execUnaryOperator( const std::string& token, ExecStackT&
442  execStack, bool generateOutput ) const;
443 
444  /*!
445  \brief Execute the given unary operator using the given input raster
446  \param inRaster Input raster.
447  \param band1 Input raster band.
448  \param unaryOptFunctPtr The unary operation function pointer.
449  \param outRasterPtr The generated output raster.
450  \return true if OK, false on errors..
451  */
453  const unsigned int band, const UnaryOpFuncPtrT unaryOptFunctPtr,
454  std::unique_ptr<te::rst::Raster>& outRasterPtr) const;
455 
456  /*!
457  \brief Execute the given unary operator using the given a real number
458  \param unaryOptFunctPtr The unary operation function pointer.
459  \param outRasterPtr The generated output raster.
460  \param realNumberIsRigthtTerm true if the real number is the right term.
461  \return true if OK, false on errors..
462  */
463  bool execUnaryOperatorReal(const double value,
464  const UnaryOpFuncPtrT unaryOptFunctPtr,
465  std::unique_ptr<te::rst::Raster>& outRasterPtr,
466  const bool realNumberIsRigthtTerm) const;
467 
468  /*!
469  \brief Returns true if the given token is a real number.
470  \param token Input token.
471  \param realValue The output converted value.
472  \return Returns true if the given token is a real number.
473  */
474  bool isRealNumberToken( const std::string& token, double& realValue ) const;
475 
476  /*!
477  \brief Allocate a new RAM memory raster.
478  \param grid The output raster grid.
479  \param rasterPtr The output raster pointer.
480  \return Returns true if OK, false on errors.
481  */
482  bool allocResultRaster( const te::rst::Grid& grid,
483  std::unique_ptr<te::rst::Raster>& rasterPtr ) const;
484 
485  /*!
486  \brief Split the input string into a vector of token strings
487  \param inputStr The input string.
488  \param outTokens The generated output tokens vector.
489  */
490  void getTokensStrs( const std::string& inputStr,
491  std::vector< std::string >& outTokens ) const;
492  };
493  } // end namespace rp
494 } // end namespace te
495 
496 #endif // __TERRALIB_RP_INTERNAL_ARITHMETICOPERATIONS_H
te::rp::ArithmeticOperations::execBinaryOperatorRasterXRaster
bool execBinaryOperatorRasterXRaster(const te::rst::Raster &inRaster1, const unsigned int band1, const te::rst::Raster &inRaster2, const unsigned int band2, const BinOpFuncPtrT binOptFunctPtr, std::unique_ptr< te::rst::Raster > &outRasterPtr) const
Execute the given binary operator using the given input rasters.
te::rp::ArithmeticOperations::isOperator
bool isOperator(const std::string &inputToken) const
Returns true if the given token is an operator.
te::rp::ArithmeticOperations::InputParameters::m_arithmeticString
std::string m_arithmeticString
Arithmetic string.
Definition: ArithmeticOperations.h:94
te::rp::ArithmeticOperations::additionBinOp
void additionBinOp(const double &inputValue1, const double &inputValue2, double &outputValue) const
Addition binary operator function.
Definition: ArithmeticOperations.h:241
te::rp::ArithmeticOperations::executeString
bool executeString(const std::string &aStr, const std::vector< te::rst::Raster * > &inRasters, std::unique_ptr< te::rst::Raster > &outRaster, bool generateOutput, te::common::TaskProgress *const progressPtr) const
Execute the automata parsing the given input string.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::AlgorithmOutputParameters
Raster Processing algorithm output parameters base interface.
Definition: AlgorithmOutputParameters.h:40
te::rp::ArithmeticOperations::ExecStackT
std::stack< ExecStackElement > ExecStackT
Execution stack type definition.
Definition: ArithmeticOperations.h:224
te::rp::ArithmeticOperations::OutputParameters::m_outputRasterPtr
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
The generated output registered raster.
Definition: ArithmeticOperations.h:130
te::rp::ArithmeticOperations::execUnaryOperatorReal
bool execUnaryOperatorReal(const double value, const UnaryOpFuncPtrT unaryOptFunctPtr, std::unique_ptr< te::rst::Raster > &outRasterPtr, const bool realNumberIsRigthtTerm) const
Execute the given unary operator using the given a real number.
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::rp::ArithmeticOperations::InputParameters::InputParameters
InputParameters()
te::rp::ArithmeticOperations::execBinaryOperator
bool execBinaryOperator(const std::string &token, ExecStackT &execStack, bool generateOutput) const
Execute the given binary operator using the current given execution stack.
te::rp::AlgorithmInputParameters
Raster Processing algorithm input parameters base interface.
Definition: AlgorithmInputParameters.h:40
te::rp::ArithmeticOperations::ExecStackElement::m_rasterNPtr
te::rst::Raster * m_rasterNPtr
Raster pointer.
Definition: ArithmeticOperations.h:185
te::rp::ArithmeticOperations::ExecStackElement::ExecStackElement
ExecStackElement(const ExecStackElement &rhs)
Definition: ArithmeticOperations.h:193
_NOEXCEPT_OP
#define _NOEXCEPT_OP(x)
Definition: NoExceptDefinition.h:36
te::rp::ArithmeticOperations::printTokens
void printTokens(const std::vector< std::string > &input) const
Print tokens to stout.
te::rp::ArithmeticOperations::ExecStackElement::m_rasterHandler
std::unique_ptr< te::rst::Raster > m_rasterHandler
Raster handler.
Definition: ArithmeticOperations.h:191
te::rp::ArithmeticOperations::isRasterBandToken
bool isRasterBandToken(const std::string &token, unsigned int &rasterIdx, unsigned int &bandIdx) const
Returns true if the given token is a raster data token.
te::rp::ArithmeticOperations::isRealNumberToken
bool isRealNumberToken(const std::string &token, double &realValue) const
Returns true if the given token is a real number.
te::rp::ArithmeticOperations::isBinaryOperator
bool isBinaryOperator(const std::string &inputToken) const
Returns true if the given token is a binary operator.
te::rp::ArithmeticOperations::execUnaryOperator
bool execUnaryOperator(const std::string &token, ExecStackT &execStack, bool generateOutput) const
Execute the given unary operator using the current given execution stack.
te::rp::ArithmeticOperations::OutputParameters::reset
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::ArithmeticOperations::lnUnaryOp
void lnUnaryOp(const double &inputValue, double &outputValue) const
unary operator function.
Definition: ArithmeticOperations.h:322
te::rp::ArithmeticOperations::ExecStackElement::m_isRealNumber
bool m_isRealNumber
true if this is a real number element.
Definition: ArithmeticOperations.h:175
te::rp::ArithmeticOperations::ExecStackElement::m_isUnaryOp
bool m_isUnaryOp
true if this is a unary operator pointer element.
Definition: ArithmeticOperations.h:179
te::rp::Algorithm
Raster Processing algorithm base interface.
Definition: Algorithm.h:42
te::rst::Grid
A rectified grid is the spatial support for raster data.
Definition: Grid.h:69
te::rp::ArithmeticOperations::OutputParameters::m_rType
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: ArithmeticOperations.h:126
te::rp::ArithmeticOperations
Performs arithmetic operation over raster data.
Definition: ArithmeticOperations.h:81
te::rp::ArithmeticOperations::allocResultRaster
bool allocResultRaster(const te::rst::Grid &grid, std::unique_ptr< te::rst::Raster > &rasterPtr) const
Allocate a new RAM memory raster.
te::rp::ArithmeticOperations::ExecStackElement::m_binaryOp
std::string m_binaryOp
Binary operator.
Definition: ArithmeticOperations.h:187
te::rp::ArithmeticOperations::tanUnaryOp
void tanUnaryOp(const double &inputValue, double &outputValue) const
Tangent unary operator function.
Definition: ArithmeticOperations.h:310
te::rp::ArithmeticOperations::atanUnaryOp
void atanUnaryOp(const double &inputValue, double &outputValue) const
Arc Tangent unary operator function.
Definition: ArithmeticOperations.h:316
te::rst::InterpolationMethod
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
te::rp::ArithmeticOperations::InputParameters::m_enableProgress
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: ArithmeticOperations.h:98
te::rp::ArithmeticOperations::ExecStackElement::~ExecStackElement
~ExecStackElement()
Definition: ArithmeticOperations.h:221
te::rp::ArithmeticOperations::execBinaryOperatorRasterXReal
bool execBinaryOperatorRasterXReal(const te::rst::Raster &inRaster, const unsigned int bandIdx, const double value, const BinOpFuncPtrT binOptFunctPtr, std::unique_ptr< te::rst::Raster > &outRasterPtr, const bool realNumberIsRigthtTerm) const
Execute the given binary operator using the given input raster and a real number.
te::rp::ArithmeticOperations::getTokensStrs
void getTokensStrs(const std::string &inputStr, std::vector< std::string > &outTokens) const
Split the input string into a vector of token strings.
te::rp::ArithmeticOperations::ExecStackElement::m_isBinaryOp
bool m_isBinaryOp
true if this is a binary operator pointer element.
Definition: ArithmeticOperations.h:177
te::rp::ArithmeticOperations::sqrtUnaryOp
void sqrtUnaryOp(const double &inputValue, double &outputValue) const
Square root unary operator function.
Definition: ArithmeticOperations.h:274
te::rp::ArithmeticOperations::InputParameters::InputParameters
InputParameters(const InputParameters &)
te::rp::ArithmeticOperations::inFix2PostFix
void inFix2PostFix(const std::vector< std::string > &input, std::vector< std::string > &output) const
Convert the input tokens vector from the infix notation to postfix notation.
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::ArithmeticOperations::multiplicationBinOp
void multiplicationBinOp(const double &inputValue1, const double &inputValue2, double &outputValue) const
Multiplication binary operator function.
Definition: ArithmeticOperations.h:253
te::rp::ArithmeticOperations::logUnaryOp
void logUnaryOp(const double &inputValue, double &outputValue) const
Common logarithm unary operator function.
Definition: ArithmeticOperations.h:304
te::rp::ArithmeticOperations::OutputParameters::~OutputParameters
~OutputParameters()
te::rp::ArithmeticOperations::OutputParameters::m_rInfo
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition: ArithmeticOperations.h:128
te::rp::ArithmeticOperations::OutputParameters::OutputParameters
OutputParameters()
te::rp::ArithmeticOperations::InputParameters
ArithmeticOperations input parameters.
Definition: ArithmeticOperations.h:89
te::rp::ArithmeticOperations::op1HasGreaterOrEqualPrecedence
bool op1HasGreaterOrEqualPrecedence(const std::string &operator1, const std::string &operator2)const
Returns true if operator1 has greater of equal precedence over operator2.
te::rp::ArithmeticOperations::ExecStackElement::m_rasterBand
unsigned int m_rasterBand
Raster band index.
Definition: ArithmeticOperations.h:183
te::rp::ArithmeticOperations::InputParameters::reset
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::ArithmeticOperations::OutputParameters::OutputParameters
OutputParameters(const OutputParameters &)
te::rp::ArithmeticOperations::m_inputParameters
ArithmeticOperations::InputParameters m_inputParameters
Input execution parameters.
Definition: ArithmeticOperations.h:234
te::rp::ArithmeticOperations::isUnaryOperator
bool isUnaryOperator(const std::string &inputToken) const
Returns true if the given token is a unary operator.
te::rp::ArithmeticOperations::InputParameters::m_normalize
bool m_normalize
Output values normalization will be performed to fit the first original input raster values range (de...
Definition: ArithmeticOperations.h:96
te::rp::ArithmeticOperations::OutputParameters
ArithmeticOperations output parameters.
Definition: ArithmeticOperations.h:123
te::rp::ArithmeticOperations::ExecStackElement
Execution stack element.
Definition: ArithmeticOperations.h:170
te::rp::ArithmeticOperations::ExecStackElement::operator=
ExecStackElement & operator=(const ExecStackElement &rhs)
Definition: ArithmeticOperations.h:205
te::rp::ArithmeticOperations::ExecStackElement::m_realNumberValue
double m_realNumberValue
Real number value.
Definition: ArithmeticOperations.h:181
Algorithm.h
Abstract algorithm.
te::common::TaskProgress
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:54
te::rp::ArithmeticOperations::InputParameters::~InputParameters
~InputParameters()
te::rp::ArithmeticOperations::ExecStackElement::ExecStackElement
ExecStackElement()
Definition: ArithmeticOperations.h:200
te::rp::ArithmeticOperations::InputParameters::m_inputRasters
std::vector< te::rst::Raster * > m_inputRasters
Input rasters vector.
Definition: ArithmeticOperations.h:92
te::rp::ArithmeticOperations::subtractionBinOp
void subtractionBinOp(const double &inputValue1, const double &inputValue2, double &outputValue) const
Subtraction binary operator function.
Definition: ArithmeticOperations.h:247
te::rp::ArithmeticOperations::exponencialBinOp
void exponencialBinOp(const double &inputValue1, const double &inputValue2, double &outputValue) const
Exponencial binary operator function.
Definition: ArithmeticOperations.h:268
te::rp::ArithmeticOperations::divisionBinOp
void divisionBinOp(const double &inputValue1, const double &inputValue2, double &outputValue) const
Division binary operator function.
Definition: ArithmeticOperations.h:259
te::rp::ArithmeticOperations::ExecStackElement::m_isRaster
bool m_isRaster
true if this is a raster pointer element.
Definition: ArithmeticOperations.h:173
te::rp::ArithmeticOperations::sinUnaryOp
void sinUnaryOp(const double &inputValue, double &outputValue) const
Sine unary operator function.
Definition: ArithmeticOperations.h:280
te::rp::ArithmeticOperations::m_isInitialized
bool m_isInitialized
Tells if this instance is initialized.
Definition: ArithmeticOperations.h:236
te::rp::ArithmeticOperations::ExecStackElement::m_unaryOp
std::string m_unaryOp
Unary operator.
Definition: ArithmeticOperations.h:189
te::rp::ArithmeticOperations::execUnaryOperatorRaster
bool execUnaryOperatorRaster(const te::rst::Raster &inRaster, const unsigned int band, const UnaryOpFuncPtrT unaryOptFunctPtr, std::unique_ptr< te::rst::Raster > &outRasterPtr) const
Execute the given unary operator using the given input raster.
te::rp::ArithmeticOperations::InputParameters::m_interpMethod
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: ArithmeticOperations.h:100
te::rp::ArithmeticOperations::acosUnaryOp
void acosUnaryOp(const double &inputValue, double &outputValue) const
Arc cosine unary operator function.
Definition: ArithmeticOperations.h:298
te::rp::ArithmeticOperations::asinUnaryOp
void asinUnaryOp(const double &inputValue, double &outputValue) const
Arc sine unary operator function.
Definition: ArithmeticOperations.h:286
te::rp::ArithmeticOperations::cosUnaryOp
void cosUnaryOp(const double &inputValue, double &outputValue) const
Cosine unary operator function.
Definition: ArithmeticOperations.h:292