QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
Classes | Public Types | Static Public Member Functions | List of all members
QgsUnitTypes Class Reference

Helper functions for various unit types. More...

#include <qgsunittypes.h>

Classes

struct  AreaValue
 A combination of area value and unit. More...
 
struct  DistanceValue
 A combination of distance value and unit. More...
 

Public Types

enum  AngleUnit {
  AngleDegrees = 0 , AngleRadians , AngleGon , AngleMinutesOfArc ,
  AngleSecondsOfArc , AngleTurn , AngleMilliradiansSI , AngleMilNATO ,
  AngleUnknownUnit
}
 Units of angles. More...
 
enum  AreaUnit {
  AreaSquareMeters = 0 , AreaSquareKilometers , AreaSquareFeet , AreaSquareYards ,
  AreaSquareMiles , AreaHectares , AreaAcres , AreaSquareNauticalMiles ,
  AreaSquareDegrees , AreaSquareCentimeters , AreaSquareMillimeters , AreaUnknownUnit
}
 Units of area. More...
 
enum  DistanceUnit {
  DistanceMeters = 0 , DistanceKilometers , DistanceFeet , DistanceNauticalMiles ,
  DistanceYards , DistanceMiles , DistanceDegrees , DistanceCentimeters ,
  DistanceMillimeters , DistanceUnknownUnit
}
 Units of distance. More...
 
enum  DistanceUnitType { Standard = 0 , Geographic , UnknownType }
 Types of distance units. More...
 
enum  LayoutUnit {
  LayoutMillimeters = 0 , LayoutCentimeters , LayoutMeters , LayoutInches ,
  LayoutFeet , LayoutPoints , LayoutPicas , LayoutPixels
}
 Layout measurement units. More...
 
enum  LayoutUnitType { LayoutPaperUnits = 0 , LayoutScreenUnits }
 Types of layout units. More...
 
enum  RenderUnit {
  RenderMillimeters = 0 , RenderMapUnits , RenderPixels , RenderPercentage ,
  RenderPoints , RenderInches , RenderUnknownUnit , RenderMetersInMapUnits
}
 Rendering size units. More...
 
typedef QList< QgsUnitTypes::RenderUnitRenderUnitList
 List of render units. More...
 
enum  SystemOfMeasurement { UnknownSystem = 0 , MetricSystem , ImperialSystem , USCSSystem }
 Systems of unit measurement. More...
 
enum  TemporalUnit {
  TemporalMilliseconds , TemporalSeconds , TemporalMinutes , TemporalHours ,
  TemporalDays , TemporalWeeks , TemporalMonths , TemporalYears ,
  TemporalDecades , TemporalCenturies , TemporalUnknownUnit
}
 Temporal units. More...
 
enum  UnitType {
  TypeDistance = 0 , TypeArea , TypeVolume , TypeUnknown ,
  TypeTemporal
}
 Unit types. More...
 
enum  VolumeUnit {
  VolumeCubicMeters = 0 , VolumeCubicFeet , VolumeCubicYards , VolumeBarrel ,
  VolumeCubicDecimeter , VolumeLiters , VolumeGallonUS , VolumeCubicInch ,
  VolumeCubicCentimeter , VolumeCubicDegrees , VolumeUnknownUnit
}
 Units of volume. More...
 

Static Public Member Functions

static Q_INVOKABLE QgsUnitTypes::DistanceUnit areaToDistanceUnit (QgsUnitTypes::AreaUnit areaUnit)
 Converts an area unit to its corresponding distance unit, e.g., square meters to meters. More...
 
static Q_INVOKABLE QgsUnitTypes::AngleUnit decodeAngleUnit (const QString &string, bool *ok=nullptr)
 Decodes an angular unit from a string. More...
 
static Q_INVOKABLE QgsUnitTypes::AreaUnit decodeAreaUnit (const QString &string, bool *ok=nullptr)
 Decodes an areal unit from a string. More...
 
static Q_INVOKABLE QgsUnitTypes::DistanceUnit decodeDistanceUnit (const QString &string, bool *ok=nullptr)
 Decodes a distance unit from a string. More...
 
static Q_INVOKABLE QgsUnitTypes::LayoutUnit decodeLayoutUnit (const QString &string, bool *ok=nullptr)
 Decodes a layout unit from a string. More...
 
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit (const QString &string, bool *ok=nullptr)
 Decodes a render unit from a string. More...
 
static Q_INVOKABLE QgsUnitTypes::TemporalUnit decodeTemporalUnit (const QString &string, bool *ok=nullptr)
 Decodes a temporal unit from a string. More...
 
static Q_INVOKABLE QgsUnitTypes::UnitType decodeUnitType (const QString &string, bool *ok=nullptr)
 Decodes a unit type from a string. More...
 
