Skip to content

Commit

Permalink
Save raster symbology with full precision (fix #14950)
Browse files Browse the repository at this point in the history
(cherry-picked from a6cb81b)
  • Loading branch information
nyalldawson committed Jul 1, 2016
1 parent 5091c31 commit 221909f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/core/raster/qgscontrastenhancement.cpp
Expand Up @@ -25,6 +25,7 @@ class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
#include "qgslinearminmaxenhancement.h"
#include "qgslinearminmaxenhancementwithclip.h"
#include "qgscliptominmaxenhancement.h"
#include "qgsrasterblock.h"
#include <QDomDocument>
#include <QDomElement>

Expand Down Expand Up @@ -361,13 +362,13 @@ void QgsContrastEnhancement::writeXML( QDomDocument& doc, QDomElement& parentEle
{
//minimum value
QDomElement minElem = doc.createElement( "minValue" );
QDomText minText = doc.createTextNode( QString::number( mMinimumValue ) );
QDomText minText = doc.createTextNode( QgsRasterBlock::printValue( mMinimumValue ) );
minElem.appendChild( minText );
parentElem.appendChild( minElem );

//maximum value
QDomElement maxElem = doc.createElement( "maxValue" );
QDomText maxText = doc.createTextNode( QString::number( mMaximumValue ) );
QDomText maxText = doc.createTextNode( QgsRasterBlock::printValue( mMaximumValue ) );
maxElem.appendChild( maxText );
parentElem.appendChild( maxElem );

Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -1528,8 +1528,8 @@ bool QgsRasterLayer::writeXml( QDomNode & layer_node,
{
QDomElement noDataRange = document.createElement( "noDataRange" );

noDataRange.setAttribute( "min", range.min() );
noDataRange.setAttribute( "max", range.max() );
noDataRange.setAttribute( "min", QgsRasterBlock::printValue( range.min() ) );
noDataRange.setAttribute( "max", QgsRasterBlock::printValue( range.max() ) );
noDataRangeList.appendChild( noDataRange );
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/raster/qgsrastershader.cpp
Expand Up @@ -19,6 +19,7 @@ email : ersts@amnh.org
#include "qgslogger.h"
#include "qgscolorrampshader.h"
#include "qgsrastershader.h"
#include "qgsrasterblock.h"
#include <QDomDocument>
#include <QDomElement>

Expand Down Expand Up @@ -151,7 +152,7 @@ void QgsRasterShader::writeXML( QDomDocument& doc, QDomElement& parent ) const
{
QDomElement itemElem = doc.createElement( "item" );
itemElem.setAttribute( "label", itemIt->label );
itemElem.setAttribute( "value", QString::number( itemIt->value ) );
itemElem.setAttribute( "value", QgsRasterBlock::printValue( itemIt->value ) );
itemElem.setAttribute( "color", itemIt->color.name() );
itemElem.setAttribute( "alpha", itemIt->color.alpha() );
colorRampShaderElem.appendChild( itemElem );
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgssinglebandpseudocolorrenderer.cpp
Expand Up @@ -224,8 +224,8 @@ void QgsSingleBandPseudoColorRenderer::writeXML( QDomDocument& doc, QDomElement&
{
mShader->writeXML( doc, rasterRendererElem ); //todo: include color ramp items directly in this renderer
}
rasterRendererElem.setAttribute( "classificationMin", QString::number( mClassificationMin ) );
rasterRendererElem.setAttribute( "classificationMax", QString::number( mClassificationMax ) );
rasterRendererElem.setAttribute( "classificationMin", QgsRasterBlock::printValue( mClassificationMin ) );
rasterRendererElem.setAttribute( "classificationMax", QgsRasterBlock::printValue( mClassificationMax ) );
rasterRendererElem.setAttribute( "classificationMinMaxOrigin", QgsRasterRenderer::minMaxOriginName( mClassificationMinMaxOrigin ) );

parentElem.appendChild( rasterRendererElem );
Expand Down

0 comments on commit 221909f

Please sign in to comment.