Skip To Content ArcGIS for Developers Sign In Dashboard

Unit Class


Base class for classes that represent a unit of measurement. More...

Header: #include <Unit>
Since: Esri::ArcGISRuntime 100.0
Inherited By:

Esri::ArcGISRuntime::AngularUnit, Esri::ArcGISRuntime::AreaUnit, and Esri::ArcGISRuntime::LinearUnit

Public Functions

Unit(const Unit &other)
Unit(Unit &&other)
virtual ~Unit()
QString abbreviation() const
QString displayName() const
bool isEmpty() const
QString name() const
QString pluralDisplayName() const
int unitId() const
UnitType unitType() const
Unit &operator=(const Unit &other)
Unit &operator=(Unit &&other)

Static Public Members

Unit fromUnitId(int unitId)

Detailed Description

Base class for classes that represent a unit of measurement.

Unit is a base class inherited by subtypes representing different categories of measurement: LinearUnit, AngularUnit, and AreaUnit. The subtypes are used in measurement functions and spatial references.

Each instance has properties for the unit name (singular, plural and abbreviated) and provides methods for unit conversion between different units of measurement in the same category of measurement. All unit names and abbreviations are returned in the English language.

Create Unit instances using the subtypes, passing in the enumeration for a specific unit of measurement. Custom unit implementations are not supported.

Instances of Unit are immutable.

Member Function Documentation


Default constructor.

Unit::Unit(const Unit &other)

Copy constructor from other Unit.

Unit::Unit(Unit &&other)

Move constructor from other Unit.

[virtual] Unit::~Unit()


QString Unit::abbreviation() const

Gets the abbreviated unit name.

QString Unit::displayName() const

Gets the singular display name (for example, FOOT).

[static] Unit Unit::fromUnitId(int unitId)

Constructs a new %Unit based on the unitId corresponding to desired %Unit. Returns A new %Unit instance which will be one of AreaUnit, AngularUnit, LinearUnit or null if it could not be created.

bool Unit::isEmpty() const

Gets whether this Unit is empty.

A default constructed Unit is empty.

Returns true if empty.

QString Unit::name() const

Gets the unit name.

QString Unit::pluralDisplayName() const

Gets the plural display name (for example, FEET).

int Unit::unitId() const

Gets the unit ID which is unique across all types of units.

UnitType Unit::unitType() const

Gets the unit type.

Unit &Unit::operator=(const Unit &other)

Assignment operator from other Unit.

Unit &Unit::operator=(Unit &&other)

Move operator from other Unit.

Feedback on this topic?