Skip to content

Commit 47e7a10

Browse files
committedJun 16, 2018
DBL_EPSILON -> numeric_limits
1 parent eabd5c3 commit 47e7a10

13 files changed

+77
-77
lines changed
 

‎python/core/auto_generated/qgis.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Returns a string representation of a double
100100
:param precision: number of decimal places to retain
101101
%End
102102

103-
bool qgsDoubleNear( double a, double b, double epsilon = 4 * DBL_EPSILON );
103+
bool qgsDoubleNear( double a, double b, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
104104
%Docstring
105105
Compare two doubles (but allow some difference)
106106

‎src/core/geometry/qgsgeos.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,17 +310,17 @@ void QgsGeos::subdivideRecursive( const GEOSGeometry *currentPart, int maxNodes,
310310

311311
if ( height <= 0 )
312312
{
313-
halfClipRect1.setYMinimum( halfClipRect1.yMinimum() - DBL_EPSILON );
314-
halfClipRect2.setYMinimum( halfClipRect2.yMinimum() - DBL_EPSILON );
315-
halfClipRect1.setYMaximum( halfClipRect1.yMaximum() + DBL_EPSILON );
316-
halfClipRect2.setYMaximum( halfClipRect2.yMaximum() + DBL_EPSILON );
313+
halfClipRect1.setYMinimum( halfClipRect1.yMinimum() - std::numeric_limits<double>::epsilon() );
314+
halfClipRect2.setYMinimum( halfClipRect2.yMinimum() - std::numeric_limits<double>::epsilon() );
315+
halfClipRect1.setYMaximum( halfClipRect1.yMaximum() + std::numeric_limits<double>::epsilon() );
316+
halfClipRect2.setYMaximum( halfClipRect2.yMaximum() + std::numeric_limits<double>::epsilon() );
317317
}
318318
if ( width <= 0 )
319319
{
320-
halfClipRect1.setXMinimum( halfClipRect1.xMinimum() - DBL_EPSILON );
321-
halfClipRect2.setXMinimum( halfClipRect2.xMinimum() - DBL_EPSILON );
322-
halfClipRect1.setXMaximum( halfClipRect1.xMaximum() + DBL_EPSILON );
323-
halfClipRect2.setXMaximum( halfClipRect2.xMaximum() + DBL_EPSILON );
320+
halfClipRect1.setXMinimum( halfClipRect1.xMinimum() - std::numeric_limits<double>::epsilon() );
321+
halfClipRect2.setXMinimum( halfClipRect2.xMinimum() - std::numeric_limits<double>::epsilon() );
322+
halfClipRect1.setXMaximum( halfClipRect1.xMaximum() + std::numeric_limits<double>::epsilon() );
323+
halfClipRect2.setXMaximum( halfClipRect2.xMaximum() + std::numeric_limits<double>::epsilon() );
324324
}
325325

326326
geos::unique_ptr clipPart1( GEOSClipByRect_r( geosinit.ctxt, currentPart, halfClipRect1.xMinimum(), halfClipRect1.yMinimum(), halfClipRect1.xMaximum(), halfClipRect1.yMaximum() ) );

‎src/core/geometry/qgspolygon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ double QgsPolygon::pointDistanceToBoundary( double x, double y ) const
260260
( x < ( bX - aX ) * ( y - aY ) / ( bY - aY ) + aX ) )
261261
inside = !inside;
262262

263-
minimumDistance = std::min( minimumDistance, QgsGeometryUtils::sqrDistToLine( x, y, aX, aY, bX, bY, minDistX, minDistY, 4 * DBL_EPSILON ) );
263+
minimumDistance = std::min( minimumDistance, QgsGeometryUtils::sqrDistToLine( x, y, aX, aY, bX, bY, minDistX, minDistY, 4 * std::numeric_limits<double>::epsilon() ) );
264264
}
265265
}
266266

