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(
"m",
"distance" );
197 return QObject::tr(
"km",
"distance" );
200 return QObject::tr(
"ft",
"distance" );
203 return QObject::tr(
"yd",
"distance" );
206 return QObject::tr(
"mi",
"distance" );
209 return QObject::tr(
"deg",
"distance" );
212 return QObject::tr(
"cm",
"distance" );
215 return QObject::tr(
"mm",
"distance" );
221 return QObject::tr(
"NM",
"distance" );
234 QString normalized =
string.trimmed().toLower();
274 #define DEGREE_TO_METER 111319.49079327358 275 #define FEET_TO_METER 0.3048 276 #define NMILE_TO_METER 1852.0 277 #define KILOMETERS_TO_METER 1000.0 278 #define CENTIMETERS_TO_METER 0.01 279 #define MILLIMETERS_TO_METER 0.001 280 #define YARDS_TO_METER 0.9144 281 #define YARDS_TO_FEET 3.0 282 #define MILES_TO_METER 1609.344 550 return QStringLiteral(
"m2" );
552 return QStringLiteral(
"km2" );
554 return QStringLiteral(
"ft2" );
556 return QStringLiteral(
"y2" );
558 return QStringLiteral(
"mi2" );
560 return QStringLiteral(
"ha" );
562 return QStringLiteral(
"ac" );
564 return QStringLiteral(
"nm2" );
566 return QStringLiteral(
"deg2" );
568 return QStringLiteral(
"cm2" );
570 return QStringLiteral(
"mm2" );
572 return QStringLiteral(
"<unknown>" );
579 QString normalized =
string.trimmed().toLower();
620 return QObject::tr(
"square meters",
"area" );
622 return QObject::tr(
"square kilometers",
"area" );
624 return QObject::tr(
"square feet",
"area" );
626 return QObject::tr(
"square yards",
"area" );
628 return QObject::tr(
"square miles",
"area" );
630 return QObject::tr(
"hectares",
"area" );
632 return QObject::tr(
"acres",
"area" );
634 return QObject::tr(
"square nautical miles",
"area" );
636 return QObject::tr(
"square degrees",
"area" );
638 return QObject::tr(
"square millimeters",
"area" );
640 return QObject::tr(
"square centimeters",
"area" );
642 return QObject::tr(
"<unknown>",
"area" );
652 return QObject::tr(
"m²",
"area" );
654 return QObject::tr(
"km²",
"area" );
656 return QObject::tr(
"ft²",
"area" );
658 return QObject::tr(
"yd²",
"area" );
660 return QObject::tr(
"mi²",
"area" );
662 return QObject::tr(
"ha",
"area" );
664 return QObject::tr(
"ac²",
"area" );
666 return QObject::tr(
"NM²",
"area" );
668 return QObject::tr(
"deg²",
"area" );
670 return QObject::tr(
"cm²",
"area" );
672 return QObject::tr(
"mm²",
"area" );
681 QString normalized =
string.trimmed().toLower();
718 #define KM2_TO_M2 1000000.0 719 #define CM2_TO_M2 0.0001 720 #define MM2_TO_M2 0.000001 721 #define FT2_TO_M2 0.09290304 722 #define YD2_TO_M2 0.83612736 723 #define MI2_TO_M2 2589988.110336 724 #define HA_TO_M2 10000.0 725 #define AC_TO_FT2 43560.0 726 #define DEG2_TO_M2 12392029030.5 727 #define NM2_TO_M2 3429904.0 1098 switch ( distanceUnit )
1139 return QStringLiteral(
"degrees" );
1141 return QStringLiteral(
"radians" );
1143 return QStringLiteral(
"gon" );
1145 return QStringLiteral(
"moa" );
1147 return QStringLiteral(
"soa" );
1149 return QStringLiteral(
"tr" );
1151 return QStringLiteral(
"<unknown>" );
1158 QString normalized =
string.trimmed().toLower();
1188 return QObject::tr(
"degrees",
"angle" );
1190 return QObject::tr(
"radians",
"angle" );
1192 return QObject::tr(
"gon",
"angle" );
1194 return QObject::tr(
"minutes of arc",
"angle" );
1196 return QObject::tr(
"seconds of arc",
"angle" );
1198 return QObject::tr(
"turns",
"angle" );
1200 return QObject::tr(
"<unknown>",
"angle" );
1217 return M_PI / 180.0;
1219 return 400.0 / 360.0;
1236 return 180.0 / M_PI;
1240 return 200.0 / M_PI;
1242 return 60 * 180.0 / M_PI;
1244 return 3600 * 180.0 / M_PI;
1257 return 360.0 / 400.0;
1259 return M_PI / 200.0;
1263 return 60 * 360.0 / 400.0;
1265 return 3600 * 360.0 / 400.0;
1280 return M_PI / 180.0 / 60.0;
1282 return 400.0 / 360.0 / 60.0;
1288 return 1.0 / 360.0 / 60.0;
1301 return M_PI / 180.0 / 3600.0;
1303 return 400.0 / 360.0 / 3600.0;
1309 return 1.0 / 360.0 / 3600.0;
1326 return 360.0 * 60.0;
1328 return 360.0 * 3600.0;
1349 unitLabel = QObject::tr(
"°",
"angle" );
1352 unitLabel = QObject::tr(
" rad",
"angle" );
1355 unitLabel = QObject::tr(
" gon",
"angle" );
1358 unitLabel = QObject::tr(
"′",
"angle minutes" );
1361 unitLabel = QObject::tr(
"″",
"angle seconds" );
1364 unitLabel = QObject::tr(
" tr",
"angle turn" );
1370 return QStringLiteral(
"%L1%2" ).arg( angle, 0,
'f', decimals ).arg( unitLabel );
1386 else if ( std::fabs( distance ) > 1000.0 )
1391 else if ( std::fabs( distance ) < 0.01 )
1396 else if ( std::fabs( distance ) < 0.1 )
1410 if ( keepBaseUnit || std::fabs( distance ) >= 1.0 )
1423 if ( std::fabs( distance ) <= 5280.0 || keepBaseUnit )
1436 if ( std::fabs( distance ) <= 1760.0 || keepBaseUnit )
1449 if ( std::fabs( distance ) >= 1.0 || keepBaseUnit )
1488 result.
value = -1.0;
1680 return QStringLiteral(
"%L1%2" ).arg( dist.
value, 0,
'f', decimals ).arg( unitText );
1692 return QStringLiteral(
"%L1%2" ).arg( areaValue.
value, 0,
'f', decimals ).arg( unitText );
1700 return QStringLiteral(
"MM" );
1702 return QStringLiteral(
"RenderMetersInMapUnits" );
1704 return QStringLiteral(
"MapUnit" );
1706 return QStringLiteral(
"Pixel" );
1708 return QStringLiteral(
"Percentage" );
1710 return QStringLiteral(
"Point" );
1712 return QStringLiteral(
"Inch" );
1721 QString normalized =
string.trimmed().toLower();
1730 if ( normalized == QLatin1String(
"meters" ) )
1734 if ( normalized == QLatin1String(
"mapunits" ) )
1740 if ( normalized == QLatin1String(
"percent" ) )
1744 if ( normalized == QLatin1String(
"points" ) )
1761 return QObject::tr(
"millimeters",
"render" );
1764 return QObject::tr(
"meters at scale",
"render" );
1767 return QObject::tr(
"map units",
"render" );
1770 return QObject::tr(
"pixels",
"render" );
1773 return QObject::tr(
"percent",
"render" );
1776 return QObject::tr(
"points",
"render" );
1779 return QObject::tr(
"inches",
"render" );
1782 return QObject::tr(
"<unknown>",
"render" );
1795 return QStringLiteral(
"cm" );
1797 return QStringLiteral(
"m" );
1799 return QStringLiteral(
"in" );
1801 return QStringLiteral(
"ft" );
1803 return QStringLiteral(
"pt" );
1805 return QStringLiteral(
"pi" );
1807 return QStringLiteral(
"px" );
1809 return QStringLiteral(
"mm" );
1816 QString normalized =
string.trimmed().toLower();
1870 return QObject::tr(
"px" );
1872 return QObject::tr(
"mm" );
1874 return QObject::tr(
"cm" );
1876 return QObject::tr(
"m" );
1878 return QObject::tr(
"in",
"unit inch" );
1880 return QObject::tr(
"ft" );
1882 return QObject::tr(
"pt" );
1884 return QObject::tr(
"pica" );
1894 return QObject::tr(
"pixels" );
1896 return QObject::tr(
"millimeters" );
1898 return QObject::tr(
"centimeters" );
1900 return QObject::tr(
"meters" );
1902 return QObject::tr(
"inches" );
1904 return QObject::tr(
"feet" );
1906 return QObject::tr(
"points" );
1908 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.
points (e.g., for font sizes)
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.
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.