QGIS API Documentation  2.99.0-Master (a18066b)
Public Types | Static Public Member Functions | List of all members
QgsUnitTypes Class Reference

Helper functions for various unit types. More...

#include <qgsunittypes.h>

Public Types

enum  AngleUnit {
  AngleDegrees = 0, AngleRadians, AngleGon, AngleMinutesOfArc,
  AngleSecondsOfArc, AngleTurn, AngleUnknownUnit
}
 Units of angles. More...
 
enum  AreaUnit {
  AreaSquareMeters = 0, AreaSquareKilometers, AreaSquareFeet, AreaSquareYards,
  AreaSquareMiles, AreaHectares, AreaAcres, AreaSquareNauticalMiles,
  AreaSquareDegrees, AreaUnknownUnit
}
 Units of area. More...
 
enum  DistanceUnit {
  DistanceMeters = 0, DistanceKilometers, DistanceFeet, DistanceNauticalMiles,
  DistanceYards, DistanceMiles, DistanceDegrees, DistanceUnknownUnit
}
 Units of distance. More...
 
enum  DistanceUnitType { Standard = 0, Geographic, UnknownType }
 Types of distance units. More...
 
enum  RenderUnit {
  RenderMillimeters = 0, RenderMapUnits, RenderPixels, RenderPercentage,
  RenderPoints, RenderInches, RenderUnknownUnit
}
 Rendering size units. More...
 
typedef QList< RenderUnitRenderUnitList
 List of render units. More...
 

Static Public Member Functions

static Q_INVOKABLE AngleUnit decodeAngleUnit (const QString &string, bool *ok=0)
 Decodes an angular unit from a string. More...
 
static Q_INVOKABLE AreaUnit decodeAreaUnit (const QString &string, bool *ok=0)
 Decodes an areal unit from a string. More...
 
static Q_INVOKABLE QgsUnitTypes::DistanceUnit decodeDistanceUnit (const QString &string, bool *ok=0)
 Decodes a distance unit from a string. More...
 
static Q_INVOKABLE RenderUnit decodeRenderUnit (const QString &string, bool *ok=0)
 Decodes a render unit from a string. More...
 
static Q_INVOKABLE AreaUnit distanceToAreaUnit (QgsUnitTypes::DistanceUnit distanceUnit)
 Converts a distance unit to its corresponding area unit, e.g., meters to square meters. More...
 
static Q_INVOKABLE QString encodeUnit (QgsUnitTypes::DistanceUnit unit)
 Encodes a distance unit to a string. More...
 
static Q_INVOKABLE QString encodeUnit (AreaUnit unit)
 Encodes an areal unit to a string. More...
 
static Q_INVOKABLE QString encodeUnit (AngleUnit unit)
 Encodes an angular unit to a string. More...
 
static Q_INVOKABLE QString encodeUnit (RenderUnit unit)
 Encodes a render unit to a string. More...
 
static Q_INVOKABLE QString formatAngle (double angle, int decimals, AngleUnit unit)
 Returns an angle 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 (AreaUnit fromUnit, AreaUnit toUnit)
 Returns the conversion factor between the specified areal units. More...
 
static Q_INVOKABLE double fromUnitToUnitFactor (AngleUnit fromUnit, AngleUnit toUnit)
 Returns the conversion factor between the specified angular units. More...
 
static Q_INVOKABLE AreaUnit stringToAreaUnit (const QString &string, bool *ok=0)
 Converts a translated string to an areal unit. More...
 
static Q_INVOKABLE QgsUnitTypes::DistanceUnit stringToDistanceUnit (const QString &string, bool *ok=0)
 Converts a translated string to a distance unit. More...
 
static Q_INVOKABLE QString toString (QgsUnitTypes::DistanceUnit unit)
 Returns a translated string representing a distance unit. More...
 
static Q_INVOKABLE QString toString (AreaUnit unit)
 Returns a translated string representing an areal unit. More...
 
