-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit fixed interval classification to generate at most 999 classes #50290
Conversation
I'd suggest we don't change the value at all, but instead just apply the limit internally. For bonus points we could add some error reporting capacity to calculateBreaks and then show a warning label in the gui that too many classes were generated and the classification was limited to 999 classes. |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
*/ | ||
void updateClasses( const QgsVectorLayer *vl, int nclasses ); | ||
void updateClasses( const QgsVectorLayer *vl, int nclasses, QString *error = nullptr ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void updateClasses( const QgsVectorLayer *vl, int nclasses, QString *error = nullptr ); | |
void updateClasses( const QgsVectorLayer *vl, int nclasses, QString *error SIP_OUT = nullptr ); |
*/ | ||
QList<QgsClassificationRange> classes( const QgsVectorLayer *layer, const QString &expression, int nclasses ); | ||
QList<QgsClassificationRange> classes( const QgsVectorLayer *layer, const QString &expression, int nclasses, QString *error = nullptr ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QList<QgsClassificationRange> classes( const QgsVectorLayer *layer, const QString &expression, int nclasses, QString *error = nullptr ); | |
QList<QgsClassificationRange> classes( const QgsVectorLayer *layer, const QString &expression, int nclasses, QString *error SIP_PYARGREMOVE = nullptr ); |
We can't add this to the bindings, or the method will start returning a tuple and break existing scripts
@@ -335,7 +336,7 @@ class CORE_EXPORT QgsClassificationMethod SIP_ABSTRACT | |||
* The maximum value is expected to be added at the end of the list, but not the minimum | |||
*/ | |||
virtual QList<double> calculateBreaks( double &minimum, double &maximum, | |||
const QList<double> &values, int nclasses ) = 0; | |||
const QList<double> &values, int nclasses, QString *error = nullptr ) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const QList<double> &values, int nclasses, QString *error = nullptr ) = 0; | |
const QList<double> &values, int nclasses, QString *error SIP_PYARGREMOVE = nullptr ) = 0; |
For the same reason as above... although, I'm unsure how sip will handle this with a virtual method 😱
if ( breaks.length() >= 999 ) | ||
{ | ||
error->clear(); | ||
error->append( QObject::tr( "The specified interval would generate too many classes.\nOnly the first 999 classes are actually added." ) ); | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( breaks.length() >= 999 ) | |
{ | |
error->clear(); | |
error->append( QObject::tr( "The specified interval would generate too many classes.\nOnly the first 999 classes are actually added." ) ); | |
break; | |
} | |
if ( breaks.length() >= 999 && error ) | |
{ | |
error = QObject::tr( "The specified interval would generate too many classes.\nOnly the first 999 classes are actually added." ); | |
break; | |
} |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist. |
Resurrected in #57722 |
Description
Fixed interval has a default value of 1 which can generate way too many classes, leading to crashes - see #49333.
This PR automatically changes the interval size to a value that will not cause more than 999 classes.
999 is the maximum number of classes that we allow for the other interval types so I used this as a ceiling.
Editing the Interval size line edit widget can be a little klutzy when trying to change the forced minimum value, but that's a way better side effect than what we have now (potential crash).
@nyalldawson is there a more elegant way to change the parameter's default value dynamically?
Fix #49333