DBL_EPSILON -> numeric_limits

This commit is contained in:
Nyall Dawson 2018-06-16 08:48:57 +10:00
parent eabd5c3b3d
commit 47e7a100d9
13 changed files with 77 additions and 77 deletions

View File

@ -100,7 +100,7 @@ Returns a string representation of a double
:param precision: number of decimal places to retain
%End
bool qgsDoubleNear( double a, double b, double epsilon = 4 * DBL_EPSILON );
bool qgsDoubleNear( double a, double b, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
%Docstring
Compare two doubles (but allow some difference)

View File

@ -310,17 +310,17 @@ void QgsGeos::subdivideRecursive( const GEOSGeometry *currentPart, int maxNodes,
if ( height <= 0 )
{
halfClipRect1.setYMinimum( halfClipRect1.yMinimum() - DBL_EPSILON );
halfClipRect2.setYMinimum( halfClipRect2.yMinimum() - DBL_EPSILON );
halfClipRect1.setYMaximum( halfClipRect1.yMaximum() + DBL_EPSILON );
halfClipRect2.setYMaximum( halfClipRect2.yMaximum() + DBL_EPSILON );
halfClipRect1.setYMinimum( halfClipRect1.yMinimum() - std::numeric_limits<double>::epsilon() );
halfClipRect2.setYMinimum( halfClipRect2.yMinimum() - std::numeric_limits<double>::epsilon() );
halfClipRect1.setYMaximum( halfClipRect1.yMaximum() + std::numeric_limits<double>::epsilon() );
halfClipRect2.setYMaximum( halfClipRect2.yMaximum() + std::numeric_limits<double>::epsilon() );
}
if ( width <= 0 )
{
halfClipRect1.setXMinimum( halfClipRect1.xMinimum() - DBL_EPSILON );
halfClipRect2.setXMinimum( halfClipRect2.xMinimum() - DBL_EPSILON );
halfClipRect1.setXMaximum( halfClipRect1.xMaximum() + DBL_EPSILON );
halfClipRect2.setXMaximum( halfClipRect2.xMaximum() + DBL_EPSILON );
halfClipRect1.setXMinimum( halfClipRect1.xMinimum() - std::numeric_limits<double>::epsilon() );
halfClipRect2.setXMinimum( halfClipRect2.xMinimum() - std::numeric_limits<double>::epsilon() );
halfClipRect1.setXMaximum( halfClipRect1.xMaximum() + std::numeric_limits<double>::epsilon() );
halfClipRect2.setXMaximum( halfClipRect2.xMaximum() + std::numeric_limits<double>::epsilon() );
}
geos::unique_ptr clipPart1( GEOSClipByRect_r( geosinit.ctxt, currentPart, halfClipRect1.xMinimum(), halfClipRect1.yMinimum(), halfClipRect1.xMaximum(), halfClipRect1.yMaximum() ) );

View File

@ -260,7 +260,7 @@ double QgsPolygon::pointDistanceToBoundary( double x, double y ) const
( x < ( bX - aX ) * ( y - aY ) / ( bY - aY ) + aX ) )
inside = !inside;
minimumDistance = std::min( minimumDistance, QgsGeometryUtils::sqrDistToLine( x, y, aX, aY, bX, bY, minDistX, minDistY, 4 * DBL_EPSILON ) );
minimumDistance = std::min( minimumDistance, QgsGeometryUtils::sqrDistToLine( x, y, aX, aY, bX, bY, minDistX, minDistY, 4 * std::numeric_limits<double>::epsilon() ) );
}
}

View File