static Q_INVOKABLE QString toString (AngleUnit unit)
 Returns a translated string representing an angular unit. More...
 
static Q_INVOKABLE DistanceUnitType unitType (DistanceUnit unit)
 Returns the type for a distance unit. More...
 
static Q_INVOKABLE DistanceUnitType unitType (AreaUnit unit)
 Returns the type for an areal unit. More...
 

Detailed Description

Helper functions for various unit types.

Note
Added in version 2.14

Definition at line 36 of file qgsunittypes.h.

Member Typedef Documentation

◆ RenderUnitList

List of render units.

Definition at line 104 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.

AngleUnknownUnit 

Unknown angle unit.

Definition at line 80 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.

AreaUnknownUnit 

Unknown areal unit.

Definition at line 65 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.

DistanceUnknownUnit 

Unknown distance unit.

Definition at line 43 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 57 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 
RenderInches 

points (e.g., for font sizes)

RenderUnknownUnit 

Inches.

Mixed or unknown units

Definition at line 92 of file qgsunittypes.h.

Member Function Documentation

◆ decodeAngleUnit()

QgsUnitTypes::AngleUnit QgsUnitTypes::decodeAngleUnit ( const QString &  string,
bool *  ok = 0 
)
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 853 of file qgsunittypes.cpp.

◆ decodeAreaUnit()

QgsUnitTypes::AreaUnit QgsUnitTypes::decodeAreaUnit ( const QString &  string,
bool *  ok = 0 
)
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 426 of file qgsunittypes.cpp.

◆ decodeDistanceUnit()

QgsUnitTypes::DistanceUnit QgsUnitTypes::decodeDistanceUnit ( const QString &  string,
bool *  ok = 0 
)
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 108 of file qgsunittypes.cpp.

◆ decodeRenderUnit()

QgsUnitTypes::RenderUnit QgsUnitTypes::decodeRenderUnit ( const QString &  string,
bool *  ok = 0 
)
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 1092 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 799 of file qgsunittypes.cpp.

◆ encodeUnit() [1/4]

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 71 of file qgsunittypes.cpp.

◆ encodeUnit() [2/4]

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 398 of file qgsunittypes.cpp.

◆ encodeUnit() [3/4]

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 831 of file qgsunittypes.cpp.

◆ encodeUnit() [4/4]

QString QgsUnitTypes::encodeUnit ( RenderUnit  unit)
static

Encodes a render unit to a string.

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

Definition at line 1070 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 1039 of file qgsunittypes.cpp.

◆ fromUnitToUnitFactor() [1/3]

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 211 of file qgsunittypes.cpp.

◆ fromUnitToUnitFactor() [2/3]

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 521 of file qgsunittypes.cpp.

◆ fromUnitToUnitFactor() [3/3]

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 902 of file qgsunittypes.cpp.

◆ stringToAreaUnit()

QgsUnitTypes::AreaUnit QgsUnitTypes::stringToAreaUnit ( const QString &  string,
bool *  ok = 0 
)
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
See also
toString()

Definition at line 488 of file qgsunittypes.cpp.

◆ stringToDistanceUnit()

QgsUnitTypes::DistanceUnit QgsUnitTypes::stringToDistanceUnit ( const QString &  string,
bool *  ok = 0 
)
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
See also
toString()

Definition at line 175 of file qgsunittypes.cpp.

◆ toString() [1/3]

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 138 of file qgsunittypes.cpp.

◆ toString() [2/3]

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 460 of file qgsunittypes.cpp.

◆ toString() [3/3]

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

Returns a translated string representing an angular unit.

Parameters
unitunit to convert to string

Definition at line 880 of file qgsunittypes.cpp.

◆ unitType() [1/2]

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

Returns the type for a distance unit.

Definition at line 26 of file qgsunittypes.cpp.

◆ unitType() [2/2]

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

Returns the type for an areal unit.

Definition at line 47 of file qgsunittypes.cpp.


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