‎src/core/qgis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ inline QString qgsDoubleToString( double a, int precision = 17 )
248248
* \param b second double
249249
* \param epsilon maximum difference allowable between doubles
250250
*/
251-
inline bool qgsDoubleNear( double a, double b, double epsilon = 4 * DBL_EPSILON )
251+
inline bool qgsDoubleNear( double a, double b, double epsilon = 4 * std::numeric_limits<double>::epsilon() )
252252
{
253253
const double diff = a - b;
254254
return diff > -epsilon && diff <= epsilon;

‎tests/src/core/testqgsdistancearea.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ void TestQgsDistanceArea::collections()
234234
double result = myDa.measureLength( lines );
235235
QGSCOMPARENEAR( result, 12006159, 1 );
236236
result = myDa.measureArea( lines );
237-
QGSCOMPARENEAR( result, 0, 4 * DBL_EPSILON );
237+
QGSCOMPARENEAR( result, 0, 4 * std::numeric_limits<double>::epsilon() );
238238

239239
//collection of polygons
240240
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() );
241241
result = myDa.measureArea( polys );
242242
QGSCOMPARENEAR( result, 670434859475LL, 1 );
243243
result = myDa.measureLength( polys );
244-
QGSCOMPARENEAR( result, 0, 4 * DBL_EPSILON );
244+
QGSCOMPARENEAR( result, 0, 4 * std::numeric_limits<double>::epsilon() );
245245

246246
//mixed collection
247247
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() );

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,8 @@ void TestQgsGeometry::point()
681681
//toQPointF
682682
QgsPoint p11a( 5.0, 9.0 );
683683
QPointF result = p11a.toQPointF();
684-
QGSCOMPARENEAR( result.x(), 5.0, 4 * DBL_EPSILON );
685-
QGSCOMPARENEAR( result.y(), 9.0, 4 * DBL_EPSILON );
684+
QGSCOMPARENEAR( result.x(), 5.0, 4 * std::numeric_limits<double>::epsilon() );
685+
QGSCOMPARENEAR( result.y(), 9.0, 4 * std::numeric_limits<double>::epsilon() );
686686

