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