QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
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, Radians, Gon, MinutesOfArc,
  SecondsOfArc, Turn, UnknownAngleUnit
}
 Units of angles. More...
 
enum  AreaUnit {
  SquareMeters = 0, SquareKilometers, SquareFeet, SquareYards,
  SquareMiles, Hectares, Acres, SquareNauticalMiles,
  SquareDegrees, UnknownAreaUnit
}
 Units of area. More...
 
enum  DistanceUnitType { Standard = 0, Geographic, UnknownType }
 Types of distance units. More...
 

Static Public Member Functions

static AngleUnit decodeAngleUnit (const QString &string, bool *ok=0)
 Decodes an angular unit from a string. More...
 
static AreaUnit decodeAreaUnit (const QString &string, bool *ok=0)
 Decodes an areal unit from a string. More...
 
static QGis::UnitType decodeDistanceUnit (const QString &string, bool *ok=0)
 Decodes a distance unit from a string. More...
 
static AreaUnit distanceToAreaUnit (QGis::UnitType distanceUnit)
 Converts a distance unit to its corresponding area unit, eg meters to square meters. More...
 
static QString encodeUnit (QGis::UnitType unit)
 Encodes a distance unit to a string. More...
 
static QString encodeUnit (AreaUnit unit)
 Encodes an areal unit to a string. More...
 
static QString encodeUnit (AngleUnit unit)
 Encodes an angular unit to a string. More...
 
static QString formatAngle (double angle, int decimals, AngleUnit unit)
 Returns an angle formatted as a friendly string. More...
 
static double fromUnitToUnitFactor (QGis::UnitType fromUnit, QGis::UnitType toUnit)
 Returns the conversion factor between the specified distance units. More...
 
static double fromUnitToUnitFactor (AreaUnit fromUnit, AreaUnit toUnit)
 Returns the conversion factor between the specified areal units. More...
 
static double fromUnitToUnitFactor (AngleUnit fromUnit, AngleUnit toUnit)
 Returns the conversion factor between the specified angular units. More...
 
static AreaUnit stringToAreaUnit (const QString &string, bool *ok=0)
 Converts a translated string to an areal unit. More...
 
static QGis::UnitType stringToDistanceUnit (const QString &string, bool *ok=0)
 Converts a translated string to a distance unit. More...
 
static QString toString (QGis::UnitType unit)
 Returns a translated string representing a distance unit. More...
 
static QString toString (AreaUnit unit)
 Returns a translated string representing an areal unit. More...
 
static QString toString (AngleUnit unit)
 Returns a translated string representing an angular unit. More...
 
static DistanceUnitType unitType (QGis::UnitType unit)
 Returns the type for a distance unit. More...
 
static 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 35 of file qgsunittypes.h.

Member Enumeration Documentation

Units of angles.

Enumerator
AngleDegrees 

degrees

Radians 

square kilometers

Gon 

gon/gradian

MinutesOfArc 

minutes of arc

SecondsOfArc 

seconds of arc

Turn 

turn/revolutions

UnknownAngleUnit 

unknown angle unit

Definition at line 64 of file qgsunittypes.h.

Units of area.

Enumerator
SquareMeters 

square meters

SquareKilometers 

square kilometers

SquareFeet 

square feet

SquareYards 

square yards

SquareMiles 

square miles

Hectares 

hectares

Acres 

acres

SquareNauticalMiles 

square nautical miles

SquareDegrees 

square degrees, for planar geographic CRS area measurements

UnknownAreaUnit 

unknown areal unit

Definition at line 49 of file qgsunittypes.h.

Types of distance units.

Enumerator
Standard 

unit is a standard measurement unit

Geographic 

unit is a geographic (eg degree based) unit

UnknownType 

unknown unit type

Definition at line 41 of file qgsunittypes.h.

Member Function Documentation

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

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

QGis::UnitType 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.

QgsUnitTypes::AreaUnit QgsUnitTypes::distanceToAreaUnit ( QGis::UnitType  distanceUnit)
static

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

Parameters
distanceUnitdistance unit to convert
Returns
matching areal unit

Definition at line 805 of file qgsunittypes.cpp.

QString QgsUnitTypes::encodeUnit ( QGis::UnitType  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.

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

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

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

double QgsUnitTypes::fromUnitToUnitFactor ( QGis::UnitType  fromUnit,
QGis::UnitType  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.

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

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

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

QGis::UnitType 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.

QString QgsUnitTypes::toString ( QGis::UnitType  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.

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

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

Returns a translated string representing an angular unit.

Parameters
unitunit to convert to string

Definition at line 886 of file qgsunittypes.cpp.

QgsUnitTypes::DistanceUnitType QgsUnitTypes::unitType ( QGis::UnitType  unit)
static

Returns the type for a distance unit.

Definition at line 26 of file qgsunittypes.cpp.

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: