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) _NOEXCEPT_OP(false) |
| Executes the algorithm using the supplied parameters. More... | |
| const std::string & | getErrorMessage () const |
| Return the current error message if there is any. More... | |
| bool | initialize (const AlgorithmInputParameters &inputParams) _NOEXCEPT_OP(false) |
| 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 () _NOEXCEPT_OP(false) |
| Clear all internal allocated objects and reset the algorithm to its initial state. More... | |
| ~ArithmeticOperations () | |
Protected Types | |
| typedef void(ArithmeticOperations::* | BinOpFuncPtrT) (const double &inputValue1, const double &inputValue2, double &outputValue) const |
| Type definition for a operation function pointer. More... | |
| typedef std::stack< ExecStackElement > | ExecStackT |
| Execution stack type definition. More... | |
| typedef void(ArithmeticOperations::* | UnaryOpFuncPtrT) (const double &inputValue1, double &outputValue) const |
Protected Member Functions | |
| void | acosUnaryOp (const double &inputValue, double &outputValue) const |
| Arc cosine unary operator function. More... | |
| void | additionBinOp (const double &inputValue1, const double &inputValue2, double &outputValue) const |
| Addition binary operator function. More... | |
| bool | allocResultRaster (const te::rst::Grid &grid, std::unique_ptr< te::rst::Raster > &rasterPtr) const |
| Allocate a new RAM memory raster. More... | |
| void | asinUnaryOp (const double &inputValue, double &outputValue) const |
| Arc sine unary operator function. More... | |
| void | atanUnaryOp (const double &inputValue, double &outputValue) const |
| Arc Tangent unary operator function. More... | |
| void | cosUnaryOp (const double &inputValue, double &outputValue) const |
| Cosine unary operator function. More... | |
| void | divisionBinOp (const double &inputValue1, const double &inputValue2, double &outputValue) const |
| Division binary operator function. 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 | 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. More... | |
| 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. 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 | 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. More... | |
| 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. More... | |
| 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. More... | |
| void | exponencialBinOp (const double &inputValue1, const double &inputValue2, double &outputValue) const |
| Exponencial binary operator function. 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... | |
| void | lnUnaryOp (const double &inputValue, double &outputValue) const |
| unary operator function. More... | |
| void | logUnaryOp (const double &inputValue, double &outputValue) const |
| Common logarithm unary operator function. More... | |
| void | multiplicationBinOp (const double &inputValue1, const double &inputValue2, double &outputValue) const |
| Multiplication binary operator function. 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... | |
| void | setErrorMessage (const std::string &newErrorMessage) |
| Set the current error message. More... | |
| void | sinUnaryOp (const double &inputValue, double &outputValue) const |
| Sine unary operator function. More... | |
| void | sqrtUnaryOp (const double &inputValue, double &outputValue) const |
| Square root unary operator function. More... | |
| void | subtractionBinOp (const double &inputValue1, const double &inputValue2, double &outputValue) const |
| Subtraction binary operator function. More... | |
| void | tanUnaryOp (const double &inputValue, double &outputValue) const |
| Tangent unary operator function. 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: +(Sum of Rasters or a raster and a real number), -(Subtraction of Rasters or a raster and a real number), (Multiplication of Rasters or a raster and a real number), /(Division of Rasters or a raster and a real number) ^(Exponential of a raster and a real number) sqrt() (Square root of a raster) sin() (Sine of a raster) asin() (Arc Sine of a raster) cos() (Cosine of a raster) acos() (Arc Cosine of a raster) log() (Common (base-10) logarithm of a raster) tan() (Tangent of a raster) atan() (Arc tangent of a raster) ln() (Natural (base e) logarithm of a raster)
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 82 of file ArithmeticOperations.h.
|
protected |
Type definition for a operation function pointer.
Definition at line 231 of file ArithmeticOperations.h.
|
protected |
Execution stack type definition.
Definition at line 226 of file ArithmeticOperations.h.
|
protected |
Definition at line 234 of file ArithmeticOperations.h.
| te::rp::ArithmeticOperations::ArithmeticOperations | ( | ) |
Definition at line 128 of file src/terralib/rp/ArithmeticOperations.cpp.
References te::rp::ArithmeticOperations::InputParameters::reset(), and ~ArithmeticOperations().
|
default |
Referenced by ArithmeticOperations().
|
inlineprotected |
Arc cosine unary operator function.
Definition at line 300 of file ArithmeticOperations.h.
Referenced by execUnaryOperator().
|
inlineprotected |
Addition binary operator function.
Definition at line 243 of file ArithmeticOperations.h.
Referenced by execBinaryOperator().
|
protected |
Allocate a new RAM memory raster.
| grid | The output raster grid. |
| rasterPtr | The output raster pointer. |
Definition at line 1065 of file src/terralib/rp/ArithmeticOperations.cpp.
References te::dt::DOUBLE_TYPE, te::rst::Grid::getNumberOfColumns(), and te::rst::Grid::getNumberOfRows().
Referenced by execBinaryOperatorRasterXRaster(), execBinaryOperatorRasterXReal(), and execUnaryOperatorRaster().
|
inlineprotected |
Arc sine unary operator function.
Definition at line 288 of file ArithmeticOperations.h.
Referenced by execUnaryOperator().
|
inlineprotected |
Arc Tangent unary operator function.
Definition at line 318 of file ArithmeticOperations.h.
Referenced by execUnaryOperator().
|
inlineprotected |
Cosine unary operator function.
Definition at line 294 of file ArithmeticOperations.h.
Referenced by execUnaryOperator().
|
inlineprotected |
Division binary operator function.
Definition at line 261 of file ArithmeticOperations.h.
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 587 of file src/terralib/rp/ArithmeticOperations.cpp.
References additionBinOp(), divisionBinOp(), execBinaryOperatorRasterXRaster(), execBinaryOperatorRasterXReal(), exponencialBinOp(), te::rp::ArithmeticOperations::ExecStackElement::m_isRaster, te::rp::ArithmeticOperations::ExecStackElement::m_isRealNumber, te::rp::ArithmeticOperations::ExecStackElement::m_rasterBand, te::rp::ArithmeticOperations::ExecStackElement::m_rasterHandler, te::rp::ArithmeticOperations::ExecStackElement::m_rasterNPtr, te::rp::ArithmeticOperations::ExecStackElement::m_realNumberValue, multiplicationBinOp(), subtractionBinOp(), TERP_LOG_AND_RETURN_FALSE, and TERP_TRUE_OR_RETURN_FALSE.
Referenced by executeString().
|
protected |
Execute the given binary operator using the given input rasters.
| inRaster1 | Input raster 1. |
| band1 | Input raster 1 band. |
| inRaster2 | Input raster 2. |
| band2 | Input raster 2 band. |
| binOptFunctPtr | The binary operation function pointer. |
| outRasterPtr | The generated output raster. |
Definition at line 673 of file src/terralib/rp/ArithmeticOperations.cpp.
References allocResultRaster(), col, te::rst::Grid::geoToGrid(), te::rst::Raster::getBand(), te::rst::Grid::getExtent(), te::rst::Raster::getGrid(), te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::rst::Band::getProperty(), te::rst::Raster::getSRID(), te::rst::Grid::getSRID(), te::rst::Band::getValue(), te::rst::Grid::gridToGeo(), m_inputParameters, te::rp::ArithmeticOperations::InputParameters::m_interpMethod, te::rst::BandProperty::m_noDataValue, nCols, te::rst::Band::setValue(), and te::gm::Envelope::transform().
Referenced by execBinaryOperator().
|
protected |
Execute the given binary operator using the given input raster and a real number.
| inRaster | Input raster. |
| bandIdx | Input raster band. |
| binOptFunctPtr | The binary operation function pointer. |
| outRasterPtr | The generated output raster. |
| realNumberIsRigthtTerm | true if the real number is the right term. |
Definition at line 810 of file src/terralib/rp/ArithmeticOperations.cpp.
References allocResultRaster(), col, te::rst::Raster::getBand(), te::rst::Raster::getGrid(), te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::rst::Band::getProperty(), te::rst::Band::getValue(), te::rst::BandProperty::m_noDataValue, nCols, and te::rst::Band::setValue().
Referenced by execBinaryOperator().
|
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 877 of file src/terralib/rp/ArithmeticOperations.cpp.
References acosUnaryOp(), asinUnaryOp(), atanUnaryOp(), cosUnaryOp(), execUnaryOperatorRaster(), lnUnaryOp(), logUnaryOp(), te::rp::ArithmeticOperations::ExecStackElement::m_isRaster, te::rp::ArithmeticOperations::ExecStackElement::m_rasterBand, te::rp::ArithmeticOperations::ExecStackElement::m_rasterHandler, te::rp::ArithmeticOperations::ExecStackElement::m_rasterNPtr, sinUnaryOp(), sqrtUnaryOp(), tanUnaryOp(), TERP_LOG_AND_RETURN_FALSE, and TERP_TRUE_OR_RETURN_FALSE.
Referenced by executeString().
|
protected |
Execute the given unary operator using the given input raster.
| inRaster | Input raster. |
| band1 | Input raster band. |
| unaryOptFunctPtr | The unary operation function pointer. |
| outRasterPtr | The generated output raster. |
Definition at line 960 of file src/terralib/rp/ArithmeticOperations.cpp.
References allocResultRaster(), col, te::rst::Raster::getBand(), te::rst::Raster::getGrid(), te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::rst::Band::getProperty(), te::rst::Band::getValue(), te::rst::BandProperty::m_noDataValue, nCols, and te::rst::Band::setValue().
Referenced by execUnaryOperator().
|
protected |
Execute the given unary operator using the given a real number.
| unaryOptFunctPtr | The unary operation function pointer. |
| outRasterPtr | The generated output raster. |
| realNumberIsRigthtTerm | true if the real number is the right term. |
Definition at line 1003 of file src/terralib/rp/ArithmeticOperations.cpp.
References col, te::rst::Band::getProperty(), te::rst::BandProperty::m_noDataValue, nCols, and te::rst::Band::setValue().
|
virtual |
Executes the algorithm using the supplied parameters.
| outputParams | Output parameters. |
Implements te::rp::Algorithm.
Definition at line 135 of file src/terralib/rp/ArithmeticOperations.cpp.
References col, te::dt::DOUBLE_TYPE, executeString(), te::rst::Raster::getBand(), te::rp::GetDataTypeRange(), te::rst::Band::getProperty(), te::rst::Raster::getValue(), isOperator(), te::rp::ArithmeticOperations::InputParameters::m_arithmeticString, te::rp::ArithmeticOperations::InputParameters::m_enableProgress, m_inputParameters, te::rp::ArithmeticOperations::InputParameters::m_inputRasters, m_isInitialized, te::rst::BandProperty::m_noDataValue, te::rp::ArithmeticOperations::InputParameters::m_normalize, te::rp::ArithmeticOperations::OutputParameters::m_outputRasterPtr, te::rp::ArithmeticOperations::OutputParameters::m_rInfo, te::rp::ArithmeticOperations::OutputParameters::m_rType, te::rst::RasterFactory::make(), MAX, MIN, nCols, te::rst::Raster::setValue(), TERP_INSTANCE_TRUE_OR_RETURN_FALSE, and TERP_TRUE_OR_THROW.
Referenced by ArithmeticOperations(), BOOST_AUTO_TEST_CASE(), and te::qt::widgets::ArithmeticOpDialogForm::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.. |
| progressPtr | A pointer to a progress interface to be pulsed on each operation or a null pointer. |
Definition at line 346 of file src/terralib/rp/ArithmeticOperations.cpp.
References execBinaryOperator(), execUnaryOperator(), getTokensStrs(), inFix2PostFix(), te::common::TaskProgress::isActive(), isBinaryOperator(), isRasterBandToken(), isRealNumberToken(), isUnaryOperator(), te::rp::ArithmeticOperations::ExecStackElement::m_isRaster, te::rp::ArithmeticOperations::ExecStackElement::m_isRealNumber, te::rp::ArithmeticOperations::ExecStackElement::m_rasterBand, te::rp::ArithmeticOperations::ExecStackElement::m_rasterNPtr, te::rp::ArithmeticOperations::ExecStackElement::m_realNumberValue, te::common::TaskProgress::pulse(), TERP_LOG_AND_RETURN_FALSE, and TERP_TRUE_OR_RETURN_FALSE.
Referenced by execute(), and initialize().
|
inlineprotected |
Exponencial binary operator function.
Definition at line 270 of file ArithmeticOperations.h.
Referenced by execBinaryOperator().
|
inherited |
Return the current error message if there is any.
Definition at line 44 of file rp/Algorithm.cpp.
References te::rp::Algorithm::m_errorMessage.
Referenced by te::qt::widgets::FilterDialogForm::applyPreview(), te::qt::widgets::PostClassificationWidget::execute(), te::qt::widgets::ClassifierWizard::execute(), te::qt::widgets::MixtureModelWizard::execute(), te::qt::widgets::ContrastDialogForm::execute(), te::qt::widgets::FilterDialogForm::execute(), te::qt::widgets::ArithmeticOpDialogForm::execute(), te::qt::widgets::MosaicWizard::executeGeoMosaic(), te::qt::widgets::FusionWizard::executeIHS(), te::qt::widgets::FusionWizard::executePCA(), te::qt::widgets::MosaicWizard::executeSequenceMosaic(), te::qt::widgets::MosaicWizard::executeTiePointMosaic(), and te::qt::widgets::FusionWizard::executeWisper().
|
protected |
Split the input string into a vector of token strings.
| inputStr | The input string. |
| outTokens | The generated output tokens vector. |
Definition at line 1084 of file src/terralib/rp/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 436 of file src/terralib/rp/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 304 of file src/terralib/rp/ArithmeticOperations.cpp.
References executeString(), te::rp::ArithmeticOperations::InputParameters::m_arithmeticString, m_inputParameters, te::rp::ArithmeticOperations::InputParameters::m_inputRasters, m_isInitialized, te::common::RAccess, te::rp::ArithmeticOperations::InputParameters::reset(), TERP_INSTANCE_TRUE_OR_RETURN_FALSE, and TERP_TRUE_OR_THROW.
Referenced by ArithmeticOperations(), BOOST_AUTO_TEST_CASE(), and te::qt::widgets::ArithmeticOpDialogForm::execute().
|
protected |
Returns true if the given token is a binary operator.
| inputToken | Input token. |
Definition at line 516 of file src/terralib/rp/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 341 of file src/terralib/rp/ArithmeticOperations.cpp.
References m_isInitialized.
|
protected |
Returns true if the given token is an operator.
| inputToken | Input token. |
Definition at line 510 of file src/terralib/rp/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 549 of file src/terralib/rp/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 1038 of file src/terralib/rp/ArithmeticOperations.cpp.
Referenced by executeString().
|
protected |
Returns true if the given token is a unary operator.
| inputToken | Input token. |
Definition at line 523 of file src/terralib/rp/ArithmeticOperations.cpp.
Referenced by executeString(), and isOperator().
|
inlineprotected |
unary operator function.
Definition at line 324 of file ArithmeticOperations.h.
References band.
Referenced by execUnaryOperator().
|
inlineprotected |
Common logarithm unary operator function.
Definition at line 306 of file ArithmeticOperations.h.
Referenced by execUnaryOperator().
|
inlineprotected |
Multiplication binary operator function.
Definition at line 255 of file ArithmeticOperations.h.
Referenced by execBinaryOperator().
|
protected |
Returns true if operator1 has greater of equal precedence over operator2.
| operator1 | Operator1 input token. |
| operator2 | Operator2 input token. |
Definition at line 531 of file src/terralib/rp/ArithmeticOperations.cpp.
Referenced by inFix2PostFix().
|
protected |
Print tokens to stout.
| input | The input tokens vector. |
Definition at line 498 of file src/terralib/rp/ArithmeticOperations.cpp.
|
virtual |
Clear all internal allocated objects and reset the algorithm to its initial state.
Reimplemented from te::rp::Algorithm.
Definition at line 296 of file src/terralib/rp/ArithmeticOperations.cpp.
References m_inputParameters, m_isInitialized, te::rp::Algorithm::reset(), and te::rp::ArithmeticOperations::InputParameters::reset().
|
protectedinherited |
Set the current error message.
| newErrorMessage | New error message; |
Definition at line 49 of file rp/Algorithm.cpp.
References te::rp::Algorithm::m_errorMessage.
|
inlineprotected |
Sine unary operator function.
Definition at line 282 of file ArithmeticOperations.h.
Referenced by execUnaryOperator().
|
inlineprotected |
Square root unary operator function.
Definition at line 276 of file ArithmeticOperations.h.
Referenced by execUnaryOperator().
|
inlineprotected |
Subtraction binary operator function.
Definition at line 249 of file ArithmeticOperations.h.
Referenced by execBinaryOperator().
|
inlineprotected |
Tangent unary operator function.
Definition at line 312 of file ArithmeticOperations.h.
Referenced by execUnaryOperator().
|
protected |
Input execution parameters.
Definition at line 236 of file ArithmeticOperations.h.
Referenced by execBinaryOperatorRasterXRaster(), execute(), initialize(), and reset().
|
protected |
Tells if this instance is initialized.
Definition at line 238 of file ArithmeticOperations.h.
Referenced by execute(), initialize(), isInitialized(), and reset().