Skip to content
Permalink
Browse files

Use qIsNaN and qIsInf for QgsRectangle::isFinite

git-svn-id: http://svn.osgeo.org/qgis/trunk@15138 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Feb 8, 2011
1 parent b5bad19 commit 6a2c261b3da50b6aaf8bd7a452374fbd67921ed4
Showing with 6 additions and 10 deletions.
  1. +6 −10 src/core/qgsrectangle.cpp
@@ -21,6 +21,7 @@
#include <limits>
#include <QString>
#include <QTextStream>
#include <qnumeric.h>

#include "qgspoint.h"
#include "qgsrectangle.h"
@@ -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 6a2c261

Please sign in to comment.
You can’t perform that action at this time.