687687
//to/from WKB
688688
QgsPoint p12( QgsWkbTypes::PointZM, 1.0, 2.0, 3.0, -4.0 );
@@ -4199,26 +4199,26 @@ void TestQgsGeometry::lineString()
41994199
l35.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) );
42004200
QVERIFY( l35.closestSegment( QgsPoint( 5, 10 ), p, v ) < 0 );
42014201
l35.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 10 ) );
4202-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 4, 11 ), p, v, &leftOf ), 2.0, 4 * DBL_EPSILON );
4202+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 4, 11 ), p, v, &leftOf ), 2.0, 4 * std::numeric_limits<double>::epsilon() );
42034203
QCOMPARE( p, QgsPoint( 5, 10 ) );
42044204
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
42054205
QCOMPARE( leftOf, -1 );
4206-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 8, 11 ), p, v, &leftOf ), 1.0, 4 * DBL_EPSILON );
4206+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 8, 11 ), p, v, &leftOf ), 1.0, 4 * std::numeric_limits<double>::epsilon() );
42074207
QCOMPARE( p, QgsPoint( 8, 10 ) );
42084208
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
42094209
QCOMPARE( leftOf, -1 );
4210-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 8, 9 ), p, v, &leftOf ), 1.0, 4 * DBL_EPSILON );
4210+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 8, 9 ), p, v, &leftOf ), 1.0, 4 * std::numeric_limits<double>::epsilon() );
42114211
QCOMPARE( p, QgsPoint( 8, 10 ) );
42124212
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
42134213
QCOMPARE( leftOf, 1 );
4214-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 11, 9 ), p, v, &leftOf ), 2.0, 4 * DBL_EPSILON );
4214+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 11, 9 ), p, v, &leftOf ), 2.0, 4 * std::numeric_limits<double>::epsilon() );
42154215
QCOMPARE( p, QgsPoint( 10, 10 ) );
42164216
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
42174217
QCOMPARE( leftOf, 1 );
42184218
l35.setPoints( QgsPointSequence() << QgsPoint( 5, 10 )
42194219
<< QgsPoint( 10, 10 )
42204220
<< QgsPoint( 10, 15 ) );
4221-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 11, 12 ), p, v, &leftOf ), 1.0, 4 * DBL_EPSILON );
4221+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 11, 12 ), p, v, &leftOf ), 1.0, 4 * std::numeric_limits<double>::epsilon() );
42224222
QCOMPARE( p, QgsPoint( 10, 12 ) );
42234223
QCOMPARE( v, QgsVertexId( 0, 0, 2 ) );
42244224
QCOMPARE( leftOf, 1 );
@@ -4227,7 +4227,7 @@ void TestQgsGeometry::lineString()
42274227
<< QgsPoint( 6, 4 )
42284228
<< QgsPoint( 4, 4 )
42294229
<< QgsPoint( 5, 5 ) );
4230-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * DBL_EPSILON );
4230+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * std::numeric_limits<double>::epsilon() );
42314231
QCOMPARE( p, QgsPoint( 4, 4 ) );
42324232
QCOMPARE( v, QgsVertexId( 0, 0, 2 ) );
42334233
QCOMPARE( leftOf, -1 );
@@ -4236,7 +4236,7 @@ void TestQgsGeometry::lineString()
42364236
<< QgsPoint( 4, 4 )
42374237
<< QgsPoint( 6, 4 )
42384238
<< QgsPoint( 5, 5 ) );
4239-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * DBL_EPSILON );
4239+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 2.35, 4 ), p, v, &leftOf ), 2.7225, 4 * std::numeric_limits<double>::epsilon() );
42404240
QCOMPARE( p, QgsPoint( 4, 4 ) );
42414241
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
42424242
QCOMPARE( leftOf, 1 );
@@ -4245,7 +4245,7 @@ void TestQgsGeometry::lineString()
42454245
<< QgsPoint( 6, 4 )
42464246
<< QgsPoint( 4, 4 )
42474247
<< QgsPoint( 5, 5 ) );
4248-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * DBL_EPSILON );
4248+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * std::numeric_limits<double>::epsilon() );
42494249
QCOMPARE( p, QgsPoint( 4, 4 ) );
42504250
QCOMPARE( v, QgsVertexId( 0, 0, 2 ) );
42514251
QCOMPARE( leftOf, -1 );
@@ -4254,7 +4254,7 @@ void TestQgsGeometry::lineString()
42544254
<< QgsPoint( 4, 4 )
42554255
<< QgsPoint( 6, 4 )
42564256
<< QgsPoint( 5, 5 ) );
4257-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * DBL_EPSILON );
4257+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 3.5, 2 ), p, v, &leftOf ), 4.250000, 4 * std::numeric_limits<double>::epsilon() );
42584258
QCOMPARE( p, QgsPoint( 4, 4 ) );
42594259
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
42604260
QCOMPARE( leftOf, 1 );
@@ -4263,7 +4263,7 @@ void TestQgsGeometry::lineString()
42634263
<< QgsPoint( 1, 4 )
42644264
<< QgsPoint( 2, 2 )
42654265
<< QgsPoint( 1, 1 ) );
4266-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * DBL_EPSILON );
4266+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * std::numeric_limits<double>::epsilon() );
42674267
QCOMPARE( p, QgsPoint( 1, 1 ) );
42684268
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
42694269
QCOMPARE( leftOf, -1 );
@@ -4272,7 +4272,7 @@ void TestQgsGeometry::lineString()
42724272
<< QgsPoint( 2, 2 )
42734273
<< QgsPoint( 1, 4 )
42744274
<< QgsPoint( 1, 1 ) );
4275-
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * DBL_EPSILON );
4275+
QGSCOMPARENEAR( l35.closestSegment( QgsPoint( 1, 0 ), p, v, &leftOf ), 1, 4 * std::numeric_limits<double>::epsilon() );
42764276
QCOMPARE( p, QgsPoint( 1, 1 ) );
42774277
QCOMPARE( v, QgsVertexId( 0, 0, 1 ) );
42784278
QCOMPARE( leftOf, 1 );
@@ -4287,13 +4287,13 @@ void TestQgsGeometry::lineString()
42874287
QCOMPARE( area, 1.0 );
42884288
l36.setPoints( QgsPointSequence() << QgsPoint( 5, 10 ) << QgsPoint( 10, 10 ) );
42894289
l36.sumUpArea( area );
4290-
QGSCOMPARENEAR( area, -24, 4 * DBL_EPSILON );
4290+
QGSCOMPARENEAR( area, -24, 4 * std::numeric_limits<double>::epsilon() );
42914291
l36.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) );
42924292
l36.sumUpArea( area );
4293-
QGSCOMPARENEAR( area, -22, 4 * DBL_EPSILON );
4293+
QGSCOMPARENEAR( area, -22, 4 * std::numeric_limits<double>::epsilon() );
42944294
l36.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 2, 0 ) << QgsPoint( 2, 2 ) << QgsPoint( 0, 2 ) );
42954295
l36.sumUpArea( area );
4296-
QGSCOMPARENEAR( area, -18, 4 * DBL_EPSILON );
4296+
QGSCOMPARENEAR( area, -18, 4 * std::numeric_limits<double>::epsilon() );
42974297

