Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use qIsNaN and qIsInf for QgsRectangle::isFinite
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15138 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Feb 8, 2011
1 parent 7661f4b commit 98b631c
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/core/qgsrectangle.cpp
Expand Up @@ -21,6 +21,7 @@
#include <limits>
#include <QString>
#include <QTextStream>
#include <qnumeric.h>

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

bool QgsRectangle::isFinite() const
{
if ( std::numeric_limits<double>::has_infinity )
if ( qIsInf( xmin ) || qIsInf( ymin ) || qIsInf( xmax ) || qIsInf( ymax ) )
{
if ( xmin == std::numeric_limits<double>::infinity() ||
xmax == std::numeric_limits<double>::infinity() ||
ymin == std::numeric_limits<double>::infinity() ||
ymax == std::numeric_limits<double>::infinity() )
return false;
return false;
}
// By design, if a variable is nan, it won't equal itself, so that's
// how we test for nan
if ( xmin != xmin || xmax != xmax || ymin != ymin || ymax != ymax )
if ( qIsNaN( xmin ) || qIsNaN( ymin ) || qIsNaN( xmax ) || qIsNaN( ymax ) )
{
return false;

}
return true;
}

0 comments on commit 98b631c

Please sign in to comment.