@ -248,7 +248,7 @@ inline QString qgsDoubleToString( double a, int precision = 17 )
* \param b second double
* \param epsilon maximum difference allowable between doubles
*/
inline bool qgsDoubleNear( double a, double b, double epsilon = 4 * DBL_EPSILON )
inline bool qgsDoubleNear( double a, double b, double epsilon = 4 * std::numeric_limits<double>::epsilon() )
{
const double diff = a - b;
return diff > -epsilon && diff <= epsilon;

View File

@ -234,14 +234,14 @@ void TestQgsDistanceArea::collections()
double result = myDa.measureLength( lines );
QGSCOMPARENEAR( result, 12006159, 1 );
result = myDa.measureArea( lines );
QGSCOMPARENEAR( result, 0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( result, 0, 4 * std::numeric_limits<double>::epsilon() );
//collection of polygons
QgsGeometry polys( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) ).release() );
result = myDa.measureArea( polys );
QGSCOMPARENEAR( result, 670434859475LL, 1 );
result = myDa.measureLength( polys );
QGSCOMPARENEAR( result, 0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( result, 0, 4 * std::numeric_limits<double>::epsilon() );
//mixed collection
QgsGeometry mixed( QgsGeometryFactory::geomFromWkt( QStringLiteral( "GeometryCollection( LineString(0 36.53, 5.76 -48.16), LineString(0 25.54, 24.20 36.70), Polygon((0 36.53, 5.76 -48.16, 0 25.54, 0 36.53)), Polygon((10 20, 15 20, 15 10, 10 20)) )" ) ).release() );

View File

@ -681,8 +681,8 @@ void TestQgsGeometry::point()
//toQPointF
QgsPoint p11a( 5.0, 9.0 );
QPointF result = p11a.toQPointF();
QGSCOMPARENEAR( result.x(), 5.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( result.y(), 9.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( result.x(), 5.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( result.y(), 9.0, 4 * std::numeric_limits<double>::epsilon() );
//to/from WKB
QgsPoint p12( QgsWkbTypes::PointZM, 1.0, 2.0, 3.0, -4.0 );
@ -4199,26 +4199,26 @@ void TestQgsGeometry::lineString()
l35.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) );
QVERIFY( l35.closestSegment( QgsPoint( 5, 10 ), p, v ) < 0 );
l35.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 10 ) );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 4, 11 ), p, v, &leftOf ), 2.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 4, 11 ), p, v, &leftOf ), 2.0, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 5, 10 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
QCOMPARE( leftOf, -1 );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 8, 11 ), p, v, &leftOf ), 1.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 8, 11 ), p, v, &leftOf ), 1.0, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 8, 10 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
QCOMPARE( leftOf, -1 );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 8, 9 ), p, v, &leftOf ), 1.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 8, 9 ), p, v, &leftOf ), 1.0, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 8, 10 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
QCOMPARE( leftOf, 1 );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 11, 9 ), p, v, &leftOf ), 2.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 11, 9 ), p, v, &leftOf ), 2.0, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 10, 10 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
QCOMPARE( leftOf, 1 );
l35.setPoints( QgsPointSequence() << QgsPoint( 5, 10 )
<< QgsPoint( 10, 10 )
<< QgsPoint( 10, 15 ) );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 11, 12 ), p, v, &leftOf ), 1.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 11, 12 ), p, v, &leftOf ), 1.0, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 10, 12 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 2 ) );
QCOMPARE( leftOf, 1 );
@ -4227,7 +4227,7 @@ void TestQgsGeometry::lineString()
<< QgsPoint( 6, 4 )
<< QgsPoint( 4, 4 )
<< QgsPoint( 5, 5 ) );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 4, 4 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 2 ) );
QCOMPARE( leftOf, -1 );
@ -4236,7 +4236,7 @@ void TestQgsGeometry::lineString()
<< QgsPoint( 4, 4 )
<< QgsPoint( 6, 4 )
<< QgsPoint( 5, 5 ) );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 4, 4 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
QCOMPARE( leftOf, 1 );
@ -4245,7 +4245,7 @@ void TestQgsGeometry::lineString()
<< QgsPoint( 6, 4 )
<< QgsPoint( 4, 4 )
<< QgsPoint( 5, 5 ) );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 4, 4 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 2 ) );
QCOMPARE( leftOf, -1 );
@ -4254,7 +4254,7 @@ void TestQgsGeometry::lineString()
<< QgsPoint( 4, 4 )
<< QgsPoint( 6, 4 )
<< QgsPoint( 5, 5 ) );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 4, 4 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
QCOMPARE( leftOf, 1 );
@ -4263,7 +4263,7 @@ void TestQgsGeometry::lineString()
<< QgsPoint( 1, 4 )
<< QgsPoint( 2, 2 )
<< QgsPoint( 1, 1 ) );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 1, 1 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
QCOMPARE( leftOf, -1 );
@ -4272,7 +4272,7 @@ void TestQgsGeometry::lineString()
<< QgsPoint( 2, 2 )
<< QgsPoint( 1, 4 )
<< QgsPoint( 1, 1 ) );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * std::numeric_limits<double>::epsilon() );
QCOMPARE( p, QgsPoint( 1, 1 ) );
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
QCOMPARE( leftOf, 1 );
@ -4287,13 +4287,13 @@ void TestQgsGeometry::lineString()
QCOMPARE( area, 1.0 );
l36.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 10 ) );
l36.sumUpArea( area );
QGSCOMPARENEAR( area, -24, 4 * DBL_EPSILON );
QGSCOMPARENEAR( area, -24, 4 * std::numeric_limits<double>::epsilon() );
l36.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) );
l36.sumUpArea( area );
QGSCOMPARENEAR( area, -22, 4 * DBL_EPSILON );
QGSCOMPARENEAR( area, -22, 4 * std::numeric_limits<double>::epsilon() );
l36.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) << QgsPoint( 0, 2 ) );
l36.sumUpArea( area );
QGSCOMPARENEAR( area, -18, 4 * DBL_EPSILON );
QGSCOMPARENEAR( area, -18, 4 * std::numeric_limits<double>::epsilon() );
//boundingBox - test that bounding box is updated after every modification to the line string
QgsLineString l37;
@ -4342,8 +4342,8 @@ void TestQgsGeometry::lineString()
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 1.5708, 0.0001 );
( void )l38.vertexAngle( QgsVertexId( 0, 0, 2 ) ); //no crash
l38.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) );
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 0.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 0.0, 4 * std::numeric_limits<double>::epsilon() );
l38.setPoints( QgsPointSequence() << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) );
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 4.71239, 0.0001 );
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 4.71239, 0.0001 );
@ -10927,7 +10927,7 @@ void TestQgsGeometry::compoundCurve()
<< QgsPoint( 1, 1 ) );
double lsArea = 0.0;
ls.sumUpArea( lsArea );
QGSCOMPARENEAR( ccArea, lsArea, 4 * DBL_EPSILON );
QGSCOMPARENEAR( ccArea, lsArea, 4 * std::numeric_limits<double>::epsilon() );
//addVertex

