QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
Public Types | Public Member Functions | List of all members
QgsGeographicCoordinateNumericFormat Class Reference

A numeric formatter which returns a text representation of a geographic coordinate (latitude or longitude). More...

#include <qgscoordinatenumericformat.h>

Inheritance diagram for QgsGeographicCoordinateNumericFormat:
Inheritance graph
[legend]

Public Types

enum class  AngleFormat { DegreesMinutesSeconds , DegreesMinutes , DecimalDegrees }
 Angle format options. More...
 
- Public Types inherited from QgsBasicNumericFormat
enum  RoundingType { DecimalPlaces , SignificantFigures }
 Sets rounding type and behavior of the numberDecimalPlaces() setting. More...
 

Public Member Functions

 QgsGeographicCoordinateNumericFormat ()
 Default constructor. More...
 
AngleFormat angleFormat () const
 Returns the angle format, which controls how bearing the angles are formatted described in the returned strings. More...
 
QgsGeographicCoordinateNumericFormatclone () const override
 Clones the format, returning a new object. More...
 
QVariantMap configuration (const QgsReadWriteContext &context) const override
 Returns the current configuration of the formatter. More...
 
QgsNumericFormatcreate (const QVariantMap &configuration, const QgsReadWriteContext &context) const override
 Creates a new copy of the format, using the supplied configuration. More...
 
QString formatDouble (double value, const QgsNumericFormatContext &context) const override
 Returns a formatted string representation of a numeric double value. More...
 
QString id () const override
 Returns a unique id for this numeric format. More...
 
void setAngleFormat (AngleFormat format)
 Sets the directional formatting option, which controls how bearing the angles are formatted described in the returned strings. More...
 
void setConfiguration (const QVariantMap &configuration, const QgsReadWriteContext &context) override
 Sets the format's configuration. More...
 
void setShowDegreeLeadingZeros (bool show)
 Sets whether leading zeros for the degree values should be shown. More...
 
