Showing with 21 additions and 2 deletions.
  1. +19 −0 src/analysis/interpolation/qgsgridfilewriter.cpp
  2. +2 −2 src/analysis/interpolation/qgsinterpolator.h
19 changes: 19 additions & 0 deletions src/analysis/interpolation/qgsgridfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

#include "qgsgridfilewriter.h"
#include "qgsinterpolator.h"
#include "qgsvectorlayer.h"
#include <QFile>
#include <QFileInfo>
#include <QProgressDialog>

QgsGridFileWriter::QgsGridFileWriter( QgsInterpolator* i, QString outputPath, QgsRectangle extent, int nCols, int nRows , double cellSizeX, double cellSizeY )
Expand Down Expand Up @@ -96,6 +98,23 @@ int QgsGridFileWriter::writeFile( bool showProgressDialog )
}
}

// create prj file
QgsInterpolator::LayerData ld;
ld = mInterpolator->layerData().first();
QgsVectorLayer* vl = ld.vectorLayer;
QString crs = vl->crs().toWkt();
QFileInfo fi( mOutputFilePath );
QString fileName = fi.absolutePath() + "/" + fi.completeBaseName() + ".prj";
QFile prjFile( fileName );
if ( !prjFile.open( QFile::WriteOnly ) )
{
return 1;
}
QTextStream prjStream( &prjFile );
prjStream << crs;
prjStream << endl;
prjFile.close();

delete progressDialog;
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/interpolation/qgsinterpolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class ANALYSIS_EXPORT QgsInterpolator
@return 0 in case of success*/
virtual int interpolatePoint( double x, double y, double& result ) = 0;

const QList<LayerData>& layerData() const { return mLayerData; }

protected:
/**Caches the vertex and value data from the provider. All the vertex data
will be held in virtual memory
Expand All @@ -86,8 +88,6 @@ class ANALYSIS_EXPORT QgsInterpolator
@param attributeValue the attribute value for interpolation (if not interpolated from z-coordinate)
@return 0 in case of success*/
int addVerticesToCache( QgsGeometry* geom, bool zCoord, double attributeValue );


};

#endif