static Q_INVOKABLE QgsUnitTypes::VolumeUnit decodeVolumeUnit (const QString &string, bool *ok=nullptr)
 Decodes a volume unit from a string. More...
 
static Q_INVOKABLE QgsUnitTypes::AreaUnit distanceToAreaUnit (QgsUnitTypes::DistanceUnit distanceUnit)
 Converts a distance unit to its corresponding area unit, e.g., meters to square meters. More...
 
static Q_INVOKABLE QgsUnitTypes::VolumeUnit distanceToVolumeUnit (QgsUnitTypes::DistanceUnit distanceUnit)
 Converts a distance unit to its corresponding volume unit, e.g., meters to cubic meters. More...
 
static Q_INVOKABLE QString encodeUnit (QgsUnitTypes::AngleUnit unit)
 Encodes an angular unit to a string. More...
 
static Q_INVOKABLE QString encodeUnit (QgsUnitTypes::AreaUnit unit)
 Encodes an areal unit to a string. More...
 
static Q_INVOKABLE QString encodeUnit (QgsUnitTypes::DistanceUnit unit)
 Encodes a distance unit to a string. More...
 
static Q_INVOKABLE QString encodeUnit (QgsUnitTypes::LayoutUnit unit)
 Encodes a layout unit to a string. More...
 
static Q_INVOKABLE QString encodeUnit (QgsUnitTypes::RenderUnit unit)
 Encodes a render unit to a string. More...
 
static Q_INVOKABLE QString encodeUnit (QgsUnitTypes::TemporalUnit unit)
 Encodes a temporal unit to a string. More...
 
static Q_INVOKABLE QString encodeUnit (QgsUnitTypes::VolumeUnit unit)
 Encodes a volume unit to a string. More...
 
static Q_INVOKABLE QString encodeUnitType (QgsUnitTypes::UnitType type)
 Encodes a unit type to a string. More...
 
static Q_INVOKABLE QString formatAngle (double angle, int decimals, QgsUnitTypes::AngleUnit unit)
 Returns an angle formatted as a friendly string. More...
 
static Q_INVOKABLE QString formatArea (double area, int decimals, QgsUnitTypes::AreaUnit unit, bool keepBaseUnit=false)
 Returns an area formatted as a friendly string. More...
 
static Q_INVOKABLE QString formatDistance (double distance, int decimals, QgsUnitTypes::DistanceUnit unit, bool keepBaseUnit=false)
 Returns an distance formatted as a friendly string. More...
 
static Q_INVOKABLE double fromUnitToUnitFactor (QgsUnitTypes::AngleUnit fromUnit, QgsUnitTypes::AngleUnit toUnit)
 Returns the conversion factor between the specified angular units. More...
 
static Q_INVOKABLE double fromUnitToUnitFactor (QgsUnitTypes::AreaUnit fromUnit, QgsUnitTypes::AreaUnit toUnit)
 Returns the conversion factor between the specified areal units. More...
 
