@@ -428,53 +428,56 @@ void QgsMultiBandColorRenderer::toSld( QDomDocument &doc, QDomElement &element,
428
428
// create base structure
429
429
QgsRasterRenderer::toSld ( doc, element, props );
430
430
431
- // TODO: the following commented code is necessary to avoid to export channelSelection in
431
+
432
+ #if 0
433
+ // TODO: the following jumped code is necessary to avoid to export channelSelection in
432
434
// case it's set as default value. The drawback is that it's necessary to calc band
433
435
// statistics that can be really slow depending on dataProvider and rastr localtion.
434
436
// this is the reason this part of code is commented and the channelSlection is
435
437
// always exported.
436
438
//
437
439
// before to export check if the band combination and contrast setting are the
438
440
// default ones to avoid to export this tags
439
- // bool isDefaultCombination = true;
440
- // QList<int> defaultBandCombination( { 1, 2, 3 } );
441
-
442
- // isDefaultCombination = isDefaultCombination && ( usesBands() == defaultBandCombination );
443
- // isDefaultCombination = isDefaultCombination && (
444
- // mRedContrastEnhancement->contrastEnhancementAlgorithm() == QgsContrastEnhancement::StretchToMinimumMaximum &&
445
- // mGreenContrastEnhancement->contrastEnhancementAlgorithm() == QgsContrastEnhancement::StretchToMinimumMaximum &&
446
- // mBlueContrastEnhancement->contrastEnhancementAlgorithm() == QgsContrastEnhancement::StretchToMinimumMaximum
447
- // );
448
- // // compute raster statistics (slow) only if true the previous conditions
449
- // if ( isDefaultCombination)
450
- // {
451
- // QgsRasterBandStats statRed = bandStatistics(1, QgsRasterBandStats::Min|QgsRasterBandStats::Max);
452
- // isDefaultCombination = isDefaultCombination && (
453
- // ( mRedContrastEnhancement->minimumValue() == statRed.minimumValue &&
454
- // mRedContrastEnhancement->maximumValue() == statRed.maximumValue )
455
- // );
456
- // }
457
- // if ( isDefaultCombination)
458
- // {
459
- // QgsRasterBandStats statGreen = bandStatistics(2, QgsRasterBandStats::Min|QgsRasterBandStats::Max);
460
- // isDefaultCombination = isDefaultCombination && (
461
- // ( mGreenContrastEnhancement->minimumValue() == statGreen.minimumValue &&
462
- // mGreenContrastEnhancement->maximumValue() == statGreen.maximumValue )
463
- // );
464
- // }
465
- // if ( isDefaultCombination)
466
- // {
467
- // QgsRasterBandStats statBlue = bandStatistics(3, QgsRasterBandStats::Min|QgsRasterBandStats::Max);
468
- // isDefaultCombination = isDefaultCombination && (
469
- // ( mBlueContrastEnhancement->minimumValue() == statBlue.minimumValue &&
470
- // mBlueContrastEnhancement->maximumValue() == statBlue.maximumValue )
471
- // );
472
- // }
473
- // if ( isDefaultCombination ):
474
- // return
475
-
476
- // look for RasterSymbolizer tag
477
- QDomNodeList elements = element.elementsByTagName ( QStringLiteral ( " sld:RasterSymbolizer" ) );
441
+ bool isDefaultCombination = true;
442
+ QList<int> defaultBandCombination( { 1, 2, 3 } );
443
+
444
+ isDefaultCombination = isDefaultCombination && ( usesBands() == defaultBandCombination );
445
+ isDefaultCombination = isDefaultCombination && (
446
+ mRedContrastEnhancement->contrastEnhancementAlgorithm() == QgsContrastEnhancement::StretchToMinimumMaximum &&
447
+ mGreenContrastEnhancement->contrastEnhancementAlgorithm() == QgsContrastEnhancement::StretchToMinimumMaximum &&
448
+ mBlueContrastEnhancement->contrastEnhancementAlgorithm() == QgsContrastEnhancement::StretchToMinimumMaximum
449
+ );
450
+ // compute raster statistics (slow) only if true the previous conditions
451
+ if ( isDefaultCombination )
452
+ {
453
+ QgsRasterBandStats statRed = bandStatistics( 1, QgsRasterBandStats::Min | QgsRasterBandStats::Max );
454
+ isDefaultCombination = isDefaultCombination && (
455
+ ( mRedContrastEnhancement->minimumValue() == statRed.minimumValue &&
456
+ mRedContrastEnhancement->maximumValue() == statRed.maximumValue )
457
+ );
458
+ }
459
+ if ( isDefaultCombination )
460
+ {
461
+ QgsRasterBandStats statGreen = bandStatistics( 2, QgsRasterBandStats::Min | QgsRasterBandStats::Max );
462
+ isDefaultCombination = isDefaultCombination && (
463
+ ( mGreenContrastEnhancement->minimumValue() == statGreen.minimumValue &&
464
+ mGreenContrastEnhancement->maximumValue() == statGreen.maximumValue )
465
+ );
466
+ }
467
+ if ( isDefaultCombination )
468
+ {
469
+ QgsRasterBandStats statBlue = bandStatistics( 3, QgsRasterBandStats::Min | QgsRasterBandStats::Max );
470
+ isDefaultCombination = isDefaultCombination && (
471
+ ( mBlueContrastEnhancement->minimumValue() == statBlue.minimumValue &&
472
+ mBlueContrastEnhancement->maximumValue() == statBlue.maximumValue )
473
+ );
474
+ }
475
+ if ( isDefaultCombination ):
476
+ return
477
+ #endif
478
+
479
+ // look for RasterSymbolizer tag
480
+ QDomNodeList elements = element.elementsByTagName ( QStringLiteral ( " sld:RasterSymbolizer" ) );
478
481
if ( elements.size () == 0 )
479
482
return ;
480
483
0 commit comments