42984298
//boundingBox - test that bounding box is updated after every modification to the line string
42994299
QgsLineString l37;
@@ -4342,8 +4342,8 @@ void TestQgsGeometry::lineString()
43424342
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 1.5708, 0.0001 );
43434343
( void )l38.vertexAngle( QgsVertexId( 0, 0, 2 ) ); //no crash
43444344
l38.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 1 ) );
4345-
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 0.0, 4 * DBL_EPSILON );
4346-
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 0.0, 4 * DBL_EPSILON );
4345+
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 0.0, 4 * std::numeric_limits<double>::epsilon() );
4346+
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 0.0, 4 * std::numeric_limits<double>::epsilon() );
43474347
l38.setPoints( QgsPointSequence() << QgsPoint( 1, 0 ) << QgsPoint( 0, 0 ) );
43484348
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 0 ) ), 4.71239, 0.0001 );
43494349
QGSCOMPARENEAR( l38.vertexAngle( QgsVertexId( 0, 0, 1 ) ), 4.71239, 0.0001 );
@@ -10927,7 +10927,7 @@ void TestQgsGeometry::compoundCurve()
1092710927
<< QgsPoint( 1, 1 ) );
1092810928
double lsArea = 0.0;
1092910929
ls.sumUpArea( lsArea );
10930-
QGSCOMPARENEAR( ccArea, lsArea, 4 * DBL_EPSILON );
10930+
QGSCOMPARENEAR( ccArea, lsArea, 4 * std::numeric_limits<double>::epsilon() );
1093110931

1093210932

1093310933
//addVertex

‎tests/src/core/testqgsgeometryimport.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ void TestQgsGeometryImport::pointWkt()
8585
QCOMPARE( geom.wkbType(), QgsWkbTypes::Point );
8686
QgsPointXY point = geom.asPoint();
8787

88-
QGSCOMPARENEAR( point.x(), x, 4 * DBL_EPSILON );
89-
QGSCOMPARENEAR( point.y(), y, 4 * DBL_EPSILON );
88+
QGSCOMPARENEAR( point.x(), x, 4 * std::numeric_limits<double>::epsilon() );
89+
QGSCOMPARENEAR( point.y(), y, 4 * std::numeric_limits<double>::epsilon() );
9090
}
9191

9292
void TestQgsGeometryImport::pointWkb_data()
@@ -113,8 +113,8 @@ void TestQgsGeometryImport::pointWkb()
113113
QgsPointXY point = geom.asPoint();
114114

115115
QCOMPARE( geom.wkbType(), QgsWkbTypes::Point );
116-
QGSCOMPARENEAR( point.x(), x, 4 * DBL_EPSILON );
117-
QGSCOMPARENEAR( point.y(), y, 4 * DBL_EPSILON );
116+
QGSCOMPARENEAR( point.x(), x, 4 * std::numeric_limits<double>::epsilon() );
117+
QGSCOMPARENEAR( point.y(), y, 4 * std::numeric_limits<double>::epsilon() );
118118
}
119119

120120
void TestQgsGeometryImport::pointGeos_data()
@@ -140,8 +140,8 @@ void TestQgsGeometryImport::pointGeos()
140140

141141
QgsPointXY geomPt = geom.asPoint();
142142

143-
QGSCOMPARENEAR( x, geomPt.x(), 4 * DBL_EPSILON );
144-
QGSCOMPARENEAR( y, geomPt.y(), 4 * DBL_EPSILON );
143+
QGSCOMPARENEAR( x, geomPt.x(), 4 * std::numeric_limits<double>::epsilon() );
144+
QGSCOMPARENEAR( y, geomPt.y(), 4 * std::numeric_limits<double>::epsilon() );
145145
}
146146

147147
void TestQgsGeometryImport::linestringWkt_data()

‎tests/src/core/testqgsgeometryutils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ void TestQgsGeometryUtils::testSegmentMidPoint()
211211
midPoint, radius, left );
212212

213213
QVERIFY( ok );
214-
QGSCOMPARENEAR( midPoint.x(), expectedX, 4 * DBL_EPSILON );
215-
QGSCOMPARENEAR( midPoint.y(), expectedY, 4 * DBL_EPSILON );
214+
QGSCOMPARENEAR( midPoint.x(), expectedX, 4 * std::numeric_limits<double>::epsilon() );
215+
QGSCOMPARENEAR( midPoint.y(), expectedY, 4 * std::numeric_limits<double>::epsilon() );
216216
}
217217

