Skip to content

Commit ff0ec3f

Browse files
author
jef
committed
use Qt for isnan/isinf/abs
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14711 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7f7202d commit ff0ec3f

File tree

13 files changed

+37
-40
lines changed

13 files changed

+37
-40
lines changed

src/analysis/interpolation/qgsinterpolator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int QgsInterpolator::cacheBaseData()
8383
continue;
8484
}
8585
attributeValue = att_it.value().toDouble( &attributeConversionOk );
86-
if ( !attributeConversionOk || isnan( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
86+
if ( !attributeConversionOk || qIsNaN( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
8787
{
8888
continue;
8989
}

src/analysis/interpolation/qgstininterpolator.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@
2727
#include "qgsvectorlayer.h"
2828
#include <QProgressDialog>
2929

30-
QgsTINInterpolator::QgsTINInterpolator( const QList<LayerData>& inputData, TIN_INTERPOLATION interpolation, bool showProgressDialog ): QgsInterpolator( inputData ), mTriangulation( 0 ), \
31-
mTriangleInterpolator( 0 ), mIsInitialized( false ), mShowProgressDialog( showProgressDialog ), mExportTriangulationToFile( false ), mInterpolation( interpolation )
30+
QgsTINInterpolator::QgsTINInterpolator( const QList<LayerData>& inputData, TIN_INTERPOLATION interpolation, bool showProgressDialog )
31+
: QgsInterpolator( inputData )
32+
, mTriangulation( 0 )
33+
, mTriangleInterpolator( 0 )
34+
, mIsInitialized( false )
35+
, mShowProgressDialog( showProgressDialog )
36+
, mExportTriangulationToFile( false )
37+
, mInterpolation( interpolation )
3238
{
3339
}
3440

@@ -185,7 +191,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
185191
return 3;
186192
}
187193
attributeValue = att_it.value().toDouble( &attributeConversionOk );
188-
if ( !attributeConversionOk || isnan( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
194+
if ( !attributeConversionOk || qIsNaN( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
189195
{
190196
return 4;
191197
}

src/app/qgsprojectproperties.h

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "ui_qgsprojectpropertiesbase.h"
2222
#include "qgis.h"
2323
#include "qgisgui.h"
24-
#include "qgssnappingdialog.h"
2524
#include "qgscontexthelp.h"
2625

2726
class QgsMapCanvas;

src/core/qgis.h

+2-10
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,12 @@
1818

1919
#ifndef QGIS_H
2020
#define QGIS_H
21+
2122
#include <QEvent>
2223
#include <QString>
2324
#include <cfloat>
24-
25-
#ifndef Q_OS_MACX
2625
#include <cmath>
27-
#else
28-
#include <math.h>
29-
#endif
30-
#ifdef WIN32
31-
#include <float.h>
32-
#define isnan(f) _isnan(f)
33-
#define isinf(f) (!_finite(f) && !_isnan(f))
34-
#endif
26+
#include <qnumeric.h>
3527

3628
/** \ingroup core
3729
* The QGis class provides global constants for use throughout the application.

src/core/qgsclipper.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ inline void QgsClipper::trimFeatureToBoundary(
157157
// look at each edge of the polygon in turn
158158

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

269269
QgsPoint p;
270270

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

283283
return p;

src/core/qgspallabeling.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
453453
//data defined position / alignment / rotation?
454454
bool dataDefinedPosition = false;
455455
bool dataDefinedRotation = false;
456-
double xPos, yPos, angle;
456+
double xPos = 0.0, yPos = 0.0, angle = 0.0;
457457
bool ddXPos, ddYPos;
458458

459459
QMap< DataDefinedProperties, int >::const_iterator dPosXIt = dataDefinedProperties.find( QgsPalLayerSettings::PositionX );

src/core/qgspoint.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ QString QgsPoint::toString( int thePrecision ) const
137137
QString QgsPoint::toDegreesMinutesSeconds( int thePrecision ) const
138138
{
139139
int myDegreesX = int( std::abs( m_x ) );
140-
float myFloatMinutesX = float(( std::abs( m_x ) - myDegreesX ) * 60 );
140+
float myFloatMinutesX = float(( qAbs( m_x ) - myDegreesX ) * 60 );
141141
int myIntMinutesX = int( myFloatMinutesX );
142142
float mySecondsX = float( myFloatMinutesX - myIntMinutesX ) * 60;
143143

144144
int myDegreesY = int( std::abs( m_y ) );
145-
float myFloatMinutesY = float(( std::abs( m_y ) - myDegreesY ) * 60 );
145+
float myFloatMinutesY = float(( qAbs( m_y ) - myDegreesY ) * 60 );
146146
int myIntMinutesY = int( myFloatMinutesY );
147147
float mySecondsY = float( myFloatMinutesY - myIntMinutesY ) * 60;
148148

src/core/qgsvectorlayer.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ unsigned char *QgsVectorLayer::drawLineString( unsigned char *feature, QgsRender
426426
// the rest of them so end the loop at that point.
427427
for ( register unsigned int i = 0; i < nPoints; ++i )
428428
{
429-
if ( std::abs( x[i] ) > QgsClipper::MAX_X ||
430-
std::abs( y[i] ) > QgsClipper::MAX_Y )
429+
if ( qAbs( x[i] ) > QgsClipper::MAX_X ||
430+
qAbs( y[i] ) > QgsClipper::MAX_Y )
431431
{
432432
QgsClipper::trimFeature( x, y, true ); // true = polyline
433433
nPoints = x.size(); // trimming may change nPoints.
@@ -546,8 +546,8 @@ unsigned char *QgsVectorLayer::drawPolygon( unsigned char *feature, QgsRenderCon
546546
// the rest of them so end the loop at that point.
547547
for ( register unsigned int i = 0; i < nPoints; ++i )
548548
{
549-
if ( std::abs( ring->first[i] ) > QgsClipper::MAX_X ||
550-
std::abs( ring->second[i] ) > QgsClipper::MAX_Y )
549+
if ( qAbs( ring->first[i] ) > QgsClipper::MAX_X ||
550+
qAbs( ring->second[i] ) > QgsClipper::MAX_Y )
551551
{
552552
QgsClipper::trimFeature( ring->first, ring->second, false );
553553
break;
@@ -4037,8 +4037,8 @@ void QgsVectorLayer::drawFeature( QgsRenderContext &renderContext,
40374037
double y = *(( double * )( feature + 5 + sizeof( double ) ) );
40384038

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

40874087
// Work around a +/- 32768 limitation on coordinates
4088-
if ( std::abs( x ) > QgsClipper::MAX_X ||
4089-
std::abs( y ) > QgsClipper::MAX_Y )
4088+
if ( qAbs( x ) > QgsClipper::MAX_X ||
4089+
qAbs( y ) > QgsClipper::MAX_Y )
40904090
needToTrim = true;
40914091
else
40924092
p->drawImage( pt, *marker );

src/core/spatialindex/geometry/Region.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ double Tools::Geometry::Region::getMinimumDistance( const Region& r ) const
306306

307307
if ( r.m_pHigh[i] < m_pLow[i] )
308308
{
309-
x = std::abs( r.m_pHigh[i] - m_pLow[i] );
309+
x = qAbs( r.m_pHigh[i] - m_pLow[i] );
310310
}
311311
else if ( m_pHigh[i] < r.m_pLow[i] )
312312
{
313-
x = std::abs( r.m_pLow[i] - m_pHigh[i] );
313+
x = qAbs( r.m_pLow[i] - m_pHigh[i] );
314314
}
315315

316316
ret += x * x;

src/gui/qgsquickprint.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ void QgsQuickPrint::renderPrintScaleBar( QPainter * thepPainter,
798798
//Get map units per pixel. This can be negative at times (to do with
799799
//projections) and that just confuses the rest of the code in this
800800
//function, so force to a positive number.
801-
double myMapUnitsPerPixelDouble = std::abs( thepMapRenderer->mapUnitsPerPixel() );
801+
double myMapUnitsPerPixelDouble = qAbs( thepMapRenderer->mapUnitsPerPixel() );
802802
//
803803
// Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze
804804
int myLayerCount = thepMapRenderer->layerSet().count();

src/plugins/georeferencer/qgsgeoreftransform.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ int QgsLinearGeorefTransform::linear_transform( void *pTransformerArg, int bDstT
372372
else
373373
{
374374
// Guard against division by zero
375-
if ( abs( t->scaleX ) < std::numeric_limits<double>::epsilon() ||
376-
abs( t->scaleY ) < std::numeric_limits<double>::epsilon() )
375+
if ( qAbs( t->scaleX ) < std::numeric_limits<double>::epsilon() ||
376+
qAbs( t->scaleY ) < std::numeric_limits<double>::epsilon() )
377377
{
378378
for ( int i = 0; i < nPointCount; ++i )
379379
{
@@ -591,7 +591,7 @@ bool QgsProjectiveGeorefTransform::updateParametersFromGCPs( const std::vector<Q
591591

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

594-
if ( std::abs( det ) < 1024.0*std::numeric_limits<double>::epsilon() )
594+
if ( qAbs( det ) < 1024.0*std::numeric_limits<double>::epsilon() )
595595
{
596596
mParameters.hasInverse = false;
597597
}
@@ -644,7 +644,7 @@ int QgsProjectiveGeorefTransform::projective_transform( void *pTransformerArg, i
644644
{
645645
double Z = x[i] * H[6] + y[i] * H[7] + H[8];
646646
// Projects to infinity?
647-
if ( std::abs( Z ) < 1024.0*std::numeric_limits<double>::epsilon() )
647+
if ( qAbs( Z ) < 1024.0*std::numeric_limits<double>::epsilon() )
648648
{
649649
panSuccess[i] = false;
650650
continue;

src/plugins/georeferencer/qgsleastsquares.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ void QgsLeastSquares::linear( std::vector<QgsPoint> mapCoords,
5959
origin.setX( aX );
6060
origin.setY( aY );
6161

62-
pixelXSize = std::abs( bX );
63-
pixelYSize = std::abs( bY );
62+
pixelXSize = qAbs( bX );
63+
pixelYSize = qAbs( bY );
6464
}
6565

6666

src/plugins/scale_bar/plugin.cpp

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

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

0 commit comments

Comments
 (0)