Skip to content
Permalink
Browse files

Remove use of some other q* functions which are implemented in std

  • Loading branch information
nyalldawson committed Aug 24, 2017
1 parent ad89193 commit d3854e9e5aacf849b7f21f2f472262e6a2b798e8
Showing with 106 additions and 106 deletions.
  1. +1 −1 src/analysis/interpolation/qgsinterpolator.cpp
  2. +1 −1 src/analysis/interpolation/qgstininterpolator.cpp
  3. +1 −1 src/analysis/raster/qgsalignraster.cpp
  4. +1 −1 src/analysis/vector/qgszonalstatistics.cpp
  5. +1 −1 src/app/qgsmergeattributesdialog.cpp
  6. +3 −3 src/app/qgsrasterlayerproperties.cpp
  7. +1 −1 src/app/qgsstatisticalsummarydockwidget.cpp
  8. +2 −2 src/core/composer/qgscomposernodesitem.cpp
  9. +1 −1 src/core/dxf/qgsdxfexport.cpp
  10. +2 −2 src/core/expression/qgsexpressionutils.h
  11. +1 −1 src/core/geometry/qgscurve.cpp
  12. +7 −7 src/core/geometry/qgspoint.cpp
  13. +2 −2 src/core/geometry/qgsrectangle.cpp
  14. +1 −1 src/core/qgsaggregatecalculator.cpp
  15. +2 −2 src/core/qgsclipper.h
  16. +2 −2 src/core/qgscolorramp.cpp
  17. +1 −1 src/core/qgscoordinatetransform.cpp
  18. +2 −2 src/core/qgspointxy.cpp
  19. +3 −3 src/core/qgsstatisticalsummary.h
  20. +1 −1 src/core/qgsvectorlayerdiagramprovider.cpp
  21. +1 −1 src/core/raster/qgscolorrampshader.cpp
  22. +1 −1 src/core/raster/qgsraster.cpp
  23. +2 −2 src/core/raster/qgsrasterblock.cpp
  24. +1 −1 src/core/raster/qgsrasterblock.h
  25. +1 −1 src/core/raster/qgsrasterchecker.cpp
  26. +2 −2 src/core/raster/qgsrasterinterface.cpp
  27. +2 −2 src/core/raster/qgsrastertransparency.cpp
  28. +2 −2 src/gui/qgsrasterlayersaveasdialog.cpp
  29. +2 −2 src/gui/raster/qgsmultibandcolorrendererwidget.cpp
  30. +3 −3 src/gui/raster/qgsrastertransparencywidget.cpp
  31. +2 −2 src/gui/raster/qgssinglebandgrayrendererwidget.cpp
  32. +5 −5 src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
  33. +1 −1 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  34. +1 −1 src/providers/gdal/qgsgdalprovider.cpp
  35. +1 −1 src/providers/grass/qgsgrassrasterprovider.cpp
  36. +1 −1 src/providers/wcs/qgswcsprovider.cpp
  37. +16 −16 tests/src/core/testqgsgeometry.cpp
  38. +2 −2 tests/src/core/testqgsgeometryutils.cpp
  39. +24 −24 tests/src/core/testqgsstatisticalsummary.cpp