View File

@ -85,8 +85,8 @@ void TestQgsGeometryImport::pointWkt()
QCOMPARE( geom.wkbType(), QgsWkbTypes::Point );
QgsPointXY point = geom.asPoint();
QGSCOMPARENEAR( point.x(), x, 4 * DBL_EPSILON );
QGSCOMPARENEAR( point.y(), y, 4 * DBL_EPSILON );
QGSCOMPARENEAR( point.x(), x, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( point.y(), y, 4 * std::numeric_limits<double>::epsilon() );
}
void TestQgsGeometryImport::pointWkb_data()
@ -113,8 +113,8 @@ void TestQgsGeometryImport::pointWkb()
QgsPointXY point = geom.asPoint();
QCOMPARE( geom.wkbType(), QgsWkbTypes::Point );
QGSCOMPARENEAR( point.x(), x, 4 * DBL_EPSILON );
QGSCOMPARENEAR( point.y(), y, 4 * DBL_EPSILON );
QGSCOMPARENEAR( point.x(), x, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( point.y(), y, 4 * std::numeric_limits<double>::epsilon() );
}
void TestQgsGeometryImport::pointGeos_data()
@ -140,8 +140,8 @@ void TestQgsGeometryImport::pointGeos()
QgsPointXY geomPt = geom.asPoint();
QGSCOMPARENEAR( x, geomPt.x(), 4 * DBL_EPSILON );
QGSCOMPARENEAR( y, geomPt.y(), 4 * DBL_EPSILON );
QGSCOMPARENEAR( x, geomPt.x(), 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( y, geomPt.y(), 4 * std::numeric_limits<double>::epsilon() );
}
void TestQgsGeometryImport::linestringWkt_data()

View File

