Skip to content

Commit 725301a

Browse files
committed
Make more use of math constants
1 parent 7f44737 commit 725301a

18 files changed

+47
-47
lines changed

python/core/qgsdistancearea.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Constructor
179179
:rtype: float
180180
%End
181181

182-
double measureLineProjected( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI / 2, QgsPointXY *projectedPoint /Out/ = 0 ) const;
182+
double measureLineProjected( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI_2, QgsPointXY *projectedPoint /Out/ = 0 ) const;
183183
%Docstring
184184
Calculates the distance from one point with distance in meters and azimuth (direction)
185185
When the sourceCrs() is geographic, computeSpheroidProject() will be called
@@ -279,7 +279,7 @@ Constructor
279279
:rtype: float
280280
%End
281281

282-
QgsPointXY computeSpheroidProject( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI / 2 ) const;
282+
QgsPointXY computeSpheroidProject( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI_2 ) const;
283283
%Docstring
284284
Given a location, an azimuth and a distance, computes the
285285
location of the projected point. Based on Vincenty's formula

src/core/composer/qgscomposerarrow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,18 +388,18 @@ double QgsComposerArrow::computeMarkerMargin() const
388388
{
389389
if ( mMarkerMode == DefaultMarker )
390390
{
391-
margin = mPen.widthF() / std::sqrt( 2.0 ) + mArrowHeadWidth / 2.0;
391+
margin = mPen.widthF() * M_SQRT1_2 + mArrowHeadWidth / 2.0;
392392
}
393393
else if ( mMarkerMode == NoMarker )
394394
{
395-
margin = mPen.widthF() / std::sqrt( 2.0 );
395+
margin = mPen.widthF() * M_SQRT1_2;
396396
}
397397
else if ( mMarkerMode == SVGMarker )
398398
{
399399
double startMarkerMargin = std::sqrt( 0.25 * ( mStartArrowHeadHeight * mStartArrowHeadHeight + mArrowHeadWidth * mArrowHeadWidth ) );
400400
double stopMarkerMargin = std::sqrt( 0.25 * ( mStopArrowHeadHeight * mStopArrowHeadHeight + mArrowHeadWidth * mArrowHeadWidth ) );
401401
double markerMargin = std::max( startMarkerMargin, stopMarkerMargin );
402-
margin = std::max( mPen.widthF() / std::sqrt( 2.0 ), markerMargin );
402+
margin = std::max( mPen.widthF() * M_SQRT1_2, markerMargin );
403403
}
404404
}
405405
return margin;

src/core/effects/qgsshadoweffect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ void QgsShadowEffect::draw( QgsRenderContext &context )
5656
double offsetDist = context.convertToPainterUnits( mOffsetDist, mOffsetUnit, mOffsetMapUnitScale );
5757

5858
double angleRad = mOffsetAngle * M_PI / 180; // to radians
59-
QPointF transPt( -offsetDist * std::cos( angleRad + M_PI / 2 ),
60-
-offsetDist * std::sin( angleRad + M_PI / 2 ) );
59+
QPointF transPt( -offsetDist * std::cos( angleRad + M_PI_2 ),
60+
-offsetDist * std::sin( angleRad + M_PI_2 ) );
6161

6262
//transparency, scale
6363
QgsImageOperation::multiplyOpacity( colorisedIm, mOpacity );