@@ -82,7 +82,7 @@ int QgsInterpolator::cacheBaseData()
continue;
}
attributeValue = attributeVariant.toDouble( &attributeConversionOk );
if ( !attributeConversionOk || qIsNaN( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
if ( !attributeConversionOk || std::isnan( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
{
continue;
}
@@ -176,7 +176,7 @@ int QgsTINInterpolator::insertData( QgsFeature *f, bool zCoord, int attr, InputT
return 3;
}
attributeValue = attributeVariant.toDouble( &attributeConversionOk );
if ( !attributeConversionOk || qIsNaN( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
if ( !attributeConversionOk || std::isnan( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
{
return 4;
}
@@ -390,7 +390,7 @@ void QgsAlignRaster::dump() const
int QgsAlignRaster::suggestedReferenceLayer() const
{
int bestIndex = -1;
double bestCellArea = qInf();
double bestCellArea = INFINITY;
QSizeF cs;
int i = 0;

@@ -497,7 +497,7 @@ void QgsZonalStatistics::statisticsFromPreciseIntersection( const QgsGeometry &p

bool QgsZonalStatistics::validPixel( float value ) const
{
if ( value == mInputNodataValue || qIsNaN( value ) )
if ( value == mInputNodataValue || std::isnan( value ) )
{
return false;
}
@@ -369,7 +369,7 @@ QVariant QgsMergeAttributesDialog::calcStatistic( int col, QgsStatisticalSummary
summary.calculate( values );

double val = summary.statistic( stat );
return qIsNaN( val ) ? QVariant( QVariant::Double ) : val;
return std::isnan( val ) ? QVariant( QVariant::Double ) : val;
}

QVariant QgsMergeAttributesDialog::concatenationAttribute( int col )
@@ -669,7 +669,7 @@ void QgsRasterLayerProperties::sync()

mSrcNoDataValueCheckBox->setChecked( mRasterLayer->dataProvider()->useSourceNoDataValue( 1 ) );

bool enableSrcNoData = mRasterLayer->dataProvider()->sourceHasNoDataValue( 1 ) && !qIsNaN( mRasterLayer->dataProvider()->sourceNoDataValue( 1 ) );
bool enableSrcNoData = mRasterLayer->dataProvider()->sourceHasNoDataValue( 1 ) && !std::isnan( mRasterLayer->dataProvider()->sourceNoDataValue( 1 ) );

mSrcNoDataValueCheckBox->setEnabled( enableSrcNoData );
lblSrcNoDataValue->setEnabled( enableSrcNoData );
@@ -1231,14 +1231,14 @@ void QgsRasterLayerProperties::setTransparencyCell( int row, int column, double
case Qgis::Float32:
case Qgis::Float64:
lineEdit->setValidator( new QDoubleValidator( nullptr ) );
if ( !qIsNaN( value ) )
if ( !std::isnan( value ) )
{
valueString = QgsRasterBlock::printValue( value );
}
break;
default:
lineEdit->setValidator( new QIntValidator( nullptr ) );
if ( !qIsNaN( value ) )
if ( !std::isnan( value ) )
{
valueString = QString::number( static_cast<int>( value ) );
}
@@ -185,7 +185,7 @@ void QgsStatisticalSummaryDockWidget::updateNumericStatistics( bool selectedOnly
{
double val = stats.statistic( stat );
addRow( row, QgsStatisticalSummary::displayName( stat ),
qIsNaN( val ) ? QString() : QString::number( val ),
std::isnan( val ) ? QString() : QString::number( val ),
stats.count() != 0 );
row++;
}
@@ -76,15 +76,15 @@ bool QgsComposerNodesItem::addNode( QPointF pt,
const double b = pt1.y() - coef * pt1.x();

double distance = std::numeric_limits<double>::max();
if ( qIsInf( coef ) )
if ( std::isinf( coef ) )
distance = std::fabs( pt1.x() - start.x() );
else
{
const double coef2 = ( -1 / coef );
const double b2 = start.y() - coef2 * start.x();

QPointF inter;
if ( qIsInf( coef2 ) )
if ( std::isinf( coef2 ) )
{
distance = std::fabs( pt1.y() - start.y() );
inter.setX( start.x() );
@@ -443,7 +443,7 @@ void QgsDxfExport::writeGroup( int code, const QgsPoint &p )
{
writeGroup( code + 10, p.x() );
writeGroup( code + 20, p.y() );
if ( p.is3D() && qIsFinite( p.z() ) )
if ( p.is3D() && std::isfinite( p.z() ) )
writeGroup( code + 30, p.z() );
}

@@ -144,7 +144,7 @@ class QgsExpressionUtils
{
bool ok;
double val = v.toString().toDouble( &ok );
ok = ok && qIsFinite( val ) && !qIsNaN( val );
ok = ok && std::isfinite( val ) && !std::isnan( val );
return ok;
}
return false;
@@ -191,7 +191,7 @@ class QgsExpressionUtils
{
bool ok;
double x = value.toDouble( &ok );
if ( !ok || qIsNaN( x ) || !qIsFinite( x ) )
if ( !ok || std::isnan( x ) || !std::isfinite( x ) )
{
parent->setEvalErrorString( QObject::tr( "Cannot convert '%1' to double" ).arg( value.toString() ) );
return 0;
@@ -35,7 +35,7 @@ bool QgsCurve::isClosed() const
bool closed = qgsDoubleNear( start.x(), end.x(), 1E-8 ) &&
qgsDoubleNear( start.y(), end.y(), 1E-8 );
if ( is3D() && closed )
closed &= qgsDoubleNear( start.z(), end.z(), 1E-8 ) || ( qIsNaN( start.z() ) && qIsNaN( end.z() ) );
closed &= qgsDoubleNear( start.z(), end.z(), 1E-8 ) || ( std::isnan( start.z() ) && std::isnan( end.z() ) );
return closed;
}

@@ -43,14 +43,14 @@ QgsPoint::QgsPoint( double x, double y, double z, double m, QgsWkbTypes::Type wk
Q_ASSERT( QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point );
mWkbType = wkbType;
}
else if ( qIsNaN( z ) )
else if ( std::isnan( z ) )
{
if ( qIsNaN( m ) )
if ( std::isnan( m ) )
mWkbType = QgsWkbTypes::Point;
else
mWkbType = QgsWkbTypes::PointM;
}
else if ( qIsNaN( m ) )
else if ( std::isnan( m ) )
mWkbType = QgsWkbTypes::PointZ;
else
mWkbType = QgsWkbTypes::PointZM;
@@ -101,9 +101,9 @@ bool QgsPoint::operator==( const QgsPoint &pt ) const
equal &= qgsDoubleNear( pt.x(), mX, 1E-8 );
equal &= qgsDoubleNear( pt.y(), mY, 1E-8 );
if ( QgsWkbTypes::hasZ( type ) )
equal &= qgsDoubleNear( pt.z(), mZ, 1E-8 ) || ( qIsNaN( pt.z() ) && qIsNaN( mZ ) );
equal &= qgsDoubleNear( pt.z(), mZ, 1E-8 ) || ( std::isnan( pt.z() ) && std::isnan( mZ ) );
if ( QgsWkbTypes::hasM( type ) )
equal &= qgsDoubleNear( pt.m(), mM, 1E-8 ) || ( qIsNaN( pt.m() ) && qIsNaN( mM ) );
equal &= qgsDoubleNear( pt.m(), mM, 1E-8 ) || ( std::isnan( pt.m() ) && std::isnan( mM ) );

return equal;
}
@@ -501,7 +501,7 @@ double QgsPoint::distanceSquared( const QgsPoint &other ) const
double QgsPoint::distance3D( double x, double y, double z ) const
{
double zDistSquared = 0.0;
if ( is3D() || !qIsNaN( z ) )
if ( is3D() || !std::isnan( z ) )
zDistSquared = ( mZ - z ) * ( mZ - z );

return sqrt( ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y ) + zDistSquared );
@@ -519,7 +519,7 @@ double QgsPoint::distance3D( const QgsPoint &other ) const
double QgsPoint::distanceSquared3D( double x, double y, double z ) const
{
double zDistSquared = 0.0;
if ( is3D() || !qIsNaN( z ) )
if ( is3D() || !std::isnan( z ) )
zDistSquared = ( mZ - z ) * ( mZ - z );

return ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y ) + zDistSquared;
@@ -377,11 +377,11 @@ QgsRectangle &QgsRectangle::operator=( const QgsRectangle &r )

bool QgsRectangle::isFinite() const
{
if ( qIsInf( mXmin ) || qIsInf( mYmin ) || qIsInf( mXmax ) || qIsInf( mYmax ) )
if ( std::isinf( mXmin ) || std::isinf( mYmin ) || std::isinf( mXmax ) || std::isinf( mYmax ) )
{
return false;
}
if ( qIsNaN( mXmin ) || qIsNaN( mYmin ) || qIsNaN( mXmax ) || qIsNaN( mYmax ) )
if ( std::isnan( mXmin ) || std::isnan( mYmin ) || std::isnan( mXmax ) || std::isnan( mYmax ) )
{
return false;
}
@@ -434,7 +434,7 @@ QVariant QgsAggregateCalculator::calculateNumericAggregate( QgsFeatureIterator &
}
s.finalize();
double val = s.statistic( stat );
return qIsNaN( val ) ? QVariant() : val;
return std::isnan( val ) ? QVariant() : val;
}

QVariant QgsAggregateCalculator::calculateStringAggregate( QgsFeatureIterator &fit, int attr, QgsExpression *expression,
@@ -234,8 +234,8 @@ inline void QgsClipper::trimFeatureToBoundary(
// look at each edge of the polygon in turn

//ignore segments with nan or inf coordinates
if ( qIsNaN( inX[i2] ) || qIsNaN( inY[i2] ) || qIsInf( inX[i2] ) || qIsInf( inY[i2] )
|| qIsNaN( inX[i1] ) || qIsNaN( inY[i1] ) || qIsInf( inX[i1] ) || qIsInf( inY[i1] ) )
if ( std::isnan( inX[i2] ) || std::isnan( inY[i2] ) || std::isinf( inX[i2] ) || std::isinf( inY[i2] )
|| std::isnan( inX[i1] ) || std::isnan( inY[i1] ) || std::isinf( inX[i1] ) || std::isinf( inY[i1] ) )
{
i1 = i2;
continue;
@@ -29,7 +29,7 @@

static QColor _interpolate( const QColor &c1, const QColor &c2, const double value )
{
if ( qIsNaN( value ) ) return c2;
if ( std::isnan( value ) ) return c2;

qreal r = ( c1.redF() + value * ( c2.redF() - c1.redF() ) );
qreal g = ( c1.greenF() + value * ( c2.greenF() - c1.greenF() ) );
@@ -433,7 +433,7 @@ QColor QgsRandomColorRamp::color( double value ) const
int maxVal = 255;

//if value is nan, then use last precalculated color
int colorIndex = ( !qIsNaN( value ) ? value : 1 ) * ( mTotalColorCount - 1 );
int colorIndex = ( !std::isnan( value ) ? value : 1 ) * ( mTotalColorCount - 1 );
if ( mTotalColorCount >= 1 && mPrecalculatedColors.length() > colorIndex )
{
//use precalculated hue
@@ -410,7 +410,7 @@ QgsRectangle QgsCoordinateTransform::transformBoundingBox( const QgsRectangle &r

for ( int i = 0; i < nXPoints * nYPoints; i++ )
{
if ( !qIsFinite( x[i] ) || !qIsFinite( y[i] ) )
if ( !std::isfinite( x[i] ) || !std::isfinite( y[i] ) )
{
continue;
}
@@ -53,8 +53,8 @@ QString QgsPointXY::toString() const

QString QgsPointXY::toString( int precision ) const
{
QString x = qIsFinite( mX ) ? QString::number( mX, 'f', precision ) : QObject::tr( "infinite" );
QString y = qIsFinite( mY ) ? QString::number( mY, 'f', precision ) : QObject::tr( "infinite" );
QString x = std::isfinite( mX ) ? QString::number( mX, 'f', precision ) : QObject::tr( "infinite" );
QString y = std::isfinite( mY ) ? QString::number( mY, 'f', precision ) : QObject::tr( "infinite" );
return QStringLiteral( "%1,%2" ).arg( x, y );
}

@@ -18,7 +18,7 @@

#include <QMap>
#include <QVariant>

#include <cmath>
#include "qgis_core.h"

/***************************************************************************
@@ -179,7 +179,7 @@ class CORE_EXPORT QgsStatisticalSummary
/** Returns calculated range (difference between maximum and minimum values). A NaN value may be returned if the range cannot
* be calculated.
*/
double range() const { return qIsNaN( mMax ) || qIsNaN( mMin ) ? std::numeric_limits<double>::quiet_NaN() : mMax - mMin; }
double range() const { return std::isnan( mMax ) || std::isnan( mMin ) ? std::numeric_limits<double>::quiet_NaN() : mMax - mMin; }

/** Returns population standard deviation. This is only calculated if Statistic::StDev has
* been specified in the constructor or via setStatistics. A NaN value may be returned if the standard deviation cannot
@@ -239,7 +239,7 @@ class CORE_EXPORT QgsStatisticalSummary
* \see firstQuartile
* \see thirdQuartile
*/
double interQuartileRange() const { return qIsNaN( mThirdQuartile ) || qIsNaN( mFirstQuartile ) ? std::numeric_limits<double>::quiet_NaN() : mThirdQuartile - mFirstQuartile; }
double interQuartileRange() const { return std::isnan( mThirdQuartile ) || std::isnan( mFirstQuartile ) ? std::numeric_limits<double>::quiet_NaN() : mThirdQuartile - mFirstQuartile; }

/** Returns the friendly display name for a statistic
* \param statistic statistic to return name for
@@ -266,7 +266,7 @@ QgsLabelFeature *QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature &fea
ddPosX = mSettings.dataDefinedProperties().valueAsDouble( QgsDiagramLayerSettings::PositionX, context.expressionContext(), std::numeric_limits<double>::quiet_NaN() );
ddPosY = mSettings.dataDefinedProperties().valueAsDouble( QgsDiagramLayerSettings::PositionY, context.expressionContext(), std::numeric_limits<double>::quiet_NaN() );

ddPos = !qIsNaN( ddPosX ) && !qIsNaN( ddPosY );
ddPos = !std::isnan( ddPosX ) && !std::isnan( ddPosY );

if ( ddPos )
{
@@ -313,7 +313,7 @@ bool QgsColorRampShader::shade( double value, int *returnRedValue, int *returnGr
{
return false;
}
if ( qIsNaN( value ) || qIsInf( value ) )
if ( std::isnan( value ) || std::isinf( value ) )
return false;

int colorRampItemListCount = mColorRampItemList.count();
@@ -34,7 +34,7 @@ bool QgsRaster::isRepresentableValue( double value, Qgis::DataType dataType )
case Qgis::Int32:
return value >= std::numeric_limits<qint32>::min() && value <= std::numeric_limits<qint32>::max();
case Qgis::Float32:
return qIsNaN( value ) || qIsInf( value ) ||
return std::isnan( value ) || std::isinf( value ) ||
( value >= -std::numeric_limits<float>::max() && value <= std::numeric_limits<float>::max() );
default:
return true;
@@ -262,9 +262,9 @@ void QgsRasterBlock::resetNoDataValue()
bool QgsRasterBlock::isNoDataValue( double value, double noDataValue )
{
// TODO: optimize no data value test by memcmp()
// More precise would be qIsNaN(value) && qIsNaN(noDataValue(bandNo)), but probably
// More precise would be std::isnan(value) && std::isnan(noDataValue(bandNo)), but probably
// not important and slower
if ( qIsNaN( value ) ||
if ( std::isnan( value ) ||
qgsDoubleNear( value, noDataValue ) )
{
return true;
@@ -532,7 +532,7 @@ inline double QgsRasterBlock::value( qgssize index ) const SIP_SKIP

inline bool QgsRasterBlock::isNoDataValue( double value ) const SIP_SKIP
{
return qIsNaN( value ) || qgsDoubleNear( value, mNoDataValue );
return std::isnan( value ) || qgsDoubleNear( value, mNoDataValue );
}

#endif
@@ -224,7 +224,7 @@ void QgsRasterChecker::compare( const QString &paramName, int verifiedVal, int e
bool QgsRasterChecker::compare( double verifiedVal, double expectedVal, double tolerance )
{
// values may be nan
return ( qIsNaN( verifiedVal ) && qIsNaN( expectedVal ) ) || ( std::fabs( verifiedVal - expectedVal ) <= tolerance );
return ( std::isnan( verifiedVal ) && std::isnan( expectedVal ) ) || ( std::fabs( verifiedVal - expectedVal ) <= tolerance );
}

void QgsRasterChecker::compare( const QString &paramName, double verifiedVal, double expectedVal, QString &report, bool &ok, double tolerance )
@@ -260,7 +260,7 @@ void QgsRasterInterface::initHistogram( QgsRasterHistogram &histogram,

int mySrcDataType = sourceDataType( bandNo );

if ( qIsNaN( histogram.minimum ) )
if ( std::isnan( histogram.minimum ) )
{
// TODO: this was OK when stats/histogram were calced in provider,
// but what TODO in other interfaces? Check for mInput for now.
@@ -277,7 +277,7 @@ void QgsRasterInterface::initHistogram( QgsRasterHistogram &histogram,
histogram.minimum = stats.minimumValue;
}
}
if ( qIsNaN( histogram.maximum ) )
if ( std::isnan( histogram.maximum ) )
{
if ( !mInput && mySrcDataType == Qgis::Byte )
{
@@ -104,7 +104,7 @@ void QgsRasterTransparency::setTransparentThreeValuePixelList( const QList<QgsRa
int QgsRasterTransparency::alphaValue( double value, int globalTransparency ) const
{
//if NaN return 0, transparent
if ( qIsNaN( value ) )
if ( std::isnan( value ) )
{
return 0;
}
@@ -144,7 +144,7 @@ int QgsRasterTransparency::alphaValue( double value, int globalTransparency ) co
int QgsRasterTransparency::alphaValue( double redValue, double greenValue, double blueValue, int globalTransparency ) const
{
//if NaN return 0, transparent
if ( qIsNaN( redValue ) || qIsNaN( greenValue ) || qIsNaN( blueValue ) )
if ( std::isnan( redValue ) || std::isnan( greenValue ) || std::isnan( blueValue ) )
{
return 0;
}
@@ -527,14 +527,14 @@ void QgsRasterLayerSaveAsDialog::addNoDataRow( double min, double max )
case Qgis::Float32:
case Qgis::Float64:
lineEdit->setValidator( new QDoubleValidator( nullptr ) );
if ( !qIsNaN( value ) )
if ( !std::isnan( value ) )
{
valueString = QgsRasterBlock::printValue( value );
}
break;
default:
lineEdit->setValidator( new QIntValidator( nullptr ) );
if ( !qIsNaN( value ) )
if ( !std::isnan( value ) )
{
valueString = QString::number( static_cast<int>( value ) );
}

0 comments on commit d3854e9

Please sign in to comment.
You can’t perform that action at this time.