218218
void TestQgsGeometryUtils::testSegmentMidPointCenter()
@@ -266,7 +266,7 @@ void TestQgsGeometryUtils::testCircleLength()
266266
QFETCH( double, y3 );
267267
QFETCH( double, expected );
268268

269-
QGSCOMPARENEAR( expected, QgsGeometryUtils::circleLength( x1, y1, x2, y2, x3, y3 ), 4 * DBL_EPSILON );
269+
QGSCOMPARENEAR( expected, QgsGeometryUtils::circleLength( x1, y1, x2, y2, x3, y3 ), 4 * std::numeric_limits<double>::epsilon() );
270270
}
271271

272272
void TestQgsGeometryUtils::testNormalizedAngle_data()
@@ -323,7 +323,7 @@ void TestQgsGeometryUtils::testLineAngle()
323323

324324
double lineAngle = QgsGeometryUtils::lineAngle( x1, y1, x2, y2 ) * 180 / M_PI;
325325
if ( expected > -99999 )
326-
QGSCOMPARENEAR( lineAngle, expected, 4 * DBL_EPSILON );
326+
QGSCOMPARENEAR( lineAngle, expected, 4 * std::numeric_limits<double>::epsilon() );
327327
}
328328

329329
void TestQgsGeometryUtils::testLinePerpendicularAngle_data()
@@ -530,9 +530,9 @@ void TestQgsGeometryUtils::testCircleCenterRadius()
530530

531531
double radius, centerX, centerY;
532532
QgsGeometryUtils::circleCenterRadius( QgsPoint( x1, y1 ), QgsPoint( x2, y2 ), QgsPoint( x3, y3 ), radius, centerX, centerY );
533-
QGSCOMPARENEAR( expectedRadius, radius, 4 * DBL_EPSILON );
534-
QGSCOMPARENEAR( expectedCenterX, centerX, 4 * DBL_EPSILON );
535-
QGSCOMPARENEAR( expectedCenterY, centerY, 4 * DBL_EPSILON );
533+
QGSCOMPARENEAR( expectedRadius, radius, 4 * std::numeric_limits<double>::epsilon() );
534+
QGSCOMPARENEAR( expectedCenterX, centerX, 4 * std::numeric_limits<double>::epsilon() );
535+
QGSCOMPARENEAR( expectedCenterY, centerY, 4 * std::numeric_limits<double>::epsilon() );
536536
}
537537

538538
//QgsGeometryUtils::sqrDistToLine

‎tests/src/core/testqgslayout.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,9 @@ void TestQgsLayout::georeference()
841841
t = exporter.computeGeoTransform( map );
842842
QGSCOMPARENEAR( t[0], 1925.0, 1.0 );
843843
QGSCOMPARENEAR( t[1], 0.211719, 0.0001 );
844-
QGSCOMPARENEAR( t[2], 0.0, 4 * DBL_EPSILON );
844+
QGSCOMPARENEAR( t[2], 0.0, 4 * std::numeric_limits<double>::epsilon() );
845845
QGSCOMPARENEAR( t[3], 3050, 1 );
846-
QGSCOMPARENEAR( t[4], 0.0, 4 * DBL_EPSILON );
846+
QGSCOMPARENEAR( t[4], 0.0, 4 * std::numeric_limits<double>::epsilon() );
847847
QGSCOMPARENEAR( t[5], -0.211694, 0.0001 );
848848
t.reset();
849849

@@ -852,29 +852,29 @@ void TestQgsLayout::georeference()
852852
t = exporter.computeGeoTransform();
853853
QGSCOMPARENEAR( t[0], 1925.0, 1.0 );
854854
QGSCOMPARENEAR( t[1], 0.211719, 0.0001 );
855-
QGSCOMPARENEAR( t[2], 0.0, 4 * DBL_EPSILON );
855+
QGSCOMPARENEAR( t[2], 0.0, 4 * std::numeric_limits<double>::epsilon() );
856856
QGSCOMPARENEAR( t[3], 3050, 1 );
857-
QGSCOMPARENEAR( t[4], 0.0, 4 * DBL_EPSILON );
857+
QGSCOMPARENEAR( t[4], 0.0, 4 * std::numeric_limits<double>::epsilon() );
858858
QGSCOMPARENEAR( t[5], -0.211694, 0.0001 );
859859
t.reset();
860860