@ -211,8 +211,8 @@ void TestQgsGeometryUtils::testSegmentMidPoint()
midPoint, radius, left );
QVERIFY( ok );
QGSCOMPARENEAR( midPoint.x(), expectedX, 4 * DBL_EPSILON );
QGSCOMPARENEAR( midPoint.y(), expectedY, 4 * DBL_EPSILON );
QGSCOMPARENEAR( midPoint.x(), expectedX, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( midPoint.y(), expectedY, 4 * std::numeric_limits<double>::epsilon() );
}
void TestQgsGeometryUtils::testSegmentMidPointCenter()
@ -266,7 +266,7 @@ void TestQgsGeometryUtils::testCircleLength()
QFETCH( double, y3 );
QFETCH( double, expected );
QGSCOMPARENEAR( expected, QgsGeometryUtils::circleLength( x1, y1, x2, y2, x3, y3 ), 4 * DBL_EPSILON );
QGSCOMPARENEAR( expected, QgsGeometryUtils::circleLength( x1, y1, x2, y2, x3, y3 ), 4 * std::numeric_limits<double>::epsilon() );
}
void TestQgsGeometryUtils::testNormalizedAngle_data()
@ -323,7 +323,7 @@ void TestQgsGeometryUtils::testLineAngle()
double lineAngle = QgsGeometryUtils::lineAngle( x1, y1, x2, y2 ) * 180 / M_PI;
if ( expected > -99999 )
QGSCOMPARENEAR( lineAngle, expected, 4 * DBL_EPSILON );
QGSCOMPARENEAR( lineAngle, expected, 4 * std::numeric_limits<double>::epsilon() );
}
void TestQgsGeometryUtils::testLinePerpendicularAngle_data()
@ -530,9 +530,9 @@ void TestQgsGeometryUtils::testCircleCenterRadius()
double radius, centerX, centerY;
QgsGeometryUtils::circleCenterRadius( QgsPoint( x1, y1 ), QgsPoint( x2, y2 ), QgsPoint( x3, y3 ), radius, centerX, centerY );
QGSCOMPARENEAR( expectedRadius, radius, 4 * DBL_EPSILON );
QGSCOMPARENEAR( expectedCenterX, centerX, 4 * DBL_EPSILON );
QGSCOMPARENEAR( expectedCenterY, centerY, 4 * DBL_EPSILON );
QGSCOMPARENEAR( expectedRadius, radius, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( expectedCenterX, centerX, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( expectedCenterY, centerY, 4 * std::numeric_limits<double>::epsilon() );
}
//QgsGeometryUtils::sqrDistToLine

View File

@ -841,9 +841,9 @@ void TestQgsLayout::georeference()
t = exporter.computeGeoTransform( map );
QGSCOMPARENEAR( t[0], 1925.0, 1.0 );
QGSCOMPARENEAR( t[1], 0.211719, 0.0001 );
QGSCOMPARENEAR( t[2], 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( t[2], 0.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( t[3], 3050, 1 );
QGSCOMPARENEAR( t[4], 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( t[4], 0.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( t[5], -0.211694, 0.0001 );
t.reset();
@ -852,9 +852,9 @@ void TestQgsLayout::georeference()
t = exporter.computeGeoTransform();
QGSCOMPARENEAR( t[0], 1925.0, 1.0 );
QGSCOMPARENEAR( t[1], 0.211719, 0.0001 );
QGSCOMPARENEAR( t[2], 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( t[2], 0.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( t[3], 3050, 1 );
QGSCOMPARENEAR( t[4], 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( t[4], 0.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( t[5], -0.211694, 0.0001 );
t.reset();
@ -862,9 +862,9 @@ void TestQgsLayout::georeference()
t = exporter.computeGeoTransform( map, QRectF( 70, 100, 50, 60 ) );
QGSCOMPARENEAR( t[0], 2100.0, 1.0 );
QGSCOMPARENEAR( t[1], 0.211864, 0.0001 );
QGSCOMPARENEAR( t[2], 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( t[2], 0.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( t[3], 2800, 1 );
QGSCOMPARENEAR( t[4], 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( t[4], 0.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( t[5], -0.211864, 0.0001 );
t.reset();
@ -872,9 +872,9 @@ void TestQgsLayout::georeference()
t = exporter.computeGeoTransform( map, QRectF(), 75 );
QGSCOMPARENEAR( t[0], 1925.0, 1 );
QGSCOMPARENEAR( t[1], 0.847603, 0.0001 );
QGSCOMPARENEAR( t[2], 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( t[2], 0.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( t[3], 3050.0, 1 );
QGSCOMPARENEAR( t[4], 0.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( t[4], 0.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( t[5], -0.846774, 0.0001 );
t.reset();

View File

@ -1091,18 +1091,18 @@ void TestQgsLayoutItem::fixedSize()
item->setRect( 0, 0, 5.0, 6.0 ); //temporarily set rect to random size
item->attemptResize( QgsLayoutSize( 7.0, 8.0, QgsUnitTypes::LayoutPoints ) );
//check size matches fixed item size converted to mm
QGSCOMPARENEAR( item->rect().width(), 2.0 * 25.4, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().height(), 4.0 * 25.4, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().width(), 2.0 * 25.4, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( item->rect().height(), 4.0 * 25.4, 4 * std::numeric_limits<double>::epsilon() );
item->attemptResize( QgsLayoutSize( 7.0, 8.0, QgsUnitTypes::LayoutInches ) );
//check size matches fixed item size converted to mm
QGSCOMPARENEAR( item->rect().width(), 2.0 * 25.4, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().height(), 4.0 * 25.4, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().width(), 2.0 * 25.4, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( item->rect().height(), 4.0 * 25.4, 4 * std::numeric_limits<double>::epsilon() );
//check that setting a fixed size applies this size immediately
item->updateFixedSize( QgsLayoutSize( 150, 250, QgsUnitTypes::LayoutMillimeters ) );
QGSCOMPARENEAR( item->rect().width(), 150.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().width(), 150.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * std::numeric_limits<double>::epsilon() );
}
void TestQgsLayoutItem::minSize()
@ -1120,18 +1120,18 @@ void TestQgsLayoutItem::minSize()
//try to resize to less than minimum size
item->attemptResize( QgsLayoutSize( 1.0, 0.5, QgsUnitTypes::LayoutPoints ) );
//check size matches min item size converted to mm
QGSCOMPARENEAR( item->rect().width(), 50.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().height(), 100.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().width(), 50.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( item->rect().height(), 100.0, 4 * std::numeric_limits<double>::epsilon() );
//check that resize to larger than min size works
item->attemptResize( QgsLayoutSize( 0.1, 0.2, QgsUnitTypes::LayoutMeters ) );
QGSCOMPARENEAR( item->rect().width(), 100.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().height(), 200.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().width(), 100.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( item->rect().height(), 200.0, 4 * std::numeric_limits<double>::epsilon() );
//check that setting a minimum size applies this size immediately
item->updateMinSize( QgsLayoutSize( 150, 250, QgsUnitTypes::LayoutMillimeters ) );
QGSCOMPARENEAR( item->rect().width(), 150.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( item->rect().width(), 150.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * std::numeric_limits<double>::epsilon() );
//also need check that fixed size trumps min size
std::unique_ptr< FixedMinSizedItem > fixedMinItem( new FixedMinSizedItem( &l ) );
@ -1144,8 +1144,8 @@ void TestQgsLayoutItem::minSize()
//try to resize to less than minimum size
fixedMinItem->attemptResize( QgsLayoutSize( 1.0, 0.5, QgsUnitTypes::LayoutPoints ) );
//check size matches fixed item size, not minimum size (converted to mm)
QGSCOMPARENEAR( fixedMinItem->rect().width(), 20.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( fixedMinItem->rect().height(), 40.0, 4 * DBL_EPSILON );
QGSCOMPARENEAR( fixedMinItem->rect().width(), 20.0, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( fixedMinItem->rect().height(), 40.0, 4 * std::numeric_limits<double>::epsilon() );
}
void TestQgsLayoutItem::move()

View File

@ -112,8 +112,8 @@ void TestQgsLayoutUtils::rotate()
double x = ( *it ).first.x1();
double y = ( *it ).first.y1();
QgsLayoutUtils::rotate( ( *it ).second, x, y );
QGSCOMPARENEAR( x, ( *it ).first.x2(), 4 * DBL_EPSILON );
QGSCOMPARENEAR( y, ( *it ).first.y2(), 4 * DBL_EPSILON );
QGSCOMPARENEAR( x, ( *it ).first.x2(), 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( y, ( *it ).first.y2(), 4 * std::numeric_limits<double>::epsilon() );
}
}
@ -140,7 +140,7 @@ void TestQgsLayoutUtils::normalizedAngle()
{
double result = QgsLayoutUtils::normalizedAngle( ( *it ).first );
qDebug() << QStringLiteral( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second );
QGSCOMPARENEAR( result, ( *it ).second, 4 * DBL_EPSILON );
QGSCOMPARENEAR( result, ( *it ).second, 4 * std::numeric_limits<double>::epsilon() );
}
@ -161,7 +161,7 @@ void TestQgsLayoutUtils::normalizedAngle()
{
double result = QgsLayoutUtils::normalizedAngle( ( *it ).first, true );
qDebug() << QStringLiteral( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second );
QGSCOMPARENEAR( result, ( *it ).second, 4 * DBL_EPSILON );
QGSCOMPARENEAR( result, ( *it ).second, 4 * std::numeric_limits<double>::epsilon() );
}
}
@ -211,7 +211,7 @@ void TestQgsLayoutUtils::snappedAngle()
QList< QPair< double, double > >::const_iterator it = testVals.constBegin();
for ( ; it != testVals.constEnd(); ++it )
{
QGSCOMPARENEAR( QgsLayoutUtils::snappedAngle( ( *it ).first ), ( *it ).second, 4 * DBL_EPSILON );
QGSCOMPARENEAR( QgsLayoutUtils::snappedAngle( ( *it ).first ), ( *it ).second, 4 * std::numeric_limits<double>::epsilon() );
}
}
@ -594,7 +594,7 @@ void TestQgsLayoutUtils::largestRotatedRect()
|| ( qgsDoubleNear( rotatedRectBounds.height(), bounds.height(), 0.001 ) && ( rotatedRectBounds.width() <= bounds.width() ) ) );
//also verify that aspect ratio of rectangle has not changed
QGSCOMPARENEAR( result.width() / result.height(), wideRect.width() / wideRect.height(), 4 * DBL_EPSILON );
QGSCOMPARENEAR( result.width() / result.height(), wideRect.width() / wideRect.height(), 4 * std::numeric_limits<double>::epsilon() );
}
//and again for the high rectangle
for ( double rotation = 10; rotation < 360; rotation += 10 )
@ -609,7 +609,7 @@ void TestQgsLayoutUtils::largestRotatedRect()
|| ( qgsDoubleNear( rotatedRectBounds.height(), bounds.height(), 0.001 ) && ( rotatedRectBounds.width() <= bounds.width() ) ) );
//also verify that aspect ratio of rectangle has not changed
QGSCOMPARENEAR( result.width() / result.height(), highRect.width() / highRect.height(), 4 * DBL_EPSILON );
QGSCOMPARENEAR( result.width() / result.height(), highRect.width() / highRect.height(), 4 * std::numeric_limits<double>::epsilon() );
}
}

View File

@ -390,7 +390,7 @@ void TestQgsRasterLayer::checkStats()
//QVERIFY( myStatistics.elementCount == 100 );
QVERIFY( myStatistics.minimumValue == 0 );
QVERIFY( myStatistics.maximumValue == 9 );
QGSCOMPARENEAR( myStatistics.mean, 4.5, 4 * DBL_EPSILON );
QGSCOMPARENEAR( myStatistics.mean, 4.5, 4 * std::numeric_limits<double>::epsilon() );
double stdDev = 2.87228132326901431;
// TODO: verify why GDAL stdDev is so different from generic (2.88675)
mReport += QStringLiteral( "stdDev = %1 expected = %2<br>\n" ).arg( myStatistics.stdDev ).arg( stdDev );

View File

@ -171,8 +171,8 @@ void TestQgsRasterSubLayer::checkStats()
QVERIFY( sublayer->width() == width );
QVERIFY( sublayer->height() == height );
QGSCOMPARENEAR( myStatistics.minimumValue, min, 4 * DBL_EPSILON );
QGSCOMPARENEAR( myStatistics.maximumValue, max, 4 * DBL_EPSILON );
QGSCOMPARENEAR( myStatistics.minimumValue, min, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( myStatistics.maximumValue, max, 4 * std::numeric_limits<double>::epsilon() );
mReport += QLatin1String( "<p>Passed</p>" );
delete sublayer;
}