Skip to content
Permalink
Browse files

More DBL_MIN/MAX_EPSILON upgrades

  • Loading branch information
nyalldawson committed Jun 16, 2018
1 parent ce6fc8f commit 17cd2fd5f3de99c6e1b09be2ad475c2f331f558f
@@ -434,9 +434,9 @@ sub fix_annotations {

sub fix_constants {
my $line = $_[0];
$line =~ s/\bstd::numeric_limits<double>::max\(\)/DBL_MAX/;
$line =~ s/\bstd::numeric_limits<double>::lowest\(\)/-DBL_MAX/;
$line =~ s/\bstd::numeric_limits<double>::epsilon\(\)/DBL_EPSILON/;
$line =~ s/\bstd::numeric_limits<double>::max\(\)/DBL_MAX/g;
$line =~ s/\bstd::numeric_limits<double>::lowest\(\)/-DBL_MAX/g;
$line =~ s/\bstd::numeric_limits<double>::epsilon\(\)/DBL_EPSILON/g;
return $line;
}

@@ -356,7 +356,7 @@ class CORE_EXPORT QgsAbstractGeometry
*/
virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT,
QgsVertexId &vertexAfter SIP_OUT,
int *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const = 0;
int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const = 0;

//low-level editing

@@ -486,7 +486,7 @@ class CORE_EXPORT QgsAbstractGeometry
*
* \since QGIS 3.0
*/
virtual bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) = 0;
virtual bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) = 0;

/**
* Returns approximate angle at a vertex. This is usually the average angle between adjacent
@@ -101,7 +101,7 @@ class CORE_EXPORT QgsCircularString: public QgsCurve
QgsPoint endPoint() const override;
QgsLineString *curveToLine( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override SIP_FACTORY;
QgsCircularString *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const override SIP_FACTORY;
bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) override;
bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;

void draw( QPainter &p ) const override;
void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform, bool transformZ = false ) override SIP_THROW( QgsCsException );
@@ -111,7 +111,7 @@ class CORE_EXPORT QgsCircularString: public QgsCurve
bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) override;
bool deleteVertex( QgsVertexId position ) override;
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;
bool pointAt( int node, QgsPoint &point, QgsVertexId::VertexType &type ) const override;
void sumUpArea( double &sum SIP_OUT ) const override;
bool hasCurvedSegments() const override;
@@ -68,7 +68,7 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve
QgsLineString *curveToLine( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const override SIP_FACTORY;

QgsCompoundCurve *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const override SIP_FACTORY;
bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) override;
bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;

/**
* Returns the number of curves in the geometry.
@@ -104,7 +104,7 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve
bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) override;
bool deleteVertex( QgsVertexId position ) override;
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;
bool pointAt( int node, QgsPoint &point, QgsVertexId::VertexType &type ) const override;
void sumUpArea( double &sum SIP_OUT ) const override;

@@ -63,7 +63,7 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface
QgsPolygon *surfaceToPolygon() const override SIP_FACTORY;
QgsAbstractGeometry *boundary() const override SIP_FACTORY;
QgsCurvePolygon *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const override SIP_FACTORY;
bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) override;
bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;

//curve polygon interface
int numInteriorRings() const;
@@ -130,7 +130,7 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface
int nCoordinates() const override;
int vertexNumberFromVertexId( QgsVertexId id ) const override;
bool isEmpty() const override;
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;

bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;
@@ -794,7 +794,7 @@ class CORE_EXPORT QgsGeometry
*
* \since QGIS 3.0
*/
bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false );
bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false );

/**
* Returns true if this geometry exactly intersects with a \a rectangle. This test is exact
@@ -1630,7 +1630,7 @@ class CORE_EXPORT QgsGeometry
* tolerance
* \since QGIS 2.9
*/
static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * DBL_EPSILON );
static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * std::numeric_limits<double>::epsilon() );
% MethodCode
{
sipRes = false;
@@ -68,7 +68,7 @@ class CORE_EXPORT QgsGeometryCollection: public QgsAbstractGeometry
QString geometryType() const override;
void clear() override;
QgsGeometryCollection *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const override SIP_FACTORY;
bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) override;
bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;
QgsAbstractGeometry *boundary() const override SIP_FACTORY;
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;
int vertexNumberFromVertexId( QgsVertexId id ) const override;
@@ -108,7 +108,7 @@ class CORE_EXPORT QgsGeometryCollection: public QgsAbstractGeometry
QgsCoordinateSequence coordinateSequence() const override;
int nCoordinates() const override;