861861
// specify extent
862862
t = exporter.computeGeoTransform( map, QRectF( 70, 100, 50, 60 ) );
863863
QGSCOMPARENEAR( t[0], 2100.0, 1.0 );
864864
QGSCOMPARENEAR( t[1], 0.211864, 0.0001 );
865-
QGSCOMPARENEAR( t[2], 0.0, 4 * DBL_EPSILON );
865+
QGSCOMPARENEAR( t[2], 0.0, 4 * std::numeric_limits<double>::epsilon() );
866866
QGSCOMPARENEAR( t[3], 2800, 1 );
867-
QGSCOMPARENEAR( t[4], 0.0, 4 * DBL_EPSILON );
867+
QGSCOMPARENEAR( t[4], 0.0, 4 * std::numeric_limits<double>::epsilon() );
868868
QGSCOMPARENEAR( t[5], -0.211864, 0.0001 );
869869
t.reset();
870870

871871
// specify dpi
872872
t = exporter.computeGeoTransform( map, QRectF(), 75 );
873873
QGSCOMPARENEAR( t[0], 1925.0, 1 );
874874
QGSCOMPARENEAR( t[1], 0.847603, 0.0001 );
875-
QGSCOMPARENEAR( t[2], 0.0, 4 * DBL_EPSILON );
875+
QGSCOMPARENEAR( t[2], 0.0, 4 * std::numeric_limits<double>::epsilon() );
876876
QGSCOMPARENEAR( t[3], 3050.0, 1 );
877-
QGSCOMPARENEAR( t[4], 0.0, 4 * DBL_EPSILON );
877+
QGSCOMPARENEAR( t[4], 0.0, 4 * std::numeric_limits<double>::epsilon() );
878878
QGSCOMPARENEAR( t[5], -0.846774, 0.0001 );
879879
t.reset();
880880

‎tests/src/core/testqgslayoutitem.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,18 +1091,18 @@ void TestQgsLayoutItem::fixedSize()
10911091
item->setRect( 0, 0, 5.0, 6.0 ); //temporarily set rect to random size
10921092
item->attemptResize( QgsLayoutSize( 7.0, 8.0, QgsUnitTypes::LayoutPoints ) );
10931093
//check size matches fixed item size converted to mm
1094-
QGSCOMPARENEAR( item->rect().width(), 2.0 * 25.4, 4 * DBL_EPSILON );
1095-
QGSCOMPARENEAR( item->rect().height(), 4.0 * 25.4, 4 * DBL_EPSILON );
1094+
QGSCOMPARENEAR( item->rect().width(), 2.0 * 25.4, 4 * std::numeric_limits<double>::epsilon() );
1095+
QGSCOMPARENEAR( item->rect().height(), 4.0 * 25.4, 4 * std::numeric_limits<double>::epsilon() );
10961096

10971097
item->attemptResize( QgsLayoutSize( 7.0, 8.0, QgsUnitTypes::LayoutInches ) );
10981098
//check size matches fixed item size converted to mm
1099-
QGSCOMPARENEAR( item->rect().width(), 2.0 * 25.4, 4 * DBL_EPSILON );
1100-
QGSCOMPARENEAR( item->rect().height(), 4.0 * 25.4, 4 * DBL_EPSILON );
1099+
QGSCOMPARENEAR( item->rect().width(), 2.0 * 25.4, 4 * std::numeric_limits<double>::epsilon() );
1100+
QGSCOMPARENEAR( item->rect().height(), 4.0 * 25.4, 4 * std::numeric_limits<double>::epsilon() );
11011101

11021102
//check that setting a fixed size applies this size immediately
11031103
item->updateFixedSize( QgsLayoutSize( 150, 250, QgsUnitTypes::LayoutMillimeters ) );
1104-
QGSCOMPARENEAR( item->rect().width(), 150.0, 4 * DBL_EPSILON );
1105-
QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * DBL_EPSILON );
1104+
QGSCOMPARENEAR( item->rect().width(), 150.0, 4 * std::numeric_limits<double>::epsilon() );
1105+
QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * std::numeric_limits<double>::epsilon() );
11061106
}
11071107