src/core/expression/qgsexpressionfunction.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,9 +2645,9 @@ static QVariant fcnAzimuth( const QVariantList &values, const QgsExpressionConte
26452645
if ( pt1->y() == pt2->y() )
26462646
{
26472647
if ( pt1->x() < pt2->x() )
2648-
return M_PI / 2;
2648+
return M_PI_2;
26492649
else if ( pt1->x() > pt2->x() )
2650-
return M_PI + ( M_PI / 2 );
2650+
return M_PI + ( M_PI_2 );
26512651
else
26522652
return 0;
26532653
}
@@ -2661,7 +2661,7 @@ static QVariant fcnAzimuth( const QVariantList &values, const QgsExpressionConte
26612661
else /* ( pt1->y() > pt2->y() ) - equality case handled above */
26622662
{
26632663
return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
2664-
+ ( M_PI / 2 );
2664+
+ ( M_PI_2 );
26652665
}
26662666
}
26672667

@@ -2675,7 +2675,7 @@ static QVariant fcnAzimuth( const QVariantList &values, const QgsExpressionConte
26752675
else /* ( pt1->y() < pt2->y() ) - equality case handled above */
26762676
{
26772677
return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
2678-
+ ( M_PI + ( M_PI / 2 ) );
2678+
+ ( M_PI + ( M_PI_2 ) );
26792679
}
26802680
}
26812681
}
@@ -3791,7 +3791,7 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
37913791
<< new QgsStaticExpressionFunction( QStringLiteral( "degrees" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "radians" ) ), fcnDegrees, QStringLiteral( "Math" ) )
37923792
<< new QgsStaticExpressionFunction( QStringLiteral( "azimuth" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "point_b" ) ), fcnAzimuth, QStringList() << QStringLiteral( "Math" ) << QStringLiteral( "GeometryGroup" ) )
37933793
<< new QgsStaticExpressionFunction( QStringLiteral( "inclination" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "point_b" ) ), fcnInclination, QStringList() << QStringLiteral( "Math" ) << QStringLiteral( "GeometryGroup" ) )
3794-
<< new QgsStaticExpressionFunction( QStringLiteral( "project" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "point" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "distance" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "azimuth" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "elevation" ), true, M_PI / 2 ), fcnProject, QStringLiteral( "GeometryGroup" ) )
3794+
<< new QgsStaticExpressionFunction( QStringLiteral( "project" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "point" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "distance" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "azimuth" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "elevation" ), true, M_PI_2 ), fcnProject, QStringLiteral( "GeometryGroup" ) )
37953795
<< new QgsStaticExpressionFunction( QStringLiteral( "abs" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "value" ) ), fcnAbs, QStringLiteral( "Math" ) )
37963796
<< new QgsStaticExpressionFunction( QStringLiteral( "cos" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "angle" ) ), fcnCos, QStringLiteral( "Math" ) )
37973797
<< new QgsStaticExpressionFunction( QStringLiteral( "sin" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "angle" ) ), fcnSin, QStringLiteral( "Math" ) )

src/core/geometry/qgscircularstring.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ void QgsCircularString::sumUpArea( double &sum ) const
772772
bool circlePointLeftOfLine = QgsGeometryUtils::leftOfLine( p2.x(), p2.y(), p1.x(), p1.y(), p3.x(), p3.y() ) < 0;
773773
bool centerPointLeftOfLine = QgsGeometryUtils::leftOfLine( centerX, centerY, p1.x(), p1.y(), p3.x(), p3.y() ) < 0;
774774

