@@ -103,7 +103,7 @@ QgsSingleBandPseudoColorRendererWidget::QgsSingleBandPseudoColorRendererWidget(
103103 mColorInterpolationComboBox ->setCurrentIndex ( 1 );
104104 mClassificationModeComboBox ->addItem ( tr ( " Continuous" ), Continuous );
105105 mClassificationModeComboBox ->addItem ( tr ( " Equal interval" ), EqualInterval );
106- // quantile would be nice as well
106+ mClassificationModeComboBox -> addItem ( tr ( " Quantile " ), Quantile );
107107
108108 mNumberOfEntriesSpinBox ->setValue ( 5 ); // some default
109109
@@ -343,6 +343,38 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
343343 }
344344 }
345345 }
346+ else if ( mClassificationModeComboBox ->itemData ( mClassificationModeComboBox ->currentIndex () ).toInt () == Quantile )
347+ { // Quantile
348+ mMinMaxWidget ->load ();
349+
350+ numberOfEntries = mNumberOfEntriesSpinBox ->value ();
351+
352+ int bandNr = mBandComboBox ->itemData ( bandComboIndex ).toInt ();
353+ // QgsRasterHistogram myRasterHistogram = mRasterLayer->dataProvider()->histogram( bandNr );
354+
355+ double myMin = std::numeric_limits<double >::quiet_NaN ();
356+ double myMax = std::numeric_limits<double >::quiet_NaN ();
357+
358+ QgsRectangle myExtent = mMinMaxWidget ->extent ();
359+ int mySampleSize = mMinMaxWidget ->sampleSize ();
360+
361+ double intervalDiff;
362+ if ( numberOfEntries > 1 )
363+ {
364+ intervalDiff = 1.0 / ( numberOfEntries - 1 );
365+ entryValues.reserve ( numberOfEntries );
366+ for ( int i = 0 ; i < numberOfEntries; ++i )
367+ {
368+ mRasterLayer ->dataProvider ()->cumulativeCut ( bandNr, 0.0 , i * intervalDiff, myMin, myMax, myExtent, mySampleSize );
369+ entryValues.push_back ( myMax );
370+ }
371+ }
372+ else if ( numberOfEntries == 1 )
373+ {
374+ mRasterLayer ->dataProvider ()->cumulativeCut ( bandNr, 0.0 , 0.5 , myMin, myMax, myExtent, mySampleSize );
375+ entryValues.push_back ( myMax );
376+ }
377+ }
346378 else // EqualInterval
347379 {
348380 numberOfEntries = mNumberOfEntriesSpinBox ->value ();
@@ -438,7 +470,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
438470
439471void QgsSingleBandPseudoColorRendererWidget::on_mClassificationModeComboBox_currentIndexChanged ( int index )
440472{
441- mNumberOfEntriesSpinBox ->setEnabled ( mClassificationModeComboBox ->itemData ( index ).toInt () == EqualInterval );
473+ mNumberOfEntriesSpinBox ->setEnabled ( mClassificationModeComboBox ->itemData ( index ).toInt () != Continuous );
442474}
443475
444476void QgsSingleBandPseudoColorRendererWidget::on_mColorRampComboBox_currentIndexChanged ( int index )
0 commit comments