Make sure (f)abs are prefixed with std::

This commit is contained in:
Nyall Dawson 2017-08-25 02:12:54 +10:00
parent f2b2c6d2fd
commit 77c3be97e3
88 changed files with 274 additions and 274 deletions

View File

@ -210,7 +210,7 @@ double MathUtils::distPointFromLine( QgsPoint *thepoint, QgsPoint *p1, QgsPoint
double a = normal.getX();
double b = normal.getY();
double c = -( normal.getX() * p2->x() + normal.getY() * p2->y() );
double distance = fabs( ( a * thepoint->x() + b * thepoint->y() + c ) / ( sqrt( a * a + b * b ) ) );
double distance = std::fabs( ( a * thepoint->x() + b * thepoint->y() + c ) / ( sqrt( a * a + b * b ) ) );
return distance;
}
else
@ -471,7 +471,7 @@ double MathUtils::power( double a, int b )
return 1;
}
double tmp = a;
for ( int i = 2; i <= abs( b ); i++ )
for ( int i = 2; i <= std::abs( b ); i++ )
{
a *= tmp;

View File

@ -30,7 +30,7 @@
static double ceil_with_tolerance( double value )
{
if ( fabs( value - std::round( value ) ) < 1e-6 )
if ( std::fabs( value - std::round( value ) ) < 1e-6 )
return std::round( value );
else
return qCeil( value );
@ -38,7 +38,7 @@ static double ceil_with_tolerance( double value )
static double floor_with_tolerance( double value )
{
if ( fabs( value - std::round( value ) ) < 1e-6 )
if ( std::fabs( value - std::round( value ) ) < 1e-6 )
return std::round( value );
else
return qFloor( value );
@ -538,7 +538,7 @@ bool QgsAlignRaster::suggestedWarpOutput( const QgsAlignRaster::RasterInfo &info
if ( eErr != CE_None )
return false;
QSizeF cs( fabs( adfDstGeoTransform[1] ), fabs( adfDstGeoTransform[5] ) );
QSizeF cs( std::fabs( adfDstGeoTransform[1] ), std::fabs( adfDstGeoTransform[5] ) );
if ( rect )
*rect = QgsRectangle( extents[0], extents[1], extents[2], extents[3] );
@ -582,7 +582,7 @@ QgsAlignRaster::RasterInfo::~RasterInfo()
QSizeF QgsAlignRaster::RasterInfo::cellSize() const
{
return QSizeF( fabs( mGeoTransform[1] ), fabs( mGeoTransform[5] ) );
return QSizeF( std::fabs( mGeoTransform[1] ), std::fabs( mGeoTransform[5] ) );
}
QPointF QgsAlignRaster::RasterInfo::gridOffset() const

View File

@ -353,7 +353,7 @@ bool QgsRelief::processNineCellWindow( float *x1, float *x2, float *x3, float *x
float aspect = mAspectFilter->processNineCellWindow( x1, x2, x3, x4, x5, x6, x7, x8, x9 );
if ( hillShadeValue285 != mOutputNodataValue && aspect != mOutputNodataValue )
{
double angle_diff = fabs( 285 - aspect );
double angle_diff = std::fabs( 285 - aspect );
if ( angle_diff > 180 )
{
angle_diff -= 180;

View File

@ -110,8 +110,8 @@ class Raytracer
// See http://playtechs.blogspot.ch/2007/03/raytracing-on-grid.html
public:
Raytracer( float x0, float y0, float x1, float y1 )
: m_dx( fabs( x1 - x0 ) )
, m_dy( fabs( y1 - y0 ) )
: m_dx( std::fabs( x1 - x0 ) )
, m_dy( std::fabs( y1 - y0 ) )
, m_x( qFloor( x0 ) )
, m_y( qFloor( y0 ) )
, m_n( 1 )

View File

@ -36,7 +36,7 @@
void DRW_Entity::calculateAxis( DRW_Coord extPoint )
{
//Follow the arbitrary DXF definitions for extrusion axes.
if ( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 )
if ( std::fabs( extPoint.x ) < 0.015625 && std::fabs( extPoint.y ) < 0.015625 )
{
//If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec.
//The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x
@ -797,7 +797,7 @@ void DRW_Arc::applyExtrusion()
// Note that the following code only handles the special case where there is a 2D
// drawing with the z axis heading into the paper (or rather screen). An arbitrary
// extrusion axis (with x and y values greater than 1/64) may still have issues.
if ( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 && extPoint.z < 0.0 )
if ( std::fabs( extPoint.x ) < 0.015625 && std::fabs( extPoint.y ) < 0.015625 && extPoint.z < 0.0 )
{
staangle = M_PI - staangle;
endangle = M_PI - endangle;
@ -902,7 +902,7 @@ void DRW_Ellipse::correctAxis()
}
if ( ratio > 1 )
{
if ( fabs( endparam - staparam - M_PIx2 ) < 1.0e-10 )
if ( std::fabs( endparam - staparam - M_PIx2 ) < 1.0e-10 )
complete = true;
double incX = secPoint.x;
secPoint.x = -( secPoint.y * ratio );
@ -977,7 +977,7 @@ void DRW_Ellipse::toPolyline( DRW_Polyline *pol, int parts ) const
curAngle += incAngle;
}
if ( fabs( endAngle - staparam - M_PIx2 ) < 1.0e-10 )
if ( std::fabs( endAngle - staparam - M_PIx2 ) < 1.0e-10 )
{
pol->flags = 1;
}
@ -2065,7 +2065,7 @@ bool DRW_Vertex::parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs, dou
stawidth = buf->getBitDouble();
if ( stawidth < 0 )
endwidth = stawidth = fabs( stawidth );
endwidth = stawidth = std::fabs( stawidth );
else
endwidth = buf->getBitDouble();
bulge = buf->getBitDouble();

View File

@ -505,7 +505,7 @@ void DRW_LType::update()
size = path.size();
for ( std::vector<double>::size_type i = 0; i < size; i++ )
{
d += fabs( path.at( i ) );
d += std::fabs( path.at( i ) );
}
length = d;
}

View File

@ -582,7 +582,7 @@ int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList< QPa
QLineF lineWest( mapPolygon[3], mapPolygon[0] );
double len = lineEast.length();
Q_ASSERT( fabs( len - lineWest.length() ) < 1e-6 ); // no shear
Q_ASSERT( std::fabs( len - lineWest.length() ) < 1e-6 ); // no shear
double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0;
double dist = static_cast< int >( ( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY;
@ -626,7 +626,7 @@ int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList< QPa
QLineF lineNorth( mapPolygon[0], mapPolygon[1] );
double len = lineSouth.length();
Q_ASSERT( fabs( len - lineNorth.length() ) < 1e-6 ); // no shear
Q_ASSERT( std::fabs( len - lineNorth.length() ) < 1e-6 ); // no shear
const QRectF &mapBoundingRect = mapPolygon.boundingRect();
double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
@ -836,8 +836,8 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values )
// TODO add a function in QgsRasterLayer to get x/y resolution from provider,
// because this might not be 100% accurate
QgsRectangle extent = rlayer->extent();
values[0] = fabs( extent.xMaximum() - extent.xMinimum() ) / rlayer->width();
values[1] = fabs( extent.yMaximum() - extent.yMinimum() ) / rlayer->height();
values[0] = std::fabs( extent.xMaximum() - extent.xMinimum() ) / rlayer->width();
values[1] = std::fabs( extent.yMaximum() - extent.yMinimum() ) / rlayer->height();
// calculate offset - when using very high resolution rasters in geographic CRS
// there seems to be a small shift, but this may be due to rendering issues and depends on zoom

View File

@ -113,7 +113,7 @@ void QgsDecorationScaleBar::render( const QgsMapSettings &mapSettings, QgsRender
//Get map units per pixel. This can be negative at times (to do with
//projections) and that just confuses the rest of the code in this
//function, so force to a positive number.
double myMapUnitsPerPixelDouble = fabs( context.mapToPixel().mapUnitsPerPixel() );
double myMapUnitsPerPixelDouble = std::fabs( context.mapToPixel().mapUnitsPerPixel() );
double myActualSize = mPreferredSize;
// Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze

View File

@ -237,7 +237,7 @@ void QgsLabelingGui::setLayer( QgsMapLayer *mapLayer )
// curved label max character angles
mMaxCharAngleInDSpinBox->setValue( lyr.maxCurvedCharAngleIn );
// lyr.maxCurvedCharAngleOut must be negative, but it is shown as positive spinbox in GUI
mMaxCharAngleOutDSpinBox->setValue( fabs( lyr.maxCurvedCharAngleOut ) );
mMaxCharAngleOutDSpinBox->setValue( std::fabs( lyr.maxCurvedCharAngleOut ) );
wrapCharacterEdit->setText( lyr.wrapChar );
mFontMultiLineAlignComboBox->setCurrentIndex( ( unsigned int ) lyr.multilineAlign );

View File

@ -64,9 +64,9 @@ void QgsMapToolMeasureAngle::canvasMoveEvent( QgsMapMouseEvent *e )
double azimuthOne = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
double azimuthTwo = mDa.bearing( mAnglePoints.at( 1 ), point );
double resultAngle = azimuthTwo - azimuthOne;
QgsDebugMsg( QString::number( fabs( resultAngle ) ) );
QgsDebugMsg( QString::number( std::fabs( resultAngle ) ) );
QgsDebugMsg( QString::number( M_PI ) );
if ( fabs( resultAngle ) > M_PI )
if ( std::fabs( resultAngle ) > M_PI )
{
if ( resultAngle < 0 )
{
@ -163,9 +163,9 @@ void QgsMapToolMeasureAngle::updateSettings()
double azimuthOne = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 0 ) );
double azimuthTwo = mDa.bearing( mAnglePoints.at( 1 ), mAnglePoints.at( 2 ) );
double resultAngle = azimuthTwo - azimuthOne;
QgsDebugMsg( QString::number( fabs( resultAngle ) ) );
QgsDebugMsg( QString::number( std::fabs( resultAngle ) ) );
QgsDebugMsg( QString::number( M_PI ) );
if ( fabs( resultAngle ) > M_PI )
if ( std::fabs( resultAngle ) > M_PI )
{
if ( resultAngle < 0 )
{

View File

@ -78,7 +78,7 @@ void QgsUndoWidget::indexChanged( int curIndx )
canRedo = mUndoStack->canRedo();
curCount = mUndoStack->count();
}
int offset = abs( mPreviousIndex - curIndx );
int offset = std::abs( mPreviousIndex - curIndx );
// when individually redoing, differentiate between last redo and a new command added to stack
bool lastRedo = ( mPreviousIndex == ( mPreviousCount - 1 ) && mPreviousCount == curCount && !canRedo );

View File

@ -409,7 +409,7 @@ void QgsComposerArrow::adaptItemSceneRect()
{
//rectangle containing start and end point
QRectF rect = QRectF( qMin( mStartPoint.x(), mStopPoint.x() ), qMin( mStartPoint.y(), mStopPoint.y() ),
fabs( mStopPoint.x() - mStartPoint.x() ), fabs( mStopPoint.y() - mStartPoint.y() ) );
std::fabs( mStopPoint.x() - mStartPoint.x() ), std::fabs( mStopPoint.y() - mStartPoint.y() ) );
double enlarge = computeMarkerMargin();
rect.adjust( -enlarge, -enlarge, enlarge, enlarge );
QgsComposerItem::setSceneRect( rect );

View File

@ -1465,11 +1465,11 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr
if ( geographic )
{
//insert degree symbol for geographic coordinates
return QString::number( fabs( value ), 'f', mGridAnnotationPrecision ) + QChar( 176 ) + hemisphere;
return QString::number( std::fabs( value ), 'f', mGridAnnotationPrecision ) + QChar( 176 ) + hemisphere;
}
else
{
return QString::number( fabs( value ), 'f', mGridAnnotationPrecision ) + hemisphere;
return QString::number( std::fabs( value ), 'f', mGridAnnotationPrecision ) + hemisphere;
}
}
else if ( mGridAnnotationFormat == CustomFormat )

View File

@ -593,7 +593,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *event
double diffY = mouseMoveStopPoint.y() - mMouseMoveStartPos.y();
//it was only a click
if ( fabs( diffX ) < std::numeric_limits<double>::min() && fabs( diffY ) < std::numeric_limits<double>::min() )
if ( std::fabs( diffX ) < std::numeric_limits<double>::min() && std::fabs( diffY ) < std::numeric_limits<double>::min() )
{
mIsDragging = false;
mIsResizing = false;
@ -824,7 +824,7 @@ void QgsComposerMouseHandles::dragMouseMove( QPointF currentPosition, bool lockM
{
//constrained (shift) moving should lock to horizontal/vertical movement
//reset the smaller of the x/y movements
if ( fabs( moveRectX ) <= fabs( moveRectY ) )
if ( std::fabs( moveRectX ) <= std::fabs( moveRectY ) )
{
moveRectX = 0;
}
@ -1091,7 +1091,7 @@ void QgsComposerMouseHandles::resizeMouseMove( QPointF currentPosition, bool loc
mResizeRect = QRectF( QPointF( -( mBeginHandleWidth + rx ), -( mBeginHandleHeight + ry ) ), QPointF( 0, 0 ) );
}
setRect( 0, 0, fabs( mBeginHandleWidth + rx ), fabs( mBeginHandleHeight + ry ) );
setRect( 0, 0, std::fabs( mBeginHandleWidth + rx ), std::fabs( mBeginHandleHeight + ry ) );
//show current size of selection in status bar
mComposition->setStatusMessage( QString( tr( "width: %1 mm height: %2 mm" ) ).arg( rect().width() ).arg( rect().height() ) );
@ -1270,7 +1270,7 @@ QPointF QgsComposerMouseHandles::alignPos( QPointF pos, double &alignX, double &
double alignThreshold = mComposition->snapTolerance() / viewScaleFactor;
QPointF result( pos.x(), pos.y() );
if ( fabs( nearestX - pos.x() ) < alignThreshold )
if ( std::fabs( nearestX - pos.x() ) < alignThreshold )
{
result.setX( nearestX );
alignX = nearestX;
@ -1280,7 +1280,7 @@ QPointF QgsComposerMouseHandles::alignPos( QPointF pos, double &alignX, double &
alignX = -1;
}
if ( fabs( nearestY - pos.y() ) < alignThreshold )
if ( std::fabs( nearestY - pos.y() ) < alignThreshold )
{
result.setY( nearestY );
alignY = nearestY;
@ -1359,7 +1359,7 @@ void QgsComposerMouseHandles::checkNearestItem( double checkCoord, const QMap< d
return;
}
double currentDiff = fabs( checkCoord - currentCoord );
double currentDiff = std::fabs( checkCoord - currentCoord );
//convert snap tolerance from pixels to mm
double viewScaleFactor = graphicsView()->transform().m11();
double alignThreshold = mComposition->snapTolerance() / viewScaleFactor;

View File

@ -77,7 +77,7 @@ bool QgsComposerNodesItem::addNode( QPointF pt,
double distance = std::numeric_limits<double>::max();
if ( qIsInf( coef ) )
distance = fabs( pt1.x() - start.x() );
distance = std::fabs( pt1.x() - start.x() );
else
{
const double coef2 = ( -1 / coef );
@ -86,7 +86,7 @@ bool QgsComposerNodesItem::addNode( QPointF pt,
QPointF inter;
if ( qIsInf( coef2 ) )
{
distance = fabs( pt1.y() - start.y() );
distance = std::fabs( pt1.y() - start.y() );
inter.setX( start.x() );
inter.setY( pt1.y() );
}
@ -104,7 +104,7 @@ bool QgsComposerNodesItem::addNode( QPointF pt,
const double length3 = computeDistance( pt1, pt2 );
const double length4 = length1 + length2;
if ( fabs( length3 - length4 ) < std::numeric_limits<float>::epsilon() )
if ( std::fabs( length3 - length4 ) < std::numeric_limits<float>::epsilon() )
distance = computeDistance( inter, start );
}

View File

@ -578,8 +578,8 @@ void QgsComposerPicture::setSceneRect( const QRectF &rectangle )
//if height has changed more than width, then fix width and set height correspondingly
//else, do the opposite
if ( fabs( rect().width() - rectangle.width() ) <
fabs( rect().height() - rectangle.height() ) )
if ( std::fabs( rect().width() - rectangle.width() ) <
std::fabs( rect().height() - rectangle.height() ) )
{
newRect.setHeight( targetImageSize.height() * newRect.width() / targetImageSize.width() );
}

View File

@ -189,8 +189,8 @@ QRectF QgsComposerUtils::largestRotatedRectWithinBounds( const QRectF &originalR
double sinAngle = sin( angleRad );
//calculate size of bounds of rotated rectangle
double widthBoundsRotatedRect = originalWidth * fabs( cosAngle ) + originalHeight * fabs( sinAngle );
double heightBoundsRotatedRect = originalHeight * fabs( cosAngle ) + originalWidth * fabs( sinAngle );
double widthBoundsRotatedRect = originalWidth * std::fabs( cosAngle ) + originalHeight * std::fabs( sinAngle );
double heightBoundsRotatedRect = originalHeight * std::fabs( cosAngle ) + originalWidth * std::fabs( sinAngle );
//compare ratio of rotated rect with bounds rect and calculate scaling of rotated
//rect to fit within bounds
@ -221,9 +221,9 @@ QRectF QgsComposerUtils::largestRotatedRectWithinBounds( const QRectF &originalR
//now calculate offset position of rotated rectangle
double offsetX = ratioBoundsRotatedRect > ratioBoundsRect ? 0 : ( boundsWidth - rectScale * widthBoundsRotatedRect ) / 2.0;
offsetX += fabs( minX );
offsetX += std::fabs( minX );
double offsetY = ratioBoundsRotatedRect > ratioBoundsRect ? ( boundsHeight - rectScale * heightBoundsRotatedRect ) / 2.0 : 0;
offsetY += fabs( minY );
offsetY += std::fabs( minY );
return QRectF( offsetX, offsetY, rectScaledWidth, rectScaledHeight );
}

View File

@ -2047,12 +2047,12 @@ QPointF QgsComposition::snapPointToGrid( QPointF scenePoint ) const
double viewScaleFactor = graphicsView()->transform().m11();
double alignThreshold = mSnapTolerance / viewScaleFactor;
if ( fabs( xSnapped - scenePoint.x() ) > alignThreshold )
if ( std::fabs( xSnapped - scenePoint.x() ) > alignThreshold )
{
//snap distance is outside of tolerance
xSnapped = scenePoint.x();
}
if ( fabs( ySnapped - scenePoint.y() ) > alignThreshold )
if ( std::fabs( ySnapped - scenePoint.y() ) > alignThreshold )
{
//snap distance is outside of tolerance
ySnapped = scenePoint.y();

View File

@ -262,7 +262,7 @@ double QgsDxfPaintEngine::power( double a, int b )
return 1;
double tmp = a;
for ( int i = 2; i <= abs( b ); i++ )
for ( int i = 2; i <= std::abs( b ); i++ )
a *= tmp;
if ( b > 0 )

View File

@ -889,8 +889,8 @@ QRect QgsImageOperation::nonTransparentImageRect( const QImage &image, QSize min
if ( center )
{
// recompute min and max to center image
const int dx = qMax( abs( xmax - width / 2 ), abs( xmin - width / 2 ) );
const int dy = qMax( abs( ymax - height / 2 ), abs( ymin - height / 2 ) );
const int dx = qMax( std::abs( xmax - width / 2 ), std::abs( xmin - width / 2 ) );
const int dy = qMax( std::abs( ymax - height / 2 ), std::abs( ymin - height / 2 ) );
xmin = qMax( 0, width / 2 - dx );
xmax = qMin( width, width / 2 + dx );
ymin = qMax( 0, height / 2 - dy );

View File

@ -241,7 +241,7 @@ static QVariant fcnSqrt( const QVariantList &values, const QgsExpressionContext
static QVariant fcnAbs( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
{
double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
return QVariant( fabs( val ) );
return QVariant( std::fabs( val ) );
}
static QVariant fcnRadians( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
@ -1007,13 +1007,13 @@ static QVariant fcnWordwrap( const QVariantList &values, const QgsExpressionCont
if ( strhit == lasthit || strhit == -1 )
{
//if no new backward delimiter found, try to locate forward
strhit = lines[i].indexOf( rx, strcurrent + labs( wrap ) );
strhit = lines[i].indexOf( rx, strcurrent + std::labs( wrap ) );
}
lasthit = strhit;
}
else
{
strhit = lines[i].indexOf( rx, strcurrent + labs( wrap ) );
strhit = lines[i].indexOf( rx, strcurrent + std::labs( wrap ) );
}
if ( strhit > -1 )
{
@ -2656,11 +2656,11 @@ static QVariant fcnAzimuth( const QVariantList &values, const QgsExpressionConte
{
if ( pt1->y() < pt2->y() )
{
return atan( fabs( pt1->x() - pt2->x() ) / fabs( pt1->y() - pt2->y() ) );
return atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) );
}
else /* ( pt1->y() > pt2->y() ) - equality case handled above */
{
return atan( fabs( pt1->y() - pt2->y() ) / fabs( pt1->x() - pt2->x() ) )
return atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
+ ( M_PI / 2 );
}
}
@ -2669,12 +2669,12 @@ static QVariant fcnAzimuth( const QVariantList &values, const QgsExpressionConte
{
if ( pt1->y() > pt2->y() )
{
return atan( fabs( pt1->x() - pt2->x() ) / fabs( pt1->y() - pt2->y() ) )
return atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) )
+ M_PI;
}
else /* ( pt1->y() < pt2->y() ) - equality case handled above */
{
return atan( fabs( pt1->y() - pt2->y() ) / fabs( pt1->x() - pt2->x() ) )
return atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
+ ( M_PI + ( M_PI / 2 ) );
}
}

View File

@ -52,24 +52,24 @@ static bool isPerpendicular( const QgsPoint &pt1, const QgsPoint &pt2, const Qgs
double yDelta_b = pt3.y() - pt2.y();
double xDelta_b = pt3.x() - pt2.x();
if ( ( fabs( xDelta_a ) <= epsilon ) && ( fabs( yDelta_b ) <= epsilon ) )
if ( ( std::fabs( xDelta_a ) <= epsilon ) && ( std::fabs( yDelta_b ) <= epsilon ) )
{
return false;
}
if ( fabs( yDelta_a ) <= epsilon )
if ( std::fabs( yDelta_a ) <= epsilon )
{
return true;
}
else if ( fabs( yDelta_b ) <= epsilon )
else if ( std::fabs( yDelta_b ) <= epsilon )
{
return true;
}
else if ( fabs( xDelta_a ) <= epsilon )
else if ( std::fabs( xDelta_a ) <= epsilon )
{
return true;
}
else if ( fabs( xDelta_b ) <= epsilon )
else if ( std::fabs( xDelta_b ) <= epsilon )
{
return true;
}
@ -138,7 +138,7 @@ QgsCircle QgsCircle::from3Points( const QgsPoint &pt1, const QgsPoint &pt2, cons
double aSlope = yDelta_a / xDelta_a;
double bSlope = yDelta_b / xDelta_b;
if ( ( fabs( xDelta_a ) <= epsilon ) && ( fabs( yDelta_b ) <= epsilon ) )
if ( ( std::fabs( xDelta_a ) <= epsilon ) && ( std::fabs( yDelta_b ) <= epsilon ) )
{
center.setX( 0.5 * ( p2.x() + p3.x() ) );
center.setY( 0.5 * ( p1.y() + p2.y() ) );
@ -147,7 +147,7 @@ QgsCircle QgsCircle::from3Points( const QgsPoint &pt1, const QgsPoint &pt2, cons
return QgsCircle( center, radius );
}
if ( fabs( aSlope - bSlope ) <= epsilon )
if ( std::fabs( aSlope - bSlope ) <= epsilon )
{
return QgsCircle();
}
@ -191,8 +191,8 @@ QgsCircle QgsCircle::from3Tangents( const QgsPoint &pt1_tg1, const QgsPoint &pt2
QgsCircle QgsCircle::fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 )
{
double delta_x = fabs( pt1.x() - pt2.x() );
double delta_y = fabs( pt1.x() - pt2.y() );
double delta_x = std::fabs( pt1.x() - pt2.x() );
double delta_y = std::fabs( pt1.x() - pt2.y() );
if ( !qgsDoubleNear( delta_x, delta_y ) )
{
return QgsCircle();

View File

@ -133,7 +133,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse
*/
void setSemiMajorAxis( const double semiMajorAxis ) override
{
mSemiMajorAxis = fabs( semiMajorAxis );
mSemiMajorAxis = std::fabs( semiMajorAxis );
mSemiMinorAxis = mSemiMajorAxis;
}
@ -143,7 +143,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse
*/
void setSemiMinorAxis( const double semiMinorAxis ) override
{
mSemiMajorAxis = fabs( semiMinorAxis );
mSemiMajorAxis = std::fabs( semiMinorAxis );
mSemiMinorAxis = mSemiMajorAxis;
}
@ -152,7 +152,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse
//! Set the radius of the circle
void setRadius( double radius )
{
mSemiMajorAxis = fabs( radius );
mSemiMajorAxis = std::fabs( radius );
mSemiMinorAxis = mSemiMajorAxis;
}

View File

@ -370,7 +370,7 @@ double QgsCurvePolygon::area() const
{
double area = 0.0;
mExteriorRing->sumUpArea( area );
totalArea += fabs( area );
totalArea += std::fabs( area );
}
QList<QgsCurve *>::const_iterator ringIt = mInteriorRings.constBegin();
@ -380,7 +380,7 @@ double QgsCurvePolygon::area() const
if ( ( *ringIt )->isRing() )
{
( *ringIt )->sumUpArea( area );
totalArea -= fabs( area );
totalArea -= std::fabs( area );
}
}
return totalArea;

View File

@ -25,8 +25,8 @@
void QgsEllipse::normalizeAxis()
{
mSemiMajorAxis = fabs( mSemiMajorAxis );
mSemiMinorAxis = fabs( mSemiMinorAxis );
mSemiMajorAxis = std::fabs( mSemiMajorAxis );
mSemiMinorAxis = std::fabs( mSemiMinorAxis );
if ( mSemiMajorAxis < mSemiMinorAxis )
{
std::swap( mSemiMajorAxis, mSemiMinorAxis );
@ -72,8 +72,8 @@ QgsEllipse QgsEllipse::fromFoci( const QgsPoint &pt1, const QgsPoint &pt2, const
QgsEllipse QgsEllipse::fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 )
{
QgsPoint center = QgsGeometryUtils::midpoint( pt1, pt2 );
double axis_a = fabs( pt2.x() - pt1.x() ) / 2.0;
double axis_b = fabs( pt2.y() - pt1.y() ) / 2.0;
double axis_a = std::fabs( pt2.x() - pt1.x() ) / 2.0;
double axis_b = std::fabs( pt2.y() - pt1.y() ) / 2.0;
double azimuth = 90.0;
return QgsEllipse( center, axis_a, axis_b, azimuth );
@ -81,8 +81,8 @@ QgsEllipse QgsEllipse::fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 )
QgsEllipse QgsEllipse::fromCenterPoint( const QgsPoint &center, const QgsPoint &pt1 )
{
double axis_a = fabs( pt1.x() - center.x() );
double axis_b = fabs( pt1.y() - center.y() );
double axis_a = std::fabs( pt1.x() - center.x() );
double axis_b = std::fabs( pt1.y() - center.y() );
double azimuth = 90.0;
return QgsEllipse( center, axis_a, axis_b, azimuth );

View File

@ -2558,7 +2558,7 @@ QgsLineString *smoothCurve( const QgsLineString &line, const unsigned int iterat
QgsPoint p3 = result->pointN( 1 );
double angle = QgsGeometryUtils::angleBetweenThreePoints( p1.x(), p1.y(), p2.x(), p2.y(),
p3.x(), p3.y() );
angle = fabs( M_PI - angle );
angle = std::fabs( M_PI - angle );
skipFirst = angle > maxAngleRads;
}
for ( int i = 0; i < result->numPoints() - 1; i++ )

View File

@ -468,7 +468,7 @@ void QgsGeometryUtils::circleCenterRadius( const QgsPoint &pt1, const QgsPoint &
d = 2 * ( dx21 * dy31 - dx31 * dy21 );
// Check colinearity, Cross product = 0
if ( qgsDoubleNear( fabs( d ), 0.0, 0.00000000001 ) )
if ( qgsDoubleNear( std::fabs( d ), 0.0, 0.00000000001 ) )
{
radius = -1.0;
return;

View File

@ -2705,12 +2705,12 @@ int QgsGeos::geomDigits( const GEOSGeometry *geom )
GEOSCoordSeq_getX_r( geosinit.ctxt, bBoxCoordSeq, i, &t );
int digits;
digits = ceil( log10( fabs( t ) ) );
digits = ceil( log10( std::fabs( t ) ) );
if ( digits > maxDigits )
maxDigits = digits;
GEOSCoordSeq_getY_r( geosinit.ctxt, bBoxCoordSeq, i, &t );
digits = ceil( log10( fabs( t ) ) );
digits = ceil( log10( std::fabs( t ) ) );
if ( digits > maxDigits )
maxDigits = digits;
}

View File

@ -290,7 +290,7 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision,
bool dotProductWithinAngleTolerance( double dotProduct, double lowerThreshold, double upperThreshold )
{
return lowerThreshold > fabs( dotProduct ) || fabs( dotProduct ) > upperThreshold;
return lowerThreshold > std::fabs( dotProduct ) || std::fabs( dotProduct ) > upperThreshold;
}
double normalizedDotProduct( const QgsPoint &a, const QgsPoint &b, const QgsPoint &c )
@ -341,7 +341,7 @@ double squareness( QgsLineString *ring, double lowerThreshold, double upperThres
if ( !dotProductWithinAngleTolerance( dotProduct, lowerThreshold, upperThreshold ) )
continue;
sum += 2.0 * qMin( fabs( dotProduct - 1.0 ), qMin( fabs( dotProduct ), fabs( dotProduct + 1 ) ) );
sum += 2.0 * qMin( std::fabs( dotProduct - 1.0 ), qMin( std::fabs( dotProduct ), std::fabs( dotProduct + 1 ) ) );
}
a = b;
b = c;

View File

@ -46,13 +46,13 @@ QgsRegularPolygon::QgsRegularPolygon( const QgsPoint &center, const double radiu
{
case InscribedCircle:
{
mRadius = fabs( radius );
mRadius = std::fabs( radius );
mFirstVertex = mCenter.project( mRadius, azimuth );
break;
}
case CircumscribedCircle:
{
mRadius = apothemToRadius( fabs( radius ), numSides );
mRadius = apothemToRadius( std::fabs( radius ), numSides );
mFirstVertex = mCenter.project( mRadius, azimuth - centralAngle( numSides ) / 2 );
break;
}
@ -118,7 +118,7 @@ QgsRegularPolygon::QgsRegularPolygon( const QgsPoint &pt1, const QgsPoint &pt2,
mCenter = pt1.project( hypothenuse, azimuth + angle );
mFirstVertex = pt1;
mRadius = fabs( hypothenuse );
mRadius = std::fabs( hypothenuse );
}
}
@ -152,7 +152,7 @@ void QgsRegularPolygon::setCenter( const QgsPoint &center )
void QgsRegularPolygon::setRadius( const double radius )
{
mRadius = fabs( radius );
mRadius = std::fabs( radius );
double azimuth = mCenter.azimuth( mFirstVertex );
// TODO: double inclination = mCenter.inclination(mFirstVertex);
mFirstVertex = mCenter.project( mRadius, azimuth );

View File

@ -89,7 +89,7 @@ QPointF QgsLayoutSnapper::snapPointToGrid( QPointF point, double scaleFactor, bo
//convert snap tolerance from pixels to layout units
double alignThreshold = mTolerance / scaleFactor;
if ( fabs( xSnapped - point.x() ) > alignThreshold )
if ( std::fabs( xSnapped - point.x() ) > alignThreshold )
{
//snap distance is outside of tolerance
xSnapped = point.x();
@ -98,7 +98,7 @@ QPointF QgsLayoutSnapper::snapPointToGrid( QPointF point, double scaleFactor, bo
{
snappedX = true;
}
if ( fabs( ySnapped - point.y() ) > alignThreshold )
if ( std::fabs( ySnapped - point.y() ) > alignThreshold )
{
//snap distance is outside of tolerance
ySnapped = point.y();
@ -128,7 +128,7 @@ double QgsLayoutSnapper::snapPointToGuides( double original, QgsLayoutGuide::Ori
Q_FOREACH ( QgsLayoutGuide *guide, mLayout->guides().guides( orientation ) )
{
double guidePos = guide->layoutPosition();
double diff = fabs( original - guidePos );
double diff = std::fabs( original - guidePos );
if ( diff < smallestDiff )
{
smallestDiff = diff;

View File

@ -720,7 +720,7 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList<LabelPosit
//calculate some cost penalties
double segmentCost = 1.0 - ( distanceToEndOfSegment - distanceToStartOfSegment ) / longestSegmentLength; // 0 -> 1 (lower for longer segments)
double segmentAngleCost = 1 - fabs( fmod( currentSegmentAngle, M_PI ) - M_PI_2 ) / M_PI_2; // 0 -> 1, lower for more horizontal segments
double segmentAngleCost = 1 - std::fabs( fmod( currentSegmentAngle, M_PI ) - M_PI_2 ) / M_PI_2; // 0 -> 1, lower for more horizontal segments
while ( currentDistanceAlongLine + labelWidth < distanceToEndOfSegment )
{
@ -745,7 +745,7 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList<LabelPosit
// penalize positions which are further from the straight segments's midpoint
double labelCenter = currentDistanceAlongLine + labelWidth / 2.0;
double costCenter = 2 * fabs( labelCenter - distanceToCenterOfSegment ) / ( distanceToEndOfSegment - distanceToStartOfSegment ); // 0 -> 1
double costCenter = 2 * std::fabs( labelCenter - distanceToCenterOfSegment ) / ( distanceToEndOfSegment - distanceToStartOfSegment ); // 0 -> 1
cost += costCenter * 0.0005; // < 0, 0.0005 >
if ( !closedLine )
@ -753,7 +753,7 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList<LabelPosit
// penalize positions which are further from absolute center of whole linestring
// this only applies to non closed linestrings, since the middle of a closed linestring is effectively arbitrary
// and irrelevant to labeling
double costLineCenter = 2 * fabs( labelCenter - middleOfLine ) / totalLineLength; // 0 -> 1
double costLineCenter = 2 * std::fabs( labelCenter - middleOfLine ) / totalLineLength; // 0 -> 1
cost += costLineCenter * 0.0005; // < 0, 0.0005 >
}
@ -901,7 +901,7 @@ int FeaturePart::createCandidatesAlongLineNearMidpoint( QList<LabelPosition *> &
}
// penalize positions which are further from the line's midpoint
double costCenter = fabs( totalLineLength / 2 - ( currentDistanceAlongLine + labelWidth / 2 ) ) / totalLineLength; // <0, 0.5>
double costCenter = std::fabs( totalLineLength / 2 - ( currentDistanceAlongLine + labelWidth / 2 ) ) / totalLineLength; // <0, 0.5>
cost += costCenter / 1000; // < 0, 0.0005 >
cost += initialCost;
@ -1223,7 +1223,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
{
if ( tmp != slp ) // not first?
{
diff = fabs( tmp->getAlpha() - angle_last );
diff = std::fabs( tmp->getAlpha() - angle_last );
if ( diff > 2 * M_PI ) diff -= 2 * M_PI;
diff = qMin( diff, 2 * M_PI - diff ); // difference 350 deg is actually just 10 deg...
angle_diff += diff;
@ -1241,7 +1241,7 @@ int FeaturePart::createCurvedCandidatesAlongLine( QList< LabelPosition * > &lPos
// penalize positions which are further from the line's midpoint
double labelCenter = i + getLabelWidth() / 2;
double costCenter = fabs( total_distance / 2 - labelCenter ) / total_distance; // <0, 0.5>
double costCenter = std::fabs( total_distance / 2 - labelCenter ) / total_distance; // <0, 0.5>
cost += costCenter / 1000; // < 0, 0.0005 >
slp->setCost( cost );

View File

@ -371,9 +371,9 @@ void PointSet::splitPolygons( QLinkedList<PointSet *> &shapes_toProcess,
// lookup for the deepest point in the hole
for ( i = ips; i != cHull[ihn]; i = ( i + 1 ) % nbp )
{
cp = fabs( GeomFunction::cross_product( x[cHull[ihs]], y[cHull[ihs]],
x[cHull[ihn]], y[cHull[ihn]],
x[i], y[i] ) );
cp = std::fabs( GeomFunction::cross_product( x[cHull[ihs]], y[cHull[ihs]],
x[cHull[ihn]], y[cHull[ihn]],
x[i], y[i] ) );
if ( cp - bestcp > EPSILON )
{
bestcp = cp;
@ -444,7 +444,7 @@ void PointSet::splitPolygons( QLinkedList<PointSet *> &shapes_toProcess,
fx = cx + dx;
fy = cy - dy;
if ( seg_length < EPSILON || fabs( ( b = GeomFunction::cross_product( ex, ey, fx, fy, x[retainedPt], y[retainedPt] ) / ( seg_length ) ) ) > ( seg_length / 2 ) ) // retainedPt is not fronting i->j
if ( seg_length < EPSILON || std::fabs( ( b = GeomFunction::cross_product( ex, ey, fx, fy, x[retainedPt], y[retainedPt] ) / ( seg_length ) ) ) > ( seg_length / 2 ) ) // retainedPt is not fronting i->j
{
if ( ( ex = GeomFunction::dist_euc2d_sq( x[i], y[i], x[retainedPt], y[retainedPt] ) ) < ( ey = GeomFunction::dist_euc2d_sq( x[j], y[j], x[retainedPt], y[retainedPt] ) ) )
{

View File

@ -395,7 +395,7 @@ inline QgsPointXY QgsClipper::intersect( const double x1, const double y1,
QgsPointXY p;
if ( fabs( r_d ) > SMALL_NUM && fabs( r_n ) > SMALL_NUM )
if ( std::fabs( r_d ) > SMALL_NUM && std::fabs( r_n ) > SMALL_NUM )
{
// they cross
double r = r_n / r_d;
@ -405,7 +405,7 @@ inline QgsPointXY QgsClipper::intersect( const double x1, const double y1,
{
// Should never get here, but if we do for some reason, cause a
// clunk because something else is wrong if we do.
Q_ASSERT( fabs( r_d ) > SMALL_NUM && fabs( r_n ) > SMALL_NUM );
Q_ASSERT( std::fabs( r_d ) > SMALL_NUM && std::fabs( r_n ) > SMALL_NUM );
}
return p;

View File

@ -1164,7 +1164,7 @@ void QgsCoordinateReferenceSystem::setMapUnits()
static const double FEET_TO_METER = 0.3048;
static const double SMALL_NUM = 1e-3;
if ( fabs( toMeter - FEET_TO_METER ) < SMALL_NUM )
if ( std::fabs( toMeter - FEET_TO_METER ) < SMALL_NUM )
unit = QStringLiteral( "Foot" );
if ( qgsDoubleNear( toMeter, 1.0 ) ) //Unit name for meters would be "metre"

View File

@ -442,7 +442,7 @@ QgsPointXY QgsDistanceArea::computeSpheroidProject(
sigma = ( distance / ( b * A ) ) + delta_sigma;
i++;
}
while ( i < 999 && fabs( ( last_sigma - sigma ) / sigma ) > 1.0e-9 );
while ( i < 999 && std::fabs( ( last_sigma - sigma ) / sigma ) > 1.0e-9 );
lat2 = atan2( ( sin( u1 ) * cos( sigma ) + cos( u1 ) * sin( sigma ) *
cos( azimuth ) ), ( omf * sqrt( POW2( sin_alpha ) +
@ -571,7 +571,7 @@ double QgsDistanceArea::computeDistanceBearing(
double tu2 = 0;
int iterLimit = 20;
while ( fabs( lambda - lambdaP ) > 1e-12 && --iterLimit > 0 )
while ( std::fabs( lambda - lambdaP ) > 1e-12 && --iterLimit > 0 )
{
sinLambda = sin( lambda );
cosLambda = cos( lambda );
@ -741,7 +741,7 @@ double QgsDistanceArea::computePolygonArea( const QList<QgsPointXY> &points ) co
dx = x2 - x1;
dy = y2 - y1;
if ( fabs( dy ) > thresh )
if ( std::fabs( dy ) > thresh )
{
/* account for different latitudes y1, y2 */
area += dx * ( m_Qp - ( Qbar2 - Qbar1 ) / dy );

View File

@ -134,12 +134,12 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs
QgsDebugMsgLevel( QString( "\n0:%1 %2x%3\n1:%4\n2:%5 %6x%7 (w:%8 h:%9)" )
.arg( extent.toString() ).arg( extent.width() ).arg( extent.height() )
.arg( extent1.toString(), extent2.toString() ).arg( extent2.width() ).arg( extent2.height() )
.arg( fabs( 1.0 - extent2.width() / extent.width() ) )
.arg( fabs( 1.0 - extent2.height() / extent.height() ) )
.arg( std::fabs( 1.0 - extent2.width() / extent.width() ) )
.arg( std::fabs( 1.0 - extent2.height() / extent.height() ) )
, 3 );
if ( fabs( 1.0 - extent2.width() / extent.width() ) < 0.5 &&
fabs( 1.0 - extent2.height() / extent.height() ) < 0.5 )
if ( std::fabs( 1.0 - extent2.width() / extent.width() ) < 0.5 &&
std::fabs( 1.0 - extent2.height() / extent.height() ) < 0.5 )
{
extent = extent1;
}

View File

@ -143,8 +143,8 @@ void QgsMapSettings::updateDerived()
{
// Use abs() on the extent to avoid the case where the extent is
// symmetrical about 0.
double xMean = ( fabs( extent.xMinimum() ) + fabs( extent.xMaximum() ) ) * 0.5;
double yMean = ( fabs( extent.yMinimum() ) + fabs( extent.yMaximum() ) ) * 0.5;
double xMean = ( std::fabs( extent.xMinimum() ) + std::fabs( extent.xMaximum() ) ) * 0.5;
double yMean = ( std::fabs( extent.yMinimum() ) + std::fabs( extent.yMaximum() ) ) * 0.5;
double xRange = extent.width() / xMean;
double yRange = extent.height() / yMean;

View File

@ -1171,8 +1171,8 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF *fm, QString t
#if 0 // XXX strk
QgsPointXY ptSize = xform->toMapCoordinatesF( w, h );
labelX = fabs( ptSize.x() - ptZero.x() );
labelY = fabs( ptSize.y() - ptZero.y() );
labelX = std::fabs( ptSize.x() - ptZero.x() );
labelY = std::fabs( ptSize.y() - ptZero.y() );
#else
double uPP = xform->mapUnitsPerPixel();
labelX = w * uPP;
@ -1224,7 +1224,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
// scales closer than 1:1
if ( maxScale < 0 )
{
maxScale = 1 / fabs( maxScale );
maxScale = 1 / std::fabs( maxScale );
}
if ( !qgsDoubleNear( maxScale, 0.0 ) && context.rendererScale() < maxScale )
@ -1239,7 +1239,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
// scales closer than 1:1
if ( minScale < 0 )
{
minScale = 1 / fabs( minScale );
minScale = 1 / std::fabs( minScale );
}
if ( !qgsDoubleNear( minScale, 0.0 ) && context.rendererScale() > minScale )
@ -1436,7 +1436,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
}
}
// make sure maxcharangleout is always negative
maxcharangleout = -( fabs( maxcharangleout ) );
maxcharangleout = -( std::fabs( maxcharangleout ) );
}
// data defined centroid whole or clipped?

View File

@ -84,13 +84,13 @@ QString QgsPointXY::toDegreesMinutesSeconds( int precision, const bool useSuffix
myWrappedY = myWrappedY + 180.0;
}
int myDegreesX = int( fabs( myWrappedX ) );
double myFloatMinutesX = double( ( fabs( myWrappedX ) - myDegreesX ) * 60 );
int myDegreesX = int( std::fabs( myWrappedX ) );
double myFloatMinutesX = double( ( std::fabs( myWrappedX ) - myDegreesX ) * 60 );
int myIntMinutesX = int( myFloatMinutesX );
double mySecondsX = double( myFloatMinutesX - myIntMinutesX ) * 60;
int myDegreesY = int( fabs( myWrappedY ) );
double myFloatMinutesY = double( ( fabs( myWrappedY ) - myDegreesY ) * 60 );
int myDegreesY = int( std::fabs( myWrappedY ) );
double myFloatMinutesY = double( ( std::fabs( myWrappedY ) - myDegreesY ) * 60 );
int myIntMinutesY = int( myFloatMinutesY );
double mySecondsY = double( myFloatMinutesY - myIntMinutesY ) * 60;
@ -186,11 +186,11 @@ QString QgsPointXY::toDegreesMinutes( int precision, const bool useSuffix, const
myWrappedX = myWrappedX + 360.0;
}
int myDegreesX = int( fabs( myWrappedX ) );
double myFloatMinutesX = double( ( fabs( myWrappedX ) - myDegreesX ) * 60 );
int myDegreesX = int( std::fabs( myWrappedX ) );
double myFloatMinutesX = double( ( std::fabs( myWrappedX ) - myDegreesX ) * 60 );
int myDegreesY = int( fabs( mY ) );
double myFloatMinutesY = double( ( fabs( mY ) - myDegreesY ) * 60 );
int myDegreesY = int( std::fabs( mY ) );
double myFloatMinutesY = double( ( std::fabs( mY ) - myDegreesY ) * 60 );
//make sure rounding to specified precision doesn't create minutes >= 60
if ( std::round( myFloatMinutesX * pow( 10.0, precision ) ) >= 60 * pow( 10.0, precision ) )

View File

@ -381,8 +381,8 @@ bool QgsRenderChecker::compareImages( const QString &testName,
{
qDebug( "Test image and result image for %s are different dimensions", testName.toLocal8Bit().constData() );
if ( abs( myExpectedImage.width() - myResultImage.width() ) > mMaxSizeDifferenceX ||
abs( myExpectedImage.height() - myResultImage.height() ) > mMaxSizeDifferenceY )
if ( std::abs( myExpectedImage.width() - myResultImage.width() ) > mMaxSizeDifferenceX ||
std::abs( myExpectedImage.height() - myResultImage.height() ) > mMaxSizeDifferenceY )
{
mReport += QLatin1String( "<tr><td colspan=3>" );
mReport += "<font color=red>Expected image and result image for " + testName + " are different dimensions - FAILING!</font>";
@ -438,10 +438,10 @@ bool QgsRenderChecker::compareImages( const QString &testName,
}
else
{
if ( abs( qRed( myExpectedPixel ) - qRed( myActualPixel ) ) > pixelTolerance ||
abs( qGreen( myExpectedPixel ) - qGreen( myActualPixel ) ) > pixelTolerance ||
abs( qBlue( myExpectedPixel ) - qBlue( myActualPixel ) ) > pixelTolerance ||
abs( qAlpha( myExpectedPixel ) - qAlpha( myActualPixel ) ) > pixelTolerance )
if ( std::abs( qRed( myExpectedPixel ) - qRed( myActualPixel ) ) > pixelTolerance ||
std::abs( qGreen( myExpectedPixel ) - qGreen( myActualPixel ) ) > pixelTolerance ||
std::abs( qBlue( myExpectedPixel ) - qBlue( myActualPixel ) ) > pixelTolerance ||
std::abs( qAlpha( myExpectedPixel ) - qAlpha( myActualPixel ) ) > pixelTolerance )
{
++mMismatchCount;
diffScanline[ x ] = qRgb( 255, 0, 0 );

View File

@ -29,7 +29,7 @@
bool _xxxresult = qgsDoubleNear( value, expected, epsilon ); \
if ( !_xxxresult ) \
{ \
qDebug( "Expecting %f got %f (diff %f > %f)", static_cast< double >( expected ), static_cast< double >( value ), fabs( static_cast< double >( expected ) - value ), static_cast< double >( epsilon ) ); \
qDebug( "Expecting %f got %f (diff %f > %f)", static_cast< double >( expected ), static_cast< double >( value ), std::fabs( static_cast< double >( expected ) - value ), static_cast< double >( epsilon ) ); \
} \
QVERIFY( qgsDoubleNear( value, expected, epsilon ) ); \
}
@ -38,7 +38,7 @@
bool _xxxresult = qgsDoubleNear( value, not_expected, epsilon ); \
if ( _xxxresult ) \
{ \
qDebug( "Expecting %f to be differerent from %f (diff %f > %f)", static_cast< double >( value ), static_cast< double >( not_expected ), fabs( static_cast< double >( not_expected ) - value ), static_cast< double >( epsilon ) ); \
qDebug( "Expecting %f to be differerent from %f (diff %f > %f)", static_cast< double >( value ), static_cast< double >( not_expected ), std::fabs( static_cast< double >( not_expected ) - value ), static_cast< double >( epsilon ) ); \
} \
QVERIFY( !qgsDoubleNear( value, not_expected, epsilon ) ); \
}

View File

@ -264,7 +264,7 @@ int point2vertex( const QgsTracerGraph &g, const QgsPointXY &pt, double epsilon
for ( int i = 0; i < g.v.count(); ++i )
{
const QgsTracerGraph::V &v = g.v.at( i );
if ( v.pt == pt || ( fabs( v.pt.x() - pt.x() ) < epsilon && fabs( v.pt.y() - pt.y() ) < epsilon ) )
if ( v.pt == pt || ( std::fabs( v.pt.x() - pt.x() ) < epsilon && std::fabs( v.pt.y() - pt.y() ) < epsilon ) )
return i;
}

View File

@ -1383,17 +1383,17 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn
result.value = qgsRound( distance, decimals );
result.unit = QgsUnitTypes::DistanceMeters;
}
else if ( fabs( distance ) > 1000.0 )
else if ( std::fabs( distance ) > 1000.0 )
{
result.value = qgsRound( distance / 1000, decimals );
result.unit = QgsUnitTypes::DistanceKilometers;
}
else if ( fabs( distance ) < 0.01 )
else if ( std::fabs( distance ) < 0.01 )
{
result.value = qgsRound( distance * 1000, decimals );
result.unit = QgsUnitTypes::DistanceMillimeters;
}
else if ( fabs( distance ) < 0.1 )
else if ( std::fabs( distance ) < 0.1 )
{
result.value = qgsRound( distance * 100, decimals );
@ -1407,7 +1407,7 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn
break;
case DistanceKilometers:
if ( keepBaseUnit || fabs( distance ) >= 1.0 )
if ( keepBaseUnit || std::fabs( distance ) >= 1.0 )
{
result.value = qgsRound( distance, decimals );
result.unit = QgsUnitTypes::DistanceKilometers;
@ -1420,7 +1420,7 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn
break;
case DistanceFeet:
if ( fabs( distance ) <= 5280.0 || keepBaseUnit )
if ( std::fabs( distance ) <= 5280.0 || keepBaseUnit )
{
result.value = qgsRound( distance, decimals );
result.unit = QgsUnitTypes::DistanceFeet;
@ -1433,7 +1433,7 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn
break;
case DistanceYards:
if ( fabs( distance ) <= 1760.0 || keepBaseUnit )
if ( std::fabs( distance ) <= 1760.0 || keepBaseUnit )
{
result.value = qgsRound( distance, decimals );
result.unit = QgsUnitTypes::DistanceYards;
@ -1446,7 +1446,7 @@ QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance( double distance, QgsUn
break;
case DistanceMiles:
if ( fabs( distance ) >= 1.0 || keepBaseUnit )
if ( std::fabs( distance ) >= 1.0 || keepBaseUnit )
{
result.value = qgsRound( distance, decimals );
result.unit = QgsUnitTypes::DistanceMiles;
@ -1531,12 +1531,12 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are
result.value = qgsRound( area, decimals );
result.unit = QgsUnitTypes::AreaSquareMeters;
}
else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareKilometers, QgsUnitTypes::AreaSquareMeters ) )
else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareKilometers, QgsUnitTypes::AreaSquareMeters ) )
{
result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMeters, QgsUnitTypes::AreaSquareKilometers ), decimals );
result.unit = QgsUnitTypes::AreaSquareKilometers;
}
else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaHectares, QgsUnitTypes::AreaSquareMeters ) )
else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaHectares, QgsUnitTypes::AreaSquareMeters ) )
{
result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMeters, QgsUnitTypes::AreaHectares ), decimals );
result.unit = QgsUnitTypes::AreaHectares;
@ -1563,7 +1563,7 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are
result.value = qgsRound( area, decimals );
result.unit = QgsUnitTypes::AreaSquareFeet;
}
else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaSquareFeet ) )
else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaSquareFeet ) )
{
result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareFeet, QgsUnitTypes::AreaSquareMiles ), decimals );
result.unit = QgsUnitTypes::AreaSquareMiles;
@ -1583,7 +1583,7 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are
result.value = qgsRound( area, decimals );
result.unit = QgsUnitTypes::AreaSquareYards;
}
else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaSquareYards ) )
else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaSquareYards ) )
{
result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareYards, QgsUnitTypes::AreaSquareMiles ), decimals );
result.unit = QgsUnitTypes::AreaSquareMiles;
@ -1610,7 +1610,7 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are
result.value = qgsRound( area, decimals );
result.unit = QgsUnitTypes::AreaHectares;
}
else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareKilometers, QgsUnitTypes::AreaHectares ) )
else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareKilometers, QgsUnitTypes::AreaHectares ) )
{
result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaHectares, QgsUnitTypes::AreaSquareKilometers ), decimals );
result.unit = QgsUnitTypes::AreaSquareKilometers;
@ -1630,7 +1630,7 @@ QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea( double area, QgsUnitTypes::Are
result.value = qgsRound( area, decimals );
result.unit = QgsUnitTypes::AreaAcres;
}
else if ( fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaAcres ) )
else if ( std::fabs( area ) > QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaSquareMiles, QgsUnitTypes::AreaAcres ) )
{
result.value = qgsRound( area * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AreaAcres, QgsUnitTypes::AreaSquareMiles ), decimals );
result.unit = QgsUnitTypes::AreaSquareMiles;

View File

@ -2472,7 +2472,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer *layer,
{
QVariant min = layer->minimumValue( i );
QVariant max = layer->maximumValue( i );
if ( qMax( llabs( min.toLongLong() ), llabs( max.toLongLong() ) ) < INT_MAX )
if ( qMax( std::llabs( min.toLongLong() ), std::llabs( max.toLongLong() ) ) < INT_MAX )
{
fields[i].setType( QVariant::Int );
}

View File

@ -465,7 +465,7 @@ void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap &
if ( mSettings->maxCurvedCharAngleIn > 0 || mSettings->maxCurvedCharAngleOut > 0 )
{
// SLD has no notion for this, the GeoTools ecosystem can only do a single angle
double angle = qMin( fabs( mSettings->maxCurvedCharAngleIn ), fabs( mSettings->maxCurvedCharAngleOut ) );
double angle = qMin( std::fabs( mSettings->maxCurvedCharAngleIn ), std::fabs( mSettings->maxCurvedCharAngleOut ) );
QDomElement vo = QgsSymbolLayerUtils::createVendorOptionElement( doc, QStringLiteral( "maxAngleDelta" ), qgsDoubleToString( angle ) );
textSymbolizerElement.appendChild( vo );
}

View File

@ -285,7 +285,7 @@ void QgsColorRampShader::classifyColorRamp( const int classes, const int band, c
QVector<QColor>::const_iterator color_it = entryColors.begin();
// calculate a reasonable number of decimals to display
double maxabs = log10( qMax( fabs( max ), fabs( min ) ) );
double maxabs = log10( qMax( std::fabs( max ), std::fabs( min ) ) );
int nDecimals = std::round( qMax( 3.0 + maxabs - log10( max - min ), maxabs <= 15.0 ? maxabs + 0.49 : 0.0 ) );
QList<QgsColorRampShader::ColorRampItem> colorRampItems;

View File

@ -203,7 +203,7 @@ double QgsRasterChecker::tolerance( double val, int places )
{
// float precision is about 7 decimal digits, double about 16
// default places = 6
return 1. * qPow( 10, std::round( log10( fabs( val ) ) - places ) );
return 1. * qPow( 10, std::round( log10( std::fabs( val ) ) - places ) );
}
QString QgsRasterChecker::compareHead()
@ -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 ) ) || ( fabs( verifiedVal - expectedVal ) <= tolerance );
return ( qIsNaN( verifiedVal ) && qIsNaN( expectedVal ) ) || ( std::fabs( verifiedVal - expectedVal ) <= tolerance );
}
void QgsRasterChecker::compare( const QString &paramName, double verifiedVal, double expectedVal, QString &report, bool &ok, double tolerance )

View File

@ -40,9 +40,9 @@ bool QgsRasterMinMaxOrigin::operator ==( const QgsRasterMinMaxOrigin &other ) co
return mLimits == other.mLimits &&
mExtent == other.mExtent &&
mAccuracy == other.mAccuracy &&
fabs( mCumulativeCutLower - other.mCumulativeCutLower ) < 1e-5 &&
fabs( mCumulativeCutUpper - other.mCumulativeCutUpper ) < 1e-5 &&
fabs( mStdDevFactor - other.mStdDevFactor ) < 1e-5;
std::fabs( mCumulativeCutLower - other.mCumulativeCutLower ) < 1e-5 &&
std::fabs( mCumulativeCutUpper - other.mCumulativeCutUpper ) < 1e-5 &&
std::fabs( mStdDevFactor - other.mStdDevFactor ) < 1e-5;
}
QString QgsRasterMinMaxOrigin::limitsString( Limits limits )

View File

@ -65,7 +65,7 @@ static double triarea3d( const QgsPoint &P1, const QgsPoint &P2, const QgsPoint
cy = az * bx - ax * bz;
cz = ax * by - ay * bx;
area = fabs( 0.5 * ( sqrt( cx * cx + cy * cy + cz * cz ) ) );
area = std::fabs( 0.5 * ( sqrt( cx * cx + cy * cy + cz * cz ) ) );
return area;
}

View File

@ -53,7 +53,7 @@
"set_color_part( " \
" @symbol_color," \
" 'value'," \
" 40 + 19 * abs( $pi - azimuth( " \
" 40 + 19 * std::abs( $pi - azimuth( " \
" point_n( geometry_n($geometry, @geometry_part_num) , 1 ), " \
" point_n( geometry_n($geometry, @geometry_part_num) , 2 )" \
" ) ) " \

View File

@ -355,7 +355,7 @@ bool pointsToCircle( QPointF a, QPointF b, QPointF c, QPointF &center, qreal &ra
QPointF bc2 = ( b + c ) / 2.0;
// Aligned points
if ( fabs( ab.x() * bc.y() - ab.y() * bc.x() ) < 0.001 ) // Empirical threshold for nearly aligned points
if ( std::fabs( ab.x() * bc.y() - ab.y() * bc.x() ) < 0.001 ) // Empirical threshold for nearly aligned points
return false;
// in case AB is horizontal
@ -493,9 +493,9 @@ QPolygonF curvedArrow( QPointF po, QPointF pm, QPointF pd,
qreal length = euclidian_distance( po, pd );
// for close points and deltaAngle < 180, draw a straight line
if ( fabs( deltaAngle ) < M_PI && ( ( ( headType == QgsArrowSymbolLayer::HeadSingle ) && ( length < headWidth ) ) ||
( ( headType == QgsArrowSymbolLayer::HeadReversed ) && ( length < headWidth ) ) ||
( ( headType == QgsArrowSymbolLayer::HeadDouble ) && ( length < 2 * headWidth ) ) ) )
if ( std::fabs( deltaAngle ) < M_PI && ( ( ( headType == QgsArrowSymbolLayer::HeadSingle ) && ( length < headWidth ) ) ||
( ( headType == QgsArrowSymbolLayer::HeadReversed ) && ( length < headWidth ) ) ||
( ( headType == QgsArrowSymbolLayer::HeadDouble ) && ( length < 2 * headWidth ) ) ) )
{
return straightArrow( po, pd, startWidth, width, headWidth, headHeight, headType, arrowType, offset );
}

View File

@ -395,7 +395,7 @@ QgsSymbolLayer *QgsSimpleFillSymbolLayer::createFromSld( QDomElement &element )
double QgsSimpleFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const
{
double penBleed = context.convertToPainterUnits( mStrokeStyle == Qt::NoPen ? 0 : ( mStrokeWidth / 2.0 ), mStrokeWidthUnit, mStrokeWidthMapUnitScale );
double offsetBleed = context.convertToPainterUnits( qMax( fabs( mOffset.x() ), fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
double offsetBleed = context.convertToPainterUnits( qMax( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
return penBleed + offsetBleed;
}
@ -916,7 +916,7 @@ QgsGradientFillSymbolLayer *QgsGradientFillSymbolLayer::clone() const
double QgsGradientFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const
{
double offsetBleed = context.convertToPainterUnits( qMax( fabs( mOffset.x() ), fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
double offsetBleed = context.convertToPainterUnits( qMax( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
return offsetBleed;
}
@ -1512,7 +1512,7 @@ QgsShapeburstFillSymbolLayer *QgsShapeburstFillSymbolLayer::clone() const
double QgsShapeburstFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const
{
double offsetBleed = context.convertToPainterUnits( qMax( fabs( mOffset.x() ), fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
double offsetBleed = context.convertToPainterUnits( qMax( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
return offsetBleed;
}
@ -2600,14 +2600,14 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext &
lineAngle += 360.;
}
height = abs( height );
width = abs( width );
height = std::abs( height );
width = std::abs( width );
outputPixelDist = height * cos( lineAngle * M_PI / 180 );
// Round offset to correspond to one pixel height, otherwise lines may
// be shifted on tile border if offset falls close to pixel center
int offsetHeight = std::round( fabs( outputPixelOffset / cos( lineAngle * M_PI / 180 ) ) );
int offsetHeight = std::round( std::fabs( outputPixelOffset / cos( lineAngle * M_PI / 180 ) ) );
outputPixelOffset = offsetHeight * cos( lineAngle * M_PI / 180 );
}
@ -3749,7 +3749,7 @@ QgsRasterFillSymbolLayer *QgsRasterFillSymbolLayer::clone() const
double QgsRasterFillSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const
{
return context.convertToPainterUnits( qMax( fabs( mOffset.x() ), fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
return context.convertToPainterUnits( qMax( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
}
void QgsRasterFillSymbolLayer::setImageFilePath( const QString &imagePath )

View File

@ -581,7 +581,7 @@ double QgsSimpleLineSymbolLayer::estimateMaxBleed( const QgsRenderContext &conte
else
{
return context.convertToPainterUnits( ( mWidth / 2.0 ), mWidthUnit, mWidthMapUnitScale ) +
context.convertToPainterUnits( fabs( mOffset ), mOffsetUnit, mOffsetMapUnitScale );
context.convertToPainterUnits( std::fabs( mOffset ), mOffsetUnit, mOffsetMapUnitScale );
}
}
@ -1236,7 +1236,7 @@ void QgsMarkerLineSymbolLayer::renderOffsetVertexAlongLine( const QPolygonF &poi
QPointF previousPoint = points[vertex];
int startPoint = distance > 0 ? qMin( vertex + 1, points.count() - 1 ) : qMax( vertex - 1, 0 );
int endPoint = distance > 0 ? points.count() - 1 : 0;
double distanceLeft = fabs( distance );
double distanceLeft = std::fabs( distance );
for ( int i = startPoint; pointIncrement > 0 ? i <= endPoint : i >= endPoint; i += pointIncrement )
{
@ -1604,7 +1604,7 @@ QSet<QString> QgsMarkerLineSymbolLayer::usedAttributes( const QgsRenderContext &
double QgsMarkerLineSymbolLayer::estimateMaxBleed( const QgsRenderContext &context ) const
{
return context.convertToPainterUnits( ( mMarker->size() / 2.0 ), mMarker->sizeUnit(), mMarker->sizeMapUnitScale() ) +
context.convertToPainterUnits( fabs( mOffset ), mOffsetUnit, mOffsetMapUnitScale );
context.convertToPainterUnits( std::fabs( mOffset ), mOffsetUnit, mOffsetMapUnitScale );
}

View File

@ -3895,7 +3895,7 @@ QList<double> QgsSymbolLayerUtils::prettyBreaks( double minimum, double maximum,
else
{
int U = 1;
cell = qMax( fabs( minimum ), fabs( maximum ) );
cell = qMax( std::fabs( minimum ), std::fabs( maximum ) );
if ( adjustBias >= 1.5 * h + 0.5 )
{
U = 1 + ( 1.0 / ( 1 + h ) );

View File

@ -376,11 +376,11 @@ QgsLayoutGuide *QgsLayoutRuler::guideAtPoint( QPoint localPoint ) const
switch ( mOrientation )
{
case Qt::Horizontal:
currentDelta = fabs( layoutPoint.x() - guide->layoutPosition() );
currentDelta = std::fabs( layoutPoint.x() - guide->layoutPosition() );
break;
case Qt::Vertical:
currentDelta = fabs( layoutPoint.y() - guide->layoutPosition() );
currentDelta = std::fabs( layoutPoint.y() - guide->layoutPosition() );
break;
}
if ( currentDelta < minDelta )

View File

@ -456,7 +456,7 @@ void QgsLayoutView::wheelZoom( QWheelEvent *event )
double zoomFactor = settings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble();
// "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * fabs( event->angleDelta().y() );
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() );
if ( event->modifiers() & Qt::ControlModifier )
{

View File

@ -49,14 +49,14 @@ QRectF QgsLayoutViewRubberBand::updateRect( QPointF start, QPointF position, boo
if ( constrainSquare )
{
if ( fabs( dx ) > fabs( dy ) )
if ( std::fabs( dx ) > std::fabs( dy ) )
{
width = fabs( dx );
width = std::fabs( dx );
height = width;
}
else
{
height = fabs( dy );
height = std::fabs( dy );
width = height;
}

View File

@ -31,7 +31,7 @@ bool QgsLayoutViewTool::isClickAndDrag( QPoint startViewPoint, QPoint endViewPoi
{
int diffX = endViewPoint.x() - startViewPoint.x();
int diffY = endViewPoint.y() - startViewPoint.y();
if ( abs( diffX ) >= 2 || abs( diffY ) >= 2 )
if ( std::abs( diffX ) >= 2 || std::abs( diffY ) >= 2 )
{
return true;
}

View File

@ -66,11 +66,11 @@ bool QgsAdvancedDigitizingDockWidget::lineCircleIntersection( const QgsPointXY &
const int sgnDy = dy < 0 ? -1 : 1;
const double ax = center.x() + ( d * dy + sgnDy * dx * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) );
const double ay = center.y() + ( -d * dx + fabs( dy ) * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) );
const double ay = center.y() + ( -d * dx + std::fabs( dy ) * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) );
const QgsPointXY p1( ax, ay );
const double bx = center.x() + ( d * dy - sgnDy * dx * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) );
const double by = center.y() + ( -d * dx - fabs( dy ) * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) );
const double by = center.y() + ( -d * dx - std::fabs( dy ) * sqrt( pow( radius, 2 ) * pow( dr, 2 ) - pow( d, 2 ) ) ) / ( pow( dr, 2 ) );
const QgsPointXY p2( bx, by );
// snap to nearest intersection
@ -656,14 +656,14 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent *e )
softAngle -= deltaAngle;
}
int quo = std::round( softAngle / commonAngle );
if ( fabs( softAngle - quo * commonAngle ) * 180.0 * M_1_PI <= SOFT_CONSTRAINT_TOLERANCE_DEGREES )
if ( std::fabs( softAngle - quo * commonAngle ) * 180.0 * M_1_PI <= SOFT_CONSTRAINT_TOLERANCE_DEGREES )
{
// also check the distance in pixel to the line, otherwise it's too sticky at long ranges
softAngle = quo * commonAngle ;
// http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html
// use the direction vector (cos(a),sin(a)) from previous point. |x2-x1|=1 since sin2+cos2=1
const double dist = fabs( qCos( softAngle + deltaAngle ) * ( previousPt.y() - point.y() )
- qSin( softAngle + deltaAngle ) * ( previousPt.x() - point.x() ) );
const double dist = std::fabs( qCos( softAngle + deltaAngle ) * ( previousPt.y() - point.y() )
- qSin( softAngle + deltaAngle ) * ( previousPt.x() - point.x() ) );
if ( dist / mMapCanvas->mapSettings().mapUnitsPerPixel() < SOFT_CONSTRAINT_TOLERANCE_PIXEL )
{
mAngleConstraint->setLockMode( CadConstraint::SoftLock );
@ -745,7 +745,7 @@ bool QgsAdvancedDigitizingDockWidget::applyConstraints( QgsMapMouseEvent *e )
// do not compute intersection if lines are almost parallel
// this threshold might be adapted
if ( fabs( d ) > 0.01 )
if ( std::fabs( d ) > 0.01 )
{
point.setX( ( ( x3 - x4 ) * ( x1 * y2 - y1 * x2 ) - ( x1 - x2 ) * ( x3 * y4 - y3 * x4 ) ) / d );
point.setY( ( ( y3 - y4 ) * ( x1 * y2 - y1 * x2 ) - ( y1 - y2 ) * ( x3 * y4 - y3 * x4 ) ) / d );

View File

@ -464,7 +464,7 @@ void QgsColorWheel::paintEvent( QPaintEvent *event )
double mx = ( sx + vx ) / 2.0;
double my = ( sy + vy ) / 2.0;
double a = ( 1 - 2.0 * fabs( lightness - 0.5 ) ) * mCurrentColor.hslSaturationF();
double a = ( 1 - 2.0 * std::fabs( lightness - 0.5 ) ) * mCurrentColor.hslSaturationF();
double x = sx + ( vx - sx ) * lightness + ( hx - mx ) * a;
double y = sy + ( vy - sy ) * lightness + ( hy - my ) * a;
@ -564,7 +564,7 @@ void QgsColorWheel::setColorFromPos( const QPointF pos )
double triangleSideLength = sqrt( 3.0 ) * triangleLength;
double newL = ( ( -sin( rad0 ) * r ) / triangleSideLength ) + 0.5;
double widthShare = 1.0 - ( fabs( newL - 0.5 ) * 2.0 );
double widthShare = 1.0 - ( std::fabs( newL - 0.5 ) * 2.0 );
double newS = ( ( ( cos( rad0 ) * r ) + ( triangleLength / 2.0 ) ) / ( 1.5 * triangleLength ) ) / widthShare;
s = qMin( static_cast< int >( std::round( qMax( 0.0, newS ) * 255.0 ) ), 255 );
l = qMin( static_cast< int >( std::round( qMax( 0.0, newL ) * 255.0 ) ), 255 );

View File

@ -753,7 +753,7 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent *e )
//was this just a click? or a click and drag?
bool clickOnly = false;
if ( fabs( diffX ) < 2 && fabs( diffY ) < 2 )
if ( std::fabs( diffX ) < 2 && std::fabs( diffY ) < 2 )
{
clickOnly = true;
}
@ -1315,14 +1315,14 @@ void QgsComposerView::updateRubberBandRect( QPointF &pos, const bool constrainSq
if ( constrainSquare )
{
if ( fabs( dx ) > fabs( dy ) )
if ( std::fabs( dx ) > std::fabs( dy ) )
{
width = fabs( dx );
width = std::fabs( dx );
height = width;
}
else
{
height = fabs( dy );
height = std::fabs( dy );
width = height;
}
@ -2015,7 +2015,7 @@ void QgsComposerView::wheelZoom( QWheelEvent *event )
double zoomFactor = mySettings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble();
// "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * fabs( event->angleDelta().y() );
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( event->angleDelta().y() );
if ( event->modifiers() & Qt::ControlModifier )
{

View File

@ -285,7 +285,7 @@ int QgsGradientStopEditor::findClosestStop( int x, int threshold ) const
int i = 1;
Q_FOREACH ( const QgsGradientStop &stop, mGradient.stops() )
{
currentDiff = abs( relativePositionToPoint( stop.offset ) + 1 - x );
currentDiff = std::abs( relativePositionToPoint( stop.offset ) + 1 - x );
if ( ( threshold < 0 || currentDiff < threshold ) && currentDiff < closestDiff )
{
closestStop = i;
@ -295,7 +295,7 @@ int QgsGradientStopEditor::findClosestStop( int x, int threshold ) const
}
//first stop
currentDiff = abs( relativePositionToPoint( 0.0 ) + 1 - x );
currentDiff = std::abs( relativePositionToPoint( 0.0 ) + 1 - x );
if ( ( threshold < 0 || currentDiff < threshold ) && currentDiff < closestDiff )
{
closestStop = 0;
@ -303,7 +303,7 @@ int QgsGradientStopEditor::findClosestStop( int x, int threshold ) const
}
//last stop
currentDiff = abs( relativePositionToPoint( 1.0 ) + 1 - x );
currentDiff = std::abs( relativePositionToPoint( 1.0 ) + 1 - x );
if ( ( threshold < 0 || currentDiff < threshold ) && currentDiff < closestDiff )
{
closestStop = mGradient.count() - 1;

View File

@ -1091,8 +1091,8 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent *e )
// Don't want to interfer with mouse events
QgsRectangle currentExtent = mapSettings().visibleExtent();
double dx = fabs( currentExtent.width() / 4 );
double dy = fabs( currentExtent.height() / 4 );
double dx = std::fabs( currentExtent.width() / 4 );
double dy = std::fabs( currentExtent.height() / 4 );
switch ( e->key() )
{
@ -1420,7 +1420,7 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e )
double zoomFactor = mWheelZoomFactor;
// "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * fabs( e->angleDelta().y() );
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( e->angleDelta().y() );
if ( e->modifiers() & Qt::ControlModifier )
{

View File

@ -187,7 +187,7 @@ QgsMapCanvasAnnotationItem::MouseMoveAction QgsMapCanvasAnnotationItem::moveActi
int cursorSensitivity = 7;
if ( mAnnotation && mAnnotation->hasFixedMapPosition() &&
fabs( itemPos.x() ) < cursorSensitivity && fabs( itemPos.y() ) < cursorSensitivity ) //move map point if position is close to the origin
std::fabs( itemPos.x() ) < cursorSensitivity && std::fabs( itemPos.y() ) < cursorSensitivity ) //move map point if position is close to the origin
{
return MoveMapPosition;
}
@ -196,10 +196,10 @@ QgsMapCanvasAnnotationItem::MouseMoveAction QgsMapCanvasAnnotationItem::moveActi
QSizeF frameSize = mAnnotation ? mAnnotation->frameSize() : QSizeF( 0, 0 );
bool left, right, up, down;
left = fabs( itemPos.x() - offset.x() ) < cursorSensitivity;
right = fabs( itemPos.x() - ( offset.x() + frameSize.width() ) ) < cursorSensitivity;
up = fabs( itemPos.y() - offset.y() ) < cursorSensitivity;
down = fabs( itemPos.y() - ( offset.y() + frameSize.height() ) ) < cursorSensitivity;
left = std::fabs( itemPos.x() - offset.x() ) < cursorSensitivity;
right = std::fabs( itemPos.x() - ( offset.x() + frameSize.width() ) ) < cursorSensitivity;
up = std::fabs( itemPos.y() - offset.y() ) < cursorSensitivity;
down = std::fabs( itemPos.y() - ( offset.y() + frameSize.height() ) ) < cursorSensitivity;
if ( left && up )
{

View File

@ -47,7 +47,7 @@ void QgsMapToolExtent::canvasMoveEvent( QgsMapMouseEvent *e )
QgsPointXY p = toMapCoordinates( e->pos() );
if ( mRatio.width() > 0 && mRatio.height() > 0 )
{
double width = fabs( p.x() - mStartPoint.x() );
double width = std::fabs( p.x() - mStartPoint.x() );
double height = width * ( mRatio.width() / mRatio.height() );
if ( p.y() - mStartPoint.y() < 0 )
height *= -1;
@ -98,7 +98,7 @@ void QgsMapToolExtent::calculateEndPoint( QgsPointXY &point )
{
if ( mRatio.width() > 0 && mRatio.height() > 0 )
{
double width = fabs( point.x() - mStartPoint.x() );
double width = std::fabs( point.x() - mStartPoint.x() );
double height = width * mRatio.height() / mRatio.width();
if ( point.y() - mStartPoint.y() < 0 )
height *= -1;

View File

@ -98,7 +98,7 @@ void QgsScaleComboBox::showPopup()
{
parts = itemText( i ).split( ':' );
nextScale = parts.at( 1 ).toLong( &ok );
delta = labs( currScale - nextScale );
delta = std::labs( currScale - nextScale );
if ( delta < min )
{
min = delta;

View File

@ -1005,7 +1005,7 @@ QString findClosestTickVal( double target, const QwtScaleDiv *scale, int div = 1
current += diff;
if ( current > target )
{
closest = ( fabs( target - current + diff ) < fabs( target - current ) ) ? current - diff : current;
closest = ( std::fabs( target - current + diff ) < std::fabs( target - current ) ) ? current - diff : current;
break;
}
}

View File

@ -158,11 +158,11 @@ void QgsGraduatedHistogramWidget::findClosestRange( double value, int &closestRa
int pressedPixel = mPlot->canvasMap( QwtPlot::xBottom ).transform( value );
for ( int i = 0; i < ranges.count() - 1; ++i )
{
if ( fabs( mPressedValue - ranges.at( i ).upperValue() ) < minDistance )
if ( std::fabs( mPressedValue - ranges.at( i ).upperValue() ) < minDistance )
{
closestRangeIndex = i;
minDistance = fabs( mPressedValue - ranges.at( i ).upperValue() );
pixelDistance = fabs( pressedPixel - mPlot->canvasMap( QwtPlot::xBottom ).transform( ranges.at( i ).upperValue() ) );
minDistance = std::fabs( mPressedValue - ranges.at( i ).upperValue() );
pixelDistance = std::fabs( pressedPixel - mPlot->canvasMap( QwtPlot::xBottom ).transform( ranges.at( i ).upperValue() ) );
}
}
}

View File

@ -111,7 +111,7 @@ void QgsGeometryOverlapCheck::fixError( QgsGeometryCheckError *error, int method
for ( int iPart = 0, nParts = interGeom->partCount(); iPart < nParts; ++iPart )
{
QgsAbstractGeometry *part = QgsGeometryCheckerUtils::getGeomPart( interGeom, iPart );
if ( fabs( part->area() - overlapError->value().toDouble() ) < QgsGeometryCheckPrecision::reducedTolerance() &&
if ( std::fabs( part->area() - overlapError->value().toDouble() ) < QgsGeometryCheckPrecision::reducedTolerance() &&
QgsGeometryCheckerUtils::pointsFuzzyEqual( part->centroid(), overlapError->location(), QgsGeometryCheckPrecision::reducedTolerance() ) )
{
interPart = part;

View File

@ -38,7 +38,7 @@ class QgsGeometryOverlapCheckError : public QgsGeometryCheckError
other->featureId() == featureId() &&
err->otherId() == otherId() &&
QgsGeometryCheckerUtils::pointsFuzzyEqual( location(), other->location(), QgsGeometryCheckPrecision::reducedTolerance() ) &&
fabs( value().toDouble() - other->value().toDouble() ) < QgsGeometryCheckPrecision::reducedTolerance();
std::fabs( value().toDouble() - other->value().toDouble() ) < QgsGeometryCheckPrecision::reducedTolerance();
}
bool closeMatch( QgsGeometryCheckError *other ) const override

View File

@ -54,7 +54,7 @@ namespace QgsGeometryCheckerUtils
static inline double pointLineDist( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q )
{
double nom = fabs( ( p2.y() - p1.y() ) * q.x() - ( p2.x() - p1.x() ) * q.y() + p2.x() * p1.y() - p2.y() * p1.x() );
double nom = std::fabs( ( p2.y() - p1.y() ) * q.x() - ( p2.x() - p1.x() ) * q.y() + p2.x() * p1.y() - p2.y() * p1.x() );
double dx = p2.x() - p1.x();
double dy = p2.y() - p1.y();
return nom / qSqrt( dx * dx + dy * dy );

View File

@ -77,7 +77,7 @@ double QgsDmsAndDdDelegate::dmsToDD( const QString &dms ) const
{
QStringList list = dms.split( ' ' );
QString tmpStr = list.at( 0 );
double res = fabs( tmpStr.toDouble() );
double res = std::fabs( tmpStr.toDouble() );
tmpStr = list.value( 1 );
if ( !tmpStr.isEmpty() )

View File

@ -379,8 +379,8 @@ int QgsLinearGeorefTransform::linear_transform( void *pTransformerArg, int bDstT
else
{
// Guard against division by zero
if ( fabs( t->scaleX ) < std::numeric_limits<double>::epsilon() ||
fabs( t->scaleY ) < std::numeric_limits<double>::epsilon() )
if ( std::fabs( t->scaleX ) < std::numeric_limits<double>::epsilon() ||
std::fabs( t->scaleY ) < std::numeric_limits<double>::epsilon() )
{
for ( int i = 0; i < nPointCount; ++i )
{
@ -460,7 +460,7 @@ int QgsHelmertGeorefTransform::helmert_transform( void *pTransformerArg, int bDs
else
{
// Guard against division by zero
if ( fabs( s ) < std::numeric_limits<double>::epsilon() )
if ( std::fabs( s ) < std::numeric_limits<double>::epsilon() )
{
for ( int i = 0; i < nPointCount; ++i )
{
@ -602,7 +602,7 @@ bool QgsProjectiveGeorefTransform::updateParametersFromGCPs( const QVector<QgsPo
double det = H[0] * adjoint[0] + H[3] * adjoint[1] + H[6] * adjoint[2];
if ( fabs( det ) < 1024.0 * std::numeric_limits<double>::epsilon() )
if ( std::fabs( det ) < 1024.0 * std::numeric_limits<double>::epsilon() )
{
mParameters.hasInverse = false;
}
@ -654,7 +654,7 @@ int QgsProjectiveGeorefTransform::projective_transform( void *pTransformerArg, i
{
double Z = x[i] * H[6] + y[i] * H[7] + H[8];
// Projects to infinity?
if ( fabs( Z ) < 1024.0 * std::numeric_limits<double>::epsilon() )
if ( std::fabs( Z ) < 1024.0 * std::numeric_limits<double>::epsilon() )
{
panSuccess[i] = false;
continue;

View File

@ -57,8 +57,8 @@ void QgsLeastSquares::linear( const QVector<QgsPointXY> &mapCoords,
origin.setX( aX );
origin.setY( aY );
pixelXSize = fabs( bX );
pixelYSize = fabs( bY );
pixelXSize = std::fabs( bX );
pixelYSize = std::fabs( bY );
}

View File

@ -137,7 +137,7 @@ double QgsMapCoordsDialog::dmsToDD( const QString &dms )
{
QStringList list = dms.split( ' ' );
QString tmpStr = list.at( 0 );
double res = fabs( tmpStr.toDouble() );
double res = std::fabs( tmpStr.toDouble() );
tmpStr = list.value( 1 );
if ( !tmpStr.isEmpty() )

View File

@ -1087,7 +1087,7 @@ void QgsGrassNewMapset::drawRegion()
double x1 = points[i].x();
double x2 = points[i + 1].x();
if ( fabs( x2 - x1 ) > 150 )
if ( std::fabs( x2 - x1 ) > 150 )
{
if ( x2 < x1 )
{

View File

@ -196,9 +196,9 @@ ColorEntry ColorScheme::colorEntry( int index, uint randomSeed ) const
QColor &color = entry.color;
int newHue = abs( ( color.hue() + hueDifference ) % MAX_HUE );
int newValue = qMin( abs( color.value() + valueDifference ), 255 );
int newSaturation = qMin( abs( color.saturation() + saturationDifference ), 255 );
int newHue = std::abs( ( color.hue() + hueDifference ) % MAX_HUE );
int newValue = qMin( std::abs( color.value() + valueDifference ), 255 );
int newSaturation = qMin( std::abs( color.saturation() + saturationDifference ), 255 );
color.setHsv( newHue, newSaturation, newValue );
}

View File

@ -817,7 +817,7 @@ void TerminalDisplay::scrollImage( int lines, const QRect &screenWindowRegion )
if ( lines == 0
|| _image == 0
|| !region.isValid()
|| ( region.top() + abs( lines ) ) >= region.bottom()
|| ( region.top() + std::abs( lines ) ) >= region.bottom()
|| this->_lines <= region.height() ) return;
// hide terminal size label to prevent it being scrolled
@ -848,10 +848,10 @@ void TerminalDisplay::scrollImage( int lines, const QRect &screenWindowRegion )
scrollRect.setRight( width() - scrollBarWidth - SCROLLBAR_CONTENT_GAP );
}
void *firstCharPos = &_image[ region.top() * this->_columns ];
void *lastCharPos = &_image[( region.top() + abs( lines ) ) * this->_columns ];
void *lastCharPos = &_image[( region.top() + std::abs( lines ) ) * this->_columns ];
int top = _topMargin + ( region.top() * _fontHeight );
int linesToMove = region.height() - abs( lines );
int linesToMove = region.height() - std::abs( lines );
int bytesToMove = linesToMove *
this->_columns *
sizeof( Character );
@ -884,7 +884,7 @@ void TerminalDisplay::scrollImage( int lines, const QRect &screenWindowRegion )
memmove( lastCharPos, firstCharPos, bytesToMove );
//set region of the display to scroll
scrollRect.setTop( top + abs( lines ) * _fontHeight );
scrollRect.setTop( top + std::abs( lines ) * _fontHeight );
}
scrollRect.setHeight( linesToMove * _fontHeight );
@ -2392,7 +2392,7 @@ void TerminalDisplay::wheelEvent( QWheelEvent *ev )
// QWheelEvent::delta() gives rotation in eighths of a degree
int wheelDegrees = ev->delta() / 8;
int linesToScroll = abs( wheelDegrees ) / 5;
int linesToScroll = std::abs( wheelDegrees ) / 5;
QKeyEvent keyScrollEvent( QEvent::KeyPress, key, Qt::NoModifier );

View File

@ -528,7 +528,7 @@ void QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pi
int srcBottom = ySize() - 1;
int srcRight = xSize() - 1;
// Note: original approach for xRes < srcXRes || yRes < fabs( srcYRes ) was to avoid
// Note: original approach for xRes < srcXRes || yRes < std::fabs( srcYRes ) was to avoid
// second resampling and read with GDALRasterIO to another temporary data block
// extended to fit src grid. The problem was that with src resolution much bigger
// than dst res, the target could become very large
@ -587,7 +587,7 @@ void QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pi
{
tmpWidth = static_cast<int>( std::round( srcWidth * srcXRes / xRes ) );
}
if ( yRes > fabs( srcYRes ) )
if ( yRes > std::fabs( srcYRes ) )
{
tmpHeight = static_cast<int>( std::round( -1.*srcHeight * srcYRes / yRes ) );
}
@ -1291,8 +1291,8 @@ bool QgsGdalProvider::hasHistogram( int bandNo,
// min/max are stored as text in aux file => use threshold
if ( myBinCount != myHistogram.binCount ||
fabs( myMinVal - myExpectedMinVal ) > fabs( myExpectedMinVal ) / 10e6 ||
fabs( myMaxVal - myExpectedMaxVal ) > fabs( myExpectedMaxVal ) / 10e6 )
std::fabs( myMinVal - myExpectedMinVal ) > std::fabs( myExpectedMinVal ) / 10e6 ||
std::fabs( myMaxVal - myExpectedMaxVal ) > std::fabs( myExpectedMaxVal ) / 10e6 )
{
QgsDebugMsg( QString( "Params do not match binCount: %1 x %2, minVal: %3 x %4, maxVal: %5 x %6" ).arg( myBinCount ).arg( myHistogram.binCount ).arg( myMinVal ).arg( myExpectedMinVal ).arg( myMaxVal ).arg( myExpectedMaxVal ) );
return false;

View File

@ -123,7 +123,7 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const &uri )
else if ( mGrassDataType == DCELL_TYPE )
{
// Don't use numeric limits, raster layer is using
// fabs( myValue - mNoDataValue ) <= TINY_VALUE
// std::fabs( myValue - mNoDataValue ) <= TINY_VALUE
// if the mNoDataValue would be a limit, the subtraction could overflow.
// No data value is shown in GUI, use some nice number.
// Choose values with small representation error.

View File

@ -1413,8 +1413,8 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, QgsRa
point.x() + xRes * width / 2,
point.y() + yRes * height / 2 );
double xResDiff = fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes );
double yResDiff = fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes );
double xResDiff = std::fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes );
double yResDiff = std::fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes );
if ( !mCachedGdalDataset ||
!mCachedViewExtent.contains( point ) ||
@ -1434,8 +1434,8 @@ QgsRasterIdentifyResult QgsWcsProvider::identify( const QgsPointXY &point, QgsRa
double xRes = finalExtent.width() / width;
double yRes = finalExtent.height() / height;
QgsDebugMsg( QString( "width = %1 height = %2 xRes = %3 yRes = %4" ).arg( finalExtent.width() ).arg( finalExtent.height() ).arg( xRes ).arg( yRes ) );
double xResDiff = fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes );
double yResDiff = fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes );
double xResDiff = std::fabs( mCachedViewExtent.width() / mCachedViewWidth - xRes );
double yResDiff = std::fabs( mCachedViewExtent.height() / mCachedViewHeight - yRes );
QgsDebugMsg( QString( "xRes diff = %1 yRes diff = %2 relative xResDiff = %3 relative yResDiff = %4" ).arg( xResDiff ).arg( yResDiff ).arg( xResDiff / xRes ).arg( yResDiff / yRes ) );
if ( !mCachedGdalDataset ||
!mCachedViewExtent.contains( point ) ||

View File

@ -403,10 +403,10 @@ void QgsWfsCapabilities::capabilitiesReplyFinished()
QgsDebugMsg( ptMinBack.toString() );
QgsDebugMsg( ptMaxBack.toString() );
if ( fabs( featureType.bbox.xMinimum() - ptMinBack.x() ) < 1e-5 &&
fabs( featureType.bbox.yMinimum() - ptMinBack.y() ) < 1e-5 &&
fabs( featureType.bbox.xMaximum() - ptMaxBack.x() ) < 1e-5 &&
fabs( featureType.bbox.yMaximum() - ptMaxBack.y() ) < 1e-5 )
if ( std::fabs( featureType.bbox.xMinimum() - ptMinBack.x() ) < 1e-5 &&
std::fabs( featureType.bbox.yMinimum() - ptMinBack.y() ) < 1e-5 &&
std::fabs( featureType.bbox.xMaximum() - ptMaxBack.x() ) < 1e-5 &&
std::fabs( featureType.bbox.yMaximum() - ptMaxBack.y() ) < 1e-5 )
{
QgsDebugMsg( "Values of LatLongBoundingBox are consistent with WGS84 long/lat bounds, so as the CRS is projected, assume they are indeed in WGS84 and not in the CRS units" );
featureType.bboxSRSIsWGS84 = true;

View File

@ -89,8 +89,8 @@ struct LessThanTileRequest
QPointF p1 = req1.rect.center();
QPointF p2 = req2.rect.center();
// using chessboard distance (loading order more natural than euclidean/manhattan distance)
double d1 = qMax( fabs( center.x() - p1.x() ), fabs( center.y() - p1.y() ) );
double d2 = qMax( fabs( center.x() - p2.x() ), fabs( center.y() - p2.y() ) );
double d1 = qMax( std::fabs( center.x() - p1.x() ), std::fabs( center.y() - p1.y() ) );
double d2 = qMax( std::fabs( center.x() - p2.x() ), std::fabs( center.y() - p2.y() ) );
return d1 < d2;
}
};
@ -4044,7 +4044,7 @@ static QString formatDouble( double x )
{
if ( x == 0.0 )
return QStringLiteral( "0" );
const int numberOfDecimals = qMax( 0, 19 - static_cast<int>( ceil( log10( fabs( x ) ) ) ) );
const int numberOfDecimals = qMax( 0, 19 - static_cast<int>( ceil( log10( std::fabs( x ) ) ) ) );
return qgsDoubleToString( x, numberOfDecimals );
}

View File

@ -243,7 +243,7 @@ void QgsBench::render()
{
for ( int i = 0; i < mTimes.size(); i++ )
{
double d = fabs( avg[t] - mTimes.at( i )[t] );
double d = std::fabs( avg[t] - mTimes.at( i )[t] );
stdev[t] += pow( d, 2 );
if ( i == 0 || d > maxdev[t] ) maxdev[t] = d;
}

View File

@ -216,14 +216,14 @@ void TestQgsComposerMap::mapPolygonVertices()
QPolygonF visibleExtent = mComposerMap->visibleExtentPolygon();
//vertices should be returned in clockwise order starting at the top-left point
QVERIFY( fabs( visibleExtent[0].x() - 781662.375 ) < 0.001 );
QVERIFY( fabs( visibleExtent[0].y() - 3345223.125 ) < 0.001 );
QVERIFY( fabs( visibleExtent[1].x() - 793062.375 ) < 0.001 );
QVERIFY( fabs( visibleExtent[1].y() - 3345223.125 ) < 0.001 );
QVERIFY( fabs( visibleExtent[2].x() - 793062.375 ) < 0.001 );
QVERIFY( fabs( visibleExtent[2].y() - 3339523.125 ) < 0.001 );
QVERIFY( fabs( visibleExtent[3].x() - 781662.375 ) < 0.001 );
QVERIFY( fabs( visibleExtent[3].y() - 3339523.125 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[0].x() - 781662.375 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[0].y() - 3345223.125 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[1].x() - 793062.375 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[1].y() - 3345223.125 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[2].x() - 793062.375 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[2].y() - 3339523.125 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[3].x() - 781662.375 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[3].y() - 3339523.125 ) < 0.001 );
//polygon should be closed
QVERIFY( visibleExtent.isClosed() );
@ -233,14 +233,14 @@ void TestQgsComposerMap::mapPolygonVertices()
visibleExtent = mComposerMap->visibleExtentPolygon();
//vertices should be returned in clockwise order starting at the top-left point
QVERIFY( fabs( visibleExtent[0].x() - 781254.0735015 ) < 0.001 );
QVERIFY( fabs( visibleExtent[0].y() - 3344190.0324834 ) < 0.001 );
QVERIFY( fabs( visibleExtent[1].x() - 792480.881886 ) < 0.001 );
QVERIFY( fabs( visibleExtent[1].y() - 3346169.62171 ) < 0.001 );
QVERIFY( fabs( visibleExtent[2].x() - 793470.676499 ) < 0.001 );
QVERIFY( fabs( visibleExtent[2].y() - 3340556.21752 ) < 0.001 );
QVERIFY( fabs( visibleExtent[3].x() - 782243.868114 ) < 0.001 );
QVERIFY( fabs( visibleExtent[3].y() - 3338576.62829 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[0].x() - 781254.0735015 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[0].y() - 3344190.0324834 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[1].x() - 792480.881886 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[1].y() - 3346169.62171 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[2].x() - 793470.676499 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[2].y() - 3340556.21752 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[3].x() - 782243.868114 ) < 0.001 );
QVERIFY( std::fabs( visibleExtent[3].y() - 3338576.62829 ) < 0.001 );
//polygon should be closed
QVERIFY( visibleExtent.isClosed() );

View File

@ -435,19 +435,19 @@ void TestQgsRasterLayer::checkScaleOffset()
QVERIFY( myRasterLayer->height() == 10 );
//QVERIFY( myStatistics.elementCount == 100 );
double minVal = 0.0;
mReport += QStringLiteral( "min = %1 expected = %2 diff = %3<br>\n" ).arg( myStatistics.minimumValue ).arg( minVal ).arg( fabs( myStatistics.minimumValue - minVal ) );
mReport += QStringLiteral( "min = %1 expected = %2 diff = %3<br>\n" ).arg( myStatistics.minimumValue ).arg( minVal ).arg( std::fabs( myStatistics.minimumValue - minVal ) );
double maxVal = 9.0;
mReport += QStringLiteral( "max = %1 expected = %2 diff = %3<br>\n" ).arg( myStatistics.maximumValue ).arg( maxVal ).arg( fabs( myStatistics.maximumValue - maxVal ) );
mReport += QStringLiteral( "max = %1 expected = %2 diff = %3<br>\n" ).arg( myStatistics.maximumValue ).arg( maxVal ).arg( std::fabs( myStatistics.maximumValue - maxVal ) );
double meanVal = 4.5;
mReport += QStringLiteral( "min = %1 expected = %2 diff = %3<br>\n" ).arg( myStatistics.mean ).arg( meanVal ).arg( fabs( myStatistics.mean - meanVal ) );
QVERIFY( fabs( myStatistics.minimumValue - minVal ) < 0.0000001 );
QVERIFY( fabs( myStatistics.maximumValue - maxVal ) < 0.0000001 );
QVERIFY( fabs( myStatistics.mean - meanVal ) < 0.0000001 );
mReport += QStringLiteral( "min = %1 expected = %2 diff = %3<br>\n" ).arg( myStatistics.mean ).arg( meanVal ).arg( std::fabs( myStatistics.mean - meanVal ) );
QVERIFY( std::fabs( myStatistics.minimumValue - minVal ) < 0.0000001 );
QVERIFY( std::fabs( myStatistics.maximumValue - maxVal ) < 0.0000001 );
QVERIFY( std::fabs( myStatistics.mean - meanVal ) < 0.0000001 );
double stdDev = 2.87228615;
// TODO: verify why GDAL stdDev is so different from generic (2.88675)
mReport += QStringLiteral( "stdDev = %1 expected = %2 diff = %3<br>\n" ).arg( myStatistics.stdDev ).arg( stdDev ).arg( fabs( myStatistics.stdDev - stdDev ) );
QVERIFY( fabs( myStatistics.stdDev - stdDev ) < 0.0000001 );
mReport += QStringLiteral( "stdDev = %1 expected = %2 diff = %3<br>\n" ).arg( myStatistics.stdDev ).arg( stdDev ).arg( std::fabs( myStatistics.stdDev - stdDev ) );
QVERIFY( std::fabs( myStatistics.stdDev - stdDev ) < 0.0000001 );
QgsRasterDataProvider *myProvider = myRasterLayer->dataProvider();
QgsPointXY myPoint( 1535030, 5083350 );
@ -474,8 +474,8 @@ void TestQgsRasterLayer::checkScaleOffset()
double value = values.value( bandNo ).toDouble();
valueString = QgsRasterBlock::printValue( value );
mReport += QStringLiteral( " %1 = %2 <br>\n" ).arg( myProvider->generateBandName( bandNo ), valueString );
mReport += QStringLiteral( " value = %1 expected = %2 diff = %3 <br>\n" ).arg( value ).arg( expected ).arg( fabs( value - expected ) );
QVERIFY( fabs( value - expected ) < 0.0000001 );
mReport += QStringLiteral( " value = %1 expected = %2 diff = %3 <br>\n" ).arg( value ).arg( expected ).arg( std::fabs( value - expected ) );
QVERIFY( std::fabs( value - expected ) < 0.0000001 );
}
}
}

View File

@ -340,7 +340,7 @@ bool TestQgsGrassProvider::compare( const QStringList &expected, const QStringLi
bool TestQgsGrassProvider::compare( double expected, double got, bool &ok )
{
if ( fabs( got - expected ) > TINY_VALUE )
if ( std::fabs( got - expected ) > TINY_VALUE )
{
ok = false;
return false;