|
QGIS API Documentation 3.99.0-Master (26c88405ac0)
|
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 | |
| typedef QList< Qgis::RenderUnit > | RenderUnitList |
| List of render units. | |
Static Public Member Functions | |
| static Q_INVOKABLE Qgis::DistanceUnit | areaToDistanceUnit (Qgis::AreaUnit areaUnit) |
| Converts an area unit to its corresponding distance unit, e.g., square meters to meters. | |
| static Q_INVOKABLE Qgis::AngleUnit | decodeAngleUnit (const QString &string, bool *ok=nullptr) |
| Decodes an angular unit from a string. | |
| static Q_INVOKABLE Qgis::AreaUnit | decodeAreaUnit (const QString &string, bool *ok=nullptr) |
| Decodes an areal unit from a string. | |
| static Q_INVOKABLE Qgis::DistanceUnit | decodeDistanceUnit (const QString &string, bool *ok=nullptr) |
| Decodes a distance unit from a string. | |
| static Q_INVOKABLE Qgis::LayoutUnit | decodeLayoutUnit (const QString &string, bool *ok=nullptr) |
| Decodes a layout unit from a string. | |
| static Q_INVOKABLE Qgis::RenderUnit | decodeRenderUnit (const QString &string, bool *ok=nullptr) |
| Decodes a render unit from a string. | |
| static Q_INVOKABLE Qgis::TemporalUnit | decodeTemporalUnit (const QString &string, bool *ok=nullptr) |
| Decodes a temporal unit from a string. | |
| static Q_INVOKABLE Qgis::UnitType | decodeUnitType (const QString &string, bool *ok=nullptr) |
| Decodes a unit type from a string. | |
| static Q_INVOKABLE Qgis::VolumeUnit | decodeVolumeUnit (const QString &string, bool *ok=nullptr) |
| Decodes a volume unit from a string. | |
| static Q_INVOKABLE Qgis::AreaUnit | distanceToAreaUnit (Qgis::DistanceUnit distanceUnit) |
| Converts a distance unit to its corresponding area unit, e.g., meters to square meters. | |
| static Q_INVOKABLE Qgis::VolumeUnit | distanceToVolumeUnit (Qgis::DistanceUnit distanceUnit) |
| Converts a distance unit to its corresponding volume unit, e.g., meters to cubic meters. | |
| static QString | encodeUnit (Qgis::AngleUnit unit) |
| Encodes an angular unit to a string. | |
| static QString | encodeUnit (Qgis::AreaUnit unit) |
| Encodes an areal unit to a string. | |
| static Q_INVOKABLE QString | encodeUnit (Qgis::DistanceUnit unit) |
| Encodes a distance unit to a string. | |
| static QString | encodeUnit (Qgis::LayoutUnit unit) |
| Encodes a layout unit to a string. | |
| static QString | encodeUnit (Qgis::RenderUnit unit) |
| Encodes a render unit to a string. | |
| static QString | encodeUnit (Qgis::TemporalUnit unit) |
| Encodes a temporal unit to a string. | |
| static QString | encodeUnit (Qgis::VolumeUnit unit) |
| Encodes a volume unit to a string. | |
| static Q_INVOKABLE QString | encodeUnitType (Qgis::UnitType type) |
| Encodes a unit type to a string. | |
| static Q_INVOKABLE QString | formatAngle (double angle, int decimals, Qgis::AngleUnit unit) |
| Returns an angle formatted as a friendly string. | |
| static Q_INVOKABLE QString | formatArea (double area, int decimals, Qgis::AreaUnit unit, bool keepBaseUnit=false) |
| Returns an area formatted as a friendly string. | |
| static Q_INVOKABLE QString | formatDistance (double distance, int decimals, Qgis::DistanceUnit unit, bool keepBaseUnit=false) |
| Returns an distance formatted as a friendly string. | |
| static double | fromUnitToUnitFactor (Qgis::AngleUnit fromUnit, Qgis::AngleUnit toUnit) |
| Returns the conversion factor between the specified angular units. | |
| static double | fromUnitToUnitFactor (Qgis::AreaUnit fromUnit, Qgis::AreaUnit toUnit) |
| Returns the conversion factor between the specified areal units. | |
| static Q_INVOKABLE double | fromUnitToUnitFactor (Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit) |
| Returns the conversion factor between the specified distance units. | |
| static double | fromUnitToUnitFactor (Qgis::TemporalUnit fromUnit, Qgis::TemporalUnit toUnit) |
| Returns the conversion factor between the specified temporal units. | |
| static double | fromUnitToUnitFactor (Qgis::VolumeUnit fromUnit, Qgis::VolumeUnit toUnit) |
| Returns the conversion factor between the specified volume units. | |
| static Q_INVOKABLE QgsUnitTypes::AreaValue | scaledArea (double area, Qgis::AreaUnit unit, int decimals, bool keepBaseUnit=false) |
| Will convert an area with a given unit to an area value which is nice to display. | |
| static Q_INVOKABLE QgsUnitTypes::DistanceValue | scaledDistance (double distance, Qgis::DistanceUnit unit, int decimals, bool keepBaseUnit=false) |
| Will convert a distance with a given unit to a distance value which is nice to display. | |
| static Q_INVOKABLE Qgis::AreaUnit | stringToAreaUnit (const QString &string, bool *ok=nullptr) |
| Converts a translated string to an areal unit. | |
| static Q_INVOKABLE Qgis::DistanceUnit | stringToDistanceUnit (const QString &string, bool *ok=nullptr) |
| Converts a translated string to a distance unit. | |
| static Q_INVOKABLE Qgis::TemporalUnit | stringToTemporalUnit (const QString &string, bool *ok=nullptr) |
| Converts a translated string to a temporal unit. | |
| static Q_INVOKABLE Qgis::VolumeUnit | stringToVolumeUnit (const QString &string, bool *ok=nullptr) |
| Converts a translated string to a volume unit. | |
| static QString | toAbbreviatedString (Qgis::AreaUnit unit) |
| Returns a translated abbreviation representing an areal unit. | |
| static Q_INVOKABLE QString | toAbbreviatedString (Qgis::DistanceUnit unit) |
| Returns a translated abbreviation representing a distance unit. | |
| static QString | toAbbreviatedString (Qgis::LayoutUnit unit) |
| Returns a translated abbreviation representing a layout unit (e.g. | |
| static QString | toAbbreviatedString (Qgis::RenderUnit unit) |
| Returns a translated abbreviation representing a render unit. | |
| static QString | toAbbreviatedString (Qgis::TemporalUnit unit) |
| Returns a translated abbreviation representing a temporal unit. | |
| static QString | toAbbreviatedString (Qgis::VolumeUnit unit) |
| Returns a translated abbreviation representing a volume unit. | |
| static QString | toString (Qgis::AngleUnit unit) |
| Returns a translated string representing an angular unit. | |
| static QString | toString (Qgis::AreaUnit unit) |
| Returns a translated string representing an areal unit. | |
| static Q_INVOKABLE QString | toString (Qgis::DistanceUnit unit) |
| Returns a translated string representing a distance unit. | |
| static QString | toString (Qgis::LayoutUnit unit) |
| Returns a translated string representing a layout unit. | |
| static QString | toString (Qgis::RenderUnit unit) |
| Returns a translated string representing a render unit. | |
| static QString | toString (Qgis::TemporalUnit unit) |
| Returns a translated string representing a temporal unit. | |
| static QString | toString (Qgis::VolumeUnit unit) |
| Returns a translated string representing a volume unit. | |
| static Qgis::DistanceUnitType | unitType (Qgis::AreaUnit unit) |
| Returns the type for an areal unit. | |
| static Q_INVOKABLE Qgis::DistanceUnitType | unitType (Qgis::DistanceUnit unit) |
| Returns the type for a distance unit. | |
| static Q_INVOKABLE Qgis::LayoutUnitType | unitType (Qgis::LayoutUnit units) |
| Returns the type for a unit of measurement. | |
| static Qgis::DistanceUnitType | unitType (Qgis::VolumeUnit unit) |
| Returns the type for an volume unit. | |
| static Q_INVOKABLE Qgis::DistanceUnit | volumeToDistanceUnit (Qgis::VolumeUnit volumeUnit) |
| Converts a volume unit to its corresponding distance unit, e.g., cubic meters to meters. | |
Helper functions for various unit types.
Definition at line 39 of file qgsunittypes.h.
| typedef QList<Qgis::RenderUnit> QgsUnitTypes::RenderUnitList |
List of render units.
Definition at line 82 of file qgsunittypes.h.
|
static |
Converts an area unit to its corresponding distance unit, e.g., square meters to meters.
| areaUnit | area unit to convert |
Definition at line 1631 of file qgsunittypes.cpp.
|
static |
Decodes an angular unit from a string.
| string | string to decode |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 2736 of file qgsunittypes.cpp.
|
static |
Decodes an areal unit from a string.
| string | string to decode |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 967 of file qgsunittypes.cpp.
|
static |
Decodes a distance unit from a string.
| string | string to decode |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 328 of file qgsunittypes.cpp.
|
static |
Decodes a layout unit from a string.
| string | string to decode |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 3524 of file qgsunittypes.cpp.
|
static |
Decodes a render unit from a string.
| string | string to decode |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 3429 of file qgsunittypes.cpp.
|
static |
Decodes a temporal unit from a string.
| string | string to decode |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 1706 of file qgsunittypes.cpp.
|
static |
Decodes a unit type from a string.
| string | string to decode |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 52 of file qgsunittypes.cpp.
|
static |
Decodes a volume unit from a string.
| string | string to decode |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 2161 of file qgsunittypes.cpp.
|
static |
Converts a distance unit to its corresponding area unit, e.g., meters to square meters.
| distanceUnit | distance unit to convert |
Definition at line 1551 of file qgsunittypes.cpp.
|
static |
Converts a distance unit to its corresponding volume unit, e.g., meters to cubic meters.
| distanceUnit | distance unit to convert |
Definition at line 2545 of file qgsunittypes.cpp.
|
static |
Encodes an angular unit to a string.
| unit | unit to encode |
Definition at line 2710 of file qgsunittypes.cpp.
|
static |
Encodes an areal unit to a string.
| unit | unit to encode |
Definition at line 933 of file qgsunittypes.cpp.
|
static |
Encodes a distance unit to a string.
| unit | unit to encode |
Definition at line 166 of file qgsunittypes.cpp.
|
static |
Encodes a layout unit to a string.
| unit | unit to encode |
Definition at line 3500 of file qgsunittypes.cpp.
|
static |
Encodes a render unit to a string.
| unit | unit to encode |
Definition at line 3405 of file qgsunittypes.cpp.
|
static |
Encodes a temporal unit to a string.
Definition at line 1674 of file qgsunittypes.cpp.
|
static |
Encodes a volume unit to a string.
Definition at line 2680 of file qgsunittypes.cpp.
|
static |
Encodes a unit type to a string.
Definition at line 29 of file qgsunittypes.cpp.
|
static |
Returns an angle formatted as a friendly string.
| angle | angle to format |
| decimals | number of decimal places to show. A value of -1 indicates that an appropriate number of decimal places should automatically be selected. |
| unit | unit of angle |
Definition at line 3006 of file qgsunittypes.cpp.
|
static |
Returns an area formatted as a friendly string.
| area | area to format |
| decimals | number of decimal places to show |
| unit | unit of area |
| keepBaseUnit | set to false to allow conversion of large areas to more suitable units, e.g., square meters to square kilometers |
Definition at line 3385 of file qgsunittypes.cpp.
|
static |
Returns an distance formatted as a friendly string.
| distance | distance to format |
| decimals | number of decimal places to show |
| unit | unit of distance |
| keepBaseUnit | set to false to allow conversion of large distances to more suitable units, e.g., meters to kilometers |
Definition at line 3365 of file qgsunittypes.cpp.
|
static |
Returns the conversion factor between the specified angular units.
| fromUnit | angle unit to convert from |
| toUnit | angle unit to convert to |
Definition at line 2793 of file qgsunittypes.cpp.
|
static |
Returns the conversion factor between the specified areal units.
| fromUnit | area unit to convert from |
| toUnit | area unit to convert to |
Definition at line 1114 of file qgsunittypes.cpp.
|
static |
Returns the conversion factor between the specified distance units.
| fromUnit | distance unit to convert from |
| toUnit | distance unit to convert to |
Definition at line 869 of file qgsunittypes.cpp.
|
static |
Returns the conversion factor between the specified temporal units.
| fromUnit | temporal unit to convert from |
| toUnit | temporal unit to convert to |
Definition at line 1846 of file qgsunittypes.cpp.
|
static |
Returns the conversion factor between the specified volume units.
| fromUnit | volume unit to convert from |
| toUnit | volume unit to convert to |
Definition at line 2295 of file qgsunittypes.cpp.
|
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).
Definition at line 3169 of file qgsunittypes.cpp.
|
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).
Definition at line 3055 of file qgsunittypes.cpp.
|
static |
Converts a translated string to an areal unit.
| string | string representing an areal unit |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 1075 of file qgsunittypes.cpp.
|
static |
Converts a translated string to a distance unit.
| string | string representing a distance unit |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 683 of file qgsunittypes.cpp.
|
static |
Converts a translated string to a temporal unit.
| string | string representing a volume unit |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 1808 of file qgsunittypes.cpp.
|
static |
Converts a translated string to a volume unit.
| string | string representing a volume unit |
| ok | optional boolean, will be set to true if string was converted successfully |
Definition at line 2258 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing an areal unit.
| unit | unit to convert to string |
Definition at line 1041 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing a distance unit.
| unit | unit to convert to string |
Definition at line 589 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing a layout unit (e.g.
"mm").
Definition at line 3575 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing a render unit.
| unit | unit to convert to string |
Definition at line 556 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing a temporal unit.
Definition at line 1776 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing a volume unit.
Definition at line 2227 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing an angular unit.
| unit | unit to convert to string |
Definition at line 2767 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing an areal unit.
| unit | unit to convert to string |
Definition at line 1007 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing a distance unit.
| unit | unit to convert to string |
Definition at line 399 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing a layout unit.
Definition at line 3599 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing a render unit.
Definition at line 3466 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing a temporal unit.
Definition at line 1744 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing a volume unit.
Definition at line 2197 of file qgsunittypes.cpp.
|
static |
Returns the type for an areal unit.
Definition at line 139 of file qgsunittypes.cpp.
|
static |
Returns the type for a distance unit.
Definition at line 76 of file qgsunittypes.cpp.
|
static |
Returns the type for a unit of measurement.
Definition at line 3555 of file qgsunittypes.cpp.
|
static |
Returns the type for an volume unit.
Definition at line 2658 of file qgsunittypes.cpp.
|
static |
Converts a volume unit to its corresponding distance unit, e.g., cubic meters to meters.
| volumeUnit | volume unit to convert |
Definition at line 2628 of file qgsunittypes.cpp.