Skip to content

Commit cc62d75

Browse files
committedApr 14, 2012
Project file conversion for singleband pseudo color
1 parent 47bba04 commit cc62d75

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed
 

‎src/core/qgsprojectfiletransform.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,29 @@ void QgsProjectFileTransform::transform1800to1900()
530530

531531
//switch depending on mColorShadingAlgorithm
532532
QString colorShadingAlgorithm = rasterPropertiesElem.firstChildElement( "mColorShadingAlgorithm" ).text();
533-
if ( colorShadingAlgorithm == "PseudoColorShader" )
533+
if ( colorShadingAlgorithm == "PseudoColorShader" || colorShadingAlgorithm == "FreakOutShader" )
534534
{
535-
535+
newColorRampShaderElem.setAttribute( "colorRampType", "INTERPOLATED" );
536+
537+
//get minmax from rasterlayer
538+
QgsRasterBandStats rasterBandStats = rasterLayer.bandStatistics( grayBand );
539+
double minValue = rasterBandStats.minimumValue;
540+
double maxValue = rasterBandStats.maximumValue;
541+
double breakSize = ( maxValue - minValue ) / 3;
542+
543+
QStringList colorList;
544+
colorList << "#0000ff" << "#00ffff" << "#ffff00" << "#ff0000";
545+
QStringList::const_iterator colorIt = colorList.constBegin();
546+
double boundValue = minValue;
547+
for ( ; colorIt != colorList.constEnd(); ++colorIt )
548+
{
549+
QDomElement newItemElem = mDom.createElement( "item" );
550+
newItemElem.setAttribute( "value", QString::number( boundValue ) );
551+
newItemElem.setAttribute( "label", QString::number( boundValue ) );
552+
newItemElem.setAttribute( "color", *colorIt );
553+
newColorRampShaderElem.appendChild( newItemElem );
554+
boundValue += breakSize;
555+
}
536556
}
537557
else if ( colorShadingAlgorithm == "ColorRampShader" )
538558
{

0 commit comments

Comments
 (0)
Please sign in to comment.