double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;
bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;

//low-level editing
@@ -229,7 +229,7 @@ class CORE_EXPORT QgsLineString: public QgsCurve
void clear() override;
bool isEmpty() const override;
QgsLineString *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const override SIP_FACTORY;
bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) override;
bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;
QPolygonF asQPolygonF() const override;

bool fromWkb( QgsConstWkbPtr &wkb ) override;
@@ -271,7 +271,7 @@ class CORE_EXPORT QgsLineString: public QgsCurve

QgsLineString *reversed() const override SIP_FACTORY;

double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;
bool pointAt( int node, QgsPoint &point, QgsVertexId::VertexType &type ) const override;

QgsPoint centroid() const override;
@@ -392,7 +392,7 @@ class CORE_EXPORT QgsPoint: public QgsAbstractGeometry
int dimension() const override;
QgsPoint *clone() const override SIP_FACTORY;
QgsPoint *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const override SIP_FACTORY;
bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) override;
bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;
void clear() override;
bool fromWkb( QgsConstWkbPtr &wkb ) override;
bool fromWkt( const QString &wkt ) override;
@@ -414,7 +414,7 @@ class CORE_EXPORT QgsPoint: public QgsAbstractGeometry
bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) override;
bool deleteVertex( QgsVertexId position ) override;

double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * DBL_EPSILON ) const override;
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;
bool nextVertex( QgsVertexId &id, QgsPoint &vertex SIP_OUT ) const override;
void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT ) const override;

@@ -1186,8 +1186,8 @@ class CORE_EXPORT QgsProcessingParameterNumber : public QgsProcessingParameterDe
Type type = Integer,
const QVariant &defaultValue = QVariant(),
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()
);

/**
@@ -210,7 +210,7 @@ class CORE_EXPORT QgsPointXY
* \returns true if points are equal within specified tolerance
* \since QGIS 2.9
*/
bool compare( const QgsPointXY &other, double epsilon = 4 * DBL_EPSILON ) const;
bool compare( const QgsPointXY &other, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const;

//! equality operator
bool operator==( const QgsPointXY &other );
@@ -143,7 +143,7 @@ void QgsGrassVectorMapLayer::load()
// Read columns' description
for ( int i = 0; i < nColumns; i++ )
{
QPair<double, double> minMax( DBL_MAX, -DBL_MAX );
QPair<double, double> minMax( std::numeric_limits<double>::max(), std::numeric_limits<double>::lowest() );

dbColumn *column = db_get_table_column( databaseTable, i );

@@ -5,14 +5,18 @@
declare -a KEYWORDS=()
declare -a HINTS=()

KEYWORDS[0]="DBL_MAX"
HINTS[0]="Use the type-safe method std::numeric_limits<double>::max() instead"
KEYWORDS[0]="\-DBL_MAX"
HINTS[0]="Use the type-safe method std::numeric_limits<double>::lowest() instead"

KEYWORDS[1]="DBL_MIN"
HINTS[1]="Use the type-safe method std::numeric_limits<double>::lowest() instead"
KEYWORDS[1]="DBL_MAX"
HINTS[1]="Use the type-safe method std::numeric_limits<double>::max() instead"

KEYWORDS[2]="DBL_MIN"
HINTS[2]="Use the type-safe method std::numeric_limits<double>::min() instead (but be careful - maybe you actually want lowest!!)"

KEYWORDS[3]="DBL_EPSILON"
HINTS[3]="Use the type-safe method std::numeric_limits<double>::epsilon() instead"

KEYWORDS[2]="DBL_EPSILON"
HINTS[2]="Use the type-safe method std::numeric_limits<double>::epsilon() instead"

RES=
DIR=$(git rev-parse --show-toplevel)

0 comments on commit 17cd2fd

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