void setShowDirectionalSuffix (bool show)
 Sets whether directional suffixes (e.g. More...
 
void setShowLeadingZeros (bool show)
 Sets whether leading zeros in the minutes or seconds values should be shown. More...
 
bool showDegreeLeadingZeros () const
 Returns true if leading zeros for the degree values should be shown. More...
 
bool showDirectionalSuffix () const
 Returns true if directional suffixes (e.g. More...
 
bool showLeadingZeros () const
 Returns true if leading zeros in the minutes or seconds values should be shown. More...
 
int sortKey () override
 Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists. More...
 
double suggestSampleValue () const override
 Returns a suggested sample value which nicely represents the current format configuration. More...
 
QString visibleName () const override
 Returns the translated, user-visible name for this format. More...
 
- Public Member Functions inherited from QgsBasicNumericFormat
 QgsBasicNumericFormat ()
 Default constructor. More...
 
QgsNumericFormatclone () const override
 Clones the format, returning a new object. More...
 
QVariantMap configuration (const QgsReadWriteContext &context) const override
 Returns the current configuration of the formatter. More...
 
QgsNumericFormatcreate (const QVariantMap &configuration, const QgsReadWriteContext &context) const override
 Creates a new copy of the format, using the supplied configuration. More...
 
QChar decimalSeparator () const
 Returns any override for the decimal separator character. More...
 
QString formatDouble (double value, const QgsNumericFormatContext &context) const override
 Returns a formatted string representation of a numeric double value. More...
 
QString id () const override
 Returns a unique id for this numeric format. More...
 
int numberDecimalPlaces () const
 Returns the maximum number of decimal places to show. More...
 
RoundingType roundingType () const
 Returns the rounding type, which controls the behavior of the numberDecimalPlaces() setting. More...
 
void setDecimalSeparator (QChar character)
 Sets an override character for the decimal separator character. More...
 
virtual void setNumberDecimalPlaces (int places)
 Sets the maximum number of decimal places to show. More...
 
void setRoundingType (RoundingType type)
 Sets the rounding type, which controls the behavior of the numberDecimalPlaces() setting. More...
 
void setShowPlusSign (bool show)
 Sets whether a leading plus sign will be shown for positive values. More...
 
void setShowThousandsSeparator (bool show)
 Sets whether the thousands grouping separator will be shown. More...
 
void setShowTrailingZeros (bool show)
 Sets whether trailing zeros will be shown (up to the specified numberDecimalPlaces()). More...
 
void setThousandsSeparator (QChar character)
 Sets an override character for the thousands separator character. More...
 
bool showPlusSign () const
 Returns true if a leading plus sign will be shown for positive values. More...
 
bool showThousandsSeparator () const
 Returns true if the thousands grouping separator will be shown. More...
 
bool showTrailingZeros () const
 Returns true if trailing zeros will be shown (up to the specified numberDecimalPlaces()). More...
 
int sortKey () override
 Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists. More...
 
QChar thousandsSeparator () const
 Returns any override for the thousands separator character. More...
 
QString visibleName () const override
 Returns the translated, user-visible name for this format. More...
 
- Public Member Functions inherited from QgsNumericFormat
 QgsNumericFormat ()=default
 Default constructor. More...
 
virtual ~QgsNumericFormat ()=default
 
virtual QgsNumericFormatclone () const =0
 Clones the format, returning a new object. More...
 
virtual QVariantMap configuration (const QgsReadWriteContext &context) const =0
 Returns the current configuration of the formatter. More...
 
virtual QgsNumericFormatcreate (const QVariantMap &configuration, const QgsReadWriteContext &context) const =0
 Creates a new copy of the format, using the supplied configuration. More...
 
virtual QString formatDouble (double value, const QgsNumericFormatContext &context) const =0
 Returns a formatted string representation of a numeric double value. More...
 
virtual QString id () const =0
 Returns a unique id for this numeric format. More...
 
bool operator!= (const QgsNumericFormat &other) const
 
bool operator== (const QgsNumericFormat &other) const
 
virtual int sortKey ()
 Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists. More...
 
virtual double suggestSampleValue () const
 Returns a suggested sample value which nicely represents the current format configuration. More...
 
virtual QString visibleName () const =0
 Returns the translated, user-visible name for this format. More...
 
void writeXml (QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
 Writes the format to an XML element. More...
 

Additional Inherited Members

virtual void setConfiguration (const QVariantMap &configuration, const QgsReadWriteContext &context)
 Sets the format's configuration. More...
 
- Protected Attributes inherited from QgsBasicNumericFormat
bool mUseScientific = false
 
- Static Protected Attributes inherited from QgsNumericFormat
static constexpr int DEFAULT_SORT_KEY = 100
 

Detailed Description

A numeric formatter which returns a text representation of a geographic coordinate (latitude or longitude).

Since
QGIS 3.26

Definition at line 28 of file qgscoordinatenumericformat.h.

Member Enumeration Documentation

◆ AngleFormat

Angle format options.

Enumerator
DegreesMinutesSeconds 

Degrees, minutes and seconds, eg 30 degrees 45'30.

DegreesMinutes 

Degrees and decimal minutes, eg 30 degrees 45.55'.

DecimalDegrees 

Decimal degrees, eg 30.7555 degrees.

Definition at line 37 of file qgscoordinatenumericformat.h.

Constructor & Destructor Documentation

◆ QgsGeographicCoordinateNumericFormat()

QgsGeographicCoordinateNumericFormat::QgsGeographicCoordinateNumericFormat ( )

Default constructor.

Definition at line 43 of file qgscoordinatenumericformat.cpp.

Member Function Documentation

◆ angleFormat()

QgsGeographicCoordinateNumericFormat::AngleFormat QgsGeographicCoordinateNumericFormat::angleFormat ( ) const

Returns the angle format, which controls how bearing the angles are formatted described in the returned strings.

See also
setAngleFormat()

Definition at line 113 of file qgscoordinatenumericformat.cpp.

◆ clone()

QgsGeographicCoordinateNumericFormat * QgsGeographicCoordinateNumericFormat::clone ( ) const
overridevirtual

Clones the format, returning a new object.

The caller takes ownership of the returned object.

Reimplemented from QgsBasicNumericFormat.

Definition at line 87 of file qgscoordinatenumericformat.cpp.

◆ configuration()

QVariantMap QgsGeographicCoordinateNumericFormat::configuration ( const QgsReadWriteContext context) const
overridevirtual

Returns the current configuration of the formatter.

This value can be used in a call to create() in order to recreate this formatter in its current state.

Reimplemented from QgsBasicNumericFormat.

Definition at line 103 of file qgscoordinatenumericformat.cpp.

◆ create()

QgsNumericFormat * QgsGeographicCoordinateNumericFormat::create ( const QVariantMap &  configuration,
const QgsReadWriteContext context 
) const
overridevirtual

Creates a new copy of the format, using the supplied configuration.

The caller takes ownership of the returned object.

Reimplemented from QgsBasicNumericFormat.

Definition at line 92 of file qgscoordinatenumericformat.cpp.

◆ formatDouble()

QString QgsGeographicCoordinateNumericFormat::formatDouble ( double  value,
const QgsNumericFormatContext context 
) const
overridevirtual

Returns a formatted string representation of a numeric double value.

Reimplemented from QgsBasicNumericFormat.

Definition at line 67 of file qgscoordinatenumericformat.cpp.

◆ id()

QString QgsGeographicCoordinateNumericFormat::id ( ) const
overridevirtual

Returns a unique id for this numeric format.

This id is used to identify this numeric format in the registry with QgsNumericFormatRegistry::format().

Reimplemented from QgsBasicNumericFormat.

Definition at line 47 of file qgscoordinatenumericformat.cpp.

◆ setAngleFormat()

void QgsGeographicCoordinateNumericFormat::setAngleFormat ( QgsGeographicCoordinateNumericFormat::AngleFormat  format)

Sets the directional formatting option, which controls how bearing the angles are formatted described in the returned strings.

See also
angleFormat()

Definition at line 118 of file qgscoordinatenumericformat.cpp.

◆ setConfiguration()

void QgsGeographicCoordinateNumericFormat::setConfiguration ( const QVariantMap &  configuration,
const QgsReadWriteContext context 
)
overridevirtual

Sets the format's configuration.

Reimplemented from QgsBasicNumericFormat.

Definition at line 123 of file qgscoordinatenumericformat.cpp.

◆ setShowDegreeLeadingZeros()

void QgsGeographicCoordinateNumericFormat::setShowDegreeLeadingZeros ( bool  show)

Sets whether leading zeros for the degree values should be shown.

See also
showDegreeLeadingZeros()

Definition at line 147 of file qgscoordinatenumericformat.cpp.

◆ setShowDirectionalSuffix()

void QgsGeographicCoordinateNumericFormat::setShowDirectionalSuffix ( bool  show)

Sets whether directional suffixes (e.g.

"N") should be included.

See also
showDirectionalSuffix()

Definition at line 157 of file qgscoordinatenumericformat.cpp.

◆ setShowLeadingZeros()

void QgsGeographicCoordinateNumericFormat::setShowLeadingZeros ( bool  show)

Sets whether leading zeros in the minutes or seconds values should be shown.

See also
showLeadingZeros()

Definition at line 137 of file qgscoordinatenumericformat.cpp.

◆ showDegreeLeadingZeros()

bool QgsGeographicCoordinateNumericFormat::showDegreeLeadingZeros ( ) const

Returns true if leading zeros for the degree values should be shown.

See also
setShowDegreeLeadingZeros()

Definition at line 142 of file qgscoordinatenumericformat.cpp.

◆ showDirectionalSuffix()

bool QgsGeographicCoordinateNumericFormat::showDirectionalSuffix ( ) const

Returns true if directional suffixes (e.g.

"N") should be included.

See also
setShowDirectionalSuffix()

Definition at line 152 of file qgscoordinatenumericformat.cpp.

◆ showLeadingZeros()

bool QgsGeographicCoordinateNumericFormat::showLeadingZeros ( ) const

Returns true if leading zeros in the minutes or seconds values should be shown.

See also
setShowLeadingZeros()

Definition at line 132 of file qgscoordinatenumericformat.cpp.

◆ sortKey()

int QgsGeographicCoordinateNumericFormat::sortKey ( )
overridevirtual

Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.

Generally, subclasses should return QgsNumericFormat::sortKey() as their sorting key.

Reimplemented from QgsBasicNumericFormat.

Definition at line 57 of file qgscoordinatenumericformat.cpp.

◆ suggestSampleValue()

double QgsGeographicCoordinateNumericFormat::suggestSampleValue ( ) const
overridevirtual

Returns a suggested sample value which nicely represents the current format configuration.

Reimplemented from QgsNumericFormat.

Definition at line 62 of file qgscoordinatenumericformat.cpp.

◆ visibleName()

QString QgsGeographicCoordinateNumericFormat::visibleName ( ) const
overridevirtual

Returns the translated, user-visible name for this format.

Reimplemented from QgsBasicNumericFormat.

Definition at line 52 of file qgscoordinatenumericformat.cpp.


The documentation for this class was generated from the following files: