Skip to content
Permalink
Browse files

DBL_MAX -> std::numeric_limits

  • Loading branch information
nyalldawson committed Jun 15, 2018
1 parent ce74d57 commit ac17d300ca1e78766c9ce5bb513c172bcb89d698
@@ -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
@@ -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;
@@ -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 );
@@ -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 );
@@ -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;
@@ -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;
@@ -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();
@@ -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();
@@ -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 )
{
@@ -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;
@@ -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();
@@ -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;

@@ -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 )
{
@@ -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
@@ -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 )
{
@@ -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;
@@ -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;
}

@@ -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();
@@ -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++ )
{
@@ -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;
@@ -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;
@@ -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++ )
{
@@ -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]] );
@@ -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:

@@ -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;
@@ -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;
@@ -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;

@@ -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;
@@ -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;
@@ -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() );
@@ -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;
};

@@ -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.
@@ -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 );
}
@@ -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;
@@ -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;
@@ -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;
@@ -15,7 +15,7 @@

#include <QTextCodec>

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

@@ -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

0 comments on commit ac17d30

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