fix dox and switch to classic enum

scope based enum is causing troubles from Python depending on sip version
This commit is contained in:
Denis Rouzaud 2019-12-06 13:06:08 +01:00
parent 9e216b40cc
commit 84d6bbe88a
5 changed files with 9 additions and 12 deletions

View File

@ -1,7 +0,0 @@
# The following has been generated automatically from src/core/classification/qgsclassificationlogarithmic.h
# monkey patching scoped based enum
QgsClassificationLogarithmic.NegativeValueHandling.NoHandling.__doc__ = "No handling"
QgsClassificationLogarithmic.NegativeValueHandling.Discard.__doc__ = "Negative values are discarded - this will require all values"
QgsClassificationLogarithmic.NegativeValueHandling.PrependBreak.__doc__ = "Prepend an extra break to include negative values - this will require all values"
QgsClassificationLogarithmic.NegativeValueHandling.__doc__ = '\n\n' + '* ``NoHandling``: ' + QgsClassificationLogarithmic.NegativeValueHandling.NoHandling.__doc__ + '\n' + '* ``Discard``: ' + QgsClassificationLogarithmic.NegativeValueHandling.Discard.__doc__ + '\n' + '* ``PrependBreak``: ' + QgsClassificationLogarithmic.NegativeValueHandling.PrependBreak.__doc__
# --

View File

@ -22,7 +22,7 @@ Implementation of a logarithmic scale method
%End
public:
enum class NegativeValueHandling
enum NegativeValueHandling
{
NoHandling,
Discard,

View File

@ -29,7 +29,11 @@ class CORE_EXPORT QgsClassificationLogarithmic : public QgsClassificationMethod
{
public:
enum class NegativeValueHandling : int
/**
* Handling of negative and 0 values in the method
* \since QGIS 3.12
*/
enum NegativeValueHandling
{
NoHandling = 0, //!< No handling
Discard, //!< Negative values are discarded - this will require all values

View File

@ -185,7 +185,7 @@ const QgsProcessingParameterDefinition *QgsClassificationMethod::parameterDefini
if ( def->name() == parameterName )
return def;
}
QgsMessageLog::logMessage( QStringLiteral( "No parameter defintion found for %1 in %2 method." ).arg( parameterName ).arg( name() ) );
QgsMessageLog::logMessage( QStringLiteral( "No parameter definition found for %1 in %2 method." ).arg( parameterName ).arg( name() ) );
return nullptr;
}

View File

@ -74,13 +74,13 @@ class TestQgsClassificationMethods(unittest.TestCase):
vl = createMemoryLayer(values)
m = QgsClassificationLogarithmic()
m.setParameterValues({'ZERO_NEG_VALUES_HANDLE': int(QgsClassificationLogarithmic.NegativeValueHandling.Discard)})
m.setParameterValues({'ZERO_NEG_VALUES_HANDLE': QgsClassificationLogarithmic.NegativeValueHandling.Discard})
r = m.classes(vl, 'value', 4)
self.assertEqual(len(r), 4)
self.assertEqual(r[0].label(), '1 - 10^1')
self.assertEqual(QgsClassificationMethod.rangesToBreaks(r), [10.0, 100.0, 1000.0, 10000.0])
m.setParameterValues({'ZERO_NEG_VALUES_HANDLE': int(QgsClassificationLogarithmic.NegativeValueHandling.PrependBreak)})
m.setParameterValues({'ZERO_NEG_VALUES_HANDLE': QgsClassificationLogarithmic.NegativeValueHandling.PrependBreak})
r = m.classes(vl, 'value', 4)
self.assertEqual(r[0].label(), '-2 - 10^0')
self.assertEqual(QgsClassificationMethod.rangesToBreaks(r), [1.0, 10.0, 100.0, 1000.0, 10000.0])