Skip to content

Commit

Permalink
assign CRS to interpolation output (fix #3578)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and mhugent committed Mar 27, 2014
1 parent 344383b commit 34421c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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->mLayerData.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
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgsinterpolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ANALYSIS_EXPORT QgsInterpolator
@return 0 in case of success*/
int addVerticesToCache( QgsGeometry* geom, bool zCoord, double attributeValue );


friend class QgsGridFileWriter;
};

#endif

0 comments on commit 34421c8

Please sign in to comment.