Skip to content

Commit 0d7b828

Browse files
committedNov 15, 2017
Update code, formatting
1 parent 8fd8b6e commit 0d7b828

File tree

3 files changed

+132
-126
lines changed

3 files changed

+132
-126
lines changed
 

‎python/core/qgscoordinateformatter.sip

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ class QgsCoordinateFormatter
2222
ensuring that only geographic coordinates and not projected coordinates are formatted to degree
2323
based formats.
2424

25-
.. note::
26-
27-
Added in version 2.14
25+
.. versionadded:: 3.0
2826
%End
2927

3028
%TypeHeaderCode
@@ -34,51 +32,52 @@ class QgsCoordinateFormatter
3432

3533
enum Format
3634
{
37-
Pair,
38-
DegreesMinutesSeconds,
39-
DegreesMinutes,
40-
DecimalDegrees,
35+
FormatPair,
36+
FormatDegreesMinutesSeconds,
37+
FormatDegreesMinutes,
38+
FormatDecimalDegrees,
4139
};
4240

4341
enum FormatFlag
4442
{
45-
DegreesUseStringSuffix,
46-
DegreesPadMinutesSeconds,
43+
FlagDegreesUseStringSuffix,
44+
FlagDegreesPadMinutesSeconds,
4745
};
4846
typedef QFlags<QgsCoordinateFormatter::FormatFlag> FormatFlags;
4947

5048

51-
static QString formatX( double x, Format format, int precision = 12, FormatFlags flags = DegreesUseStringSuffix );
49+
static QString formatX( double x, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix );
5250
%Docstring
53-
Formats an X coordinate value according to the specified parameters.
54-
@param x x-coordinate
55-
@param format string format to use for coordinate
56-
@param precision number of decimal places to include
57-
@param flags flags controlling format options
58-
@returns formatted X coordinate string
59-
@see formatY()
51+
Formats an ``x`` coordinate value according to the specified parameters.
52+
53+
The ``format`` argument indicates the desired display format for the coordinate.
54+
55+
The ``precision`` argument gives the number of decimal places to include for coordinates.
56+
57+
Optional ``flags`` can be specified to control the output format.
58+
59+
.. seealso:: formatY()
6060
:rtype: str
6161
%End
6262

63-
static QString formatY( double y, Format format, int precision = 12, FormatFlags flags = DegreesUseStringSuffix );
63+
static QString formatY( double y, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix );
6464
%Docstring
65-
Formats an Y coordinate value according to the specified parameters.
66-
@param y y-coordinate
67-
@param format string format to use for coordinate
68-
@param precision number of decimal places to include
69-
@param flags flags controlling format options
70-
@returns formatted Y coordinate string
71-
@see formatX()
65+
Formats a ``y`` coordinate value according to the specified parameters.
66+
67+
The ``format`` argument indicates the desired display format for the coordinate.
68+
69+
The ``precision`` argument gives the number of decimal places to include for coordinates.
70+
71+
Optional ``flags`` can be specified to control the output format.
72+
73+
.. seealso:: formatX()
7274
:rtype: str
7375
%End
7476

7577
static QString asPair( double x, double y, int precision = 12 );
7678
%Docstring
77-
Formats coordinates as an "x,y" pair, with optional decimal precision.
78-
@param x x-coordinate
79-
@param y y-coordinate
80-
@param precision number of decimal places to include
81-
@returns formatted coordinate string
79+
Formats coordinates as an "``x``,``y``" pair, with optional decimal ``precision`` (number
80+
of decimal places to include).
8281
:rtype: str
8382
%End
8483

‎src/core/qgscoordinateformatter.cpp

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/***************************************************************************
2-
qgscoordinateformatter.cpp
3-
--------------------------
4-
begin : Decemeber 2015
5-
copyright : (C) 2015 by Nyall Dawson
6-
email : nyall dot dawson at gmail dot com
7-
***************************************************************************/
2+
qgscoordinateformatter.cpp
3+
--------------------------
4+
begin : Decemeber 2015
5+
copyright : (C) 2015 by Nyall Dawson
6+
email : nyall dot dawson at gmail dot com
7+
***************************************************************************/
88

