Skip to content
Permalink
Browse files

use Qt for isnan/isinf/abs

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14711 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 18, 2010
1 parent 7f7202d commit ff0ec3f1cb777c3e1d8ca86853e6eba9ef918b5b
@@ -83,7 +83,7 @@ int QgsInterpolator::cacheBaseData()
continue;
}
attributeValue = att_it.value().toDouble( &attributeConversionOk );
if ( !attributeConversionOk || isnan( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
if ( !attributeConversionOk || qIsNaN( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
{
continue;
}
@@ -27,8 +27,14 @@
#include "qgsvectorlayer.h"
#include <QProgressDialog>

QgsTINInterpolator::QgsTINInterpolator( const QList<LayerData>& inputData, TIN_INTERPOLATION interpolation, bool showProgressDialog ): QgsInterpolator( inputData ), mTriangulation( 0 ), \
mTriangleInterpolator( 0 ), mIsInitialized( false ), mShowProgressDialog( showProgressDialog ), mExportTriangulationToFile( false ), mInterpolation( interpolation )
QgsTINInterpolator::QgsTINInterpolator( const QList<LayerData>& inputData, TIN_INTERPOLATION interpolation, bool showProgressDialog )
: QgsInterpolator( inputData )
, mTriangulation( 0 )
, mTriangleInterpolator( 0 )
, mIsInitialized( false )
, mShowProgressDialog( showProgressDialog )
, mExportTriangulationToFile( false )
, mInterpolation( interpolation )
{
}

@@ -185,7 +191,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
return 3;
}
attributeValue = att_it.value().toDouble( &attributeConversionOk );
if ( !attributeConversionOk || isnan( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
if ( !attributeConversionOk || qIsNaN( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
{
return 4;
}
@@ -21,7 +21,6 @@
#include "ui_qgsprojectpropertiesbase.h"
#include "qgis.h"
#include "qgisgui.h"
#include "qgssnappingdialog.h"
#include "qgscontexthelp.h"

class QgsMapCanvas;
@@ -18,20 +18,12 @@

#ifndef QGIS_H
#define QGIS_H

#include <QEvent>
#include <QString>
#include <cfloat>

#ifndef Q_OS_MACX
#include <cmath>
#else
#include <math.h>
#endif
#ifdef WIN32
#include <float.h>
#define isnan(f) _isnan(f)
#define isinf(f) (!_finite(f) && !_isnan(f))
#endif
#include <qnumeric.h>

/** \ingroup core
* The QGis class provides global constants for use throughout the application.
@@ -157,8 +157,8 @@ inline void QgsClipper::trimFeatureToBoundary(
// look at each edge of the polygon in turn

//ignore segments with nan or inf coordinates
if ( isnan( inX[i2] ) || isnan( inY[i2] ) || isinf( inX[i2] ) || isinf( inY[i2] )
|| isnan( inX[i1] ) || isnan( inY[i1] ) || isinf( inX[i1] ) || isinf( inY[i1] ) )
if ( qIsNaN( inX[i2] ) || qIsNaN( inY[i2] ) || qIsInf( inX[i2] ) || qIsInf( inY[i2] )
|| qIsNaN( inX[i1] ) || qIsNaN( inY[i1] ) || qIsInf( inX[i1] ) || qIsInf( inY[i1] ) )
{
i1 = i2;
continue;
@@ -268,7 +268,7 @@ inline QgsPoint QgsClipper::intersect( const double x1, const double y1,

QgsPoint p;

if ( std::abs( r_d ) > SMALL_NUM && std::abs( r_n ) > SMALL_NUM )
if ( qAbs( r_d ) > SMALL_NUM && qAbs( r_n ) > SMALL_NUM )
{ // they cross
double r = r_n / r_d;
p.set( x1 + r*( x2 - x1 ), y1 + r*( y2 - y1 ) );
@@ -277,7 +277,7 @@ inline QgsPoint QgsClipper::intersect( const double x1, const double y1,
{
// Should never get here, but if we do for some reason, cause a
// clunk because something else is wrong if we do.
Q_ASSERT( std::abs( r_d ) > SMALL_NUM && std::abs( r_n ) > SMALL_NUM );
Q_ASSERT( qAbs( r_d ) > SMALL_NUM && qAbs( r_n ) > SMALL_NUM );
}

return p;
@@ -453,7 +453,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
//data defined position / alignment / rotation?
bool dataDefinedPosition = false;
bool dataDefinedRotation = false;
double xPos, yPos, angle;
double xPos = 0.0, yPos = 0.0, angle = 0.0;
bool ddXPos, ddYPos;

QMap< DataDefinedProperties, int >::const_iterator dPosXIt = dataDefinedProperties.find( QgsPalLayerSettings::PositionX );
@@ -137,12 +137,12 @@ QString QgsPoint::toString( int thePrecision ) const
QString QgsPoint::toDegreesMinutesSeconds( int thePrecision ) const
{
int myDegreesX = int( std::abs( m_x ) );
float myFloatMinutesX = float(( std::abs( m_x ) - myDegreesX ) * 60 );
float myFloatMinutesX = float(( qAbs( m_x ) - myDegreesX ) * 60 );
int myIntMinutesX = int( myFloatMinutesX );
float mySecondsX = float( myFloatMinutesX - myIntMinutesX ) * 60;

int myDegreesY = int( std::abs( m_y ) );
float myFloatMinutesY = float(( std::abs( m_y ) - myDegreesY ) * 60 );
float myFloatMinutesY = float(( qAbs( m_y ) - myDegreesY ) * 60 );
int myIntMinutesY = int( myFloatMinutesY );
float mySecondsY = float( myFloatMinutesY - myIntMinutesY ) * 60;

@@ -426,8 +426,8 @@ unsigned char *QgsVectorLayer::drawLineString( unsigned char *feature, QgsRender
// the rest of them so end the loop at that point.
for ( register unsigned int i = 0; i < nPoints; ++i )
{
if ( std::abs( x[i] ) > QgsClipper::MAX_X ||
std::abs( y[i] ) > QgsClipper::MAX_Y )
if ( qAbs( x[i] ) > QgsClipper::MAX_X ||
qAbs( y[i] ) > QgsClipper::MAX_Y )
{
QgsClipper::trimFeature( x, y, true ); // true = polyline
nPoints = x.size(); // trimming may change nPoints.
@@ -546,8 +546,8 @@ unsigned char *QgsVectorLayer::drawPolygon( unsigned char *feature, QgsRenderCon
// the rest of them so end the loop at that point.
for ( register unsigned int i = 0; i < nPoints; ++i )
{
if ( std::abs( ring->first[i] ) > QgsClipper::MAX_X ||
std::abs( ring->second[i] ) > QgsClipper::MAX_Y )
if ( qAbs( ring->first[i] ) > QgsClipper::MAX_X ||
qAbs( ring->second[i] ) > QgsClipper::MAX_Y )
{
QgsClipper::trimFeature( ring->first, ring->second, false );
break;
@@ -4037,8 +4037,8 @@ void QgsVectorLayer::drawFeature( QgsRenderContext &renderContext,
double y = *(( double * )( feature + 5 + sizeof( double ) ) );

transformPoint( x, y, &renderContext.mapToPixel(), renderContext.coordinateTransform() );
if ( std::abs( x ) > QgsClipper::MAX_X ||
std::abs( y ) > QgsClipper::MAX_Y )
if ( qAbs( x ) > QgsClipper::MAX_X ||
qAbs( y ) > QgsClipper::MAX_Y )
{
break;
}
@@ -4085,8 +4085,8 @@ void QgsVectorLayer::drawFeature( QgsRenderContext &renderContext,
//QPointF pt( x, y );

// Work around a +/- 32768 limitation on coordinates
if ( std::abs( x ) > QgsClipper::MAX_X ||
std::abs( y ) > QgsClipper::MAX_Y )
if ( qAbs( x ) > QgsClipper::MAX_X ||
qAbs( y ) > QgsClipper::MAX_Y )
needToTrim = true;
else
p->drawImage( pt, *marker );
@@ -306,11 +306,11 @@ double Tools::Geometry::Region::getMinimumDistance( const Region& r ) const

if ( r.m_pHigh[i] < m_pLow[i] )
{
x = std::abs( r.m_pHigh[i] - m_pLow[i] );
x = qAbs( r.m_pHigh[i] - m_pLow[i] );
}
else if ( m_pHigh[i] < r.m_pLow[i] )
{
x = std::abs( r.m_pLow[i] - m_pHigh[i] );
x = qAbs( r.m_pLow[i] - m_pHigh[i] );
}

ret += x * x;
@@ -798,7 +798,7 @@ void QgsQuickPrint::renderPrintScaleBar( QPainter * thepPainter,
//Get map units per pixel. This can be negative at times (to do with
//projections) and that just confuses the rest of the code in this
//function, so force to a positive number.
double myMapUnitsPerPixelDouble = std::abs( thepMapRenderer->mapUnitsPerPixel() );
double myMapUnitsPerPixelDouble = qAbs( thepMapRenderer->mapUnitsPerPixel() );
//
// Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze
int myLayerCount = thepMapRenderer->layerSet().count();
@@ -372,8 +372,8 @@ int QgsLinearGeorefTransform::linear_transform( void *pTransformerArg, int bDstT
else
{
// Guard against division by zero
if ( abs( t->scaleX ) < std::numeric_limits<double>::epsilon() ||
abs( t->scaleY ) < std::numeric_limits<double>::epsilon() )
if ( qAbs( t->scaleX ) < std::numeric_limits<double>::epsilon() ||
qAbs( t->scaleY ) < std::numeric_limits<double>::epsilon() )
{
for ( int i = 0; i < nPointCount; ++i )
{
@@ -591,7 +591,7 @@ bool QgsProjectiveGeorefTransform::updateParametersFromGCPs( const std::vector<Q

double det = H[0] * adjoint[0] + H[3] * adjoint[1] + H[6] * adjoint[2];

if ( std::abs( det ) < 1024.0*std::numeric_limits<double>::epsilon() )
if ( qAbs( det ) < 1024.0*std::numeric_limits<double>::epsilon() )
{
mParameters.hasInverse = false;
}
@@ -644,7 +644,7 @@ int QgsProjectiveGeorefTransform::projective_transform( void *pTransformerArg, i
{
double Z = x[i] * H[6] + y[i] * H[7] + H[8];
// Projects to infinity?
if ( std::abs( Z ) < 1024.0*std::numeric_limits<double>::epsilon() )
if ( qAbs( Z ) < 1024.0*std::numeric_limits<double>::epsilon() )
{
panSuccess[i] = false;
continue;
@@ -59,8 +59,8 @@ void QgsLeastSquares::linear( std::vector<QgsPoint> mapCoords,
origin.setX( aX );
origin.setY( aY );

pixelXSize = std::abs( bX );
pixelYSize = std::abs( bY );
pixelXSize = qAbs( bX );
pixelYSize = qAbs( bY );
}


@@ -191,7 +191,7 @@ void QgsScaleBarPlugin::renderScaleBar( QPainter * theQPainter )
//Get map units per pixel. This can be negative at times (to do with
//projections) and that just confuses the rest of the code in this
//function, so force to a positive number.
double myMapUnitsPerPixelDouble = std::abs( qGisInterface->mapCanvas()->mapUnitsPerPixel() );
double myMapUnitsPerPixelDouble = qAbs( qGisInterface->mapCanvas()->mapUnitsPerPixel() );

// Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze
int myLayerCount = qGisInterface->mapCanvas()->layerCount();

0 comments on commit ff0ec3f

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