Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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/qgis@5894 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Sep 30, 2006
1 parent b0e13e2 commit 5e95efd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
11 changes: 0 additions & 11 deletions configure.in
Expand Up @@ -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 ---------------------------------------------------------------------------
Expand Down
25 changes: 23 additions & 2 deletions src/core/qgsrect.cpp
Expand Up @@ -19,9 +19,7 @@
#include <iostream>
#include <algorithm>
#include <cmath>
#ifdef WIN32
#include <limits>
#endif
#include <QString>
#include <QTextStream>

Expand Down Expand Up @@ -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;
}
4 changes: 4 additions & 0 deletions src/core/qgsrect.h
Expand Up @@ -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:

Expand Down
22 changes: 4 additions & 18 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -18,14 +18,6 @@

/* $Id$ */

#include "qgsconfig.h"

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

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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5e95efd

Please sign in to comment.