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 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 
   52   outStream.setCodec( 
"UTF-8" );
 
   54   outStream.setRealNumberPrecision( 8 );
 
   55   writeHeader( outStream );
 
   57   double currentYValue = mInterpolationExtent.
yMaximum() - mCellSizeY / 2.0; 
 
   59   double interpolatedValue;
 
   61   for ( 
int i = 0; i < mNumRows; ++i )
 
   63     currentXValue = mInterpolationExtent.
xMinimum() + mCellSizeX / 2.0; 
 
   64     for ( 
int j = 0; j < mNumColumns; ++j )
 
   66       if ( mInterpolator->
interpolatePoint( currentXValue, currentYValue, interpolatedValue, feedback ) == 0 )
 
   68         outStream << interpolatedValue << 
' ';
 
   72         outStream << 
"-9999 ";
 
   74       currentXValue += mCellSizeX;
 
   77     currentYValue -= mCellSizeY;
 
   86       feedback->
setProgress( 100.0 * i / 
static_cast< double >( mNumRows ) );
 
   95   QFileInfo fi( mOutputFilePath );
 
   96   QString fileName = fi.absolutePath() + 
'/' + fi.completeBaseName() + 
".prj";
 
   97   QFile prjFile( fileName );
 
   98   if ( !prjFile.open( QFile::WriteOnly | QIODevice::Truncate ) )
 
  102   QTextStream prjStream( &prjFile );
 
  110 int QgsGridFileWriter::writeHeader( QTextStream &outStream )
 
  112   outStream << 
"NCOLS " << mNumColumns << endl;
 
  113   outStream << 
"NROWS " << mNumRows << endl;
 
  114   outStream << 
"XLLCORNER " << mInterpolationExtent.
xMinimum() << endl;
 
  115   outStream << 
"YLLCORNER " <<  mInterpolationExtent.
yMinimum() << endl;
 
  116   if ( mCellSizeX == mCellSizeY ) 
 
  118     outStream << 
"CELLSIZE " << mCellSizeX << endl;
 
  122     outStream << 
"DX " << mCellSizeX << endl;
 
  123     outStream << 
"DY " << mCellSizeY << endl;
 
  125   outStream << 
"NODATA_VALUE -9999" << endl;
 
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
An interface for objects which provide features via a getFeatures method.
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
void setProgress(double progress)
Sets the current progress for the feedback object.
QgsGridFileWriter(QgsInterpolator *interpolator, const QString &outputPath, const QgsRectangle &extent, int nCols, int nRows)
Constructor for QgsGridFileWriter, for the specified interpolator.
int writeFile(QgsFeedback *feedback=nullptr)
Writes the grid file.
Interface class for interpolations.
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
A rectangle specified with double values.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
const QgsCoordinateReferenceSystem & crs
A source together with the information about interpolation attribute / z-coordinate interpolation and...
QgsFeatureSource * source
Feature source.