Skip to content

Commit

Permalink
[processing] Fix encoding for raster analysis algorithm outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
zy6p authored and nyalldawson committed Mar 29, 2021
1 parent 1d16290 commit cd0bf03
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Expand Up @@ -137,6 +137,9 @@ QVariantMap QgsNearestNeighbourAnalysisAlgorithm::processAlgorithm( const QVaria
if ( file.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
QTextStream out( &file );
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
out.setCodec( "UTF-8" );
#endif
out << QStringLiteral( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/></head><body>\n" );
out << QObject::tr( "<p>Observed mean distance: %1</p>\n" ).arg( observedDistance, 0, 'f', 11 );
out << QObject::tr( "<p>Expected mean distance: %1</p>\n" ).arg( expectedDistance, 0, 'f', 11 );
Expand Down
Expand Up @@ -185,6 +185,9 @@ QVariantMap QgsRasterLayerUniqueValuesReportAlgorithm::processAlgorithm( const Q
const QString encodedAreaUnit = QgsStringUtils::ampersandEncode( areaUnit );

QTextStream out( &file );
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
out.setCodec( "UTF-8" );
#endif
out << QStringLiteral( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/></head><body>\n" );
out << QStringLiteral( "<p>%1: %2 (%3 %4)</p>\n" ).arg( QObject::tr( "Analyzed file" ), mSource, QObject::tr( "band" ) ).arg( mBand );
out << QObject::tr( "<p>%1: %2</p>\n" ).arg( QObject::tr( "Extent" ), mExtent.toString() );
Expand Down
3 changes: 3 additions & 0 deletions src/analysis/processing/qgsalgorithmrasterstatistics.cpp
Expand Up @@ -103,6 +103,9 @@ QVariantMap QgsRasterStatisticsAlgorithm::processAlgorithm( const QVariantMap &p
if ( file.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
QTextStream out( &file );
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
out.setCodec( "UTF-8" );
#endif
out << QStringLiteral( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/></head><body>\n" );
out << QObject::tr( "<p>Analyzed file: %1 (band %2)</p>\n" ).arg( layer->source() ).arg( band );
out << QObject::tr( "<p>Minimum value: %1</p>\n" ).arg( stat.minimumValue, 0, 'g', 16 );
Expand Down
3 changes: 3 additions & 0 deletions src/analysis/processing/qgsalgorithmrastersurfacevolume.cpp
Expand Up @@ -221,6 +221,9 @@ QVariantMap QgsRasterSurfaceVolumeAlgorithm::processAlgorithm( const QVariantMap
const QString encodedAreaUnit = QgsStringUtils::ampersandEncode( areaUnit );

QTextStream out( &file );
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
out.setCodec( "UTF-8" );
#endif
out << QStringLiteral( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/></head><body>\n" );
out << QStringLiteral( "<p>%1: %2 (%3 %4)</p>\n" ).arg( QObject::tr( "Analyzed file" ), mSource, QObject::tr( "band" ) ).arg( mBand );
out << QObject::tr( "<p>%1: %2</p>\n" ).arg( QObject::tr( "Volume" ), QString::number( volume, 'g', 16 ) );
Expand Down

0 comments on commit cd0bf03

Please sign in to comment.