Performs arithmetic operation over raster data. More...
#include <ArithmeticOperations.h>
Classes | |
class | ExecStackElement |
Execution stack element. More... | |
class | InputParameters |
ArithmeticOperations input parameters. More... | |
class | OutputParameters |
ArithmeticOperations output parameters. More... | |
Public Member Functions | |
ArithmeticOperations () | |
bool | execute (AlgorithmOutputParameters &outputParams) throw ( te::rp::Exception ) |
Executes the algorithm using the supplied parameters. More... | |
bool | initialize (const AlgorithmInputParameters &inputParams) throw ( te::rp::Exception ) |
Initialize the algorithm instance making it ready for execution. More... | |
bool | isInitialized () const |
Returns true if the algorithm instance is initialized and ready for execution. More... | |
void | reset () throw ( te::rp::Exception ) |
Clear all internal allocated objects and reset the algorithm to its initial state. More... | |
~ArithmeticOperations () | |
Protected Types | |
typedef std::stack < ExecStackElement > | ExecStackT |
Execution stack type definition. More... | |
Protected Member Functions | |
bool | allocResultRaster (unsigned int nLines, unsigned int nCols, boost::shared_ptr< te::rst::Raster > &rasterPtr) const |
Allocate a new RAM memory raster. More... | |
bool | execBinaryOperator (const std::string &token, ExecStackT &execStack, bool generateOutput) const |
Execute the given binary operator using the current given execution stack. More... | |
bool | execUnaryOperator (const std::string &token, ExecStackT &execStack, bool generateOutput) const |
Execute the given unary operator using the current given execution stack. More... | |
bool | executeString (const std::string &aStr, std::vector< boost::shared_ptr< te::rst::Raster > > inRasters, boost::shared_ptr< te::rst::Raster > &outRaster, bool generateOutput) const |
Execute the automata parsing the given input string. More... | |
void | getTokensStrs (const std::string &inputStr, std::vector< std::string > &outTokens) const |
Split the input string into a vector of token strings. More... | |
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. More... | |
bool | isBinaryOperator (const std::string &inputToken) const |
Returns true if the given token is a binary operator. More... | |
bool | isOperator (const std::string &inputToken) const |
Returns true if the given token is an operator. More... | |
bool | isRasterBandToken (const std::string &token, unsigned int &rasterIdx, unsigned int &bandIdx) const |
Returns true if the given token is a raster data token. More... | |
bool | isRealNumberToken (const std::string &token, double &realValue) const |
Returns true if the given token is a real number. More... | |
bool | isUnaryOperator (const std::string &inputToken) const |
Returns true if the given token is a unary operator. More... | |
bool | op1HasGreaterOrEqualPrecedence (const std::string &operator1, const std::string &operator2) const |
Returns true if operator1 has greater of equal precedence over operator2. More... | |
void | printTokens (const std::vector< std::string > &input) const |
Print tokens to stout. More... | |
Protected Attributes | |
ArithmeticOperations::InputParameters | m_inputParameters |
Input execution parameters. More... | |
bool | m_isInitialized |
Tells if this instance is initialized. More... | |
Performs arithmetic operation over raster data.
The expression (arithmetic stringIt) must be formed by a combination of the following elements, separated by spaces:
Operators: +, -, *, /
Real Numbers (negative numbers must follow the form "-1.0")
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).
Definition at line 65 of file ArithmeticOperations.h.
|
protected |
Execution stack type definition.
Definition at line 174 of file ArithmeticOperations.h.
te::rp::ArithmeticOperations::ArithmeticOperations | ( | ) |
Definition at line 123 of file ArithmeticOperations.cpp.
References reset().
te::rp::ArithmeticOperations::~ArithmeticOperations | ( | ) |
Definition at line 128 of file ArithmeticOperations.cpp.
|
protected |
Allocate a new RAM memory raster.
nLines | Number of raster lines. |
nCols | Number of raster columns. |
rasterPtr | The output raster pointer. |
Definition at line 1058 of file ArithmeticOperations.cpp.
References te::common::Convert2String(), te::dt::DOUBLE_TYPE, and te::rst::RasterFactory::make().
Referenced by execBinaryOperator().
|
protected |
Execute the given binary operator using the current given execution stack.
token | Operator token. |
execStack | Execution stack. |
generateOutput | if true the execution will generate valid output data, if false only dummy stack elements will be generated. |
Definition at line 553 of file ArithmeticOperations.cpp.
References allocResultRaster(), te::rst::Raster::getValue(), te::rp::ArithmeticOperations::ExecStackElement::m_isRaster, te::rp::ArithmeticOperations::ExecStackElement::m_isRealNumber, te::rp::ArithmeticOperations::ExecStackElement::m_raster, te::rp::ArithmeticOperations::ExecStackElement::m_rasterBand, te::rp::ArithmeticOperations::ExecStackElement::m_realNumberValue, te::rst::Raster::setValue(), TERP_LOG_AND_RETURN_FALSE, and TERP_TRUE_OR_RETURN_FALSE.
Referenced by executeString().
|
protected |
Execute the given unary operator using the current given execution stack.
token | Operator token. |
execStack | Execution stack. |
generateOutput | if true the execution will generate valid output data, if false only dummy stack elements will be generated. |
Definition at line 1025 of file ArithmeticOperations.cpp.
Referenced by executeString().
|
virtual |
Executes the algorithm using the supplied parameters.
outputParams | Output parameters. |
Implements te::rp::Algorithm.
Definition at line 132 of file ArithmeticOperations.cpp.
References te::dt::DOUBLE_TYPE, executeString(), te::rst::Raster::getBand(), te::rp::GetDataTypeRange(), te::rst::Band::getProperty(), te::rst::BandProperty::getType(), te::rst::Raster::getValue(), isOperator(), te::rp::ArithmeticOperations::InputParameters::m_arithmeticString, te::rp::ArithmeticOperations::InputParameters::m_enableProgress, m_inputParameters, m_isInitialized, te::rp::ArithmeticOperations::InputParameters::m_normalize, te::rp::ArithmeticOperations::OutputParameters::m_outputRasterPtr, te::rp::ArithmeticOperations::InputParameters::m_rasterVec, te::rp::ArithmeticOperations::OutputParameters::m_rInfo, te::rp::ArithmeticOperations::OutputParameters::m_rType, te::rst::RasterFactory::make(), MAX, MIN, te::rst::Raster::setValue(), TERP_TRUE_OR_RETURN_FALSE, and TERP_TRUE_OR_THROW.
Referenced by te::qt::widgets::ArithmeticOpWizard::execute().
|
protected |
Execute the automata parsing the given input string.
aStr | The input arithmetic expression string. |
inRasters | Input rasters pointers. |
outRaster | Output raster pointer (pre-initiated). |
generateOutput | If true, the output raster data will be generated, if false only the automata execution will be performed.. |
Definition at line 334 of file ArithmeticOperations.cpp.
References execBinaryOperator(), execUnaryOperator(), getTokensStrs(), inFix2PostFix(), isBinaryOperator(), isRasterBandToken(), isRealNumberToken(), isUnaryOperator(), te::rp::ArithmeticOperations::ExecStackElement::m_isRaster, te::rp::ArithmeticOperations::ExecStackElement::m_isRealNumber, te::rp::ArithmeticOperations::ExecStackElement::m_raster, te::rp::ArithmeticOperations::ExecStackElement::m_rasterBand, te::rp::ArithmeticOperations::ExecStackElement::m_realNumberValue, TERP_LOG_AND_RETURN_FALSE, and TERP_TRUE_OR_RETURN_FALSE.
Referenced by execute(), and initialize().
|
protected |
Split the input string into a vector of token strings.
inputStr | The input string. |
outTokens | The generated output tokens vector. |
Definition at line 1073 of file ArithmeticOperations.cpp.
References isOperator().
Referenced by executeString().
|
protected |
Convert the input tokens vector from the infix notation to postfix notation.
input | The input tokens vector. |
output | The output tokens vector. |
Definition at line 405 of file ArithmeticOperations.cpp.
References isOperator(), and op1HasGreaterOrEqualPrecedence().
Referenced by executeString().
|
virtual |
Initialize the algorithm instance making it ready for execution.
inputParams | Input parameters. |
Implements te::rp::Algorithm.
Definition at line 285 of file ArithmeticOperations.cpp.
References executeString(), te::rp::ArithmeticOperations::InputParameters::m_arithmeticString, m_inputParameters, m_isInitialized, te::rp::ArithmeticOperations::InputParameters::m_rasterVec, reset(), TERP_TRUE_OR_RETURN_FALSE, and TERP_TRUE_OR_THROW.
Referenced by te::qt::widgets::ArithmeticOpWizard::execute().
|
protected |
Returns true if the given token is a binary operator.
inputToken | Input token. |
Definition at line 485 of file ArithmeticOperations.cpp.
Referenced by executeString(), and isOperator().
|
virtual |
Returns true if the algorithm instance is initialized and ready for execution.
Implements te::rp::Algorithm.
Definition at line 329 of file ArithmeticOperations.cpp.
References m_isInitialized.
|
protected |
Returns true if the given token is an operator.
inputToken | Input token. |
Definition at line 479 of file ArithmeticOperations.cpp.
References isBinaryOperator(), and isUnaryOperator().
Referenced by execute(), getTokensStrs(), and inFix2PostFix().
|
protected |
Returns true if the given token is a raster data token.
token | Input token. |
rasterIdx | The output converted raster index value. |
bandIdx | The output converted band index value. |
Definition at line 515 of file ArithmeticOperations.cpp.
Referenced by executeString().
|
protected |
Returns true if the given token is a real number.
token | Input token. |
realValue | The output converted value. |
Definition at line 1031 of file ArithmeticOperations.cpp.
Referenced by executeString().
|
protected |
Returns true if the given token is a unary operator.
inputToken | Input token. |
Definition at line 492 of file ArithmeticOperations.cpp.
Referenced by executeString(), and isOperator().
|
protected |
Returns true if operator1 has greater of equal precedence over operator2.
operator1 | Operator1 input token. |
operator2 | Operator2 input token. |
Definition at line 497 of file ArithmeticOperations.cpp.
Referenced by inFix2PostFix().
|
protected |
Print tokens to stout.
input | The input tokens vector. |
Definition at line 467 of file ArithmeticOperations.cpp.
|
virtual |
Clear all internal allocated objects and reset the algorithm to its initial state.
Implements te::rp::Algorithm.
Definition at line 279 of file ArithmeticOperations.cpp.
References m_inputParameters, m_isInitialized, and te::rp::ArithmeticOperations::InputParameters::reset().
Referenced by ArithmeticOperations(), initialize(), te::rp::ArithmeticOperations::InputParameters::InputParameters(), te::rp::ArithmeticOperations::InputParameters::operator=(), te::rp::ArithmeticOperations::OutputParameters::operator=(), te::rp::ArithmeticOperations::OutputParameters::OutputParameters(), te::rp::ArithmeticOperations::InputParameters::~InputParameters(), and te::rp::ArithmeticOperations::OutputParameters::~OutputParameters().
|
protected |
Input execution parameters.
Definition at line 176 of file ArithmeticOperations.h.
Referenced by execute(), initialize(), and reset().
|
protected |
Tells if this instance is initialized.
Definition at line 178 of file ArithmeticOperations.h.
Referenced by execute(), initialize(), isInitialized(), and reset().