Skip to content

Commit 221909f

Browse files
committed
Save raster symbology with full precision (fix #14950)
(cherry-picked from a6cb81b)
1 parent 5091c31 commit 221909f

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/core/raster/qgscontrastenhancement.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
2525
#include "qgslinearminmaxenhancement.h"
2626
#include "qgslinearminmaxenhancementwithclip.h"
2727
#include "qgscliptominmaxenhancement.h"
28+
#include "qgsrasterblock.h"
2829
#include <QDomDocument>
2930
#include <QDomElement>
3031

@@ -361,13 +362,13 @@ void QgsContrastEnhancement::writeXML( QDomDocument& doc, QDomElement& parentEle
361362
{
362363
//minimum value
363364
QDomElement minElem = doc.createElement( "minValue" );
364-
QDomText minText = doc.createTextNode( QString::number( mMinimumValue ) );
365+
QDomText minText = doc.createTextNode( QgsRasterBlock::printValue( mMinimumValue ) );
365366
minElem.appendChild( minText );
366367
parentElem.appendChild( minElem );
367368

368369
//maximum value
369370
QDomElement maxElem = doc.createElement( "maxValue" );
370-
QDomText maxText = doc.createTextNode( QString::number( mMaximumValue ) );
371+
QDomText maxText = doc.createTextNode( QgsRasterBlock::printValue( mMaximumValue ) );
371372
maxElem.appendChild( maxText );
372373
parentElem.appendChild( maxElem );
373374

src/core/raster/qgsrasterlayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,8 +1528,8 @@ bool QgsRasterLayer::writeXml( QDomNode & layer_node,
15281528
{
15291529
QDomElement noDataRange = document.createElement( "noDataRange" );
15301530

1531-
noDataRange.setAttribute( "min", range.min() );
1532-
noDataRange.setAttribute( "max", range.max() );
1531+
noDataRange.setAttribute( "min", QgsRasterBlock::printValue( range.min() ) );
1532+
noDataRange.setAttribute( "max", QgsRasterBlock::printValue( range.max() ) );
15331533
noDataRangeList.appendChild( noDataRange );
15341534
}
15351535

src/core/raster/qgsrastershader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ email : ersts@amnh.org
1919
#include "qgslogger.h"
2020
#include "qgscolorrampshader.h"
2121
#include "qgsrastershader.h"
22+
#include "qgsrasterblock.h"
2223
#include <QDomDocument>
2324
#include <QDomElement>
2425

@@ -151,7 +152,7 @@ void QgsRasterShader::writeXML( QDomDocument& doc, QDomElement& parent ) const
151152
{
152153
QDomElement itemElem = doc.createElement( "item" );
153154
itemElem.setAttribute( "label", itemIt->label );
154-
itemElem.setAttribute( "value", QString::number( itemIt->value ) );
155+
itemElem.setAttribute( "value", QgsRasterBlock::printValue( itemIt->value ) );
155156
itemElem.setAttribute( "color", itemIt->color.name() );
156157
itemElem.setAttribute( "alpha", itemIt->color.alpha() );
157158
colorRampShaderElem.appendChild( itemElem );

src/core/raster/qgssinglebandpseudocolorrenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ void QgsSingleBandPseudoColorRenderer::writeXML( QDomDocument& doc, QDomElement&
224224
{
225225
mShader->writeXML( doc, rasterRendererElem ); //todo: include color ramp items directly in this renderer
226226
}
227-
rasterRendererElem.setAttribute( "classificationMin", QString::number( mClassificationMin ) );
228-
rasterRendererElem.setAttribute( "classificationMax", QString::number( mClassificationMax ) );
227+
rasterRendererElem.setAttribute( "classificationMin", QgsRasterBlock::printValue( mClassificationMin ) );
228+
rasterRendererElem.setAttribute( "classificationMax", QgsRasterBlock::printValue( mClassificationMax ) );
229229
rasterRendererElem.setAttribute( "classificationMinMaxOrigin", QgsRasterRenderer::minMaxOriginName( mClassificationMinMaxOrigin ) );
230230

231231
parentElem.appendChild( rasterRendererElem );

0 commit comments

Comments
 (0)