QGIS API Documentation 3.41.0-Master (cea29feecf2)
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
27namespace QgsGeographicCoordinateNumericFormat_ns
28{
29 struct formatter : std::numpunct<wchar_t>
30 {
31 formatter( QChar thousands, bool showThousands, QChar decimal )
32 : mThousands( thousands.unicode() )
33 , mDecimal( decimal.unicode() )
34 , mShowThousands( showThousands )
35 {}
36 wchar_t do_decimal_point() const override { return mDecimal; }
37 wchar_t do_thousands_sep() const override { return mThousands; }
38 std::string do_grouping() const override { return mShowThousands ? "\3" : "\0"; }
39
40 wchar_t mThousands;
41 wchar_t mDecimal;
42 bool mShowThousands = true;
43 };
44}
46
50
52{
53 return QStringLiteral( "geographiccoordinate" );
54}
55
57{
58 return QObject::tr( "Geographic Coordinate" );
59}
60
65
67{
68 return 3.7555;
69}
70
72{
73 const QChar decimal = decimalSeparator().isNull() ? context.decimalSeparator() : decimalSeparator();
74 std::basic_stringstream<wchar_t> os;
75 os.imbue( std::locale( os.getloc(), new QgsGeographicCoordinateNumericFormat_ns::formatter( thousandsSeparator().isNull() ? context.thousandsSeparator() : thousandsSeparator(),
76 false,
77 decimal ) ) );
78
79 switch ( context.interpretation() )
80 {
82 return formatLatitude( value, os, context );
83
86 return formatLongitude( value, os, context );
87 }
89}
90
95
96QgsNumericFormat *QgsGeographicCoordinateNumericFormat::create( const QVariantMap &configuration, const QgsReadWriteContext &context ) const
97{
98 std::unique_ptr< QgsGeographicCoordinateNumericFormat > res = std::make_unique< QgsGeographicCoordinateNumericFormat >();
99 res->setConfiguration( configuration, context );
100 res->mAngleFormat = qgsEnumKeyToValue( configuration.value( QStringLiteral( "angle_format" ) ).toString(), AngleFormat::DecimalDegrees );
101 res->mShowLeadingZeros = configuration.value( QStringLiteral( "show_leading_zeros" ), false ).toBool();
102 res->mShowLeadingDegreeZeros = configuration.value( QStringLiteral( "show_leading_degree_zeros" ), false ).toBool();
103 res->mUseSuffix = configuration.value( QStringLiteral( "show_suffix" ), false ).toBool();
104 return res.release();
105}
106
108{
109 QVariantMap res = QgsBasicNumericFormat::configuration( context );
110 res.insert( QStringLiteral( "angle_format" ), qgsEnumValueToKey( mAngleFormat ) );
111 res.insert( QStringLiteral( "show_leading_zeros" ), mShowLeadingZeros );
112 res.insert( QStringLiteral( "show_leading_degree_zeros" ), mShowLeadingDegreeZeros );
113 res.insert( QStringLiteral( "show_suffix" ), mUseSuffix );
114 return res;
115}
116
121
126
127void QgsGeographicCoordinateNumericFormat::setConfiguration( const QVariantMap &configuration, const QgsReadWriteContext &context )
128{
130 mAngleFormat = qgsEnumKeyToValue( configuration.value( QStringLiteral( "angle_format" ) ).toString(), AngleFormat::DecimalDegrees );
131 mShowLeadingZeros = configuration.value( QStringLiteral( "show_leading_zeros" ), false ).toBool();
132 mShowLeadingDegreeZeros = configuration.value( QStringLiteral( "show_leading_degree_zeros" ), false ).toBool();
133 mUseSuffix = configuration.value( QStringLiteral( "show_suffix" ), false ).toBool();
134}
135
137{
138 return mShowLeadingZeros;
139}
140
142{
143 mShowLeadingZeros = newShowLeadingZeros;
144}
145
147{
148 return mShowLeadingDegreeZeros;
149}
150
152{
153 mShowLeadingDegreeZeros = show;
154}
155
157{
158 return mUseSuffix;
159}
160
162{
163 mUseSuffix = show;
164}
165
166QString QgsGeographicCoordinateNumericFormat::formatLongitude( double value, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
167{
168 switch ( mAngleFormat )
169 {
171 return formatLongitudeAsDegreesMinutesSeconds( value, ss, context );
173 return formatLongitudeAsDegreesMinutes( value, ss, context );
175 return formatLongitudeAsDegrees( value, ss, context );
176 }
178}
179
180QString QgsGeographicCoordinateNumericFormat::formatLatitude( double value, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
181{
182 switch ( mAngleFormat )
183 {
185 return formatLatitudeAsDegreesMinutesSeconds( value, ss, context );
187 return formatLatitudeAsDegreesMinutes( value, ss, context );
189 return formatLatitudeAsDegrees( value, ss, context );
190 }
192}
193
194QString QgsGeographicCoordinateNumericFormat::formatLatitudeAsDegreesMinutesSeconds( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
195{
196 //first, limit latitude to -180 to 180 degree range
197 double wrappedY = std::fmod( val, 180.0 );
198 //next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N"
199 if ( wrappedY > 90.0 )
200 {
201 wrappedY = wrappedY - 180.0;
202 }
203 else if ( wrappedY < -90.0 )
204 {
205 wrappedY = wrappedY + 180.0;
206 }
207
208 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
209
210 int degreesY = int( std::fabs( wrappedY ) );
211 const double floatMinutesY = ( std::fabs( wrappedY ) - degreesY ) * 60.0;
212 int intMinutesY = int( floatMinutesY );
213 double secondsY = ( floatMinutesY - intMinutesY ) * 60.0;
214
215 //make sure rounding to specified precision doesn't create seconds >= 60
216 if ( std::round( secondsY * precisionMultiplier ) >= 60 * precisionMultiplier )
217 {
218 secondsY = std::max( secondsY - 60, 0.0 );
219 intMinutesY++;
220 if ( intMinutesY >= 60 )
221 {
222 intMinutesY -= 60;
223 degreesY++;
224 }
225 }
226
227 QString hemisphere;
228 QString sign;
229 if ( mUseSuffix )
230 {
231 hemisphere = wrappedY < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
232 }
233 else
234 {
235 if ( wrappedY < 0 )
236 {
237 sign = context.negativeSign();
238 }
239 }
240 //check if coordinate is all zeros for the specified precision, and if so,
241 //remove the sign and hemisphere strings
242 if ( degreesY == 0 && intMinutesY == 0 && std::round( secondsY * precisionMultiplier ) == 0 )
243 {
244 sign = QString();
245 hemisphere.clear();
246 }
247
248 QString strMinutesY;
249 QString strSecondsY;
250
251 ss << std::fixed << std::setprecision( 0 );
252 ss << intMinutesY;
253
254 strMinutesY = QString::fromStdWString( ss.str() );
255 ss.str( std::wstring() );
256
257 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
258 ss << secondsY;
259 strSecondsY = QString::fromStdWString( ss.str() );
260 ss.str( std::wstring() );
261
262 trimTrailingZeros( strSecondsY, context );
263
264 //pad with leading digits if required
265 if ( mShowLeadingZeros && intMinutesY < 10 )
266 strMinutesY = '0' + strMinutesY;
267
268 if ( mShowLeadingZeros && secondsY < 10 )
269 strSecondsY = '0' + strSecondsY;
270
271 ss << std::fixed << std::setprecision( 0 );
272 ss << degreesY;
273 QString degreesYStr = QString::fromStdWString( ss.str() );
274 ss.str( std::wstring() );
275
276 if ( mShowLeadingDegreeZeros )
277 degreesYStr = QString( QStringLiteral( "00" ) + degreesYStr ).right( 2 );
278
279 return sign + degreesYStr + QChar( 176 ) +
280 strMinutesY + QChar( 0x2032 ) +
281 strSecondsY + QChar( 0x2033 ) +
282 hemisphere;
283}
284
285QString QgsGeographicCoordinateNumericFormat::formatLongitudeAsDegreesMinutesSeconds( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
286{
287 //first, limit longitude to -360 to 360 degree range
288 double wrappedX = std::fmod( val, 360.0 );
289 //next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W"
290 if ( wrappedX > 180.0 )
291 {
292 wrappedX = wrappedX - 360.0;
293 }
294 else if ( wrappedX < -180.0 )
295 {
296 wrappedX = wrappedX + 360.0;
297 }
298
299 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
300
301 int degreesX = int( std::fabs( wrappedX ) );
302 const double floatMinutesX = ( std::fabs( wrappedX ) - degreesX ) * 60.0;
303 int intMinutesX = int( floatMinutesX );
304 double secondsX = ( floatMinutesX - intMinutesX ) * 60.0;
305
306 //make sure rounding to specified precision doesn't create seconds >= 60
307 if ( std::round( secondsX * precisionMultiplier ) >= 60 * precisionMultiplier )
308 {
309 secondsX = std::max( secondsX - 60, 0.0 );
310 intMinutesX++;
311 if ( intMinutesX >= 60 )
312 {
313 intMinutesX -= 60;
314 degreesX++;
315 }
316 }
317
318 QString hemisphere;
319 QString sign;
320 if ( mUseSuffix )
321 {
322 hemisphere = wrappedX < 0 ? QObject::tr( "W" ) : QObject::tr( "E" );
323 }
324 else
325 {
326 if ( wrappedX < 0 )
327 {
328 sign = context.negativeSign();
329 }
330 }
331 //check if coordinate is all zeros for the specified precision, and if so,
332 //remove the sign and hemisphere strings
333 if ( degreesX == 0 && intMinutesX == 0 && std::round( secondsX * precisionMultiplier ) == 0 )
334 {
335 sign.clear();
336 hemisphere.clear();
337 }
338
339 //also remove directional prefix from 180 degree longitudes
340 if ( degreesX == 180 && intMinutesX == 0 && std::round( secondsX * precisionMultiplier ) == 0 )
341 {
342 hemisphere.clear();
343 }
344
345 QString minutesX;
346 QString strSecondsX;
347
348 ss << std::fixed << std::setprecision( 0 );
349 ss << intMinutesX;
350
351 minutesX = QString::fromStdWString( ss.str() );
352 ss.str( std::wstring() );
353
354 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
355 ss << secondsX;
356 strSecondsX = QString::fromStdWString( ss.str() );
357 ss.str( std::wstring() );
358
359 trimTrailingZeros( strSecondsX, context );
360
361 //pad with leading digits if required
362 if ( mShowLeadingZeros && intMinutesX < 10 )
363 minutesX = '0' + minutesX;
364
365 if ( mShowLeadingZeros && secondsX < 10 )
366 strSecondsX = '0' + strSecondsX;
367
368 ss << std::fixed << std::setprecision( 0 );
369 ss << degreesX;
370 QString degreesXStr = QString::fromStdWString( ss.str() );
371 ss.str( std::wstring() );
372
373 if ( mShowLeadingDegreeZeros )
374 degreesXStr = QString( QStringLiteral( "000" ) + degreesXStr ).right( 3 );
375
376 return sign + degreesXStr + QChar( 176 ) +
377 minutesX + QChar( 0x2032 ) +
378 strSecondsX + QChar( 0x2033 ) +
379 hemisphere;
380}
381
382QString QgsGeographicCoordinateNumericFormat::formatLatitudeAsDegreesMinutes( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
383{
384 //first, limit latitude to -180 to 180 degree range
385 double wrappedY = std::fmod( val, 180.0 );
386 //next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N"
387 if ( wrappedY > 90.0 )
388 {
389 wrappedY = wrappedY - 180.0;
390 }
391 else if ( wrappedY < -90.0 )
392 {
393 wrappedY = wrappedY + 180.0;
394 }
395
396 int degreesY = int( std::fabs( wrappedY ) );
397 double floatMinutesY = ( std::fabs( wrappedY ) - degreesY ) * 60.0;
398
399 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
400
401 //make sure rounding to specified precision doesn't create minutes >= 60
402 if ( std::round( floatMinutesY * precisionMultiplier ) >= 60 * precisionMultiplier )
403 {
404 floatMinutesY = std::max( floatMinutesY - 60, 0.0 );
405 degreesY++;
406 }
407
408 QString hemisphere;
409 QString sign;
410 if ( mUseSuffix )
411 {
412 hemisphere = wrappedY < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
413 }
414 else
415 {
416 if ( wrappedY < 0 )
417 {
418 sign = context.negativeSign();
419 }
420 }
421 //check if coordinate is all zeros for the specified precision, and if so,
422 //remove the sign and hemisphere strings
423 if ( degreesY == 0 && std::round( floatMinutesY * precisionMultiplier ) == 0 )
424 {
425 sign.clear();
426 hemisphere.clear();
427 }
428
429 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
430 ss << floatMinutesY;
431 QString strMinutesY = QString::fromStdWString( ss.str() );
432 ss.str( std::wstring() );
433
434 trimTrailingZeros( strMinutesY, context );
435
436 //pad with leading digits if required
437 if ( mShowLeadingZeros && floatMinutesY < 10 )
438 strMinutesY = '0' + strMinutesY;
439
440 ss << std::fixed << std::setprecision( 0 );
441 ss << degreesY;
442 QString degreesYStr = QString::fromStdWString( ss.str() );
443 ss.str( std::wstring() );
444
445 if ( mShowLeadingDegreeZeros )
446 degreesYStr = QString( QStringLiteral( "00" ) + degreesYStr ).right( 2 );
447
448 return sign + degreesYStr + QChar( 176 ) +
449 strMinutesY + QChar( 0x2032 ) +
450 hemisphere;
451}
452
453QString QgsGeographicCoordinateNumericFormat::formatLongitudeAsDegreesMinutes( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
454{
455 //first, limit longitude to -360 to 360 degree range
456 double wrappedX = std::fmod( val, 360.0 );
457 //next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W"
458 if ( wrappedX > 180.0 )
459 {
460 wrappedX = wrappedX - 360.0;
461 }
462 else if ( wrappedX < -180.0 )
463 {
464 wrappedX = wrappedX + 360.0;
465 }
466
467 int degreesX = int( std::fabs( wrappedX ) );
468 double floatMinutesX = ( std::fabs( wrappedX ) - degreesX ) * 60.0;
469
470 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
471
472 //make sure rounding to specified precision doesn't create minutes >= 60
473 if ( std::round( floatMinutesX * precisionMultiplier ) >= 60 * precisionMultiplier )
474 {
475 floatMinutesX = std::max( floatMinutesX - 60, 0.0 );
476 degreesX++;
477 }
478
479 QString hemisphere;
480 QString sign;
481 if ( mUseSuffix )
482 {
483 hemisphere = wrappedX < 0 ? QObject::tr( "W" ) : QObject::tr( "E" );
484 }
485 else
486 {
487 if ( wrappedX < 0 )
488 {
489 sign = context.negativeSign();
490 }
491 }
492 //check if coordinate is all zeros for the specified precision, and if so,
493 //remove the sign and hemisphere strings
494 if ( degreesX == 0 && std::round( floatMinutesX * precisionMultiplier ) == 0 )
495 {
496 sign.clear();
497 hemisphere.clear();
498 }
499
500 //also remove directional prefix from 180 degree longitudes
501 if ( degreesX == 180 && std::round( floatMinutesX * precisionMultiplier ) == 0 )
502 {
503 hemisphere.clear();
504 }
505
506 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
507 ss << floatMinutesX;
508 QString strMinutesX = QString::fromStdWString( ss.str() );
509 ss.str( std::wstring() );
510
511 trimTrailingZeros( strMinutesX, context );
512
513 //pad with leading digits if required
514 if ( mShowLeadingZeros && floatMinutesX < 10 )
515 strMinutesX = '0' + strMinutesX;
516
517 ss << std::fixed << std::setprecision( 0 );
518 ss << degreesX;
519 QString degreesXStr = QString::fromStdWString( ss.str() );
520 ss.str( std::wstring() );
521
522 if ( mShowLeadingDegreeZeros )
523 degreesXStr = QString( QStringLiteral( "000" ) + degreesXStr ).right( 3 );
524
525 return sign + degreesXStr + QChar( 176 ) +
526 strMinutesX + QChar( 0x2032 ) +
527 hemisphere;
528}
529
530QString QgsGeographicCoordinateNumericFormat::formatLatitudeAsDegrees( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
531{
532 //first, limit latitude to -180 to 180 degree range
533 double wrappedY = std::fmod( val, 180.0 );
534 //next, wrap around latitudes > 90 or < -90 degrees, so that eg "110S" -> "70N"
535 if ( wrappedY > 90.0 )
536 {
537 wrappedY = wrappedY - 180.0;
538 }
539 else if ( wrappedY < -90.0 )
540 {
541 wrappedY = wrappedY + 180.0;
542 }
543
544 const double absY = std::fabs( wrappedY );
545
546 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
547
548 QString hemisphere;
549 QString sign;
550 if ( mUseSuffix )
551 {
552 hemisphere = wrappedY < 0 ? QObject::tr( "S" ) : QObject::tr( "N" );
553 }
554 else
555 {
556 if ( wrappedY < 0 )
557 {
558 sign = context.negativeSign();
559 }
560 }
561 //check if coordinate is all zeros for the specified precision, and if so,
562 //remove the sign and hemisphere strings
563 if ( std::round( absY * precisionMultiplier ) == 0 )
564 {
565 sign.clear();
566 hemisphere.clear();
567 }
568
569 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
570 ss << absY;
571 QString strDegreesY = QString::fromStdWString( ss.str() );
572 ss.str( std::wstring() );
573
574 trimTrailingZeros( strDegreesY, context );
575
576 if ( mShowLeadingDegreeZeros && absY < 10 )
577 strDegreesY = '0' + strDegreesY;
578
579 return sign + strDegreesY + QChar( 176 ) + hemisphere;
580}
581
582QString QgsGeographicCoordinateNumericFormat::formatLongitudeAsDegrees( double val, std::basic_stringstream<wchar_t> &ss, const QgsNumericFormatContext &context ) const
583{
584 //first, limit longitude to -360 to 360 degree range
585 double wrappedX = std::fmod( val, 360.0 );
586 //next, wrap around longitudes > 180 or < -180 degrees, so that eg "190E" -> "170W"
587 if ( wrappedX > 180.0 )
588 {
589 wrappedX = wrappedX - 360.0;
590 }
591 else if ( wrappedX < -180.0 )
592 {
593 wrappedX = wrappedX + 360.0;
594 }
595
596 const double absX = std::fabs( wrappedX );
597
598 const double precisionMultiplier = std::pow( 10.0, numberDecimalPlaces() );
599
600 QString hemisphere;
601 QString sign;
602 if ( mUseSuffix )
603 {
604 hemisphere = wrappedX < 0 ? QObject::tr( "W" ) : QObject::tr( "E" );
605 }
606 else
607 {
608 if ( wrappedX < 0 )
609 {
610 sign = context.negativeSign();
611 }
612 }
613 //check if coordinate is all zeros for the specified precision, and if so,
614 //remove the sign and hemisphere strings
615 if ( std::round( absX * precisionMultiplier ) == 0 )
616 {
617 sign.clear();
618 hemisphere.clear();
619 }
620
621 //also remove directional prefix from 180 degree longitudes
622 if ( std::round( absX * precisionMultiplier ) == 180 * precisionMultiplier )
623 {
624 sign.clear();
625 hemisphere.clear();
626 }
627
628 ss << std::fixed << std::setprecision( numberDecimalPlaces() );
629 ss << absX;
630 QString strDegreesX = QString::fromStdWString( ss.str() );
631 ss.str( std::wstring() );
632
633 trimTrailingZeros( strDegreesX, context );
634
635 if ( mShowLeadingDegreeZeros && absX < 100 )
636 strDegreesX = '0' + strDegreesX;
637 if ( mShowLeadingDegreeZeros && absX < 10 )
638 strDegreesX = '0' + strDegreesX;
639
640 return sign + strDegreesX + QChar( 176 ) + hemisphere;
641}
642
643void QgsGeographicCoordinateNumericFormat::trimTrailingZeros( QString &input, const QgsNumericFormatContext &context ) const
644{
645 const QChar decimal = decimalSeparator().isNull() ? context.decimalSeparator() : decimalSeparator();
646 if ( !showTrailingZeros() && input.contains( decimal ) )
647 {
648 int trimPoint = input.length() - 1;
649
650 while ( input.at( trimPoint ) == context.zeroDigit() )
651 trimPoint--;
652
653 if ( input.at( trimPoint ) == decimal )
654 trimPoint--;
655
656 input.truncate( trimPoint + 1 );
657 }
658}
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:6234
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:6215
#define BUILTIN_UNREACHABLE
Definition qgis.h:6678