99
/***************************************************************************
1010
* *
@@ -24,16 +24,16 @@ QString QgsCoordinateFormatter::formatX( double x, QgsCoordinateFormatter::Forma
2424
{
2525
switch ( format )
2626
{
27-
case Pair:
27+
case FormatPair:
2828
return formatAsPair( x, precision );
2929

30-
case DegreesMinutesSeconds:
30+
case FormatDegreesMinutesSeconds:
3131
return formatXAsDegreesMinutesSeconds( x, precision, flags );
3232

33-
case DegreesMinutes:
33+
case FormatDegreesMinutes:
3434
return formatXAsDegreesMinutes( x, precision, flags );
3535

36-
case DecimalDegrees:
36+
case FormatDecimalDegrees:
3737
return formatXAsDegrees( x, precision, flags );
3838
}
3939
return QString(); //avoid warnings
@@ -43,16 +43,16 @@ QString QgsCoordinateFormatter::formatY( double y, QgsCoordinateFormatter::Forma
4343
{
4444
switch ( format )
4545
{
46-
case Pair:
46+
case FormatPair:
4747
return formatAsPair( y, precision );
4848

49-
case DegreesMinutesSeconds:
49+
case FormatDegreesMinutesSeconds:
5050
return formatYAsDegreesMinutesSeconds( y, precision, flags );
5151

52-
case DegreesMinutes:
52+
case FormatDegreesMinutes:
5353
return formatYAsDegreesMinutes( y, precision, flags );
5454

55-
case DecimalDegrees:
55+
case FormatDecimalDegrees:
5656
return formatYAsDegrees( y, precision, flags );
5757
}
5858
return QString(); //avoid warnings
@@ -68,13 +68,13 @@ QString QgsCoordinateFormatter::asPair( double x, double y, int precision )
6868

6969
QString QgsCoordinateFormatter::formatAsPair( double val, int precision )
7070
{
71-
return qIsFinite( val ) ? QString::number( val, 'f', precision ) : QObject::tr( "infinite" );
71+
return std::isfinite( val ) ? QString::number( val, 'f', precision ) : QObject::tr( "infinite" );
7272
}
7373

7474
QString QgsCoordinateFormatter::formatXAsDegreesMinutesSeconds( double val, int precision, FormatFlags flags )
7575
{
7676
//first, limit longitude to -360 to 360 degree range
77-
double wrappedX = fmod( val, 360.0 );
77+
double wrappedX = std::fmod( val, 360.0 );
7878
//next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W"
7979
if ( wrappedX > 180.0 )
8080
{
@@ -85,17 +85,17 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutesSeconds( double val, int
8585
wrappedX = wrappedX + 360.0;
8686
}
8787

88-
int precisionMultiplier = pow( 10.0, precision );
88+
int precisionMultiplier = std::pow( 10.0, precision );
8989

90-
int degreesX = int( qAbs( wrappedX ) );
91-
double floatMinutesX = ( qAbs( wrappedX ) - degreesX ) * 60.0;
90+
int degreesX = int( std::fabs( wrappedX ) );
91+
double floatMinutesX = ( std::fabs( wrappedX ) - degreesX ) * 60.0;
9292
int intMinutesX = int( floatMinutesX );
9393
double secondsX = ( floatMinutesX - intMinutesX ) * 60.0;
9494

9595
//make sure rounding to specified precision doesn't create seconds >= 60
96-
if ( qRound( secondsX * precisionMultiplier ) >= 60 * precisionMultiplier )
96+
if ( std::round( secondsX * precisionMultiplier ) >= 60 * precisionMultiplier )
9797
{
98-
secondsX = qMax( secondsX - 60, 0.0 );
98+
secondsX = std::max( secondsX - 60, 0.0 );
9999
intMinutesX++;
100100
if ( intMinutesX >= 60 )
101101
{
@@ -106,7 +106,7 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutesSeconds( double val, int
106106

107107
QString hemisphere;
108108
QString sign;
109-
if ( flags.testFlag( DegreesUseStringSuffix ) )
109+
if ( flags.testFlag( FlagDegreesUseStringSuffix ) )
110110
{
111111
hemisphere = wrappedX < 0 ? QObject::tr( "W" ) : QObject::tr( "E" );
112112
}
@@ -119,14 +119,14 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutesSeconds( double val, int
119119
}
120120
//check if coordinate is all zeros for the specified precision, and if so,
121121
//remove the sign and hemisphere strings
122-
if ( degreesX == 0 && intMinutesX == 0 && qRound( secondsX * precisionMultiplier ) == 0 )
122+
if ( degreesX == 0 && intMinutesX == 0 && std::round( secondsX * precisionMultiplier ) == 0 )
123123
{
124124
sign.clear();
125125
hemisphere.clear();
126126
}
127127

128128
//also remove directional prefix from 180 degree longitudes
129-
if ( degreesX == 180 && intMinutesX == 0 && qRound( secondsX * precisionMultiplier ) == 0 )
129+
if ( degreesX == 180 && intMinutesX == 0 && std::round( secondsX * precisionMultiplier ) == 0 )
130130
{
131131
hemisphere.clear();
132132
}
@@ -135,7 +135,7 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutesSeconds( double val, int
135135
QString strSecondsX;
136136

137137
//pad with leading digits if required
138-
if ( flags.testFlag( DegreesPadMinutesSeconds ) )
138+
if ( flags.testFlag( FlagDegreesPadMinutesSeconds ) )
139139
{
140140
minutesX = QString( "%1" ).arg( intMinutesX, 2, 10, QChar( '0' ) );
141141
int digits = 2 + ( precision == 0 ? 0 : 1 + precision ); //1 for decimal place if required
@@ -156,7 +156,7 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutesSeconds( double val, int
156156
QString QgsCoordinateFormatter::formatYAsDegreesMinutesSeconds( double val, int precision, FormatFlags flags )
157157
{
158158
//first, limit latitude to -180 to 180 degree range
159-
double wrappedY = fmod( val, 180.0 );
159+
double wrappedY = std::fmod( val, 180.0 );
160160
//next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N"
161161
if ( wrappedY > 90.0 )
162162
{
@@ -167,17 +167,17 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutesSeconds( double val, int
167167
wrappedY = wrappedY + 180.0;
168168
}
169169

170-
int precisionMultiplier = pow( 10.0, precision );
170+
int precisionMultiplier = std::pow( 10.0, precision );
171171

172-
int degreesY = int( qAbs( wrappedY ) );
173-
double floatMinutesY = ( qAbs( wrappedY ) - degreesY ) * 60.0;
172+
int degreesY = int( std::fabs( wrappedY ) );
173+
double floatMinutesY = ( std::fabs( wrappedY ) - degreesY ) * 60.0;
174174
int intMinutesY = int( floatMinutesY );
175175
double secondsY = ( floatMinutesY - intMinutesY ) * 60.0;
176176

177177
//make sure rounding to specified precision doesn't create seconds >= 60
178-
if ( qRound( secondsY * precisionMultiplier ) >= 60 * precisionMultiplier )
178+
if ( std::round( secondsY * precisionMultiplier ) >= 60 * precisionMultiplier )
179179
{
180-
secondsY = qMax( secondsY - 60, 0.0 );
180+
secondsY = std::max( secondsY - 60, 0.0 );
181181
intMinutesY++;
182182
if ( intMinutesY >= 60 )
183183
{
@@ -188,7 +188,7 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutesSeconds( double val, int
188188

189189
QString hemisphere;
190190
QString sign;
191-
if ( flags.testFlag( DegreesUseStringSuffix ) )
191+
if ( flags.testFlag( FlagDegreesUseStringSuffix ) )
192192
{
193193
hemisphere = wrappedY < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
194194
}
@@ -201,7 +201,7 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutesSeconds( double val, int
201201
}
202202
//check if coordinate is all zeros for the specified precision, and if so,
203203
//remove the sign and hemisphere strings
204-
if ( degreesY == 0 && intMinutesY == 0 && qRound( secondsY * precisionMultiplier ) == 0 )
204+
if ( degreesY == 0 && intMinutesY == 0 && std::round( secondsY * precisionMultiplier ) == 0 )
205205
{
206206
sign = QString();
207207
hemisphere.clear();
@@ -211,7 +211,7 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutesSeconds( double val, int
211211
QString strSecondsY;
212212

213213
//pad with leading digits if required
214-
if ( flags.testFlag( DegreesPadMinutesSeconds ) )
214+
if ( flags.testFlag( FlagDegreesPadMinutesSeconds ) )
215215
{
216216
strMinutesY = QString( "%1" ).arg( intMinutesY, 2, 10, QChar( '0' ) );
217217
int digits = 2 + ( precision == 0 ? 0 : 1 + precision ); //1 for decimal place if required
@@ -232,7 +232,7 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutesSeconds( double val, int
232232
QString QgsCoordinateFormatter::formatXAsDegreesMinutes( double val, int precision, FormatFlags flags )
233233
{
234234
//first, limit longitude to -360 to 360 degree range
235-
double wrappedX = fmod( val, 360.0 );
235+
double wrappedX = std::fmod( val, 360.0 );
236236
//next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W"
237237
if ( wrappedX > 180.0 )
238238
{
@@ -243,21 +243,21 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutes( double val, int precisi
243243
wrappedX = wrappedX + 360.0;
244244
}
245245

246-
int degreesX = int( qAbs( wrappedX ) );
247-
double floatMinutesX = ( qAbs( wrappedX ) - degreesX ) * 60.0;
246+
int degreesX = int( std::fabs( wrappedX ) );
247+
double floatMinutesX = ( std::fabs( wrappedX ) - degreesX ) * 60.0;
248248

249-
int precisionMultiplier = pow( 10.0, precision );
249+
int precisionMultiplier = std::pow( 10.0, precision );
250250

251251
//make sure rounding to specified precision doesn't create minutes >= 60
252-
if ( qRound( floatMinutesX * precisionMultiplier ) >= 60 * precisionMultiplier )
252+
if ( std::round( floatMinutesX * precisionMultiplier ) >= 60 * precisionMultiplier )
253253
{
254-
floatMinutesX = qMax( floatMinutesX - 60, 0.0 );
254+
floatMinutesX = std::max( floatMinutesX - 60, 0.0 );
255255
degreesX++;
256256
}
257257

258258
QString hemisphere;
259259
QString sign;
260-
if ( flags.testFlag( DegreesUseStringSuffix ) )
260+
if ( flags.testFlag( FlagDegreesUseStringSuffix ) )
261261
{
262262
hemisphere = wrappedX < 0 ? QObject::tr( "W" ) : QObject::tr( "E" );
263263
}
@@ -270,21 +270,21 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutes( double val, int precisi
270270
}
271271
//check if coordinate is all zeros for the specified precision, and if so,
272272
//remove the sign and hemisphere strings
273-
if ( degreesX == 0 && qRound( floatMinutesX * precisionMultiplier ) == 0 )
273+
if ( degreesX == 0 && std::round( floatMinutesX * precisionMultiplier ) == 0 )
274274
{
275275
sign.clear();
276276
hemisphere.clear();
277277
}
278278

279279
//also remove directional prefix from 180 degree longitudes
280-
if ( degreesX == 180 && qRound( floatMinutesX * precisionMultiplier ) == 0 )
280+
if ( degreesX == 180 && std::round( floatMinutesX * precisionMultiplier ) == 0 )
281281
{
282282
hemisphere.clear();
283283
}
284284

285285
//pad minutes with leading digits if required
286286
int digits = 2 + ( precision == 0 ? 0 : 1 + precision ); //1 for decimal place if required
287-
QString strMinutesX = flags.testFlag( DegreesPadMinutesSeconds ) ? QString( "%1" ).arg( floatMinutesX, digits, 'f', precision, QChar( '0' ) )
287+
QString strMinutesX = flags.testFlag( FlagDegreesPadMinutesSeconds ) ? QString( "%1" ).arg( floatMinutesX, digits, 'f', precision, QChar( '0' ) )
288288
: QString::number( floatMinutesX, 'f', precision );
289289

290290
return sign + QString::number( degreesX ) + QChar( 176 ) +
@@ -295,7 +295,7 @@ QString QgsCoordinateFormatter::formatXAsDegreesMinutes( double val, int precisi
295295
QString QgsCoordinateFormatter::formatYAsDegreesMinutes( double val, int precision, FormatFlags flags )
296296
{
297297
//first, limit latitude to -180 to 180 degree range
298-
double wrappedY = fmod( val, 180.0 );
298+
double wrappedY = std::fmod( val, 180.0 );
299299
//next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N"
300300
if ( wrappedY > 90.0 )
301301
{
@@ -306,21 +306,21 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutes( double val, int precisi
306306
wrappedY = wrappedY + 180.0;
307307
}
308308

309-
int degreesY = int( qAbs( wrappedY ) );
310-
double floatMinutesY = ( qAbs( wrappedY ) - degreesY ) * 60.0;
309+
int degreesY = int( std::fabs( wrappedY ) );
310+
double floatMinutesY = ( std::fabs( wrappedY ) - degreesY ) * 60.0;
311311

312-
int precisionMultiplier = pow( 10.0, precision );
312+
int precisionMultiplier = std::pow( 10.0, precision );
313313

314314
//make sure rounding to specified precision doesn't create minutes >= 60
315-
if ( qRound( floatMinutesY * precisionMultiplier ) >= 60 * precisionMultiplier )
315+
if ( std::round( floatMinutesY * precisionMultiplier ) >= 60 * precisionMultiplier )
316316
{
317-
floatMinutesY = qMax( floatMinutesY - 60, 0.0 );
317+
floatMinutesY = std::max( floatMinutesY - 60, 0.0 );
318318
degreesY++;
319319
}
320320

321321
QString hemisphere;
322322
QString sign;
323-
if ( flags.testFlag( DegreesUseStringSuffix ) )
323+
if ( flags.testFlag( FlagDegreesUseStringSuffix ) )
324324
{
325325
hemisphere = wrappedY < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
326326
}
@@ -333,7 +333,7 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutes( double val, int precisi
333333
}
334334
//check if coordinate is all zeros for the specified precision, and if so,
335335
//remove the sign and hemisphere strings
336-
if ( degreesY == 0 && qRound( floatMinutesY * precisionMultiplier ) == 0 )
336+
if ( degreesY == 0 && std::round( floatMinutesY * precisionMultiplier ) == 0 )
337337
{
338338
sign.clear();
339339
hemisphere.clear();
@@ -342,7 +342,7 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutes( double val, int precisi
342342

343343
//pad minutes with leading digits if required
344344
int digits = 2 + ( precision == 0 ? 0 : 1 + precision ); //1 for decimal place if required
345-
QString strMinutesY = flags.testFlag( DegreesPadMinutesSeconds ) ? QString( "%1" ).arg( floatMinutesY, digits, 'f', precision, QChar( '0' ) )
345+
QString strMinutesY = flags.testFlag( FlagDegreesPadMinutesSeconds ) ? QString( "%1" ).arg( floatMinutesY, digits, 'f', precision, QChar( '0' ) )
346346
: QString::number( floatMinutesY, 'f', precision );
347347

348348
return sign + QString::number( degreesY ) + QChar( 176 ) +
@@ -353,7 +353,7 @@ QString QgsCoordinateFormatter::formatYAsDegreesMinutes( double val, int precisi
353353
QString QgsCoordinateFormatter::formatXAsDegrees( double val, int precision, FormatFlags flags )
354354
{
355355
//first, limit longitude to -360 to 360 degree range
356-
double wrappedX = fmod( val, 360.0 );
356+
double wrappedX = std::fmod( val, 360.0 );
357357
//next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W"
358358
if ( wrappedX > 180.0 )
359359
{
@@ -364,13 +364,13 @@ QString QgsCoordinateFormatter::formatXAsDegrees( double val, int precision, For
364364
wrappedX = wrappedX + 360.0;
365365
}
366366

367-
double absX = qAbs( wrappedX );
367+
double absX = std::fabs( wrappedX );
368368

369-
int precisionMultiplier = pow( 10.0, precision );
369+
int precisionMultiplier = std::pow( 10.0, precision );
370370

371371
QString hemisphere;
372372
QString sign;
373-
if ( flags.testFlag( DegreesUseStringSuffix ) )
373+
if ( flags.testFlag( FlagDegreesUseStringSuffix ) )
374374
{
375375
hemisphere = wrappedX < 0 ? QObject::tr( "W" ) : QObject::tr( "E" );
376376
}
@@ -383,14 +383,14 @@ QString QgsCoordinateFormatter::formatXAsDegrees( double val, int precision, For
383383
}
384384
//check if coordinate is all zeros for the specified precision, and if so,
385385
//remove the sign and hemisphere strings
386-
if ( qRound( absX * precisionMultiplier ) == 0 )
386+
if ( std::round( absX * precisionMultiplier ) == 0 )
387387
{
388388
sign.clear();
389389
hemisphere.clear();
390390
}
391391

392392
//also remove directional prefix from 180 degree longitudes
393-
if ( qRound( absX * precisionMultiplier ) == 180 * precisionMultiplier )
393+
if ( std::round( absX * precisionMultiplier ) == 180 * precisionMultiplier )
394394
{
395395
sign.clear();
396396
hemisphere.clear();
@@ -402,7 +402,7 @@ QString QgsCoordinateFormatter::formatXAsDegrees( double val, int precision, For
402402
QString QgsCoordinateFormatter::formatYAsDegrees( double val, int precision, FormatFlags flags )
403403
{
404404
//first, limit latitude to -180 to 180 degree range
405-
double wrappedY = fmod( val, 180.0 );
405+
double wrappedY = std::fmod( val, 180.0 );
406406
//next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N"
407407
if ( wrappedY > 90.0 )
408408
{
@@ -413,13 +413,13 @@ QString QgsCoordinateFormatter::formatYAsDegrees( double val, int precision, For
413413
wrappedY = wrappedY + 180.0;
414414
}
415415

416-
double absY = qAbs( wrappedY );
416+
double absY = std::fabs( wrappedY );
417417

418-
int precisionMultiplier = pow( 10.0, precision );
418+
int precisionMultiplier = std::pow( 10.0, precision );
419419

420420
QString hemisphere;
421421
QString sign;
422-
if ( flags.testFlag( DegreesUseStringSuffix ) )
422+
if ( flags.testFlag( FlagDegreesUseStringSuffix ) )
423423
{
424424
hemisphere = wrappedY < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
425425
}
@@ -432,7 +432,7 @@ QString QgsCoordinateFormatter::formatYAsDegrees( double val, int precision, For
432432
}
433433
//check if coordinate is all zeros for the specified precision, and if so,
434434
//remove the sign and hemisphere strings
435-
if ( qRound( absY * precisionMultiplier ) == 0 )
435+
if ( std::round( absY * precisionMultiplier ) == 0 )
436436
{
437437
sign.clear();
438438
hemisphere.clear();

‎src/core/qgscoordinateformatter.h

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
#include <QString>
2222

23-
/** \ingroup core
23+
/**
24+
* \ingroup core
2425
* \class QgsCoordinateFormatter
2526
* \brief Contains methods for converting coordinates for display in various formats.
2627
*
@@ -31,57 +32,63 @@
3132
* ensuring that only geographic coordinates and not projected coordinates are formatted to degree
3233
* based formats.
3334
*
34-
* \note Added in version 2.14
35+
* \since QGIS 3.0
3536
*/
3637