static Q_INVOKABLE double fromUnitToUnitFactor (QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
 Returns the conversion factor between the specified distance units. More...
 
static Q_INVOKABLE double fromUnitToUnitFactor (QgsUnitTypes::TemporalUnit fromUnit, QgsUnitTypes::TemporalUnit toUnit)
 Returns the conversion factor between the specified temporal units. More...
 
static Q_INVOKABLE double fromUnitToUnitFactor (QgsUnitTypes::VolumeUnit fromUnit, QgsUnitTypes::VolumeUnit toUnit)
 Returns the conversion factor between the specified volume units. More...
 
static Q_INVOKABLE QgsUnitTypes::AreaValue scaledArea (double area, QgsUnitTypes::AreaUnit unit, int decimals, bool keepBaseUnit=false)
 Will convert an area with a given unit to an area value which is nice to display. More...
 
static Q_INVOKABLE QgsUnitTypes::DistanceValue scaledDistance (double distance, QgsUnitTypes::DistanceUnit unit, int decimals, bool keepBaseUnit=false)
 Will convert a distance with a given unit to a distance value which is nice to display. More...
 
static Q_INVOKABLE QgsUnitTypes::AreaUnit stringToAreaUnit (const QString &string, bool *ok=nullptr)
 Converts a translated string to an areal unit. More...
 
static Q_INVOKABLE QgsUnitTypes::DistanceUnit stringToDistanceUnit (const QString &string, bool *ok=nullptr)
 Converts a translated string to a distance unit. More...
 
static Q_INVOKABLE QgsUnitTypes::TemporalUnit stringToTemporalUnit (const QString &string, bool *ok=nullptr)
 Converts a translated string to a temporal unit. More...
 
static Q_INVOKABLE QgsUnitTypes::VolumeUnit stringToVolumeUnit (const QString &string, bool *ok=nullptr)
 Converts a translated string to a volume unit. More...
 
static QString toAbbreviatedString (QgsUnitTypes::AreaUnit unit)
 Returns a translated abbreviation representing an areal unit. More...
 
static Q_INVOKABLE QString toAbbreviatedString (QgsUnitTypes::DistanceUnit unit)
 Returns a translated abbreviation representing a distance unit. More...
 
static QString toAbbreviatedString (QgsUnitTypes::LayoutUnit unit)
 Returns a translated abbreviation representing a layout unit (e.g. More...
 
static QString toAbbreviatedString (QgsUnitTypes::RenderUnit unit)
 Returns a translated abbreviation representing a render unit. More...
 
static QString toAbbreviatedString (QgsUnitTypes::TemporalUnit unit)
 Returns a translated abbreviation representing a temporal unit. More...
 
static QString toAbbreviatedString (QgsUnitTypes::VolumeUnit unit)
 Returns a translated abbreviation representing a volume unit. More...
 
static QString toString (QgsUnitTypes::AngleUnit unit)
 Returns a translated string representing an angular unit. More...
 
static QString toString (QgsUnitTypes::AreaUnit unit)
 Returns a translated string representing an areal unit. More...
 
static Q_INVOKABLE QString toString (QgsUnitTypes::DistanceUnit unit)
 Returns a translated string representing a distance unit. More...
 
static QString toString (QgsUnitTypes::LayoutUnit unit)
 Returns a translated string representing a layout unit. More...
 
static QString toString (QgsUnitTypes::RenderUnit unit)
 Returns a translated string representing a render unit. More...
 
static QString toString (QgsUnitTypes::TemporalUnit unit)
 Returns a translated string representing a temporal unit. More...
 
static QString toString (QgsUnitTypes::VolumeUnit unit)
 Returns a translated string representing a volume unit. More...
 
static Q_INVOKABLE QgsUnitTypes::DistanceUnitType unitType (QgsUnitTypes::AreaUnit unit)
 Returns the type for an areal unit. More...
 
static Q_INVOKABLE QgsUnitTypes::DistanceUnitType unitType (QgsUnitTypes::DistanceUnit unit)
 Returns the type for a distance unit. More...
 
static Q_INVOKABLE QgsUnitTypes::LayoutUnitType unitType (QgsUnitTypes::LayoutUnit units)
 Returns the type for a unit of measurement. More...
 
static Q_INVOKABLE QgsUnitTypes::DistanceUnitType unitType (QgsUnitTypes::VolumeUnit unit)
 Returns the type for an volume unit. More...
 
static Q_INVOKABLE QgsUnitTypes::DistanceUnit volumeToDistanceUnit (QgsUnitTypes::VolumeUnit volumeUnit)
 Converts a volume unit to its corresponding distance unit, e.g., cubic meters to meters. More...
 

Detailed Description

Helper functions for various unit types.

Since
QGIS 2.14

Definition at line 38 of file qgsunittypes.h.

Member Typedef Documentation

◆ RenderUnitList

List of render units.

Definition at line 239 of file qgsunittypes.h.

Member Enumeration Documentation

◆ AngleUnit

Units of angles.

Enumerator
AngleDegrees 

Degrees.

AngleRadians 

Square kilometers.

AngleGon 

Gon/gradian.

AngleMinutesOfArc 

Minutes of arc.

AngleSecondsOfArc 

Seconds of arc.

AngleTurn 

Turn/revolutions.

AngleMilliradiansSI 

Angular milliradians (SI definition, 1/1000 of radian)

AngleMilNATO 

Angular mil (NATO definition, 6400 mil = 2PI radians)

AngleUnknownUnit 

Unknown angle unit.

Definition at line 131 of file qgsunittypes.h.

◆ AreaUnit

Units of area.

Enumerator
AreaSquareMeters 

Square meters.

AreaSquareKilometers 

Square kilometers.

AreaSquareFeet 

Square feet.

AreaSquareYards 

Square yards.

AreaSquareMiles 

Square miles.

AreaHectares 

Hectares.

AreaAcres 

Acres.

AreaSquareNauticalMiles 

Square nautical miles.

AreaSquareDegrees 

Square degrees, for planar geographic CRS area measurements.

AreaSquareCentimeters 

Square centimeters.

AreaSquareMillimeters 

Square millimeters.

AreaUnknownUnit 

Unknown areal unit.

Definition at line 93 of file qgsunittypes.h.

◆ DistanceUnit

Units of distance.

Enumerator
DistanceMeters 

Meters.

DistanceKilometers 

Kilometers.

DistanceFeet 

Imperial feet.

DistanceNauticalMiles 

Nautical miles.

DistanceYards 

Imperial yards.

DistanceMiles 

Terrestrial miles.

DistanceDegrees 

Degrees, for planar geographic CRS distance measurements.

DistanceCentimeters 

Centimeters.

DistanceMillimeters 

Millimeters.

DistanceUnknownUnit 

Unknown distance unit.

Definition at line 67 of file qgsunittypes.h.

◆ DistanceUnitType

Types of distance units.

Enumerator
Standard 

Unit is a standard measurement unit.

Geographic 

Unit is a geographic (e.g., degree based) unit.

UnknownType 

Unknown unit type.

Definition at line 85 of file qgsunittypes.h.

◆ LayoutUnit

Layout measurement units.

Enumerator
LayoutMillimeters 

Millimeters.

LayoutCentimeters 

Centimeters.

LayoutMeters 

Meters.

LayoutInches 

Inches.

LayoutFeet 

Feet.

LayoutPoints 

Typographic points.

LayoutPicas 

Typographic picas.

LayoutPixels 

Pixels.

Definition at line 180 of file qgsunittypes.h.

◆ LayoutUnitType

Types of layout units.

Enumerator
LayoutPaperUnits 

Unit is a paper based measurement unit.

LayoutScreenUnits 

Unit is a screen based measurement unit.

Definition at line 194 of file qgsunittypes.h.

◆ RenderUnit

Rendering size units.

Enumerator
RenderMillimeters 

Millimeters.

RenderMapUnits 

Map units.

RenderPixels 

Pixels.

RenderPercentage 

Percentage of another measurement (e.g., canvas size, feature size)

RenderPoints 

Points (e.g., for font sizes)

RenderInches 

Inches.

RenderUnknownUnit 

Mixed or unknown units.

RenderMetersInMapUnits 

Meters value as Map units.

Definition at line 166 of file qgsunittypes.h.

◆ SystemOfMeasurement

Systems of unit measurement.

Enumerator
UnknownSystem 

Unknown system of measurement.

MetricSystem 

International System of Units (SI)

ImperialSystem 

British Imperial.

USCSSystem 

United States customary system.

Definition at line 44 of file qgsunittypes.h.

◆ TemporalUnit

Temporal units.

Since
QGIS 3.14
Enumerator
TemporalMilliseconds 

Milliseconds.

TemporalSeconds 

Seconds.

TemporalMinutes 

Minutes.

TemporalHours 

Hours.

TemporalDays 

Days.

TemporalWeeks 

Weeks.

TemporalMonths 

Months.

TemporalYears 

Years.

TemporalDecades 

Decades.

TemporalCenturies 

Centuries.

TemporalUnknownUnit 

Unknown time unit.

Definition at line 149 of file qgsunittypes.h.

◆ UnitType

Unit types.

Since
QGIS 3.10
Enumerator
TypeDistance 

Distance unit.

TypeArea 

Area unit.

TypeVolume 

Volume unit.

TypeUnknown 

Unknown unit type.

TypeTemporal 

Temporal unit.

Definition at line 57 of file qgsunittypes.h.

◆ VolumeUnit

Units of volume.

Since
QGIS 3.10
Enumerator
VolumeCubicMeters 

Cubic meters.

VolumeCubicFeet 

Cubic feet.

VolumeCubicYards 

Cubic yards.

VolumeBarrel 

Barrels.

VolumeCubicDecimeter 

Cubic decimeters.

VolumeLiters 

Litres.

VolumeGallonUS 

US Gallons.

VolumeCubicInch 

Cubic inches.

VolumeCubicCentimeter 

Cubic Centimeters.

VolumeCubicDegrees 

Cubic degrees, for planar geographic CRS volume measurements.

VolumeUnknownUnit 

Unknown volume unit.

Definition at line 114 of file qgsunittypes.h.

Member Function Documentation

◆ areaToDistanceUnit()

QgsUnitTypes::DistanceUnit QgsUnitTypes::areaToDistanceUnit ( QgsUnitTypes::AreaUnit  areaUnit)
static

Converts an area unit to its corresponding distance unit, e.g., square meters to meters.

Parameters
areaUnitarea unit to convert
Returns
matching distance unit
Since
QGIS 3.10

Definition at line 1214 of file qgsunittypes.cpp.

◆ decodeAngleUnit()

QgsUnitTypes::AngleUnit QgsUnitTypes::decodeAngleUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes an angular unit from a string.

Parameters
stringstring to decode
okoptional boolean, will be set to true if string was converted successfully
Returns
decoded units
See also
encodeUnit()

Definition at line 2247 of file qgsunittypes.cpp.

◆ decodeAreaUnit()

QgsUnitTypes::AreaUnit QgsUnitTypes::decodeAreaUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes an areal unit from a string.

Parameters
stringstring to decode
okoptional boolean, will be set to true if string was converted successfully
Returns
decoded units
See also
encodeUnit()

Definition at line 657 of file qgsunittypes.cpp.

◆ decodeDistanceUnit()

QgsUnitTypes::DistanceUnit QgsUnitTypes::decodeDistanceUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes a distance unit from a string.

Parameters
stringstring to decode
okoptional boolean, will be set to true if string was converted successfully
Returns
decoded units
See also
encodeUnit()

Definition at line 165 of file qgsunittypes.cpp.

◆ decodeLayoutUnit()

QgsUnitTypes::LayoutUnit QgsUnitTypes::decodeLayoutUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes a layout unit from a string.

Parameters
stringstring to decode
okoptional boolean, will be set to true if string was converted successfully
Returns
decoded units
See also
encodeUnit()
Since
QGIS 3.0

Definition at line 2995 of file qgsunittypes.cpp.

◆ decodeRenderUnit()

QgsUnitTypes::RenderUnit QgsUnitTypes::decodeRenderUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes a render unit from a string.

Parameters
stringstring to decode
okoptional boolean, will be set to true if string was converted successfully
Returns
decoded units
See also
encodeUnit()

Definition at line 2900 of file qgsunittypes.cpp.

◆ decodeTemporalUnit()

QgsUnitTypes::TemporalUnit QgsUnitTypes::decodeTemporalUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes a temporal unit from a string.

Parameters
stringstring to decode
okoptional boolean, will be set to true if string was converted successfully
Returns
decoded units
See also
encodeUnit()
Since
QGIS 3.14

Definition at line 1284 of file qgsunittypes.cpp.

◆ decodeUnitType()

QgsUnitTypes::UnitType QgsUnitTypes::decodeUnitType ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes a unit type from a string.

Parameters
stringstring to decode
okoptional boolean, will be set to true if string was converted successfully
Returns
decoded unit type
See also
encodeUnitType()
Since
QGIS 3.10

Definition at line 49 of file qgsunittypes.cpp.

◆ decodeVolumeUnit()

QgsUnitTypes::VolumeUnit QgsUnitTypes::decodeVolumeUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes a volume unit from a string.

Parameters
stringstring to decode
okoptional boolean, will be set to true if string was converted successfully
Returns
decoded units
See also
encodeUnit()
Since
QGIS 3.10

Definition at line 1720 of file qgsunittypes.cpp.

◆ distanceToAreaUnit()

QgsUnitTypes::AreaUnit QgsUnitTypes::distanceToAreaUnit ( QgsUnitTypes::DistanceUnit  distanceUnit)
static

Converts a distance unit to its corresponding area unit, e.g., meters to square meters.

Parameters
distanceUnitdistance unit to convert
Returns
matching areal unit

Definition at line 1176 of file qgsunittypes.cpp.

◆ distanceToVolumeUnit()

QgsUnitTypes::VolumeUnit QgsUnitTypes::distanceToVolumeUnit ( QgsUnitTypes::DistanceUnit  distanceUnit)
static

Converts a distance unit to its corresponding volume unit, e.g., meters to cubic meters.

Parameters
distanceUnitdistance unit to convert
Returns
matching volume unit
Since
QGIS 3.10

Definition at line 2101 of file qgsunittypes.cpp.

◆ encodeUnit() [1/7]

QString QgsUnitTypes::encodeUnit ( QgsUnitTypes::AngleUnit  unit)
static

Encodes an angular unit to a string.

Parameters
unitunit to encode
Returns
encoded string
See also
decodeAngleUnit()

Definition at line 2221 of file qgsunittypes.cpp.

◆ encodeUnit() [2/7]

QString QgsUnitTypes::encodeUnit ( QgsUnitTypes::AreaUnit  unit)
static

Encodes an areal unit to a string.

Parameters
unitunit to encode
Returns
encoded string
See also
decodeAreaUnit()

Definition at line 625 of file qgsunittypes.cpp.

◆ encodeUnit() [3/7]

QString QgsUnitTypes::encodeUnit ( QgsUnitTypes::DistanceUnit  unit)
static

Encodes a distance unit to a string.

Parameters
unitunit to encode
Returns
encoded string
See also
decodeDistanceUnit()

Definition at line 122 of file qgsunittypes.cpp.

◆ encodeUnit() [4/7]

QString QgsUnitTypes::encodeUnit ( QgsUnitTypes::LayoutUnit  unit)
static

Encodes a layout unit to a string.

Parameters
unitunit to encode
Returns
encoded string
See also
decodeLayoutUnit()
Since
QGIS 3.0

Definition at line 2971 of file qgsunittypes.cpp.

◆ encodeUnit() [5/7]

QString QgsUnitTypes::encodeUnit ( QgsUnitTypes::RenderUnit  unit)
static

Encodes a render unit to a string.

Parameters
unitunit to encode
Returns
encoded string
See also
decodeRenderUnit()

Definition at line 2876 of file qgsunittypes.cpp.

◆ encodeUnit() [6/7]

QString QgsUnitTypes::encodeUnit ( QgsUnitTypes::TemporalUnit  unit)
static

Encodes a temporal unit to a string.

Returns
encoded string
See also
decodeTemporalUnit()
Since
QGIS 3.14

Definition at line 1254 of file qgsunittypes.cpp.

◆ encodeUnit() [7/7]

QString QgsUnitTypes::encodeUnit ( QgsUnitTypes::VolumeUnit  unit)
static

Encodes a volume unit to a string.

Returns
encoded string
See also
decodeVolumeUnit()
Since
QGIS 3.10

Definition at line 2191 of file qgsunittypes.cpp.

◆ encodeUnitType()

QString QgsUnitTypes::encodeUnitType ( QgsUnitTypes::UnitType  type)
static

Encodes a unit type to a string.

Returns
encoded string
See also
decodeUnitType()
Since
QGIS 3.10

Definition at line 26 of file qgsunittypes.cpp.

◆ formatAngle()

QString QgsUnitTypes::formatAngle ( double  angle,
int  decimals,
QgsUnitTypes::AngleUnit  unit 
)
static

Returns an angle formatted as a friendly string.

Parameters
angleangle to format
decimalsnumber of decimal places to show
unitunit of angle
Returns
formatted angle string

Definition at line 2517 of file qgsunittypes.cpp.

◆ formatArea()

QString QgsUnitTypes::formatArea ( double  area,
int  decimals,
QgsUnitTypes::AreaUnit  unit,
bool  keepBaseUnit = false 
)
static

Returns an area formatted as a friendly string.

Parameters
areaarea to format
decimalsnumber of decimal places to show
unitunit of area
keepBaseUnitset to false to allow conversion of large areas to more suitable units, e.g., square meters to square kilometers
Returns
formatted area string
See also
formatDistance()
Since
QGIS 3.0

Definition at line 2864 of file qgsunittypes.cpp.

◆ formatDistance()

QString QgsUnitTypes::formatDistance ( double  distance,
int  decimals,
QgsUnitTypes::DistanceUnit  unit,
bool  keepBaseUnit = false 
)
static

Returns an distance formatted as a friendly string.

Parameters
distancedistance to format
decimalsnumber of decimal places to show
unitunit of distance
keepBaseUnitset to false to allow conversion of large distances to more suitable units, e.g., meters to kilometers
Returns
formatted distance string
See also
formatArea()
Since
QGIS 3.0

Definition at line 2852 of file qgsunittypes.cpp.

◆ fromUnitToUnitFactor() [1/5]

double QgsUnitTypes::fromUnitToUnitFactor ( QgsUnitTypes::AngleUnit  fromUnit,
QgsUnitTypes::AngleUnit  toUnit 
)
static

Returns the conversion factor between the specified angular units.

Parameters
fromUnitangle unit to convert from
toUnitangle unit to convert to
Returns
multiplication factor to convert between units

Definition at line 2304 of file qgsunittypes.cpp.

◆ fromUnitToUnitFactor() [2/5]

double QgsUnitTypes::fromUnitToUnitFactor ( QgsUnitTypes::AreaUnit  fromUnit,
QgsUnitTypes::AreaUnit  toUnit 
)
static

Returns the conversion factor between the specified areal units.

Parameters
fromUnitarea unit to convert from
toUnitarea unit to convert to
Returns
multiplication factor to convert between units

Definition at line 796 of file qgsunittypes.cpp.

◆ fromUnitToUnitFactor() [3/5]

double QgsUnitTypes::fromUnitToUnitFactor ( QgsUnitTypes::DistanceUnit  fromUnit,
QgsUnitTypes::DistanceUnit  toUnit 
)
static

Returns the conversion factor between the specified distance units.

Parameters
fromUnitdistance unit to convert from
toUnitdistance unit to convert to
Returns
multiplication factor to convert between units

Definition at line 352 of file qgsunittypes.cpp.

◆ fromUnitToUnitFactor() [4/5]

double QgsUnitTypes::fromUnitToUnitFactor ( QgsUnitTypes::TemporalUnit  fromUnit,
QgsUnitTypes::TemporalUnit  toUnit 
)
static

Returns the conversion factor between the specified temporal units.

Note
Conversion to or from month units assumes a 30 day month length.
Conversion to or from year based units assumes a 365.25 day year length.
Parameters
fromUnittemporal unit to convert from
toUnittemporal unit to convert to
Returns
multiplication factor to convert between units
Since
QGIS 3.14

Definition at line 1416 of file qgsunittypes.cpp.

◆ fromUnitToUnitFactor() [5/5]

double QgsUnitTypes::fromUnitToUnitFactor ( QgsUnitTypes::VolumeUnit  fromUnit,
QgsUnitTypes::VolumeUnit  toUnit 
)
static

Returns the conversion factor between the specified volume units.

Parameters
fromUnitvolume unit to convert from
toUnitvolume unit to convert to
Returns
multiplication factor to convert between units
Since
QGIS 3.10

Definition at line 1854 of file qgsunittypes.cpp.

◆ scaledArea()

QgsUnitTypes::AreaValue QgsUnitTypes::scaledArea ( double  area,
QgsUnitTypes::AreaUnit  unit,
int  decimals,
bool  keepBaseUnit = false 
)
static

Will convert an area with a given unit to an area value which is nice to display.

It will convert between different units (e.g. from square meters to square kilometers) if appropriate, unless forced otherwise with keepBaseUnit. The value will also be rounded to decimals (be prepared that the returned value is still a double so it will require further formatting when converting to a string).

Since
QGIS 3.0

Definition at line 2666 of file qgsunittypes.cpp.

◆ scaledDistance()

QgsUnitTypes::DistanceValue QgsUnitTypes::scaledDistance ( double  distance,
QgsUnitTypes::DistanceUnit  unit,
int  decimals,
bool  keepBaseUnit = false 
)
static

Will convert a distance with a given unit to a distance value which is nice to display.

It will convert between different units (e.g. from meters to kilometers or millimeters) if appropriate, unless forced otherwise with keepBaseUnit. The value will also be rounded to decimals (be prepared that the returned value is still a double so it will require further formatting when converting to a string).

Since
QGIS 3.0

Definition at line 2555 of file qgsunittypes.cpp.

◆ stringToAreaUnit()

QgsUnitTypes::AreaUnit QgsUnitTypes::stringToAreaUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Converts a translated string to an areal unit.

Parameters
stringstring representing an areal unit
okoptional boolean, will be set to true if string was converted successfully
Returns
the area unit
See also
toString()

Definition at line 759 of file qgsunittypes.cpp.

◆ stringToDistanceUnit()

QgsUnitTypes::DistanceUnit QgsUnitTypes::stringToDistanceUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Converts a translated string to a distance unit.

Parameters
stringstring representing a distance unit
okoptional boolean, will be set to true if string was converted successfully
Returns
the distance unit
See also
toString()

Definition at line 312 of file qgsunittypes.cpp.

◆ stringToTemporalUnit()

QgsUnitTypes::TemporalUnit QgsUnitTypes::stringToTemporalUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Converts a translated string to a temporal unit.

Parameters
stringstring representing a volume unit
okoptional boolean, will be set to true if string was converted successfully
Returns
the temporal unit
See also
toString()
Since
QGIS 3.14

Definition at line 1380 of file qgsunittypes.cpp.

◆ stringToVolumeUnit()

QgsUnitTypes::VolumeUnit QgsUnitTypes::stringToVolumeUnit ( const QString &  string,
bool *  ok = nullptr 
)
static

Converts a translated string to a volume unit.

Parameters
stringstring representing a volume unit
okoptional boolean, will be set to true if string was converted successfully
Returns
the volume unit
See also
toString()
Since
QGIS 3.10

Definition at line 1817 of file qgsunittypes.cpp.

◆ toAbbreviatedString() [1/6]

QString QgsUnitTypes::toAbbreviatedString ( QgsUnitTypes::AreaUnit  unit)
static

Returns a translated abbreviation representing an areal unit.

Parameters
unitunit to convert to string
See also
stringToAreaUnit()
Since
QGIS 3.0

Definition at line 727 of file qgsunittypes.cpp.

◆ toAbbreviatedString() [2/6]

QString QgsUnitTypes::toAbbreviatedString ( QgsUnitTypes::DistanceUnit  unit)
static

Returns a translated abbreviation representing a distance unit.

Parameters
unitunit to convert to string
See also
stringToDistanceUnit()
Since
QGIS 3.0

Definition at line 269 of file qgsunittypes.cpp.

◆ toAbbreviatedString() [3/6]

QString QgsUnitTypes::toAbbreviatedString ( QgsUnitTypes::LayoutUnit  unit)
static

Returns a translated abbreviation representing a layout unit (e.g.

"mm").

Since
QGIS 3.0

Definition at line 3046 of file qgsunittypes.cpp.

◆ toAbbreviatedString() [4/6]

QString QgsUnitTypes::toAbbreviatedString ( QgsUnitTypes::RenderUnit  unit)
static

Returns a translated abbreviation representing a render unit.

Parameters
unitunit to convert to string
Since
QGIS 3.8

Definition at line 236 of file qgsunittypes.cpp.

◆ toAbbreviatedString() [5/6]

QString QgsUnitTypes::toAbbreviatedString ( QgsUnitTypes::TemporalUnit  unit)
static

Returns a translated abbreviation representing a temporal unit.

See also
stringToTemporalUnit()
Since
QGIS 3.14

Definition at line 1350 of file qgsunittypes.cpp.

◆ toAbbreviatedString() [6/6]

QString QgsUnitTypes::toAbbreviatedString ( QgsUnitTypes::VolumeUnit  unit)
static

Returns a translated abbreviation representing a volume unit.

See also
stringToVolumeUnit()
Since
QGIS 3.10

Definition at line 1786 of file qgsunittypes.cpp.

◆ toString() [1/7]

QString QgsUnitTypes::toString ( QgsUnitTypes::AngleUnit  unit)
static

Returns a translated string representing an angular unit.

Parameters
unitunit to convert to string

Definition at line 2278 of file qgsunittypes.cpp.

◆ toString() [2/7]

QString QgsUnitTypes::toString ( QgsUnitTypes::AreaUnit  unit)
static

Returns a translated string representing an areal unit.

Parameters
unitunit to convert to string
See also
stringToAreaUnit()

Definition at line 695 of file qgsunittypes.cpp.

◆ toString() [3/7]

QString QgsUnitTypes::toString ( QgsUnitTypes::DistanceUnit  unit)
static

Returns a translated string representing a distance unit.

Parameters
unitunit to convert to string
See also
stringToDistanceUnit()

Definition at line 199 of file qgsunittypes.cpp.

◆ toString() [4/7]

QString QgsUnitTypes::toString ( QgsUnitTypes::LayoutUnit  unit)
static

Returns a translated string representing a layout unit.

Since
QGIS 3.0

Definition at line 3070 of file qgsunittypes.cpp.

◆ toString() [5/7]

QString QgsUnitTypes::toString ( QgsUnitTypes::RenderUnit  unit)
static

Returns a translated string representing a render unit.

Since
QGIS 3.0

Definition at line 2937 of file qgsunittypes.cpp.

◆ toString() [6/7]

QString QgsUnitTypes::toString ( QgsUnitTypes::TemporalUnit  unit)
static

Returns a translated string representing a temporal unit.

See also
stringToTemporalUnit()
Since
QGIS 3.14

Definition at line 1320 of file qgsunittypes.cpp.

◆ toString() [7/7]

QString QgsUnitTypes::toString ( QgsUnitTypes::VolumeUnit  unit)
static

Returns a translated string representing a volume unit.

See also
stringToVolumeUnit()
Since
QGIS 3.10

Definition at line 1756 of file qgsunittypes.cpp.

◆ unitType() [1/4]

QgsUnitTypes::DistanceUnitType QgsUnitTypes::unitType ( QgsUnitTypes::AreaUnit  unit)
static

Returns the type for an areal unit.

Definition at line 96 of file qgsunittypes.cpp.

◆ unitType() [2/4]

QgsUnitTypes::DistanceUnitType QgsUnitTypes::unitType ( QgsUnitTypes::DistanceUnit  unit)
static

Returns the type for a distance unit.

Definition at line 73 of file qgsunittypes.cpp.

◆ unitType() [3/4]

QgsUnitTypes::LayoutUnitType QgsUnitTypes::unitType ( QgsUnitTypes::LayoutUnit  units)
static

Returns the type for a unit of measurement.

Since
QGIS 3.0

Definition at line 3026 of file qgsunittypes.cpp.

◆ unitType() [4/4]

QgsUnitTypes::DistanceUnitType QgsUnitTypes::unitType ( QgsUnitTypes::VolumeUnit  unit)
static

Returns the type for an volume unit.

Since
QGIS 3.10

Definition at line 2169 of file qgsunittypes.cpp.

◆ volumeToDistanceUnit()

QgsUnitTypes::DistanceUnit QgsUnitTypes::volumeToDistanceUnit ( QgsUnitTypes::VolumeUnit  volumeUnit)
static

Converts a volume unit to its corresponding distance unit, e.g., cubic meters to meters.

Parameters
volumeUnitvolume unit to convert
Returns
matching distance unit
Since
QGIS 3.10

Definition at line 2139 of file qgsunittypes.cpp.


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