Skip to content

Commit

Permalink
Remove use of some other q* functions which are implemented in std
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 24, 2017
1 parent ad89193 commit d3854e9
Show file tree
Hide file tree
Showing 39 changed files with 106 additions and 106 deletions.
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgsinterpolator.cpp
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgstininterpolator.cpp
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsalignraster.cpp
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/qgszonalstatistics.cpp
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -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 )
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsstatisticalsummarydockwidget.cpp
Expand Up @@ -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++;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposernodesitem.cpp
Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -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() );
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/expression/qgsexpressionutils.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgscurve.cpp
Expand Up @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions src/core/geometry/qgspoint.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 );
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsrectangle.cpp
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsaggregatecalculator.cpp
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsclipper.h
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscolorramp.cpp
Expand Up @@ -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() ) );
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgscoordinatetransform.cpp
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgspointxy.cpp
Expand Up @@ -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 );
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsstatisticalsummary.h
Expand Up @@ -18,7 +18,7 @@

#include <QMap>
#include <QVariant>

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

/***************************************************************************
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerdiagramprovider.cpp
Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgscolorrampshader.cpp
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsraster.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterblock.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterblock.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterchecker.cpp
Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterinterface.cpp
Expand Up @@ -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.
Expand All @@ -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 )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrastertransparency.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsrasterlayersaveasdialog.cpp
Expand Up @@ -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 ) );
}
Expand Down

0 comments on commit d3854e9

Please sign in to comment.