11081108
void TestQgsLayoutItem::minSize()
@@ -1120,18 +1120,18 @@ void TestQgsLayoutItem::minSize()
11201120
//try to resize to less than minimum size
11211121
item->attemptResize( QgsLayoutSize( 1.0, 0.5, QgsUnitTypes::LayoutPoints ) );
11221122
//check size matches min item size converted to mm
1123-
QGSCOMPARENEAR( item->rect().width(), 50.0, 4 * DBL_EPSILON );
1124-
QGSCOMPARENEAR( item->rect().height(), 100.0, 4 * DBL_EPSILON );
1123+
QGSCOMPARENEAR( item->rect().width(), 50.0, 4 * std::numeric_limits<double>::epsilon() );
1124+
QGSCOMPARENEAR( item->rect().height(), 100.0, 4 * std::numeric_limits<double>::epsilon() );
11251125

11261126
//check that resize to larger than min size works
11271127
item->attemptResize( QgsLayoutSize( 0.1, 0.2, QgsUnitTypes::LayoutMeters ) );
1128-
QGSCOMPARENEAR( item->rect().width(), 100.0, 4 * DBL_EPSILON );
1129-
QGSCOMPARENEAR( item->rect().height(), 200.0, 4 * DBL_EPSILON );
1128+
QGSCOMPARENEAR( item->rect().width(), 100.0, 4 * std::numeric_limits<double>::epsilon() );
1129+
QGSCOMPARENEAR( item->rect().height(), 200.0, 4 * std::numeric_limits<double>::epsilon() );
11301130

11311131
//check that setting a minimum size applies this size immediately
11321132
item->updateMinSize( QgsLayoutSize( 150, 250, QgsUnitTypes::LayoutMillimeters ) );
1133-
QGSCOMPARENEAR( item->rect().width(), 150.0, 4 * DBL_EPSILON );
1134-
QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * DBL_EPSILON );
1133+
QGSCOMPARENEAR( item->rect().width(), 150.0, 4 * std::numeric_limits<double>::epsilon() );
1134+
QGSCOMPARENEAR( item->rect().height(), 250.0, 4 * std::numeric_limits<double>::epsilon() );
11351135

11361136
//also need check that fixed size trumps min size
11371137
std::unique_ptr< FixedMinSizedItem > fixedMinItem( new FixedMinSizedItem( &l ) );
@@ -1144,8 +1144,8 @@ void TestQgsLayoutItem::minSize()
11441144
//try to resize to less than minimum size
11451145
fixedMinItem->attemptResize( QgsLayoutSize( 1.0, 0.5, QgsUnitTypes::LayoutPoints ) );
11461146
//check size matches fixed item size, not minimum size (converted to mm)
1147-
QGSCOMPARENEAR( fixedMinItem->rect().width(), 20.0, 4 * DBL_EPSILON );
1148-
QGSCOMPARENEAR( fixedMinItem->rect().height(), 40.0, 4 * DBL_EPSILON );
1147+
QGSCOMPARENEAR( fixedMinItem->rect().width(), 20.0, 4 * std::numeric_limits<double>::epsilon() );
1148+
QGSCOMPARENEAR( fixedMinItem->rect().height(), 40.0, 4 * std::numeric_limits<double>::epsilon() );
11491149
}
11501150

11511151
void TestQgsLayoutItem::move()

‎tests/src/core/testqgslayoututils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ void TestQgsLayoutUtils::rotate()
112112
double x = ( *it ).first.x1();
113113
double y = ( *it ).first.y1();
114114
QgsLayoutUtils::rotate( ( *it ).second, x, y );
115-
QGSCOMPARENEAR( x, ( *it ).first.x2(), 4 * DBL_EPSILON );
116-
QGSCOMPARENEAR( y, ( *it ).first.y2(), 4 * DBL_EPSILON );
115+
QGSCOMPARENEAR( x, ( *it ).first.x2(), 4 * std::numeric_limits<double>::epsilon() );
116+
QGSCOMPARENEAR( y, ( *it ).first.y2(), 4 * std::numeric_limits<double>::epsilon() );
117117
}
118118
}
119119

@@ -140,7 +140,7 @@ void TestQgsLayoutUtils::normalizedAngle()
140140
{
141141
double result = QgsLayoutUtils::normalizedAngle( ( *it ).first );
142142
qDebug() << QStringLiteral( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second );
143-
QGSCOMPARENEAR( result, ( *it ).second, 4 * DBL_EPSILON );
143+
QGSCOMPARENEAR( result, ( *it ).second, 4 * std::numeric_limits<double>::epsilon() );
144144

145145
}
146146

