Skip to content

Commit

Permalink
DBL_MAX -> std::numeric_limits
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 16, 2018
1 parent ce74d57 commit ac17d30
Show file tree
Hide file tree
Showing 30 changed files with 77 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,8 @@ to determine what units the distance values are in.
const QVariant &defaultValue = QVariant(),
const QString &parentParameterName = QString(),
bool optional = false,
double minValue = -DBL_MAX + 1,
double maxValue = DBL_MAX );
double minValue = std::numeric_limits<double>::lowest() + 1,
double maxValue = std::numeric_limits<double>::max() );
%Docstring
Constructor for QgsProcessingParameterDistance.
%End
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/network/qgsvectorlayerdirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct TiePointInfo

int additionalPointId = -1;
QgsPointXY mTiedPoint;
double mLength = DBL_MAX;
double mLength = std::numeric_limits<double>::max();
QgsFeatureId mNetworkFeatureId = -1;
QgsPointXY mFirstPoint;
QgsPointXY mLastPoint;
Expand Down Expand Up @@ -245,7 +245,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
{

QgsPointXY snappedPoint;
double thisSegmentClosestDist = DBL_MAX;
double thisSegmentClosestDist = std::numeric_limits<double>::max();
if ( pt1 == pt2 )
{
thisSegmentClosestDist = additionalPoint.sqrDist( pt1 );
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/vector/qgsgeometrysnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry &geometry, doubl
case EndPointPreferClosest:
{
QgsPoint nodeSnap, segmentSnap;
double distanceNode = DBL_MAX;
double distanceSegment = DBL_MAX;
double distanceNode = std::numeric_limits<double>::max();
double distanceSegment = std::numeric_limits<double>::max();
if ( snapPoint )
{
nodeSnap = snapPoint->getSnapPoint( p );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolsimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void QgsMapToolSimplify::selectOneFeature( QPoint canvasPoint )
QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( selectRect ).setSubsetOfAttributes( QgsAttributeList() ) );

QgsGeometry geometry = QgsGeometry::fromPointXY( layerCoords );
double minDistance = DBL_MAX;
double minDistance = std::numeric_limits<double>::max();
double currentDistance;
QgsFeature minDistanceFeature;
QgsFeature f;
Expand Down
2 changes: 1 addition & 1 deletion src/core/annotations/qgsannotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void QgsAnnotation::updateBalloon()
segmentList << segment( 3 );

//find closest edge / closest edge point
double minEdgeDist = DBL_MAX;
double minEdgeDist = std::numeric_limits<double>::max();
int minEdgeIndex = -1;
QLineF minEdge;
QgsPointXY minEdgePoint;
Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,10 +917,10 @@ QgsRectangle QgsGeometry::boundingBox() const
QgsGeometry QgsGeometry::orientedMinimumBoundingBox( double &area, double &angle, double &width, double &height ) const
{
QgsRectangle minRect;
area = DBL_MAX;
area = std::numeric_limits<double>::max();
angle = 0;
width = DBL_MAX;
height = DBL_MAX;
width = std::numeric_limits<double>::max();
height = std::numeric_limits<double>::max();

if ( !d->geometry || d->geometry->nCoordinates() < 2 )
return QgsGeometry();
Expand Down
8 changes: 4 additions & 4 deletions src/core/geometry/qgsinternalgeometryengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ QgsPoint surfacePoleOfInaccessibility( const QgsSurface *surface, double precisi
QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision, double *distanceFromBoundary ) const
{
if ( distanceFromBoundary )
*distanceFromBoundary = DBL_MAX;
*distanceFromBoundary = std::numeric_limits<double>::max();

if ( !mGeometry || mGeometry->isEmpty() )
return QgsGeometry();
Expand All @@ -255,7 +255,7 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision,
continue;

found = true;
double dist = DBL_MAX;
double dist = std::numeric_limits<double>::max();
QgsPoint p = surfacePoleOfInaccessibility( surface, precision, dist );
if ( dist > maxDist )
{
Expand All @@ -277,7 +277,7 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision,
if ( !surface )
return QgsGeometry();

double dist = DBL_MAX;
double dist = std::numeric_limits<double>::max();
QgsPoint p = surfacePoleOfInaccessibility( surface, precision, dist );
if ( distanceFromBoundary )
*distanceFromBoundary = dist;
Expand Down Expand Up @@ -384,7 +384,7 @@ QgsVector calcMotion( const QgsPoint &a, const QgsPoint &b, const QgsPoint &c,

QgsLineString *doOrthogonalize( QgsLineString *ring, int iterations, double tolerance, double lowerThreshold, double upperThreshold )
{
double minScore = DBL_MAX;
double minScore = std::numeric_limits<double>::max();

bool isClosed = ring->isClosed();
int numPoints = ring->numPoints();
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgspolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ double QgsPolygon::pointDistanceToBoundary( double x, double y ) const
return std::numeric_limits< double >::quiet_NaN();

bool inside = false;
double minimumDistance = DBL_MAX;
double minimumDistance = std::numeric_limits<double>::max();
double minDistX = 0.0;
double minDistY = 0.0;

Expand Down
4 changes: 2 additions & 2 deletions src/core/layout/qgslayoutaligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ void QgsLayoutAligner::distributeItems( QgsLayout *layout, const QList<QgsLayout
};


double minCoord = DBL_MAX;
double maxCoord = -DBL_MAX;
double minCoord = std::numeric_limits<double>::max();
double maxCoord = std::numeric_limits<double>::lowest();
QMap< double, QgsLayoutItem * > itemCoords;
for ( QgsLayoutItem *item : items )
{
Expand Down
8 changes: 4 additions & 4 deletions src/core/layout/qgslayoutsnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ QPointF QgsLayoutSnapper::snapPointsToGrid( const QList<QPointF> &points, double

double deltaX = 0;
double deltaY = 0;
double smallestDiffX = DBL_MAX;
double smallestDiffY = DBL_MAX;
double smallestDiffX = std::numeric_limits<double>::max();
double smallestDiffY = std::numeric_limits<double>::max();
for ( QPointF point : points )
{
//calculate y offset to current page
Expand Down Expand Up @@ -278,7 +278,7 @@ double QgsLayoutSnapper::snapPointsToGuides( const QList<double> &points, Qt::Or
double alignThreshold = mTolerance / scaleFactor;

double bestDelta = 0;
double smallestDiff = DBL_MAX;
double smallestDiff = std::numeric_limits<double>::max();

for ( double p : points )
{
Expand Down Expand Up @@ -325,7 +325,7 @@ double QgsLayoutSnapper::snapPointsToItems( const QList<double> &points, Qt::Ori
double alignThreshold = mTolerance / scaleFactor;

double bestDelta = 0;
double smallestDiff = DBL_MAX;
double smallestDiff = std::numeric_limits<double>::max();
double closest = 0;
const QList<QGraphicsItem *> itemList = mLayout->items();
QList< double > currentCoords;
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/costcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ PolygonCostCalculator::PolygonCostCalculator( LabelPosition *lp ) : lp( lp )
px = ( lp->x[0] + lp->x[2] ) / 2.0;
py = ( lp->y[0] + lp->y[2] ) / 2.0;

dist = DBL_MAX;
dist = std::numeric_limits<double>::max();
ok = false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/pal/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ void FeaturePart::extractCoords( const GEOSGeometry *geom )
coordSeq = GEOSGeom_getCoordSeq_r( geosctxt, geom );

// initialize bounding box
xmin = ymin = DBL_MAX;
xmax = ymax = -DBL_MAX;
xmin = ymin = std::numeric_limits<double>::max();
xmax = ymax = std::numeric_limits<double>::lowest();

// initialize coordinate arrays
deleteCoords();
Expand Down
8 changes: 4 additions & 4 deletions src/core/pal/labelposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ void LabelPosition::getBoundingBox( double amin[2], double amax[2] ) const
}
else
{
amin[0] = DBL_MAX;
amax[0] = -DBL_MAX;
amin[1] = DBL_MAX;
amax[1] = -DBL_MAX;
amin[0] = std::numeric_limits<double>::max();
amax[0] = std::numeric_limits<double>::lowest();
amin[1] = std::numeric_limits<double>::max();
amax[1] = std::numeric_limits<double>::lowest();
}
for ( int c = 0; c < 4; c++ )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/pal/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom
Feats *feat = nullptr;

// Filtering label positions against obstacles
amin[0] = amin[1] = -DBL_MAX;
amax[0] = amax[1] = DBL_MAX;
amin[0] = amin[1] = std::numeric_limits<double>::lowest();
amax[0] = amax[1] = std::numeric_limits<double>::max();
FilterContext filterCtx;
filterCtx.cdtsIndex = prob->candidates;
filterCtx.pal = this;
Expand Down
14 changes: 7 additions & 7 deletions src/core/pal/pointset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void PointSet::splitPolygons( QLinkedList<PointSet *> &shapes_toProcess,
int ps = -1, pe = -1, fps = -1, fpe = -1;
if ( retainedPt >= 0 && bestArea > labelArea ) // there is a hole so we'll cut the shape in two new shape (only if hole area is bigger than twice labelArea)
{
c = DBL_MAX;
c = std::numeric_limits<double>::max();

// iterate on all shape points except points which are in the hole
bool isValid;
Expand Down Expand Up @@ -568,17 +568,17 @@ CHullBox *PointSet::compute_chull_bbox()
double width;
double length;

double best_area = DBL_MAX;
double best_area = std::numeric_limits<double>::max();
double best_alpha = -1;
double best_bb[16];
double best_length = 0;
double best_width = 0;


bbox[0] = DBL_MAX;
bbox[1] = DBL_MAX;
bbox[2] = - DBL_MAX;
bbox[3] = - DBL_MAX;
bbox[0] = std::numeric_limits<double>::max();
bbox[1] = std::numeric_limits<double>::max();
bbox[2] = std::numeric_limits<double>::lowest();
bbox[3] = std::numeric_limits<double>::lowest();

for ( i = 0; i < cHullSize; i++ )
{
Expand Down Expand Up @@ -632,7 +632,7 @@ CHullBox *PointSet::compute_chull_bbox()

alpha_seg = ( ( i / 4 > 0 ? ( i / 4 ) - 1 : 3 ) ) * M_PI_2 + alpha;

best_cp = DBL_MAX;
best_cp = std::numeric_limits<double>::max();
for ( j = 0; j < nbPoints; j++ )
{
cp = GeomFunction::cross_product( bb[i + 2], bb[i + 3], bb[i], bb[i + 1], x[cHull[j]], y[cHull[j]] );
Expand Down
8 changes: 4 additions & 4 deletions src/core/pal/pointset.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ namespace pal
const GEOSPreparedGeometry *preparedGeom() const;
void invalidateGeos();

double xmin = DBL_MAX;
double xmax = -DBL_MAX;
double ymin = DBL_MAX;
double ymax = -DBL_MAX;
double xmin = std::numeric_limits<double>::max();
double xmax = std::numeric_limits<double>::lowest();
double ymin = std::numeric_limits<double>::max();
double ymax = std::numeric_limits<double>::lowest();

private:

Expand Down
10 changes: 5 additions & 5 deletions src/core/pal/problem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ double Problem::popmusic_tabu( SubPart *part )
while ( it < stop_it && best_cost >= EPSILON )
{
actualizeTabuCandidateList( m, it, nbOverlap, &candidateListSize, candidateBaseFactor, &candidateFactor, minCandidateListSize, reductionFactor, minTabuTSize, tabuFactor, &tenure, probSize );
delta_min = DBL_MAX;
delta_min = std::numeric_limits<double>::max();
choosed_feat = -1;
choosed_label = -2;
candidateId = -1;
Expand Down Expand Up @@ -1167,7 +1167,7 @@ inline Chain *Problem::chain( SubPart *part, int seed )

double delta;
double delta_min;
double delta_best = DBL_MAX;
double delta_best = std::numeric_limits<double>::max();
double delta_tmp;

int next_seed;
Expand Down Expand Up @@ -1203,7 +1203,7 @@ inline Chain *Problem::chain( SubPart *part, int seed )
{
subseed = sub[seed];
seedNbLp = featNbLp[subseed];
delta_min = DBL_MAX;
delta_min = std::numeric_limits<double>::max();
next_seed = -1;
retainedLabel = -2;

Expand Down Expand Up @@ -1447,7 +1447,7 @@ inline Chain *Problem::chain( int seed )

double delta;
double delta_min;
double delta_best = DBL_MAX;
double delta_best = std::numeric_limits<double>::max();
double delta_tmp;

int next_seed;
Expand Down Expand Up @@ -1482,7 +1482,7 @@ inline Chain *Problem::chain( int seed )
while ( seed != -1 )
{
seedNbLp = featNbLp[seed];
delta_min = DBL_MAX;
delta_min = std::numeric_limits<double>::max();

next_seed = -1;
retainedLabel = -2;
Expand Down
4 changes: 2 additions & 2 deletions src/core/processing/qgsprocessingparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2200,9 +2200,9 @@ QString QgsProcessingParameterNumber::toolTip() const
{
QString text = QgsProcessingParameterDefinition::toolTip();
QStringList parts;
if ( mMin > -DBL_MAX + 1 )
if ( mMin > std::numeric_limits<double>::lowest() + 1 )
parts << QObject::tr( "Minimum value: %1" ).arg( mMin );
if ( mMax < DBL_MAX )
if ( mMax < std::numeric_limits<double>::max() )
parts << QObject::tr( "Maximum value: %1" ).arg( mMax );
if ( mDefault.isValid() )
parts << QObject::tr( "Default value: %1" ).arg( mDataType == Integer ? mDefault.toInt() : mDefault.toDouble() );
Expand Down
8 changes: 4 additions & 4 deletions src/core/processing/qgsprocessingparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -1246,8 +1246,8 @@ class CORE_EXPORT QgsProcessingParameterNumber : public QgsProcessingParameterDe

private:

double mMin = -DBL_MAX + 1;
double mMax = DBL_MAX;
double mMin = std::numeric_limits<double>::lowest() + 1;
double mMax = std::numeric_limits<double>::max();
Type mDataType = Integer;
};

Expand All @@ -1269,8 +1269,8 @@ class CORE_EXPORT QgsProcessingParameterDistance : public QgsProcessingParameter
const QVariant &defaultValue = QVariant(),
const QString &parentParameterName = QString(),
bool optional = false,
double minValue = -DBL_MAX + 1,
double maxValue = DBL_MAX );
double minValue = std::numeric_limits<double>::lowest() + 1,
double maxValue = std::numeric_limits<double>::max() );

/**
* Returns the type name for the parameter class.
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsmaprendererjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs
// E.g. longitude -200 to +160 would be understood as +40 to +160 due to periodicity.
// We could try to clamp coords to (-180,180) for lon resp. (-90,90) for lat,
// but this seems like a safer choice.
extent = QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
extent = QgsRectangle( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
else
extent = ct.transformBoundingBox( extent, QgsCoordinateTransform::ReverseTransform );
}
Expand All @@ -209,8 +209,8 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs
{
Q_UNUSED( cse );
QgsDebugMsg( "Transform error caught" );
extent = QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
r2 = QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
extent = QgsRectangle( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
r2 = QgsRectangle( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
}

return split;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsrendercontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ double QgsRenderContext::convertToMapUnits( double size, QgsUnitTypes::RenderUni
case QgsUnitTypes::RenderMapUnits:
{
// check scale
double minSizeMU = -DBL_MAX;
double minSizeMU = std::numeric_limits<double>::lowest();
if ( scale.minSizeMMEnabled )
{
minSizeMU = scale.minSizeMM * mScaleFactor * mup;
Expand All @@ -339,7 +339,7 @@ double QgsRenderContext::convertToMapUnits( double size, QgsUnitTypes::RenderUni
}
size = std::max( size, minSizeMU );

double maxSizeMU = DBL_MAX;
double maxSizeMU = std::numeric_limits<double>::max();
if ( scale.maxSizeMMEnabled )
{
maxSizeMU = scale.maxSizeMM * mScaleFactor * mup;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectordataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <QTextCodec>

#include <cfloat> // for DBL_MAX
#include <cfloat>
#include <climits>
#include <limits>

Expand Down
8 changes: 4 additions & 4 deletions src/core/raster/qgsrasterlayerrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer *layer, QgsRender
if ( rendererContext.coordinateTransform().isValid() )
{
QgsDebugMsgLevel( "coordinateTransform set -> project extents.", 4 );
if ( rendererContext.extent().xMinimum() == -DBL_MAX &&
rendererContext.extent().yMinimum() == -DBL_MAX &&
rendererContext.extent().xMaximum() == DBL_MAX &&
rendererContext.extent().yMaximum() == DBL_MAX )
if ( rendererContext.extent().xMinimum() == std::numeric_limits<double>::lowest() &&
rendererContext.extent().yMinimum() == std::numeric_limits<double>::lowest() &&
rendererContext.extent().xMaximum() == std::numeric_limits<double>::max() &&
rendererContext.extent().yMaximum() == std::numeric_limits<double>::max() )
{
// We get in this situation if the view CRS is geographical and the
// extent goes beyond -180,-90,180,90. To avoid reprojection issues to the
Expand Down
Loading

0 comments on commit ac17d30

Please sign in to comment.