42 , mRasterName( rasterName )
44 if ( mRasterName.startsWith(
'"' ) && mRasterName.endsWith(
'"' ) )
45 mRasterName = mRasterName.mid( 1, mRasterName.size() - 2 );
67 QMap<QString, QgsRasterBlock *>::iterator it = rasterData.find( mRasterName );
68 if ( it == rasterData.end() )
73 int nRows = ( row >= 0 ? 1 : ( *it )->height() );
74 int startRow = ( row >= 0 ? row : 0 );
75 int endRow = startRow + nRows;
76 int nCols = ( *it )->width();
77 int nEntries = nCols * nRows;
78 double *data =
new double[nEntries];
83 for (
int dataRow = startRow; dataRow < endRow ; ++dataRow, ++outRow )
85 for (
int dataCol = 0; dataCol < nCols; ++dataCol )
87 data[ dataCol + nCols * outRow] = ( *it )->isNoData( dataRow, dataCol ) ? result.
nodataValue() : ( *it )->value( dataRow, dataCol );
99 if ( !mLeft || !mLeft->
calculate( rasterData, leftMatrix, row ) )
103 if ( mRight && !mRight->
calculate( rasterData, rightMatrix, row ) )
111 leftMatrix.
add( rightMatrix );
120 leftMatrix.
divide( rightMatrix );
123 leftMatrix.
power( rightMatrix );
126 leftMatrix.
equal( rightMatrix );
182 int newNColumns = leftMatrix.
nColumns();
183 int newNRows = leftMatrix.
nRows();
189 double *data =
new double[1];
197 double *data =
new double[nEntries];
198 for (
int i = 0; i < nEntries; ++i )
210 extern QgsRasterCalcNode *localParseRasterCalcString(
const QString & str, QString & parserErrorMsg );
211 return localParseRasterCalcString( str, parserErrorMsg );
double * takeData()
Returns data and ownership.
bool add(const QgsRasterMatrix &other)
Adds another matrix to this one.
void setNodataValue(double d)
double nodataValue() const
bool power(const QgsRasterMatrix &other)
bool greaterThan(const QgsRasterMatrix &other)
bool notEqual(const QgsRasterMatrix &other)
bool equal(const QgsRasterMatrix &other)
bool calculate(QMap< QString, QgsRasterBlock * > &rasterData, QgsRasterMatrix &result, int row=-1) const
Calculates result of raster calculation (might be real matrix or single number).
bool logicalOr(const QgsRasterMatrix &other)
void setData(int cols, int rows, double *data, double nodataValue)
bool subtract(const QgsRasterMatrix &other)
Subtracts another matrix from this one.
Operator
possible operators
QgsRasterCalcNode()=default
Constructor for QgsRasterCalcNode.
bool multiply(const QgsRasterMatrix &other)
bool lesserEqual(const QgsRasterMatrix &other)
bool divide(const QgsRasterMatrix &other)
bool greaterEqual(const QgsRasterMatrix &other)
double * data()
Returns data array (but not ownership)
static QgsRasterCalcNode * parseRasterCalcString(const QString &str, QString &parserErrorMsg)
bool lesserThan(const QgsRasterMatrix &other)
bool logicalAnd(const QgsRasterMatrix &other)