775-
double cov = 0.5 - d * std::sqrt( r2 - d * d ) / ( M_PI * r2 ) - 1 / M_PI * std::asin( d / radius );
775+
double cov = 0.5 - d * std::sqrt( r2 - d * d ) / ( M_PI * r2 ) - M_1_PI * std::asin( d / radius );
776776
double circleChordArea = 0;
777777
if ( circlePointLeftOfLine == centerPointLeftOfLine )
778778
{

src/core/geometry/qgsgeometryutils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ QgsLineString QgsGeometryUtils::perpendicularSegment( const QgsPoint &p, const Q
10931093
double QgsGeometryUtils::lineAngle( double x1, double y1, double x2, double y2 )
10941094
{
10951095
double at = std::atan2( y2 - y1, x2 - x1 );
1096-
double a = -at + M_PI / 2.0;
1096+
double a = -at + M_PI_2;
10971097
return normalizedAngle( a );
10981098
}
10991099

@@ -1107,7 +1107,7 @@ double QgsGeometryUtils::angleBetweenThreePoints( double x1, double y1, double x
11071107
double QgsGeometryUtils::linePerpendicularAngle( double x1, double y1, double x2, double y2 )
11081108
{
11091109
double a = lineAngle( x1, y1, x2, y2 );
1110-
a += ( M_PI / 2.0 );
1110+
a += M_PI_2;
11111111
return normalizedAngle( a );
11121112
}
11131113

src/core/geometry/qgstriangle.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ QVector<double> QgsTriangle::angles() const
386386
double a2 = std::fmod( QgsGeometryUtils::angleBetweenThreePoints( ax, ay, bx, by, cx, cy ), M_PI );
387387
double a3 = std::fmod( QgsGeometryUtils::angleBetweenThreePoints( bx, by, cx, cy, ax, ay ), M_PI );
388388

389-
angles.append( ( a1 > M_PI / 2 ? a1 - M_PI / 2 : a1 ) );
390-
angles.append( ( a2 > M_PI / 2 ? a2 - M_PI / 2 : a2 ) );
391-
angles.append( ( a3 > M_PI / 2 ? a3 - M_PI / 2 : a3 ) );
389+
angles.append( ( a1 > M_PI_2 ? a1 - M_PI_2 : a1 ) );
390+
angles.append( ( a2 > M_PI_2 ? a2 - M_PI_2 : a2 ) );
391+
angles.append( ( a3 > M_PI_2 ? a3 - M_PI_2 : a3 ) );
392392

393393
return angles;
394394
}
@@ -419,7 +419,7 @@ bool QgsTriangle::isRight( double angleTolerance ) const
419419
QVector<double>::iterator ita = a.begin();
420420
while ( ita != a.end() )
421421
{
422-
if ( qgsDoubleNear( *ita, M_PI / 2.0, angleTolerance ) )
422+
if ( qgsDoubleNear( *ita, M_PI_2, angleTolerance ) )
423423
return true;
424424
ita++;
425425
}

src/core/pal/feature.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ int FeaturePart::createCandidatesAroundPoint( double x, double y, QList< LabelPo
443443
double candidateAngleIncrement = 2 * M_PI / numberCandidates; /* angle bw 2 pos */
444444

445445
/* various angles */
446-
double a90 = M_PI / 2;
446+
double a90 = M_PI_2;
447447
double a180 = M_PI;
448448
double a270 = a180 + a90;
449449
double a360 = 2 * M_PI;
@@ -470,7 +470,7 @@ int FeaturePart::createCandidatesAroundPoint( double x, double y, QList< LabelPo
470470

471471
int i;
472472
double angleToCandidate;
473-
for ( i = 0, angleToCandidate = M_PI / 4; i < numberCandidates; i++, angleToCandidate += candidateAngleIncrement )
473+
for ( i = 0, angleToCandidate = M_PI_4; i < numberCandidates; i++, angleToCandidate += candidateAngleIncrement )
474474
{
475475
double labelX = x;
476476
double labelY = y;
@@ -763,12 +763,12 @@ int FeaturePart::createCandidatesAlongLineNearStraightSegments( QList<LabelPosit
763763
else
764764
angle = std::atan2( candidateEndY - candidateStartY, candidateEndX - candidateStartX );
765765

766-
beta = angle + M_PI / 2;
766+
beta = angle + M_PI_2;
767767

768768
if ( mLF->layer()->arrangement() == QgsPalLayerSettings::Line )
769769
{
770770
// find out whether the line direction for this candidate is from right to left
771-
bool isRightToLeft = ( angle > M_PI / 2 || angle <= -M_PI / 2 );
771+
bool isRightToLeft = ( angle > M_PI_2 || angle <= -M_PI_2 );
772772
// meaning of above/below may be reversed if using map orientation and the line has right-to-left direction
773773
bool reversed = ( ( flags & FLAG_MAP_ORIENTATION ) ? isRightToLeft : false );
774774
bool aboveLine = ( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) );
@@ -908,12 +908,12 @@ int FeaturePart::createCandidatesAlongLineNearMidpoint( QList<LabelPosition *> &
908908
else
909909
angle = std::atan2( candidateEndY - candidateStartY, candidateEndX - candidateStartX );
910910

911-
beta = angle + M_PI / 2;
911+
beta = angle + M_PI_2;
912912

913913
if ( mLF->layer()->arrangement() == QgsPalLayerSettings::Line )
914914
{
915915
// find out whether the line direction for this candidate is from right to left
916-
bool isRightToLeft = ( angle > M_PI / 2 || angle <= -M_PI / 2 );
916+
bool isRightToLeft = ( angle > M_PI_2 || angle <= -M_PI_2 );
917917
// meaning of above/below may be reversed if using map orientation and the line has right-to-left direction
918918
bool reversed = ( ( flags & FLAG_MAP_ORIENTATION ) ? isRightToLeft : false );
919919
bool aboveLine = ( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) );
@@ -1125,7 +1125,7 @@ LabelPosition *FeaturePart::curvedPlacementAtOffset( PointSet *path_positions, d
11251125
while ( render_angle >= 2 * M_PI ) render_angle -= 2 * M_PI;
11261126
while ( render_angle < 0 ) render_angle += 2 * M_PI;
11271127

1128-
if ( render_angle > M_PI / 2 && render_angle < 1.5 * M_PI )
1128+
if ( render_angle > M_PI_2 && render_angle < 1.5 * M_PI )
11291129
slp->incrementUpsideDownCharCount();
11301130
}
11311131
// END FOR
@@ -1136,7 +1136,7 @@ LabelPosition *FeaturePart::curvedPlacementAtOffset( PointSet *path_positions, d
11361136
static LabelPosition *_createCurvedCandidate( LabelPosition *lp, double angle, double dist )
11371137
{
11381138
LabelPosition *newLp = new LabelPosition( *lp );
1139-
newLp->offsetPosition( dist * std::cos( angle + M_PI / 2 ), dist * std::sin( angle + M_PI / 2 ) );
1139+
newLp->offsetPosition( dist * std::cos( angle + M_PI_2 ), dist * std::sin( angle + M_PI_2 ) );
11401140
return newLp;
11411141
}
11421142

@@ -1424,18 +1424,18 @@ int FeaturePart::createCandidatesForPolygon( QList< LabelPosition *> &lPos, Poin
14241424
}
14251425
else if ( box->length > 1.5 * labelWidth && box->width > 1.5 * labelWidth )
14261426
{
1427-
if ( box->alpha <= M_PI / 4 )
1427+
if ( box->alpha <= M_PI_4 )
14281428
{
14291429
alpha = box->alpha;
14301430
}
14311431
else
14321432
{
1433-
alpha = box->alpha - M_PI / 2;
1433+
alpha = box->alpha - M_PI_2;
14341434
}
14351435
}
14361436
else if ( box->length > box->width )
14371437
{
1438-
alpha = box->alpha - M_PI / 2;
1438+
alpha = box->alpha - M_PI_2;
14391439
}
14401440
else
14411441
{
@@ -1464,8 +1464,8 @@ int FeaturePart::createCandidatesForPolygon( QList< LabelPosition *> &lPos, Poin
14641464
for ( py = py0; py <= box->length; py += dy )
14651465
{
14661466

1467-
rx = std::cos( box->alpha ) * px + std::cos( box->alpha - M_PI / 2 ) * py;
1468-
ry = std::sin( box->alpha ) * px + std::sin( box->alpha - M_PI / 2 ) * py;
1467+
rx = std::cos( box->alpha ) * px + std::cos( box->alpha - M_PI_2 ) * py;
1468+
ry = std::sin( box->alpha ) * px + std::sin( box->alpha - M_PI_2 ) * py;
14691469

14701470
rx += box->x[0];
14711471
ry += box->y[0];

src/core/pal/geomfunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ bool GeomFunction::containsCandidate( const GEOSPreparedGeometry *geom, double x
329329
GEOSCoordSeq_setY_r( geosctxt, coord, 0, y );
330330
if ( !qgsDoubleNear( alpha, 0.0 ) )
331331
{
332-
double beta = alpha + ( M_PI / 2 );
332+
double beta = alpha + M_PI_2;
333333
double dx1 = std::cos( alpha ) * width;
334334
double dy1 = std::sin( alpha ) * width;
335335
double dx2 = std::cos( beta ) * height;

src/core/pal/labelposition.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ LabelPosition::LabelPosition( int id, double x1, double y1, double w, double h,
7070
while ( this->alpha < 0 )
7171
this->alpha += 2 * M_PI;
7272

73-
double beta = this->alpha + ( M_PI / 2 );
73+
double beta = this->alpha + M_PI_2;
7474

7575
double dx1, dx2, dy1, dy2;
7676

@@ -94,7 +94,7 @@ LabelPosition::LabelPosition( int id, double x1, double y1, double w, double h,
9494

9595
// upside down ? (curved labels are always correct)
9696
if ( !feature->layer()->isCurved() &&
97-
this->alpha > M_PI / 2 && this->alpha <= 3 * M_PI / 2 )
97+
this->alpha > M_PI_2 && this->alpha <= 3 * M_PI_2 )
9898
{
9999
if ( feature->showUprightLabels() )
100100
{

src/core/pal/pointset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ CHullBox *PointSet::compute_chull_bbox()
656656
for ( i = 0; i < 16; i += 4 )
657657
{
658658

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

661661
best_cp = DBL_MAX;
662662
for ( j = 0; j < nbPoints; j++ )

src/core/qgsdistancearea.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ void QgsDistanceArea::computeAreaInit()
662662
m_QbarC = - ( 3.0 / 25.0 ) * e4 - ( 12.0 / 35.0 ) * e6;
663663
m_QbarD = ( 4.0 / 49.0 ) * e6;
664664

665-
m_Qp = getQ( M_PI / 2 );
665+
m_Qp = getQ( M_PI_2 );
666666
m_E = 4 * M_PI * m_Qp * m_AE;
667667
if ( m_E < 0.0 )
668668
m_E = -m_E;

src/core/qgsdistancearea.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class CORE_EXPORT QgsDistanceArea
193193
* \see sourceCrs()
194194
* \see computeSpheroidProject()
195195
*/
196-
double measureLineProjected( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI / 2, QgsPointXY *projectedPoint SIP_OUT = nullptr ) const;
196+
double measureLineProjected( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI_2, QgsPointXY *projectedPoint SIP_OUT = nullptr ) const;
197197

198198
/**
199199
* Returns the units of distance for length calculations made by this object.
@@ -286,7 +286,7 @@ class CORE_EXPORT QgsDistanceArea
286286
* \param azimuth - azimuth in radians, clockwise from North
287287
* \return p2 - location of projected point as longitude/latitude.
288288
*/
289-
QgsPointXY computeSpheroidProject( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI / 2 ) const;
289+
QgsPointXY computeSpheroidProject( const QgsPointXY &p1, double distance = 1, double azimuth = M_PI_2 ) const;
290290

291291
private:
292292

src/core/qgstextrenderer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,8 +2198,8 @@ void QgsTextRenderer::drawBackground( QgsRenderContext &context, QgsTextRenderer
21982198
else if ( background.type() == QgsTextBackgroundSettings::ShapeEllipse )
21992199
{
22002200
// start with label bound by ellipse
2201-
h = h / std::sqrt( 2.0 ) * 2;
2202-
w = w / std::sqrt( 2.0 ) * 2;
2201+
h = h * M_SQRT1_2 * 2;
2202+
w = w * M_SQRT1_2 * 2;
22032203
}
22042204

22052205
double bufferWidth = context.convertToPainterUnits( background.size().width(), background.sizeUnit(),
@@ -2388,8 +2388,8 @@ void QgsTextRenderer::drawShadow( QgsRenderContext &context, const QgsTextRender
23882388
angleRad -= ( component.rotation * M_PI / 180 + component.rotationOffset * M_PI / 180 );
23892389
}
23902390

2391-
QPointF transPt( -offsetDist * std::cos( angleRad + M_PI / 2 ),
2392-
-offsetDist * std::sin( angleRad + M_PI / 2 ) );
2391+
QPointF transPt( -offsetDist * std::cos( angleRad + M_PI_2 ),
2392+
-offsetDist * std::sin( angleRad + M_PI_2 ) );
23932393

23942394
p->save();
23952395
p->setRenderHint( QPainter::SmoothPixmapTransform );

src/core/symbology/qgslinesymbollayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ class MyLine
672672
// return angle in radians
673673
double angle()
674674
{
675-
double a = ( mVertical ? M_PI / 2 : std::atan( mT ) );
675+
double a = ( mVertical ? M_PI_2 : std::atan( mT ) );
676676

677677
if ( !mIncreasing )
678678
a += M_PI;

src/plugins/georeferencer/qgsleastsquares.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void normalizeCoordinates( const QVector<QgsPointXY> &coords, QVector<QgsPointXY
201201
}
202202
meanDist *= 1.0 / coords.size();
203203

204-
double OOD = meanDist / std::sqrt( 2.0 );
204+
double OOD = meanDist * M_SQRT1_2;
205205
double D = 1.0 / OOD;
206206
normalizedCoords.resize( coords.size() );
207207
for ( int i = 0; i < coords.size(); i++ )

src/server/qgswmsprojectparser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ void QgsWmsProjectParser::addLayers( QDomDocument &doc,
13211321
if ( version == QLatin1String( "1.1.1" ) )
13221322
{
13231323
double OGC_PX_M = 0.00028; // OGC reference pixel size in meter, also used by qgis
1324-
double SCALE_TO_SCALEHINT = OGC_PX_M * std::sqrt( 2.0 );
1324+
double SCALE_TO_SCALEHINT = OGC_PX_M * M_SQRT2;
13251325

13261326
QDomElement scaleHintElem = doc.createElement( QStringLiteral( "ScaleHint" ) );
13271327
scaleHintElem.setAttribute( QStringLiteral( "min" ), QString::number( currentLayer->maximumScale() * SCALE_TO_SCALEHINT ) );

src/server/services/wms/qgswmsgetcapabilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ namespace QgsWms
10011001
if ( version == QLatin1String( "1.1.1" ) )
10021002
{
10031003
double OGC_PX_M = 0.00028; // OGC reference pixel size in meter, also used by qgis
1004-
double SCALE_TO_SCALEHINT = OGC_PX_M * std::sqrt( 2.0 );
1004+
double SCALE_TO_SCALEHINT = OGC_PX_M * M_SQRT2;
10051005

10061006
QDomElement scaleHintElem = doc.createElement( QStringLiteral( "ScaleHint" ) );
10071007
scaleHintElem.setAttribute( QStringLiteral( "min" ), QString::number( l->maximumScale() * SCALE_TO_SCALEHINT ) );

0 commit comments

Comments
 (0)