39  const QFileInfo fi( mOutputFilePath );
 
   45  auto writer = std::make_unique<QgsRasterFileWriter>( mOutputFilePath );
 
   46  writer->setOutputProviderKey( QStringLiteral( 
"gdal" ) );
 
   47  writer->setOutputFormat( outputFormat );
 
   48  writer->setCreationOptions( mCreationOptions );
 
   50  std::unique_ptr<QgsRasterDataProvider> provider( writer->createOneBandRaster( 
Qgis::DataType::Float32, mNumColumns, mNumRows, mInterpolationExtent, 
crs ) );
 
   53    QgsDebugMsgLevel( QStringLiteral( 
"Could not create raster output: %1" ).arg( mOutputFilePath ), 2 );
 
   56  if ( !provider->isValid() )
 
   62  provider->setNoDataValue( 1, mNoDataValue );
 
   64  double currentYValue = mInterpolationExtent.
yMaximum() - mCellSizeY / 2.0; 
 
   66  double interpolatedValue;
 
   68  std::vector<float> float32Row( mNumColumns );
 
   69  const double step = mNumRows > 0 ? 100.0 / mNumRows : 1;
 
   70  for ( 
int row = 0; row < mNumRows; row++ )
 
   77    currentXValue = mInterpolationExtent.
xMinimum() + mCellSizeX / 2.0; 
 
   80    for ( 
int col = 0; col < mNumColumns; col++ )
 
   82      if ( mInterpolator->
interpolatePoint( currentXValue, currentYValue, interpolatedValue, feedback ) == 0 )
 
   84        float32Row[col] = interpolatedValue;
 
   88        float32Row[col] = mNoDataValue;
 
   90      currentXValue += mCellSizeX;
 
   93    if ( !provider->writeBlock( &block, 1, 0, row ) )
 
   95      throw QgsProcessingException( QObject::tr( 
"Could not write raster block: %1" ).arg( provider->error().summary() ) );
 
   97    currentYValue -= mCellSizeY;
 
 
QgsGridFileWriter(QgsInterpolator *interpolator, const QString &outputPath, const QgsRectangle &extent, int nCols, int nRows)
Constructor for QgsGridFileWriter, for the specified interpolator.
 
virtual int interpolatePoint(double x, double y, double &result, QgsFeedback *feedback=nullptr)=0
Calculates interpolation value for map coordinates x, y.