QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgscoordinatenumericformat.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscoordinatenumericformat.cpp
3 --------------------------
4 begin : April 2022
5 copyright : (C) 2022 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17#include "moc_qgscoordinatenumericformat.cpp"
18#include "qgis.h"
20
21#include <memory>
22#include <iostream>
23#include <locale>
24#include <iomanip>
25
27struct formatter : std::numpunct<wchar_t>
28{
29 formatter( QChar thousands, bool showThousands, QChar decimal )
30 : mThousands( thousands.unicode() )
31 , mDecimal( decimal.unicode() )
32 , mShowThousands( showThousands )
33 {}
34 wchar_t do_decimal_point() const override { return mDecimal; }
35 wchar_t do_thousands_sep() const override { return mThousands; }
36 std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; }
37
38 wchar_t mThousands;
39 wchar_t mDecimal;
40 bool mShowThousands = true;
41};
43
47
49{
50 return QStringLiteral( "geographiccoordinate" );
51}
52
54{
55 return QObject::tr( "Geographic Coordinate" );
56}
57
62
64{
65 return 3.7555;
66}
67
69{
70 const QChar decimal = decimalSeparator().isNull() ? context.decimalSeparator() : decimalSeparator();
71 std::basic_stringstream<wchar_t> os;
72 os.imbue( std::locale( os.getloc(), new formatter( thousandsSeparator().isNull() ? context.thousandsSeparator() : thousandsSeparator(),
73 false,
74 decimal ) ) );
75
76 switch ( context.interpretation() )
77 {
79 return formatLatitude( value, os, context );
80
83 return formatLongitude( value, os, context );
84 }
86}
87
92
93QgsNumericFormat *QgsGeographicCoordinateNumericFormat::create( const QVariantMap &configuration, const QgsReadWriteContext &context ) const
94{
95 std::unique_ptr< QgsGeographicCoordinateNumericFormat > res = std::make_unique< QgsGeographicCoordinateNumericFormat >();
96 res->setConfiguration( configuration, context );
97 res->mAngleFormat = qgsEnumKeyToValue( configuration.value( QStringLiteral( "angle_format" ) ).toString(), AngleFormat::DecimalDegrees );
98 res->mShowLeadingZeros = configuration.value( QStringLiteral( "show_leading_zeros" ), false ).toBool();
99 res->mShowLeadingDegreeZeros = configuration.value( QStringLiteral( "show_leading_degree_zeros" ), false ).toBool();
100 res->mUseSuffix = configuration.value( QStringLiteral( "show_suffix" ), false ).toBool();
101 return res.release();
102}
103
105{
106 QVariantMap res = QgsBasicNumericFormat::configuration( context );
107 res.insert( QStringLiteral( "angle_format" ), qgsEnumValueToKey( mAngleFormat ) );
108 res.insert( QStringLiteral( "show_leading_zeros" ), mShowLeadingZeros );
109 res.insert( QStringLiteral( "show_leading_degree_zeros" ), mShowLeadingDegreeZeros );
110 res.insert( QStringLiteral( "show_suffix" ), mUseSuffix );
111 return res;
112}
113
118
123
124void QgsGeographicCoordinateNumericFormat::setConfiguration( const QVariantMap &configuration, const QgsReadWriteContext &context )
125{
127 mAngleFormat = qgsEnumKeyToValue( configuration.value( QStringLiteral( "angle_format" ) ).toString(), AngleFormat::DecimalDegrees );
128 mShowLeadingZeros = configuration.value( QStringLiteral( "show_leading_zeros" ), false ).toBool();
129 mShowLeadingDegreeZeros = configuration.value( QStringLiteral( "show_leading_degree_zeros" ), false ).toBool();
130 mUseSuffix = configuration.value( QStringLiteral( "show_suffix" ), false ).toBool();
131}
132
134{
135 return mShowLeadingZeros;
136}
137
139{
140 mShowLeadingZeros = newShowLeadingZeros;
141}
142
144{
145 return mShowLeadingDegreeZeros;
146}
147
149{
150 mShowLeadingDegreeZeros = show;
151}
152
154{
155 return mUseSuffix;
156}
157
159{
160 mUseSuffix = show;
161}
162
163QString QgsGeographicCoordinateNumericFormat::formatLongitude( double value, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
164{
165 switch ( mAngleFormat )
166 {
168 return formatLongitudeAsDegreesMinutesSeconds( value, ss, context );
170 return formatLongitudeAsDegreesMinutes( value, ss, context );
172 return formatLongitudeAsDegrees( value, ss, context );
173 }
175}
176
177QString QgsGeographicCoordinateNumericFormat::formatLatitude( double value, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
178{
179 switch ( mAngleFormat )
180 {
182 return formatLatitudeAsDegreesMinutesSeconds( value, ss, context );
184 return formatLatitudeAsDegreesMinutes( value, ss, context );
186 return formatLatitudeAsDegrees( value, ss, context );
187 }
189}
190
191QString QgsGeographicCoordinateNumericFormat::formatLatitudeAsDegreesMinutesSeconds( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
192{
193 //first, limit latitude to -180 to 180 degree range
194 double wrappedY = std::fmod( val, 180.0 );
195 //next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N"
196 if ( wrappedY > 90.0 )
197 {
198 wrappedY = wrappedY - 180.0;
199 }
200 else if ( wrappedY < -90.0 )
201 {
202 wrappedY = wrappedY + 180.0;
203 }
204
205 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
206
207 int degreesY = int( std::fabs( wrappedY ) );
208 const double floatMinutesY = ( std::fabs( wrappedY ) - degreesY ) * 60.0;
209 int intMinutesY = int( floatMinutesY );
210 double secondsY = ( floatMinutesY - intMinutesY ) * 60.0;
211
212 //make sure rounding to specified precision doesn't create seconds >= 60
213 if ( std::round( secondsY * precisionMultiplier ) >= 60 * precisionMultiplier )
214 {
215 secondsY = std::max( secondsY - 60, 0.0 );
216 intMinutesY++;
217 if ( intMinutesY >= 60 )
218 {
219 intMinutesY -= 60;
220 degreesY++;
221 }
222 }
223
224 QString hemisphere;
225 QString sign;
226 if ( mUseSuffix )
227 {
228 hemisphere = wrappedY < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
229 }
230 else
231 {
232 if ( wrappedY < 0 )
233 {
234 sign = context.negativeSign();
235 }
236 }
237 //check if coordinate is all zeros for the specified precision, and if so,
238 //remove the sign and hemisphere strings
239 if ( degreesY == 0 && intMinutesY == 0 && std::round( secondsY * precisionMultiplier ) == 0 )
240 {
241 sign = QString();
242 hemisphere.clear();
243 }
244
245 QString strMinutesY;
246 QString strSecondsY;
247
248 ss << std::fixed << std::setprecision( 0 );
249 ss << intMinutesY;
250
251 strMinutesY = QString::fromStdWString( ss.str() );
252 ss.str( std::wstring() );
253
254 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
255 ss << secondsY;
256 strSecondsY = QString::fromStdWString( ss.str() );
257 ss.str( std::wstring() );
258
259 trimTrailingZeros( strSecondsY, context );
260
261 //pad with leading digits if required
262 if ( mShowLeadingZeros && intMinutesY < 10 )
263 strMinutesY = '0' + strMinutesY;
264
265 if ( mShowLeadingZeros && secondsY < 10 )
266 strSecondsY = '0' + strSecondsY;
267
268 ss << std::fixed << std::setprecision( 0 );
269 ss << degreesY;
270 QString degreesYStr = QString::fromStdWString( ss.str() );
271 ss.str( std::wstring() );
272
273 if ( mShowLeadingDegreeZeros )
274 degreesYStr = QString( QStringLiteral( "00" ) + degreesYStr ).right( 2 );
275
276 return sign + degreesYStr + QChar( 176 ) +
277 strMinutesY + QChar( 0x2032 ) +
278 strSecondsY + QChar( 0x2033 ) +
279 hemisphere;
280}
281
282QString QgsGeographicCoordinateNumericFormat::formatLongitudeAsDegreesMinutesSeconds( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
283{
284 //first, limit longitude to -360 to 360 degree range
285 double wrappedX = std::fmod( val, 360.0 );
286 //next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W"
287 if ( wrappedX > 180.0 )
288 {
289 wrappedX = wrappedX - 360.0;
290 }
291 else if ( wrappedX < -180.0 )
292 {
293 wrappedX = wrappedX + 360.0;
294 }
295
296 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
297
298 int degreesX = int( std::fabs( wrappedX ) );
299 const double floatMinutesX = ( std::fabs( wrappedX ) - degreesX ) * 60.0;
300 int intMinutesX = int( floatMinutesX );
301 double secondsX = ( floatMinutesX - intMinutesX ) * 60.0;
302
303 //make sure rounding to specified precision doesn't create seconds >= 60
304 if ( std::round( secondsX * precisionMultiplier ) >= 60 * precisionMultiplier )
305 {
306 secondsX = std::max( secondsX - 60, 0.0 );
307 intMinutesX++;
308 if ( intMinutesX >= 60 )
309 {
310 intMinutesX -= 60;
311 degreesX++;
312 }
313 }
314
315 QString hemisphere;
316 QString sign;
317 if ( mUseSuffix )
318 {
319 hemisphere = wrappedX < 0 ? QObject::tr( "W" ) : QObject::tr( "E" );
320 }
321 else
322 {
323 if ( wrappedX < 0 )
324 {
325 sign = context.negativeSign();
326 }
327 }
328 //check if coordinate is all zeros for the specified precision, and if so,
329 //remove the sign and hemisphere strings
330 if ( degreesX == 0 && intMinutesX == 0 && std::round( secondsX * precisionMultiplier ) == 0 )
331 {
332 sign.clear();
333 hemisphere.clear();
334 }
335
336 //also remove directional prefix from 180 degree longitudes
337 if ( degreesX == 180 && intMinutesX == 0 && std::round( secondsX * precisionMultiplier ) == 0 )
338 {
339 hemisphere.clear();
340 }
341
342 QString minutesX;
343 QString strSecondsX;
344
345 ss << std::fixed << std::setprecision( 0 );
346 ss << intMinutesX;
347
348 minutesX = QString::fromStdWString( ss.str() );
349 ss.str( std::wstring() );
350
351 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
352 ss << secondsX;
353 strSecondsX = QString::fromStdWString( ss.str() );
354 ss.str( std::wstring() );
355
356 trimTrailingZeros( strSecondsX, context );
357
358 //pad with leading digits if required
359 if ( mShowLeadingZeros && intMinutesX < 10 )
360 minutesX = '0' + minutesX;
361
362 if ( mShowLeadingZeros && secondsX < 10 )
363 strSecondsX = '0' + strSecondsX;
364
365 ss << std::fixed << std::setprecision( 0 );
366 ss << degreesX;
367 QString degreesXStr = QString::fromStdWString( ss.str() );
368 ss.str( std::wstring() );
369
370 if ( mShowLeadingDegreeZeros )
371 degreesXStr = QString( QStringLiteral( "000" ) + degreesXStr ).right( 3 );
372
373 return sign + degreesXStr + QChar( 176 ) +
374 minutesX + QChar( 0x2032 ) +
375 strSecondsX + QChar( 0x2033 ) +
376 hemisphere;
377}
378
379QString QgsGeographicCoordinateNumericFormat::formatLatitudeAsDegreesMinutes( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
380{
381 //first, limit latitude to -180 to 180 degree range
382 double wrappedY = std::fmod( val, 180.0 );
383 //next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N"
384 if ( wrappedY > 90.0 )
385 {
386 wrappedY = wrappedY - 180.0;
387 }
388 else if ( wrappedY < -90.0 )
389 {
390 wrappedY = wrappedY + 180.0;
391 }
392
393 int degreesY = int( std::fabs( wrappedY ) );
394 double floatMinutesY = ( std::fabs( wrappedY ) - degreesY ) * 60.0;
395
396 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
397
398 //make sure rounding to specified precision doesn't create minutes >= 60
399 if ( std::round( floatMinutesY * precisionMultiplier ) >= 60 * precisionMultiplier )
400 {
401 floatMinutesY = std::max( floatMinutesY - 60, 0.0 );
402 degreesY++;
403 }
404
405 QString hemisphere;
406 QString sign;
407 if ( mUseSuffix )
408 {
409 hemisphere = wrappedY < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
410 }
411 else
412 {
413 if ( wrappedY < 0 )
414 {
415 sign = context.negativeSign();
416 }
417 }
418 //check if coordinate is all zeros for the specified precision, and if so,
419 //remove the sign and hemisphere strings
420 if ( degreesY == 0 && std::round( floatMinutesY * precisionMultiplier ) == 0 )
421 {
422 sign.clear();
423 hemisphere.clear();
424 }
425
426 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
427 ss << floatMinutesY;
428 QString strMinutesY = QString::fromStdWString( ss.str() );
429 ss.str( std::wstring() );
430
431 trimTrailingZeros( strMinutesY, context );
432
433 //pad with leading digits if required
434 if ( mShowLeadingZeros && floatMinutesY < 10 )
435 strMinutesY = '0' + strMinutesY;
436
437 ss << std::fixed << std::setprecision( 0 );
438 ss << degreesY;
439 QString degreesYStr = QString::fromStdWString( ss.str() );
440 ss.str( std::wstring() );
441
442 if ( mShowLeadingDegreeZeros )
443 degreesYStr = QString( QStringLiteral( "00" ) + degreesYStr ).right( 2 );
444
445 return sign + degreesYStr + QChar( 176 ) +
446 strMinutesY + QChar( 0x2032 ) +
447 hemisphere;
448}
449
450QString QgsGeographicCoordinateNumericFormat::formatLongitudeAsDegreesMinutes( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
451{
452 //first, limit longitude to -360 to 360 degree range
453 double wrappedX = std::fmod( val, 360.0 );
454 //next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W"
455 if ( wrappedX > 180.0 )
456 {
457 wrappedX = wrappedX - 360.0;
458 }
459 else if ( wrappedX < -180.0 )
460 {
461 wrappedX = wrappedX + 360.0;
462 }
463
464 int degreesX = int( std::fabs( wrappedX ) );
465 double floatMinutesX = ( std::fabs( wrappedX ) - degreesX ) * 60.0;
466
467 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
468
469 //make sure rounding to specified precision doesn't create minutes >= 60
470 if ( std::round( floatMinutesX * precisionMultiplier ) >= 60 * precisionMultiplier )
471 {
472 floatMinutesX = std::max( floatMinutesX - 60, 0.0 );
473 degreesX++;
474 }
475
476 QString hemisphere;
477 QString sign;
478 if ( mUseSuffix )
479 {
480 hemisphere = wrappedX < 0 ? QObject::tr( "W" ) : QObject::tr( "E" );
481 }
482 else
483 {
484 if ( wrappedX < 0 )
485 {
486 sign = context.negativeSign();
487 }
488 }
489 //check if coordinate is all zeros for the specified precision, and if so,
490 //remove the sign and hemisphere strings
491 if ( degreesX == 0 && std::round( floatMinutesX * precisionMultiplier ) == 0 )
492 {
493 sign.clear();
494 hemisphere.clear();
495 }
496
497 //also remove directional prefix from 180 degree longitudes
498 if ( degreesX == 180 && std::round( floatMinutesX * precisionMultiplier ) == 0 )
499 {
500 hemisphere.clear();
501 }
502
503 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
504 ss << floatMinutesX;
505 QString strMinutesX = QString::fromStdWString( ss.str() );
506 ss.str( std::wstring() );
507
508 trimTrailingZeros( strMinutesX, context );
509
510 //pad with leading digits if required
511 if ( mShowLeadingZeros && floatMinutesX < 10 )
512 strMinutesX = '0' + strMinutesX;
513
514 ss << std::fixed << std::setprecision( 0 );
515 ss << degreesX;
516 QString degreesXStr = QString::fromStdWString( ss.str() );
517 ss.str( std::wstring() );
518
519 if ( mShowLeadingDegreeZeros )
520 degreesXStr = QString( QStringLiteral( "000" ) + degreesXStr ).right( 3 );
521
522 return sign + degreesXStr + QChar( 176 ) +
523 strMinutesX + QChar( 0x2032 ) +
524 hemisphere;
525}
526
527QString QgsGeographicCoordinateNumericFormat::formatLatitudeAsDegrees( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
528{
529 //first, limit latitude to -180 to 180 degree range
530 double wrappedY = std::fmod( val, 180.0 );
531 //next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N"
532 if ( wrappedY > 90.0 )
533 {
534 wrappedY = wrappedY - 180.0;
535 }
536 else if ( wrappedY < -90.0 )
537 {
538 wrappedY = wrappedY + 180.0;
539 }
540
541 const double absY = std::fabs( wrappedY );
542
543 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
544
545 QString hemisphere;
546 QString sign;
547 if ( mUseSuffix )
548 {
549 hemisphere = wrappedY < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
550 }
551 else
552 {
553 if ( wrappedY < 0 )
554 {
555 sign = context.negativeSign();
556 }
557 }
558 //check if coordinate is all zeros for the specified precision, and if so,
559 //remove the sign and hemisphere strings
560 if ( std::round( absY * precisionMultiplier ) == 0 )
561 {
562 sign.clear();
563 hemisphere.clear();
564 }
565
566 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
567 ss << absY;
568 QString strDegreesY = QString::fromStdWString( ss.str() );
569 ss.str( std::wstring() );
570
571 trimTrailingZeros( strDegreesY, context );
572
573 if ( mShowLeadingDegreeZeros && absY < 10 )
574 strDegreesY = '0' + strDegreesY;
575
576 return sign + strDegreesY + QChar( 176 ) + hemisphere;
577}
578
579QString QgsGeographicCoordinateNumericFormat::formatLongitudeAsDegrees( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
580{
581 //first, limit longitude to -360 to 360 degree range
582 double wrappedX = std::fmod( val, 360.0 );
583 //next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W"
584 if ( wrappedX > 180.0 )
585 {
586 wrappedX = wrappedX - 360.0;
587 }
588 else if ( wrappedX < -180.0 )
589 {
590 wrappedX = wrappedX + 360.0;
591 }
592
593 const double absX = std::fabs( wrappedX );
594
595 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
596
597 QString hemisphere;
598 QString sign;
599 if ( mUseSuffix )
600 {
601 hemisphere = wrappedX < 0 ? QObject::tr( "W" ) : QObject::tr( "E" );
602 }
603 else
604 {
605 if ( wrappedX < 0 )
606 {
607 sign = context.negativeSign();
608 }
609 }
610 //check if coordinate is all zeros for the specified precision, and if so,
611 //remove the sign and hemisphere strings
612 if ( std::round( absX * precisionMultiplier ) == 0 )
613 {
614 sign.clear();
615 hemisphere.clear();
616 }
617
618 //also remove directional prefix from 180 degree longitudes
619 if ( std::round( absX * precisionMultiplier ) == 180 * precisionMultiplier )
620 {
621 sign.clear();
622 hemisphere.clear();
623 }
624
625 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
626 ss << absX;
627 QString strDegreesX = QString::fromStdWString( ss.str() );
628 ss.str( std::wstring() );
629
630 trimTrailingZeros( strDegreesX, context );
631
632 if ( mShowLeadingDegreeZeros && absX < 100 )
633 strDegreesX = '0' + strDegreesX;
634 if ( mShowLeadingDegreeZeros && absX < 10 )
635 strDegreesX = '0' + strDegreesX;
636
637 return sign + strDegreesX + QChar( 176 ) + hemisphere;
638}
639
640void QgsGeographicCoordinateNumericFormat::trimTrailingZeros( QString &input, const QgsNumericFormatContext &context ) const
641{
642 const QChar decimal = decimalSeparator().isNull() ? context.decimalSeparator() : decimalSeparator();
643 if ( !showTrailingZeros() && input.contains( decimal ) )
644 {
645 int trimPoint = input.length() - 1;
646
647 while ( input.at( trimPoint ) == context.zeroDigit() )
648 trimPoint--;
649
650 if ( input.at( trimPoint ) == decimal )
651 trimPoint--;
652
653 input.truncate( trimPoint + 1 );
654 }
655}
QChar thousandsSeparator() const
Returns any override for the thousands separator character.
virtual void setConfiguration(const QVariantMap &configuration, const QgsReadWriteContext &context)
Sets the format's configuration.
bool showTrailingZeros() const
Returns true if trailing zeros will be shown (up to the specified numberDecimalPlaces()).
QChar decimalSeparator() const
Returns any override for the decimal separator character.
int numberDecimalPlaces() const
Returns the maximum number of decimal places to show.
QVariantMap configuration(const QgsReadWriteContext &context) const override
Returns the current configuration of the formatter.
A numeric formatter which returns a text representation of a geographic coordinate (latitude or longi...
void setConfiguration(const QVariantMap &configuration, const QgsReadWriteContext &context) override
Sets the format's configuration.
@ DegreesMinutes
Degrees and decimal minutes, eg 30 degrees 45.55'.
@ DecimalDegrees
Decimal degrees, eg 30.7555 degrees.
@ DegreesMinutesSeconds
Degrees, minutes and seconds, eg 30 degrees 45'30.
QgsNumericFormat * create(const QVariantMap &configuration, const QgsReadWriteContext &context) const override
Creates a new copy of the format, using the supplied configuration.
void setShowDirectionalSuffix(bool show)
Sets whether directional suffixes (e.g.
QgsGeographicCoordinateNumericFormat * clone() const override
Clones the format, returning a new object.
double suggestSampleValue() const override
Returns a suggested sample value which nicely represents the current format configuration.
int sortKey() override
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.
QString id() const override
Returns a unique id for this numeric format.
void setShowDegreeLeadingZeros(bool show)
Sets whether leading zeros for the degree values should be shown.
QString formatDouble(double value, const QgsNumericFormatContext &context) const override
Returns a formatted string representation of a numeric double value.
bool showDirectionalSuffix() const
Returns true if directional suffixes (e.g.
QVariantMap configuration(const QgsReadWriteContext &context) const override
Returns the current configuration of the formatter.
void setShowLeadingZeros(bool show)
Sets whether leading zeros in the minutes or seconds values should be shown.
AngleFormat angleFormat() const
Returns the angle format, which controls how bearing the angles are formatted described in the return...
bool showLeadingZeros() const
Returns true if leading zeros in the minutes or seconds values should be shown.
bool showDegreeLeadingZeros() const
Returns true if leading zeros for the degree values should be shown.
QString visibleName() const override
Returns the translated, user-visible name for this format.
void setAngleFormat(AngleFormat format)
Sets the directional formatting option, which controls how bearing the angles are formatted described...
A context for numeric formats.
QChar negativeSign() const
Returns the negative sign character.
QChar thousandsSeparator() const
Returns the thousands separator character.
QChar zeroDigit() const
Returns the zero digit character.
Interpretation interpretation() const
Returns the interpretation of the numbers being converted.
QChar decimalSeparator() const
Returns the decimal separator character.
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
static constexpr int DEFAULT_SORT_KEY
The class is used as a container of context for various read/write operations on other objects.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
Definition qgis.h:6127
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:6108
#define BUILTIN_UNREACHABLE
Definition qgis.h:6571
wchar_t do_decimal_point() const override
std::string do_grouping() const override
wchar_t do_thousands_sep() const override