3738
class CORE_EXPORT QgsCoordinateFormatter
3839
{
3940
public:
4041

41-
/** Available formats for displaying coordinates.
42+
/**
43+
* Available formats for displaying coordinates.
4244
*/
4345
enum Format
4446
{
45-
Pair, /*!< Formats coordinates as an "x,y" pair */
46-
DegreesMinutesSeconds, /*!< Degrees, minutes and seconds, eg 30 degrees 45'30" */
47-
DegreesMinutes, /*!< Degrees and decimal minutes, eg 30degrees 45.55' */
48-
DecimalDegrees, /*!< Decimal degrees, eg 30.7555 degrees */
47+
FormatPair, //!< Formats coordinates as an "x,y" pair
48+
FormatDegreesMinutesSeconds, //!< Degrees, minutes and seconds, eg 30 degrees 45'30"
49+
FormatDegreesMinutes, //!< Degrees and decimal minutes, eg 30degrees 45.55'
50+
FormatDecimalDegrees, //!< Decimal degrees, eg 30.7555 degrees
4951
};
5052

51-
/** Flags for controlling formatting of coordinates.
53+
/**
54+
* Flags for controlling formatting of coordinates.
5255
*/
5356
enum FormatFlag
5457
{
55-
DegreesUseStringSuffix = 0x01, /*!< include a direction suffix (eg 'N', 'E', 'S' or 'W'), otherwise a "-" prefix is used for west and south coordinates */
56-
DegreesPadMinutesSeconds = 0x02, /*!< pad minute and second values with leading zeros, eg '05' instead of '5' */
58+
FlagDegreesUseStringSuffix = 1 << 1, //!< Include a direction suffix (eg 'N', 'E', 'S' or 'W'), otherwise a "-" prefix is used for west and south coordinates
59+
FlagDegreesPadMinutesSeconds = 1 << 2, //!< Pad minute and second values with leading zeros, eg '05' instead of '5'
5760
};
5861
Q_DECLARE_FLAGS( FormatFlags, FormatFlag )
5962

60-
/** Formats an X coordinate value according to the specified parameters.
61-
* @param x x-coordinate
62-
* @param format string format to use for coordinate
63-
* @param precision number of decimal places to include
64-
* @param flags flags controlling format options
65-
* @returns formatted X coordinate string
66-
* @see formatY()
63+
/**
64+
* Formats an \a x coordinate value according to the specified parameters.
65+
*
66+
* The \a format argument indicates the desired display format for the coordinate.
67+
*
68+
* The \a precision argument gives the number of decimal places to include for coordinates.
69+
*
70+
* Optional \a flags can be specified to control the output format.
71+
*
72+
* \see formatY()
6773
*/
68-
static QString formatX( double x, Format format, int precision = 12, FormatFlags flags = DegreesUseStringSuffix );
69-
70-
/** Formats an Y coordinate value according to the specified parameters.
71-
* @param y y-coordinate
72-
* @param format string format to use for coordinate
73-
* @param precision number of decimal places to include
74-
* @param flags flags controlling format options
75-
* @returns formatted Y coordinate string
76-
* @see formatX()
74+
static QString formatX( double x, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix );
75+
76+
/**
77+
* Formats a \a y coordinate value according to the specified parameters.
78+
*
79+
* The \a format argument indicates the desired display format for the coordinate.
80+
*
81+
* The \a precision argument gives the number of decimal places to include for coordinates.
82+
*
83+
* Optional \a flags can be specified to control the output format.
84+
*
85+
* \see formatX()
7786
*/
78-
static QString formatY( double y, Format format, int precision = 12, FormatFlags flags = DegreesUseStringSuffix );
87+
static QString formatY( double y, Format format, int precision = 12, FormatFlags flags = FlagDegreesUseStringSuffix );
7988

80-
/** Formats coordinates as an "x,y" pair, with optional decimal precision.
81-
* @param x x-coordinate
82-
* @param y y-coordinate
83-
* @param precision number of decimal places to include
84-
* @returns formatted coordinate string
89+
/**
90+
* Formats coordinates as an "\a x,\a y" pair, with optional decimal \a precision (number
91+
* of decimal places to include).
8592
*/
8693
static QString asPair( double x, double y, int precision = 12 );
8794

0 commit comments

Comments
 (0)
Please sign in to comment.