80 return QStringLiteral(
"meters" );
83 return QStringLiteral(
"km" );
86 return QStringLiteral(
"feet" );
89 return QStringLiteral(
"yd" );
92 return QStringLiteral(
"mi" );
95 return QStringLiteral(
"degrees" );
98 return QStringLiteral(
"<unknown>" );
101 return QStringLiteral(
"nautical miles" );
104 return QStringLiteral(
"cm" );
107 return QStringLiteral(
"mm" );
120 QString normalized =
string.trimmed().toLower();
157 return QObject::tr(
"meters",
"distance" );
160 return QObject::tr(
"kilometers",
"distance" );
163 return QObject::tr(
"feet",
"distance" );
166 return QObject::tr(
"yards",
"distance" );
169 return QObject::tr(
"miles",
"distance" );
172 return QObject::tr(
"degrees",
"distance" );
175 return QObject::tr(
"centimeters",
"distance" );
178 return QObject::tr(
"millimeters",
"distance" );
181 return QObject::tr(
"<unknown>",
"distance" );
184 return QObject::tr(
"nautical miles",
"distance" );
194 return QObject::tr(
"mm",
"render" );
197 return QObject::tr(
"map units",
"render" );
200 return QObject::tr(
"px",
"render" );
203 return QObject::tr(
"%",
"render" );
206 return QObject::tr(
"pt",
"render" );
209 return QObject::tr(
"in",
"render" );
212 return QObject::tr(
"unknown",
"render" );
215 return QObject::tr(
"m",
"render" );
227 return QObject::tr(
"m",
"distance" );
230 return QObject::tr(
"km",
"distance" );
233 return QObject::tr(
"ft",
"distance" );
236 return QObject::tr(
"yd",
"distance" );
239 return QObject::tr(
"mi",
"distance" );
242 return QObject::tr(
"deg",
"distance" );
245 return QObject::tr(
"cm",
"distance" );
248 return QObject::tr(
"mm",
"distance" );
254 return QObject::tr(
"NM",
"distance" );
267 QString normalized =
string.trimmed().toLower();
307 #define DEGREE_TO_METER 111319.49079327358 308 #define FEET_TO_METER 0.3048 309 #define NMILE_TO_METER 1852.0 310 #define KILOMETERS_TO_METER 1000.0 311 #define CENTIMETERS_TO_METER 0.01 312 #define MILLIMETERS_TO_METER 0.001 313 #define YARDS_TO_METER 0.9144 314 #define YARDS_TO_FEET 3.0 315 #define MILES_TO_METER 1609.344 583 return QStringLiteral(
"m2" );
585 return QStringLiteral(
"km2" );
587 return QStringLiteral(
"ft2" );
589 return QStringLiteral(
"y2" );
591 return QStringLiteral(
"mi2" );
593 return QStringLiteral(
"ha" );
595 return QStringLiteral(
"ac" );
597 return QStringLiteral(
"nm2" );
599 return QStringLiteral(
"deg2" );
601 return QStringLiteral(
"cm2" );
603 return QStringLiteral(
"mm2" );
605 return QStringLiteral(
"<unknown>" );
612 QString normalized =
string.trimmed().toLower();
653 return QObject::tr(
"square meters",
"area" );
655 return QObject::tr(
"square kilometers",
"area" );
657 return QObject::tr(
"square feet",
"area" );
659 return QObject::tr(
"square yards",
"area" );
661 return QObject::tr(
"square miles",
"area" );
663 return QObject::tr(
"hectares",
"area" );
665 return QObject::tr(
"acres",
"area" );
667 return QObject::tr(
"square nautical miles",
"area" );
669 return QObject::tr(
"square degrees",
"area" );
671 return QObject::tr(
"square millimeters",
"area" );
673 return QObject::tr(
"square centimeters",
"area" );
675 return QObject::tr(
"<unknown>",
"area" );
685 return QObject::tr(
"m²",
"area" );
687 return QObject::tr(
"km²",
"area" );
689 return QObject::tr(
"ft²",
"area" );
691 return QObject::tr(
"yd²",
"area" );
693 return QObject::tr(
"mi²",
"area" );
695 return QObject::tr(
"ha",
"area" );
697 return QObject::tr(
"ac²",
"area" );
699 return QObject::tr(
"NM²",
"area" );
701 return QObject::tr(
"deg²",
"area" );
703 return QObject::tr(
"cm²",
"area" );
705 return QObject::tr(
"mm²",
"area" );
714 QString normalized =
string.trimmed().toLower();
751 #define KM2_TO_M2 1000000.0 752 #define CM2_TO_M2 0.0001 753 #define MM2_TO_M2 0.000001 754 #define FT2_TO_M2 0.09290304 755 #define YD2_TO_M2 0.83612736 756 #define MI2_TO_M2 2589988.110336 757 #define HA_TO_M2 10000.0 758 #define AC_TO_FT2 43560.0 759 #define DEG2_TO_M2 12392029030.5 760 #define NM2_TO_M2 3429904.0 1131 switch ( distanceUnit )
1172 return QStringLiteral(
"degrees" );
1174 return QStringLiteral(
"radians" );
1176 return QStringLiteral(
"gon" );
1178 return QStringLiteral(
"moa" );
1180 return QStringLiteral(
"soa" );
1182 return QStringLiteral(
"tr" );
1184 return QStringLiteral(
"<unknown>" );
1191 QString normalized =
string.trimmed().toLower();
1221 return QObject::tr(
"degrees",
"angle" );
1223 return QObject::tr(
"radians",
"angle" );
1225 return QObject::tr(
"gon",
"angle" );
1227 return QObject::tr(
"minutes of arc",
"angle" );
1229 return QObject::tr(
"seconds of arc",
"angle" );
1231 return QObject::tr(
"turns",
"angle" );
1233 return QObject::tr(
"<unknown>",
"angle" );
1250 return M_PI / 180.0;
1252 return 400.0 / 360.0;
1269 return 180.0 / M_PI;
1273 return 200.0 / M_PI;
1275 return 60 * 180.0 / M_PI;
1277 return 3600 * 180.0 / M_PI;
1290 return 360.0 / 400.0;
1292 return M_PI / 200.0;
1296 return 60 * 360.0 / 400.0;
1298 return 3600 * 360.0 / 400.0;
1313 return M_PI / 180.0 / 60.0;
1315 return 400.0 / 360.0 / 60.0;
1321 return 1.0 / 360.0 / 60.0;
1334 return M_PI / 180.0 / 3600.0;
1336 return 400.0 / 360.0 / 3600.0;
1342 return 1.0 / 360.0 / 3600.0;
1359 return 360.0 * 60.0;
1361 return 360.0 * 3600.0;
1382 unitLabel = QObject::tr(
"°",
"angle" );
1385 unitLabel = QObject::tr(
" rad",
"angle" );
1388 unitLabel = QObject::tr(
" gon",
"angle" );
1391 unitLabel = QObject::tr(
"′",
"angle minutes" );
1394 unitLabel = QObject::tr(
"″",
"angle seconds" );
1397 unitLabel = QObject::tr(
" tr",
"angle turn" );
1403 return QStringLiteral(
"%L1%2" ).arg( angle, 0,
'f', decimals ).arg( unitLabel );
1419 else if ( std::fabs( distance ) > 1000.0 )
1424 else if ( std::fabs( distance ) < 0.01 )
1429 else if ( std::fabs( distance ) < 0.1 )
1443 if ( keepBaseUnit || std::fabs( distance ) >= 1.0 )
1456 if ( std::fabs( distance ) <= 5280.0 || keepBaseUnit )
1469 if ( std::fabs( distance ) <= 1760.0 || keepBaseUnit )
1482 if ( std::fabs( distance ) >= 1.0 || keepBaseUnit )
1521 result.
value = -1.0;
1713 return QStringLiteral(
"%L1%2" ).arg( dist.
value, 0,
'f', decimals ).arg( unitText );
1725 return QStringLiteral(
"%L1%2" ).arg( areaValue.
value, 0,
'f', decimals ).arg( unitText );
1733 return QStringLiteral(
"MM" );
1735 return QStringLiteral(
"RenderMetersInMapUnits" );
1737 return QStringLiteral(
"MapUnit" );
1739 return QStringLiteral(
"Pixel" );
1741 return QStringLiteral(
"Percentage" );
1743 return QStringLiteral(
"Point" );
1745 return QStringLiteral(
"Inch" );
1754 QString normalized =
string.trimmed().toLower();
1763 if ( normalized == QLatin1String(
"meters" ) )
1767 if ( normalized == QLatin1String(
"mapunits" ) )
1773 if ( normalized == QLatin1String(
"percent" ) )
1777 if ( normalized == QLatin1String(
"points" ) )
1794 return QObject::tr(
"millimeters",
"render" );
1797 return QObject::tr(
"meters at scale",
"render" );
1800 return QObject::tr(
"map units",
"render" );
1803 return QObject::tr(
"pixels",
"render" );
1806 return QObject::tr(
"percent",
"render" );
1809 return QObject::tr(
"points",
"render" );
1812 return QObject::tr(
"inches",
"render" );
1815 return QObject::tr(
"<unknown>",
"render" );
1828 return QStringLiteral(
"cm" );
1830 return QStringLiteral(
"m" );
1832 return QStringLiteral(
"in" );
1834 return QStringLiteral(
"ft" );
1836 return QStringLiteral(
"pt" );
1838 return QStringLiteral(
"pi" );
1840 return QStringLiteral(
"px" );
1842 return QStringLiteral(
"mm" );
1849 QString normalized =
string.trimmed().toLower();
1903 return QObject::tr(
"px" );
1905 return QObject::tr(
"mm" );
1907 return QObject::tr(
"cm" );
1909 return QObject::tr(
"m" );
1911 return QObject::tr(
"in",
"unit inch" );
1913 return QObject::tr(
"ft" );
1915 return QObject::tr(
"pt" );
1917 return QObject::tr(
"pica" );
1927 return QObject::tr(
"pixels" );
1929 return QObject::tr(
"millimeters" );
1931 return QObject::tr(
"centimeters" );
1933 return QObject::tr(
"meters" );
1935 return QObject::tr(
"inches" );
1937 return QObject::tr(
"feet" );
1939 return QObject::tr(
"points" );
1941 return QObject::tr(
"picas" );
Meters value as Map units.
static Q_INVOKABLE AreaUnit decodeAreaUnit(const QString &string, bool *ok=nullptr)
Decodes an areal unit from a string.
double value
The value part of the distance.
QgsUnitTypes::DistanceUnit unit
The value part of the distance.
double value
The value part of the distance.
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
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.
static Q_INVOKABLE QgsUnitTypes::AngleUnit decodeAngleUnit(const QString &string, bool *ok=nullptr)
Decodes an angular unit from a string.
static Q_INVOKABLE QString formatAngle(double angle, int decimals, QgsUnitTypes::AngleUnit unit)
Returns an angle formatted as a friendly string.
static Q_INVOKABLE AreaUnit stringToAreaUnit(const QString &string, bool *ok=nullptr)
Converts a translated string to an areal unit.
LayoutUnitType
Types of layout units.
DistanceUnitType
Types of distance units.
static Q_INVOKABLE QgsUnitTypes::DistanceUnit decodeDistanceUnit(const QString &string, bool *ok=nullptr)
Decodes a distance unit from a string.
Percentage of another measurement (e.g., canvas size, feature size)
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Unit is a paper based measurement unit.
#define KILOMETERS_TO_METER
AngleUnit
Units of angles.
static Q_INVOKABLE QString formatArea(double area, int decimals, QgsUnitTypes::AreaUnit unit, bool keepBaseUnit=false)
Returns an area formatted as a friendly string.
static Q_INVOKABLE QString toAbbreviatedString(QgsUnitTypes::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
static Q_INVOKABLE QgsUnitTypes::LayoutUnit decodeLayoutUnit(const QString &string, bool *ok=nullptr)
Decodes a layout unit from a string.
Degrees, for planar geographic CRS distance measurements.
#define CENTIMETERS_TO_METER
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
Square degrees, for planar geographic CRS area measurements.
A combination of distance value and unit.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
DistanceUnit
Units of distance.
static Q_INVOKABLE DistanceUnitType unitType(QgsUnitTypes::DistanceUnit unit)
Returns the type for a distance unit.
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. ...
QgsUnitTypes::AreaUnit unit
The value part of the distance.
static Q_INVOKABLE QgsUnitTypes::DistanceUnit stringToDistanceUnit(const QString &string, bool *ok=nullptr)
Converts a translated string to a distance unit.
Unit is a geographic (e.g., degree based) unit.
Points (e.g., for font sizes)
static Q_INVOKABLE QString formatDistance(double distance, int decimals, QgsUnitTypes::DistanceUnit unit, bool keepBaseUnit=false)
Returns an distance formatted as a friendly string.
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places...
#define MILLIMETERS_TO_METER
A combination of area value and unit.
LayoutUnit
Layout measurement units.
Unit is a screen based measurement unit.
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE QgsUnitTypes::AreaUnit distanceToAreaUnit(QgsUnitTypes::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding area unit, e.g., meters to square meters.
Unit is a standard measurement unit.
RenderUnit
Rendering size units.