Skip to content

Commit ac17d30

Browse files
committed
DBL_MAX -> std::numeric_limits
1 parent ce74d57 commit ac17d30

30 files changed

+77
-77
lines changed

python/core/auto_generated/processing/qgsprocessingparameters.sip.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,8 @@ to determine what units the distance values are in.
12641264
const QVariant &defaultValue = QVariant(),
12651265
const QString &parentParameterName = QString(),
12661266
bool optional = false,
1267-
double minValue = -DBL_MAX + 1,
1268-
double maxValue = DBL_MAX );
1267+
double minValue = std::numeric_limits<double>::lowest() + 1,
1268+
double maxValue = std::numeric_limits<double>::max() );
12691269
%Docstring
12701270
Constructor for QgsProcessingParameterDistance.
12711271
%End

src/analysis/network/qgsvectorlayerdirector.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct TiePointInfo
4848

4949
int additionalPointId = -1;
5050
QgsPointXY mTiedPoint;
51-
double mLength = DBL_MAX;
51+
double mLength = std::numeric_limits<double>::max();
5252
QgsFeatureId mNetworkFeatureId = -1;
5353
QgsPointXY mFirstPoint;
5454
QgsPointXY mLastPoint;
@@ -245,7 +245,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
245245
{
246246

247247
QgsPointXY snappedPoint;
248-
double thisSegmentClosestDist = DBL_MAX;
248+
double thisSegmentClosestDist = std::numeric_limits<double>::max();
249249
if ( pt1 == pt2 )
250250
{
251251
thisSegmentClosestDist = additionalPoint.sqrDist( pt1 );

src/analysis/vector/qgsgeometrysnapper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ QgsGeometry QgsGeometrySnapper::snapGeometry( const QgsGeometry &geometry, doubl
573573
case EndPointPreferClosest:
574574
{
575575
QgsPoint nodeSnap, segmentSnap;
576-
double distanceNode = DBL_MAX;
577-
double distanceSegment = DBL_MAX;
576+
double distanceNode = std::numeric_limits<double>::max();
577+
double distanceSegment = std::numeric_limits<double>::max();
578578
if ( snapPoint )
579579
{
580580
nodeSnap = snapPoint->getSnapPoint( p );

src/app/qgsmaptoolsimplify.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ void QgsMapToolSimplify::selectOneFeature( QPoint canvasPoint )
429429
QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterRect( selectRect ).setSubsetOfAttributes( QgsAttributeList() ) );
430430

431431
QgsGeometry geometry = QgsGeometry::fromPointXY( layerCoords );
432-
double minDistance = DBL_MAX;
432+
double minDistance = std::numeric_limits<double>::max();
433433
double currentDistance;
434434
QgsFeature minDistanceFeature;
435435
QgsFeature f;

src/core/annotations/qgsannotation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ void QgsAnnotation::updateBalloon()
174174
segmentList << segment( 3 );
175175

176176
//find closest edge / closest edge point
177-
double minEdgeDist = DBL_MAX;
177+
double minEdgeDist = std::numeric_limits<double>::max();
178178
int minEdgeIndex = -1;
179179
QLineF minEdge;
180180
QgsPointXY minEdgePoint;

src/core/geometry/qgsgeometry.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -917,10 +917,10 @@ QgsRectangle QgsGeometry::boundingBox() const
917917
QgsGeometry QgsGeometry::orientedMinimumBoundingBox( double &area, double &angle, double &width, double &height ) const
918918
{
919919
QgsRectangle minRect;
920-
area = DBL_MAX;
920+
area = std::numeric_limits<double>::max();
921921
angle = 0;
922-
width = DBL_MAX;
923-
height = DBL_MAX;
922+
width = std::numeric_limits<double>::max();
923+
height = std::numeric_limits<double>::max();
924924

925925
if ( !d->geometry || d->geometry->nCoordinates() < 2 )
926926
return QgsGeometry();

src/core/geometry/qgsinternalgeometryengine.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ QgsPoint surfacePoleOfInaccessibility( const QgsSurface *surface, double precisi
234234
QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision, double *distanceFromBoundary ) const
235235
{
236236
if ( distanceFromBoundary )
237-
*distanceFromBoundary = DBL_MAX;
237+
*distanceFromBoundary = std::numeric_limits<double>::max();
238238

239239
if ( !mGeometry || mGeometry->isEmpty() )
240240
return QgsGeometry();
@@ -255,7 +255,7 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision,
255255
continue;
256256

257257
found = true;
258-
double dist = DBL_MAX;
258+
double dist = std::numeric_limits<double>::max();
259259
QgsPoint p = surfacePoleOfInaccessibility( surface, precision, dist );
260260
if ( dist > maxDist )
261261
{
@@ -277,7 +277,7 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision,
277277
if ( !surface )
278278
return QgsGeometry();
279279

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

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

389389
bool isClosed = ring->isClosed();
390390
int numPoints = ring->numPoints();

src/core/geometry/qgspolygon.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ double QgsPolygon::pointDistanceToBoundary( double x, double y ) const
239239
return std::numeric_limits< double >::quiet_NaN();
240240

241241
bool inside = false;
242-
double minimumDistance = DBL_MAX;
242+
double minimumDistance = std::numeric_limits<double>::max();
243243
double minDistX = 0.0;
244244
double minDistY = 0.0;
245245

src/core/layout/qgslayoutaligner.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ void QgsLayoutAligner::distributeItems( QgsLayout *layout, const QList<QgsLayout
120120
};
121121

122122

123-
double minCoord = DBL_MAX;
124-
double maxCoord = -DBL_MAX;
123+
double minCoord = std::numeric_limits<double>::max();
124+
double maxCoord = std::numeric_limits<double>::lowest();
125125
QMap< double, QgsLayoutItem * > itemCoords;
126126
for ( QgsLayoutItem *item : items )
127127
{

src/core/layout/qgslayoutsnapper.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ QPointF QgsLayoutSnapper::snapPointsToGrid( const QList<QPointF> &points, double
206206

207207
double deltaX = 0;
208208
double deltaY = 0;
209-
double smallestDiffX = DBL_MAX;
210-
double smallestDiffY = DBL_MAX;
209+
double smallestDiffX = std::numeric_limits<double>::max();
210+
double smallestDiffY = std::numeric_limits<double>::max();
211211
for ( QPointF point : points )
212212
{
213213
//calculate y offset to current page
@@ -278,7 +278,7 @@ double QgsLayoutSnapper::snapPointsToGuides( const QList<double> &points, Qt::Or
278278
double alignThreshold = mTolerance / scaleFactor;
279279

280280
double bestDelta = 0;
281-
double smallestDiff = DBL_MAX;
281+
double smallestDiff = std::numeric_limits<double>::max();
282282

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

327327
double bestDelta = 0;
328-
double smallestDiff = DBL_MAX;
328+
double smallestDiff = std::numeric_limits<double>::max();
329329
double closest = 0;
330330
const QList<QGraphicsItem *> itemList = mLayout->items();
331331
QList< double > currentCoords;

src/core/pal/costcalculator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ PolygonCostCalculator::PolygonCostCalculator( LabelPosition *lp ) : lp( lp )
224224
px = ( lp->x[0] + lp->x[2] ) / 2.0;
225225
py = ( lp->y[0] + lp->y[2] ) / 2.0;
226226

227-
dist = DBL_MAX;
227+
dist = std::numeric_limits<double>::max();
228228
ok = false;
229229
}
230230

src/core/pal/feature.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ void FeaturePart::extractCoords( const GEOSGeometry *geom )
122122
coordSeq = GEOSGeom_getCoordSeq_r( geosctxt, geom );
123123

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

128128
// initialize coordinate arrays
129129
deleteCoords();

src/core/pal/labelposition.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,10 @@ void LabelPosition::getBoundingBox( double amin[2], double amax[2] ) const
376376
}
377377
else
378378
{
379-
amin[0] = DBL_MAX;
380-
amax[0] = -DBL_MAX;
381-
amin[1] = DBL_MAX;
382-
amax[1] = -DBL_MAX;
379+
amin[0] = std::numeric_limits<double>::max();
380+
amax[0] = std::numeric_limits<double>::lowest();
381+
amin[1] = std::numeric_limits<double>::max();
382+
amax[1] = std::numeric_limits<double>::lowest();
383383
}
384384
for ( int c = 0; c < 4; c++ )
385385
{

src/core/pal/pal.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom
323323
Feats *feat = nullptr;
324324

325325
// Filtering label positions against obstacles
326-
amin[0] = amin[1] = -DBL_MAX;
327-
amax[0] = amax[1] = DBL_MAX;
326+
amin[0] = amin[1] = std::numeric_limits<double>::lowest();
327+
amax[0] = amax[1] = std::numeric_limits<double>::max();
328328
FilterContext filterCtx;
329329
filterCtx.cdtsIndex = prob->candidates;
330330
filterCtx.pal = this;

src/core/pal/pointset.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void PointSet::splitPolygons( QLinkedList<PointSet *> &shapes_toProcess,
395395
int ps = -1, pe = -1, fps = -1, fpe = -1;
396396
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)
397397
{
398-
c = DBL_MAX;
398+
c = std::numeric_limits<double>::max();
399399

400400
// iterate on all shape points except points which are in the hole
401401
bool isValid;
@@ -568,17 +568,17 @@ CHullBox *PointSet::compute_chull_bbox()
568568
double width;
569569
double length;
570570

571-
double best_area = DBL_MAX;
571+
double best_area = std::numeric_limits<double>::max();
572572
double best_alpha = -1;
573573
double best_bb[16];
574574
double best_length = 0;
575575
double best_width = 0;
576576

577577

578-
bbox[0] = DBL_MAX;
579-
bbox[1] = DBL_MAX;
580-
bbox[2] = - DBL_MAX;
581-
bbox[3] = - DBL_MAX;
578+
bbox[0] = std::numeric_limits<double>::max();
579+
bbox[1] = std::numeric_limits<double>::max();
580+
bbox[2] = std::numeric_limits<double>::lowest();
581+
bbox[3] = std::numeric_limits<double>::lowest();
582582

583583
for ( i = 0; i < cHullSize; i++ )
584584
{
@@ -632,7 +632,7 @@ CHullBox *PointSet::compute_chull_bbox()
632632

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

635-
best_cp = DBL_MAX;
635+
best_cp = std::numeric_limits<double>::max();
636636
for ( j = 0; j < nbPoints; j++ )
637637
{
638638
cp = GeomFunction::cross_product( bb[i + 2], bb[i + 3], bb[i], bb[i + 1], x[cHull[j]], y[cHull[j]] );

src/core/pal/pointset.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ namespace pal
186186
const GEOSPreparedGeometry *preparedGeom() const;
187187
void invalidateGeos();
188188

189-
double xmin = DBL_MAX;
190-
double xmax = -DBL_MAX;
191-
double ymin = DBL_MAX;
192-
double ymax = -DBL_MAX;
189+
double xmin = std::numeric_limits<double>::max();
190+
double xmax = std::numeric_limits<double>::lowest();
191+
double ymin = std::numeric_limits<double>::max();
192+
double ymax = std::numeric_limits<double>::lowest();
193193

194194
private:
195195

src/core/pal/problem.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ double Problem::popmusic_tabu( SubPart *part )
917917
while ( it < stop_it && best_cost >= EPSILON )
918918
{
919919
actualizeTabuCandidateList( m, it, nbOverlap, &candidateListSize, candidateBaseFactor, &candidateFactor, minCandidateListSize, reductionFactor, minTabuTSize, tabuFactor, &tenure, probSize );
920-
delta_min = DBL_MAX;
920+
delta_min = std::numeric_limits<double>::max();
921921
choosed_feat = -1;
922922
choosed_label = -2;
923923
candidateId = -1;
@@ -1167,7 +1167,7 @@ inline Chain *Problem::chain( SubPart *part, int seed )
11671167

11681168
double delta;
11691169
double delta_min;
1170-
double delta_best = DBL_MAX;
1170+
double delta_best = std::numeric_limits<double>::max();
11711171
double delta_tmp;
11721172

11731173
int next_seed;
@@ -1203,7 +1203,7 @@ inline Chain *Problem::chain( SubPart *part, int seed )
12031203
{
12041204
subseed = sub[seed];
12051205
seedNbLp = featNbLp[subseed];
1206-
delta_min = DBL_MAX;
1206+
delta_min = std::numeric_limits<double>::max();
12071207
next_seed = -1;
12081208
retainedLabel = -2;
12091209

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

14481448
double delta;
14491449
double delta_min;
1450-
double delta_best = DBL_MAX;
1450+
double delta_best = std::numeric_limits<double>::max();
14511451
double delta_tmp;
14521452

14531453
int next_seed;
@@ -1482,7 +1482,7 @@ inline Chain *Problem::chain( int seed )
14821482
while ( seed != -1 )
14831483
{
14841484
seedNbLp = featNbLp[seed];
1485-
delta_min = DBL_MAX;
1485+
delta_min = std::numeric_limits<double>::max();
14861486

14871487
next_seed = -1;
14881488
retainedLabel = -2;

src/core/processing/qgsprocessingparameters.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2200,9 +2200,9 @@ QString QgsProcessingParameterNumber::toolTip() const
22002200
{
22012201
QString text = QgsProcessingParameterDefinition::toolTip();
22022202
QStringList parts;
2203-
if ( mMin > -DBL_MAX + 1 )
2203+
if ( mMin > std::numeric_limits<double>::lowest() + 1 )
22042204
parts << QObject::tr( "Minimum value: %1" ).arg( mMin );
2205-
if ( mMax < DBL_MAX )
2205+
if ( mMax < std::numeric_limits<double>::max() )
22062206
parts << QObject::tr( "Maximum value: %1" ).arg( mMax );
22072207
if ( mDefault.isValid() )
22082208
parts << QObject::tr( "Default value: %1" ).arg( mDataType == Integer ? mDefault.toInt() : mDefault.toDouble() );

src/core/processing/qgsprocessingparameters.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1246,8 +1246,8 @@ class CORE_EXPORT QgsProcessingParameterNumber : public QgsProcessingParameterDe
12461246

12471247
private:
12481248

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

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

12751275
/**
12761276
* Returns the type name for the parameter class.

src/core/qgsmaprendererjob.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs
200200
// E.g. longitude -200 to +160 would be understood as +40 to +160 due to periodicity.
201201
// We could try to clamp coords to (-180,180) for lon resp. (-90,90) for lat,
202202
// but this seems like a safer choice.
203-
extent = QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
203+
extent = QgsRectangle( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
204204
else
205205
extent = ct.transformBoundingBox( extent, QgsCoordinateTransform::ReverseTransform );
206206
}
@@ -209,8 +209,8 @@ bool QgsMapRendererJob::reprojectToLayerExtent( const QgsMapLayer *ml, const Qgs
209209
{
210210
Q_UNUSED( cse );
211211
QgsDebugMsg( "Transform error caught" );
212-
extent = QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
213-
r2 = QgsRectangle( -DBL_MAX, -DBL_MAX, DBL_MAX, DBL_MAX );
212+
extent = QgsRectangle( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
213+
r2 = QgsRectangle( std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() );
214214
}
215215

216216
return split;

src/core/qgsrendercontext.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ double QgsRenderContext::convertToMapUnits( double size, QgsUnitTypes::RenderUni
328328
case QgsUnitTypes::RenderMapUnits:
329329
{
330330
// check scale
331-
double minSizeMU = -DBL_MAX;
331+
double minSizeMU = std::numeric_limits<double>::lowest();
332332
if ( scale.minSizeMMEnabled )
333333
{
334334
minSizeMU = scale.minSizeMM * mScaleFactor * mup;
@@ -339,7 +339,7 @@ double QgsRenderContext::convertToMapUnits( double size, QgsUnitTypes::RenderUni
339339
}
340340
size = std::max( size, minSizeMU );
341341

342-
double maxSizeMU = DBL_MAX;
342+
double maxSizeMU = std::numeric_limits<double>::max();
343343
if ( scale.maxSizeMMEnabled )
344344
{
345345
maxSizeMU = scale.maxSizeMM * mScaleFactor * mup;

src/core/qgsvectordataprovider.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <QTextCodec>
1717

18-
#include <cfloat> // for DBL_MAX
18+
#include <cfloat>
1919
#include <climits>
2020
#include <limits>
2121

src/core/raster/qgsrasterlayerrenderer.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer *layer, QgsRender
9191
if ( rendererContext.coordinateTransform().isValid() )
9292
{
9393
QgsDebugMsgLevel( "coordinateTransform set -> project extents.", 4 );
94-
if ( rendererContext.extent().xMinimum() == -DBL_MAX &&
95-
rendererContext.extent().yMinimum() == -DBL_MAX &&
96-
rendererContext.extent().xMaximum() == DBL_MAX &&
97-
rendererContext.extent().yMaximum() == DBL_MAX )
94+
if ( rendererContext.extent().xMinimum() == std::numeric_limits<double>::lowest() &&
95+
rendererContext.extent().yMinimum() == std::numeric_limits<double>::lowest() &&
96+
rendererContext.extent().xMaximum() == std::numeric_limits<double>::max() &&
97+
rendererContext.extent().yMaximum() == std::numeric_limits<double>::max() )
9898
{
9999
// We get in this situation if the view CRS is geographical and the
100100
// extent goes beyond -180,-90,180,90. To avoid reprojection issues to the

0 commit comments

Comments
 (0)