Skip to content

Commit

Permalink
Move body of reclassifyValue to header so it can be optimised
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 13, 2018
1 parent a534286 commit dc77c59
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
14 changes: 1 addition & 13 deletions src/analysis/processing/qgsreclassifyutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,7 @@ void QgsReclassifyUtils::reclassify( const QVector<QgsReclassifyUtils::RasterCla
destinationRaster->setEditable( false );
}

double QgsReclassifyUtils::reclassifyValue( const QVector<QgsReclassifyUtils::RasterClass> &classes, double input, bool &reclassified )
{
reclassified = false;
for ( const QgsReclassifyUtils::RasterClass &c : classes )
{
if ( c.contains( input ) )
{
reclassified = true;
return c.value;
}
}
return input;
}


///@endcond

Expand Down
16 changes: 15 additions & 1 deletion src/analysis/processing/qgsreclassifyutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "qgis.h"
#include "qgis_analysis.h"
#include "qgsrasterrange.h"
#include <QVector>

class QgsRasterInterface;
class QgsProcessingFeedback;
Expand Down Expand Up @@ -104,12 +105,25 @@ class ANALYSIS_EXPORT QgsReclassifyUtils
* If no matching class was found then \a reclassified will be set to false, and the
* original \a input value returned unchanged.
*/
static double reclassifyValue( const QVector< RasterClass > &classes, double input, bool &reclassified );
static double reclassifyValue( const QVector< RasterClass > &classes, double input, bool &reclassified )
{
reclassified = false;
for ( const QgsReclassifyUtils::RasterClass &c : classes )
{
if ( c.contains( input ) )
{
reclassified = true;
return c.value;
}
}
return input;
}

};

Q_DECLARE_TYPEINFO( QgsReclassifyUtils::RasterClass, Q_MOVABLE_TYPE );


///@endcond PRIVATE

#endif // QGSRECLASSIFYUTILS
Expand Down

0 comments on commit dc77c59

Please sign in to comment.