Skip to content

Commit 98b631c

Browse files
author
mhugent
committed
Use qIsNaN and qIsInf for QgsRectangle::isFinite
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15138 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7661f4b commit 98b631c

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/core/qgsrectangle.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <limits>
2222
#include <QString>
2323
#include <QTextStream>
24+
#include <qnumeric.h>
2425

2526
#include "qgspoint.h"
2627
#include "qgsrectangle.h"
@@ -306,18 +307,13 @@ void QgsRectangle::unionRect( const QgsRectangle& r )
306307

307308
bool QgsRectangle::isFinite() const
308309
{
309-
if ( std::numeric_limits<double>::has_infinity )
310+
if ( qIsInf( xmin ) || qIsInf( ymin ) || qIsInf( xmax ) || qIsInf( ymax ) )
310311
{
311-
if ( xmin == std::numeric_limits<double>::infinity() ||
312-
xmax == std::numeric_limits<double>::infinity() ||
313-
ymin == std::numeric_limits<double>::infinity() ||
314-
ymax == std::numeric_limits<double>::infinity() )
315-
return false;
312+
return false;
316313
}
317-
// By design, if a variable is nan, it won't equal itself, so that's
318-
// how we test for nan
319-
if ( xmin != xmin || xmax != xmax || ymin != ymin || ymax != ymax )
314+
if ( qIsNaN( xmin ) || qIsNaN( ymin ) || qIsNaN( xmax ) || qIsNaN( ymax ) )
315+
{
320316
return false;
321-
317+
}
322318
return true;
323319
}

0 commit comments

Comments
 (0)