Skip to content
Permalink
Browse files
Move the isfinite checks in the wms provider to the qgsrect class and
use numeric_limits instead of the C99 isfinite macro/function. Remove
the check for a functioning isfinite macro/function


git-svn-id: http://svn.osgeo.org/qgis/trunk@5894 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Sep 30, 2006
1 parent 4e2d29b commit d8dada7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
@@ -100,17 +100,6 @@ dnl GDAL/OGR
dnl ---------------------------------------------------------------------------
AQ_CHECK_GDAL

dnl ---------------------------------------------------------------------------
dnl Whether to use isfinite or std::isfinite
dnl ---------------------------------------------------------------------------
have_stdisfinite=no
AC_MSG_CHECKING([[<cmath> for std::isfinite]])
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include <cmath>]], [[ std::isfinite(0) ]]),
[[have_stdisfinite=yes]
AC_DEFINE(HAVE_STDISFINITE,1,[Define to 1 if std::isfinite is available])
], [])
AC_MSG_RESULT([[$have_stdisfinite]])

dnl ---------------------------------------------------------------------------
dnl GEOS
dnl ---------------------------------------------------------------------------
@@ -19,9 +19,7 @@
#include <iostream>
#include <algorithm>
#include <cmath>
#ifdef WIN32
#include <limits>
#endif
#include <QString>
#include <QTextStream>

@@ -283,3 +281,26 @@ void QgsRect::unionRect(const QgsRect& r)
if (r.yMin() < yMin()) setYmin(r.yMin());
if (r.yMax() > yMax()) setYmax(r.yMax());
}

bool QgsRect::isFinite() const
{
if (std::numeric_limits<double>::has_infinity)
{
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;
}
// Only check for quiet NaN, as the signalling NaN will have caused
// an exception well before we get the chance to get here.
if (std::numeric_limits<double>::has_quiet_NaN)
{
if (xmin == std::numeric_limits<double>::quiet_NaN() ||
xmax == std::numeric_limits<double>::quiet_NaN() ||
ymin == std::numeric_limits<double>::quiet_NaN() ||
ymax == std::numeric_limits<double>::quiet_NaN())
return false;
}
return true;
}
@@ -111,6 +111,10 @@ class QgsRect

/** updates rectangle to include passed argument */
void unionRect(const QgsRect& rect);

/** Returns true if the rectangle has finite boundaries. Will
return false if any of the rectangle boundaries are NaN or Inf. */
bool isFinite() const;

protected:

@@ -18,14 +18,6 @@

/* $Id$ */

#include "qgsconfig.h"

#ifdef HAVE_STDISFINITE
#include <cmath>
#else
#include <math.h>
#endif

#include "qgslogger.h"
#include "qgswmsprovider.h"

@@ -1954,16 +1946,10 @@ bool QgsWmsProvider::calculateExtent()
}

//make sure extent does not contain 'inf' or 'nan'
#ifdef HAVE_STDISFINITE
if(!std::isfinite(extent.xMin()) || !std::isfinite((int)extent.yMin()) || !std::isfinite(extent.xMax()) || \
!std::isfinite((int)extent.yMax()))
#else
if(!isfinite(extent.xMin()) || !isfinite((int)extent.yMin()) || !isfinite(extent.xMax()) || \
!isfinite((int)extent.yMax()))
#endif
{
continue;
}
if (!extent.isFinite())
{
continue;
}

// add to the combined extent of all the active sublayers
if (firstLayer)

0 comments on commit d8dada7

Please sign in to comment.