QGIS API Documentation
3.10.0-A Coruña (6c816b4204)
|
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... | |
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 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::UnitType | decodeUnitType (const QString &string, bool *ok=nullptr) |
Decodes a unit type from a string. More... | |
static Q_INVOKABLE 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::DistanceUnit unit) |
Encodes a distance 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::VolumeUnit unit) |
Encodes a volume unit to a string. More... | |
static Q_INVOKABLE QString | encodeUnit (QgsUnitTypes::AngleUnit unit) |
Encodes an angular 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::LayoutUnit unit) |
Encodes a layout 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::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit) |
Returns the conversion factor between the specified distance 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::VolumeUnit fromUnit, QgsUnitTypes::VolumeUnit toUnit) |
Returns the conversion factor between the specified volume units. 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 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 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 VolumeUnit | stringToVolumeUnit (const QString &string, bool *ok=nullptr) |
Converts a translatedstring to a volume unit. More... | |
static Q_INVOKABLE QString | toAbbreviatedString (QgsUnitTypes::DistanceUnit unit) |
Returns a translated abbreviation representing a distance unit. More... | |
static QString | toAbbreviatedString (QgsUnitTypes::AreaUnit unit) |
Returns a translated abbreviation representing an areal unit. More... | |
static QString | toAbbreviatedString (QgsUnitTypes::VolumeUnit unit) |
Returns a translated abbreviation representing a volume unit. More... | |
static Q_INVOKABLE QString | toAbbreviatedString (QgsUnitTypes::RenderUnit unit) |
Returns a translated abbreviation representing a render unit. More... | |
static QString | toAbbreviatedString (QgsUnitTypes::LayoutUnit unit) |
Returns a translated abbreviation representing a layout unit (e.g. More... | |
static Q_INVOKABLE QString | toString (QgsUnitTypes::DistanceUnit unit) |
Returns a translated string representing a distance unit. More... | |
static QString | toString (QgsUnitTypes::AreaUnit unit) |
Returns a translated string representing an areal unit. More... | |
static QString | toString (QgsUnitTypes::VolumeUnit unit) |
Returns a translated string representing a volume unit. More... | |
static QString | toString (QgsUnitTypes::AngleUnit unit) |
Returns a translated string representing an angular unit. More... | |
static QString | toString (QgsUnitTypes::RenderUnit unit) |
Returns a translated string representing a render unit. More... | |
static QString | toString (QgsUnitTypes::LayoutUnit unit) |
Returns a translated string representing a layout unit. More... | |
static Q_INVOKABLE DistanceUnitType | unitType (QgsUnitTypes::DistanceUnit unit) |
Returns the type for a distance unit. More... | |
static Q_INVOKABLE DistanceUnitType | unitType (QgsUnitTypes::AreaUnit unit) |
Returns the type for an areal unit. More... | |
static Q_INVOKABLE DistanceUnitType | unitType (QgsUnitTypes::VolumeUnit unit) |
Returns the type for an volume unit. More... | |
static Q_INVOKABLE QgsUnitTypes::LayoutUnitType | unitType (QgsUnitTypes::LayoutUnit units) |
Returns the type for a unit of measurement. 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... | |
Helper functions for various unit types.
Definition at line 38 of file qgsunittypes.h.
typedef QList<QgsUnitTypes::RenderUnit> QgsUnitTypes::RenderUnitList |
List of render units.
Definition at line 218 of file qgsunittypes.h.
Units of angles.
Definition at line 130 of file qgsunittypes.h.
Units of area.
Definition at line 92 of file qgsunittypes.h.
Units of distance.
Definition at line 66 of file qgsunittypes.h.
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 84 of file qgsunittypes.h.
Layout measurement units.
Definition at line 159 of file qgsunittypes.h.
Types of layout units.
Enumerator | |
---|---|
LayoutPaperUnits | Unit is a paper based measurement unit. |
LayoutScreenUnits | Unit is a screen based measurement unit. |
Definition at line 173 of file qgsunittypes.h.
Rendering size units.
Definition at line 145 of file qgsunittypes.h.
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.
Unit types.
Enumerator | |
---|---|
TypeDistance | Distance unit. |
TypeArea | Area unit. |
TypeVolume | Volume unit. |
TypeUnknown | Unknown unit type. |
Definition at line 57 of file qgsunittypes.h.
Units of volume.
Definition at line 113 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 1209 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 1776 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 652 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 160 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 2524 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 2429 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 46 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 1249 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 1171 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 1630 of file qgsunittypes.cpp.
|
static |
Encodes a distance unit to a string.
unit | unit to encode |
Definition at line 117 of file qgsunittypes.cpp.
|
static |
Encodes an areal unit to a string.
unit | unit to encode |
Definition at line 620 of file qgsunittypes.cpp.
|
static |
Encodes a volume unit to a string.
Definition at line 1720 of file qgsunittypes.cpp.
|
static |
Encodes an angular unit to a string.
unit | unit to encode |
Definition at line 1750 of file qgsunittypes.cpp.
|
static |
Encodes a render unit to a string.
unit | unit to encode |
Definition at line 2405 of file qgsunittypes.cpp.
|
static |
Encodes a layout unit to a string.
unit | unit to encode |
Definition at line 2500 of file qgsunittypes.cpp.
|
static |
Encodes a unit type to a string.
Definition at line 26 of file qgsunittypes.cpp.
|
static |
Returns an angle formatted as a friendly string.
angle | angle to format |
decimals | number of decimal places to show |
unit | unit of angle |
Definition at line 2046 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 2393 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 2381 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 347 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 791 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 1383 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 1833 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 2195 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 2084 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 754 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 307 of file qgsunittypes.cpp.
|
static |
Converts a translatedstring 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 1346 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing a distance unit.
unit | unit to convert to string |
Definition at line 264 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing an areal unit.
unit | unit to convert to string |
Definition at line 722 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing a volume unit.
Definition at line 1315 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing a render unit.
unit | unit to convert to string |
Definition at line 231 of file qgsunittypes.cpp.
|
static |
Returns a translated abbreviation representing a layout unit (e.g.
"mm").
Definition at line 2575 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing a distance unit.
unit | unit to convert to string |
Definition at line 194 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing an areal unit.
unit | unit to convert to string |
Definition at line 690 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing a volume unit.
Definition at line 1285 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing an angular unit.
unit | unit to convert to string |
Definition at line 1807 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing a render unit.
Definition at line 2466 of file qgsunittypes.cpp.
|
static |
Returns a translated string representing a layout unit.
Definition at line 2599 of file qgsunittypes.cpp.
|
static |
Returns the type for a distance unit.
Definition at line 68 of file qgsunittypes.cpp.
|
static |
Returns the type for an areal unit.
Definition at line 91 of file qgsunittypes.cpp.
|
static |
Returns the type for an volume unit.
Definition at line 1698 of file qgsunittypes.cpp.
|
static |
Returns the type for a unit of measurement.
Definition at line 2555 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 1668 of file qgsunittypes.cpp.