27   , mOutputFilePath( outputPath )
    28   , mInterpolationExtent( extent )
    29   , mNumColumns( nCols )
    31   , mCellSizeX( extent.width() / nCols )
    32   , mCellSizeY( extent.height() / nRows )
    37   QFile outputFile( mOutputFilePath );
    39   if ( !outputFile.open( QFile::WriteOnly | QIODevice::Truncate ) )
    50   QTextStream outStream( &outputFile );
    51   outStream.setRealNumberPrecision( 8 );
    52   writeHeader( outStream );
    54   double currentYValue = mInterpolationExtent.
yMaximum() - mCellSizeY / 2.0; 
    56   double interpolatedValue;
    58   for ( 
int i = 0; i < mNumRows; ++i )
    60     currentXValue = mInterpolationExtent.
xMinimum() + mCellSizeX / 2.0; 
    61     for ( 
int j = 0; j < mNumColumns; ++j )
    63       if ( mInterpolator->
interpolatePoint( currentXValue, currentYValue, interpolatedValue, feedback ) == 0 )
    65         outStream << interpolatedValue << 
' ';
    69         outStream << 
"-9999 ";
    71       currentXValue += mCellSizeX;
    74     currentYValue -= mCellSizeY;
    83       feedback->
setProgress( 100.0 * i / static_cast< double >( mNumRows ) );
    92   QFileInfo fi( mOutputFilePath );
    93   QString fileName = fi.absolutePath() + 
'/' + fi.completeBaseName() + 
".prj";
    94   QFile prjFile( fileName );
    95   if ( !prjFile.open( QFile::WriteOnly | QIODevice::Truncate ) )
    99   QTextStream prjStream( &prjFile );
   107 int QgsGridFileWriter::writeHeader( QTextStream &outStream )
   109   outStream << 
"NCOLS " << mNumColumns << endl;
   110   outStream << 
"NROWS " << mNumRows << endl;
   111   outStream << 
"XLLCORNER " << mInterpolationExtent.
xMinimum() << endl;
   112   outStream << 
"YLLCORNER " <<  mInterpolationExtent.
yMinimum() << endl;
   113   if ( mCellSizeX == mCellSizeY ) 
   115     outStream << 
"CELLSIZE " << mCellSizeX << endl;
   119     outStream << 
"DX " << mCellSizeX << endl;
   120     outStream << 
"DY " << mCellSizeY << endl;
   122   outStream << 
"NODATA_VALUE -9999" << endl;
 A rectangle specified with double values. 
 
Interface class for interpolations. 
 
int writeFile(QgsFeedback *feedback=nullptr)
Writes the grid file. 
 
void setProgress(double progress)
Sets the current progress for the feedback object. 
 
QgsFeatureSource * source
Feature source. 
 
const QgsCoordinateReferenceSystem & crs
 
Base class for feedback objects to be used for cancellation of something running in a worker thread...
 
virtual int interpolatePoint(double x, double y, double &result, QgsFeedback *feedback=nullptr)=0
Calculates interpolation value for map coordinates x, y. 
 
QList< LayerData > layerData() const
 
QgsGridFileWriter(QgsInterpolator *interpolator, const QString &outputPath, const QgsRectangle &extent, int nCols, int nRows)
Constructor for QgsGridFileWriter, for the specified interpolator. 
 
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source. 
 
double yMinimum() const
Returns the y minimum value (bottom side of rectangle). 
 
A source together with the information about interpolation attribute / z-coordinate interpolation and...
 
bool isCanceled() const
Tells whether the operation has been canceled already. 
 
An interface for objects which provide features via a getFeatures method. 
 
double xMinimum() const
Returns the x minimum value (left side of rectangle). 
 
double yMaximum() const
Returns the y maximum value (top side of rectangle). 
 
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.