41 , mRasterName( rasterName )
43 if ( mRasterName.startsWith(
'"' ) && mRasterName.endsWith(
'"' ) )
44 mRasterName = mRasterName.mid( 1, mRasterName.size() - 2 );
60 QMap<QString, QgsRasterBlock *>::iterator it = rasterData.find( mRasterName );
61 if ( it == rasterData.end() )
63 QgsDebugMsg( QStringLiteral(
"Error: could not find raster data for \"%1\"" ).arg( mRasterName ) );
67 int nRows = ( row >= 0 ? 1 : ( *it )->height() );
68 int startRow = ( row >= 0 ? row : 0 );
69 int endRow = startRow + nRows;
70 int nCols = ( *it )->width();
71 int nEntries = nCols * nRows;
72 double *data =
new double[nEntries];
77 bool isNoData =
false;
78 for (
int dataRow = startRow; dataRow < endRow ; ++dataRow, ++outRow )
80 for (
int dataCol = 0; dataCol < nCols; ++dataCol )
82 const double value = ( *it )->valueAndNoData( dataRow, dataCol, isNoData );
83 data[ dataCol + nCols * outRow] = isNoData ? result.
nodataValue() : value;
94 if ( !mLeft || !mLeft->
calculate( rasterData, leftMatrix, row ) )
98 if ( mRight && !mRight->
calculate( rasterData, rightMatrix, row ) )
106 leftMatrix.
add( rightMatrix );
115 leftMatrix.
divide( rightMatrix );
118 leftMatrix.
power( rightMatrix );
121 leftMatrix.
equal( rightMatrix );
145 leftMatrix.
min( rightMatrix );
148 leftMatrix.
max( rightMatrix );
186 int newNColumns = leftMatrix.
nColumns();
187 int newNRows = leftMatrix.
nRows();
193 size_t nEntries =
static_cast<size_t>( result.
nColumns() * result.
nRows() );
194 double *data =
new double[ nEntries ];
195 std::fill( data, data + nEntries, mNumber );
203 double *data =
new double[nEntries];
204 for (
int i = 0; i < nEntries; ++i )
230 result = QStringLiteral(
"( %1 + %2 )" ).arg( left ).arg( right );
233 result = QStringLiteral(
"( %1 - %2 )" ).arg( left ).arg( right );
236 result = QStringLiteral(
"-%1" ).arg( left );
239 result = QStringLiteral(
"%1 * %2" ).arg( left ).arg( right );
242 result = QStringLiteral(
"%1 / %2" ).arg( left ).arg( right );
246 result = QStringLiteral(
"pow( %1, %2 )" ).arg( left ).arg( right );
248 result = QStringLiteral(
"%1^%2" ).arg( left ).arg( right );
252 result = QStringLiteral(
"( float ) ( %1 == %2 )" ).arg( left ).arg( right );
254 result = QStringLiteral(
"%1 = %2" ).arg( left ).arg( right );
258 result = QStringLiteral(
"( float ) ( %1 != %2 )" ).arg( left ).arg( right );
260 result = QStringLiteral(
"%1 != %2" ).arg( left ).arg( right );
264 result = QStringLiteral(
"( float ) ( %1 > %2 )" ).arg( left ).arg( right );
266 result = QStringLiteral(
"%1 > %2" ).arg( left ).arg( right );
270 result = QStringLiteral(
"( float ) ( %1 < %2 )" ).arg( left ).arg( right );
272 result = QStringLiteral(
"%1 < %2" ).arg( left ).arg( right );
276 result = QStringLiteral(
"( float ) ( %1 >= %2 )" ).arg( left ).arg( right );
278 result = QStringLiteral(
"%1 >= %2" ).arg( left ).arg( right );
282 result = QStringLiteral(
"( float ) ( %1 <= %2 )" ).arg( left ).arg( right );
284 result = QStringLiteral(
"%1 <= %2" ).arg( left ).arg( right );
288 result = QStringLiteral(
"( float ) ( %1 && %2 )" ).arg( left ).arg( right );
290 result = QStringLiteral(
"%1 AND %2" ).arg( left ).arg( right );
294 result = QStringLiteral(
"( float ) ( %1 || %2 )" ).arg( left ).arg( right );
296 result = QStringLiteral(
"%1 OR %2" ).arg( left ).arg( right );
299 result = QStringLiteral(
"sqrt( %1 )" ).arg( left );
302 result = QStringLiteral(
"sin( %1 )" ).arg( left );
305 result = QStringLiteral(
"cos( %1 )" ).arg( left );
308 result = QStringLiteral(
"tan( %1 )" ).arg( left );
311 result = QStringLiteral(
"asin( %1 )" ).arg( left );
314 result = QStringLiteral(
"acos( %1 )" ).arg( left );
317 result = QStringLiteral(
"atan( %1 )" ).arg( left );
320 result = QStringLiteral(
"log( %1 )" ).arg( left );
323 result = QStringLiteral(
"log10( %1 )" ).arg( left );
327 result = QStringLiteral(
"fabs( %1 )" ).arg( left );
330 result = QStringLiteral(
"abs( %1 )" ).arg( left );
334 result = QStringLiteral(
"min( ( float ) ( %1 ), ( float ) ( %2 ) )" ).arg( left ).arg( right );
336 result = QStringLiteral(
"min( %1, %2 )" ).arg( left ).arg( right );
340 result = QStringLiteral(
"max( ( float ) ( %1 ), ( float ) ( %2 ) )" ).arg( left ).arg( right );
342 result = QStringLiteral(
"max( %1, %2 )" ).arg( left ).arg( right );
350 result = QStringLiteral(
"( float ) \"%1\"" ).arg( mRasterName );
352 result = QStringLiteral(
"\"%1\"" ).arg( mRasterName );
355 result = QString::number( mNumber );
358 result = QStringLiteral(
"( float ) %1" ).arg( result );
369 QList<const QgsRasterCalcNode *> nodeList;
371 nodeList.push_back(
this );
381 extern QgsRasterCalcNode *localParseRasterCalcString(
const QString & str, QString & parserErrorMsg );
382 return localParseRasterCalcString( str, parserErrorMsg );