@@ -161,7 +161,7 @@ void TestQgsLayoutUtils::normalizedAngle()
161161
{
162162
double result = QgsLayoutUtils::normalizedAngle( ( *it ).first, true );
163163
qDebug() << QStringLiteral( "actual: %1 expected: %2" ).arg( result ).arg( ( *it ).second );
164-
QGSCOMPARENEAR( result, ( *it ).second, 4 * DBL_EPSILON );
164+
QGSCOMPARENEAR( result, ( *it ).second, 4 * std::numeric_limits<double>::epsilon() );
165165

166166
}
167167
}
@@ -211,7 +211,7 @@ void TestQgsLayoutUtils::snappedAngle()
211211
QList< QPair< double, double > >::const_iterator it = testVals.constBegin();
212212
for ( ; it != testVals.constEnd(); ++it )
213213
{
214-
QGSCOMPARENEAR( QgsLayoutUtils::snappedAngle( ( *it ).first ), ( *it ).second, 4 * DBL_EPSILON );
214+
QGSCOMPARENEAR( QgsLayoutUtils::snappedAngle( ( *it ).first ), ( *it ).second, 4 * std::numeric_limits<double>::epsilon() );
215215
}
216216
}
217217

@@ -594,7 +594,7 @@ void TestQgsLayoutUtils::largestRotatedRect()
594594
|| ( qgsDoubleNear( rotatedRectBounds.height(), bounds.height(), 0.001 ) && ( rotatedRectBounds.width() <= bounds.width() ) ) );
595595

596596
//also verify that aspect ratio of rectangle has not changed
597-
QGSCOMPARENEAR( result.width() / result.height(), wideRect.width() / wideRect.height(), 4 * DBL_EPSILON );
597+
QGSCOMPARENEAR( result.width() / result.height(), wideRect.width() / wideRect.height(), 4 * std::numeric_limits<double>::epsilon() );
598598
}
599599
//and again for the high rectangle
600600
for ( double rotation = 10; rotation < 360; rotation += 10 )
@@ -609,7 +609,7 @@ void TestQgsLayoutUtils::largestRotatedRect()
609609
|| ( qgsDoubleNear( rotatedRectBounds.height(), bounds.height(), 0.001 ) && ( rotatedRectBounds.width() <= bounds.width() ) ) );
610610

611611
//also verify that aspect ratio of rectangle has not changed
612-
QGSCOMPARENEAR( result.width() / result.height(), highRect.width() / highRect.height(), 4 * DBL_EPSILON );
612+
QGSCOMPARENEAR( result.width() / result.height(), highRect.width() / highRect.height(), 4 * std::numeric_limits<double>::epsilon() );
613613
}
614614
}
615615

‎tests/src/core/testqgsrasterlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ void TestQgsRasterLayer::checkStats()
390390
//QVERIFY( myStatistics.elementCount == 100 );
391391
QVERIFY( myStatistics.minimumValue == 0 );
392392
QVERIFY( myStatistics.maximumValue == 9 );
393-
QGSCOMPARENEAR( myStatistics.mean, 4.5, 4 * DBL_EPSILON );
393+
QGSCOMPARENEAR( myStatistics.mean, 4.5, 4 * std::numeric_limits<double>::epsilon() );
394394
double stdDev = 2.87228132326901431;
395395
// TODO: verify why GDAL stdDev is so different from generic (2.88675)
396396
mReport += QStringLiteral( "stdDev = %1 expected = %2<br>\n" ).arg( myStatistics.stdDev ).arg( stdDev );

‎tests/src/core/testqgsrastersublayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ void TestQgsRasterSubLayer::checkStats()
171171

172172
QVERIFY( sublayer->width() == width );
173173
QVERIFY( sublayer->height() == height );
174-
QGSCOMPARENEAR( myStatistics.minimumValue, min, 4 * DBL_EPSILON );
175-
QGSCOMPARENEAR( myStatistics.maximumValue, max, 4 * DBL_EPSILON );
174+
QGSCOMPARENEAR( myStatistics.minimumValue, min, 4 * std::numeric_limits<double>::epsilon() );
175+
QGSCOMPARENEAR( myStatistics.maximumValue, max, 4 * std::numeric_limits<double>::epsilon() );
176176
mReport += QLatin1String( "<p>Passed</p>" );
177177
delete sublayer;
178178
}

0 commit comments

Comments
 (0)
Please sign in to comment.