Skip to content

Commit 34421c8

Browse files
alexbruymhugent
authored andcommittedMar 27, 2014
assign CRS to interpolation output (fix #3578)
1 parent 344383b commit 34421c8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
 

‎src/analysis/interpolation/qgsgridfilewriter.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
#include "qgsgridfilewriter.h"
1919
#include "qgsinterpolator.h"
20+
#include "qgsvectorlayer.h"
2021
#include <QFile>
22+
#include <QFileInfo>
2123
#include <QProgressDialog>
2224

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

101+
// create prj file
102+
QgsInterpolator::LayerData ld;
103+
ld = mInterpolator->mLayerData.first();
104+
QgsVectorLayer* vl = ld.vectorLayer;
105+
QString crs = vl->crs().toWkt();
106+
QFileInfo fi( mOutputFilePath );
107+
QString fileName = fi.absolutePath() + "/" + fi.completeBaseName() + ".prj";
108+
QFile prjFile( fileName );
109+
if ( !prjFile.open( QFile::WriteOnly ) )
110+
{
111+
return 1;
112+
}
113+
QTextStream prjStream( &prjFile );
114+
prjStream << crs;
115+
prjStream << endl;
116+
prjFile.close();
117+
99118
delete progressDialog;
100119
return 0;
101120
}

‎src/analysis/interpolation/qgsinterpolator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class ANALYSIS_EXPORT QgsInterpolator
8787
@return 0 in case of success*/
8888
int addVerticesToCache( QgsGeometry* geom, bool zCoord, double attributeValue );
8989

90-
90+
friend class QgsGridFileWriter;
9191
};
9292

9393
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.