QGIS API Documentation 3.28.14-Firenze (exported)
Loading...
Searching...
No Matches
qgsunittypes.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsunittypes.h
3 --------------
4 begin : February 2016
5 copyright : (C) 2016 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSUNITTYPES_H
19#define QGSUNITTYPES_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include <QObject>
24
25/***************************************************************************
26 * This class is considered CRITICAL and any change MUST be accompanied with
27 * full unit tests in test_qgsunittypes.py.
28 * See details in QEP #17
29 ****************************************************************************/
30
38class CORE_EXPORT QgsUnitTypes
39{
40 Q_GADGET
41
42 public:
45 {
46 UnknownSystem = 0,
49 USCSSystem
50 };
51 Q_ENUM( SystemOfMeasurement )
52
53
65
80 Q_ENUM( DistanceUnit )
81
82
86 {
87 Standard = 0,
90 };
91
108 Q_ENUM( AreaUnit )
109
110
128 Q_ENUM( VolumeUnit )
129
130
143 Q_ENUM( AngleUnit )
144
145
164 Q_ENUM( TemporalUnit )
165
166
178 Q_ENUM( RenderUnit )
179
180
192 Q_ENUM( LayoutUnit )
193
194
196 {
197 LayoutPaperUnits = 0,
198 LayoutScreenUnits
199 };
200
207 {
208
212 double value;
213
218 };
219
226 {
227
231 double value;
232
237 };
238
240 typedef QList<QgsUnitTypes::RenderUnit> RenderUnitList;
241
248 Q_INVOKABLE static QString encodeUnitType( QgsUnitTypes::UnitType type );
249
258 Q_INVOKABLE static QgsUnitTypes::UnitType decodeUnitType( const QString &string, bool *ok SIP_OUT = nullptr );
259
260
261 // DISTANCE UNITS
262
266 Q_INVOKABLE static QgsUnitTypes::DistanceUnitType unitType( QgsUnitTypes::DistanceUnit unit );
267
274 Q_INVOKABLE static QString encodeUnit( QgsUnitTypes::DistanceUnit unit );
275
283 Q_INVOKABLE static QgsUnitTypes::DistanceUnit decodeDistanceUnit( const QString &string, bool *ok SIP_OUT = nullptr );
284
290 Q_INVOKABLE static QString toString( QgsUnitTypes::DistanceUnit unit );
291
299 Q_INVOKABLE static QString toAbbreviatedString( QgsUnitTypes::DistanceUnit unit );
300
308 Q_INVOKABLE static QgsUnitTypes::DistanceUnit stringToDistanceUnit( const QString &string, bool *ok SIP_OUT = nullptr );
309
316 Q_INVOKABLE static double fromUnitToUnitFactor( QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit );
317
318 // AREAL UNITS
319
324
331 static QString encodeUnit( QgsUnitTypes::AreaUnit unit );
332
340 Q_INVOKABLE static QgsUnitTypes::AreaUnit decodeAreaUnit( const QString &string, bool *ok SIP_OUT = nullptr );
341
347 static QString toString( QgsUnitTypes::AreaUnit unit );
348
356 static QString toAbbreviatedString( QgsUnitTypes::AreaUnit unit );
357
365 Q_INVOKABLE static QgsUnitTypes::AreaUnit stringToAreaUnit( const QString &string, bool *ok SIP_OUT = nullptr );
366
373 static double fromUnitToUnitFactor( QgsUnitTypes::AreaUnit fromUnit, QgsUnitTypes::AreaUnit toUnit );
374
380 Q_INVOKABLE static QgsUnitTypes::AreaUnit distanceToAreaUnit( QgsUnitTypes::DistanceUnit distanceUnit );
381
388 Q_INVOKABLE static QgsUnitTypes::DistanceUnit areaToDistanceUnit( QgsUnitTypes::AreaUnit areaUnit );
389
390 // TEMPORAL UNITS
391
398 static QString encodeUnit( QgsUnitTypes::TemporalUnit unit );
399
408 Q_INVOKABLE static QgsUnitTypes::TemporalUnit decodeTemporalUnit( const QString &string, bool *ok SIP_OUT = nullptr );
409
415 static QString toString( QgsUnitTypes::TemporalUnit unit );
416
423 static QString toAbbreviatedString( QgsUnitTypes::TemporalUnit unit );
424
433 Q_INVOKABLE static QgsUnitTypes::TemporalUnit stringToTemporalUnit( const QString &string, bool *ok SIP_OUT = nullptr );
434
446 static double fromUnitToUnitFactor( QgsUnitTypes::TemporalUnit fromUnit, QgsUnitTypes::TemporalUnit toUnit );
447
448 // VOLUME UNITS
449
455
462 static QString encodeUnit( QgsUnitTypes::VolumeUnit unit );
463
472 Q_INVOKABLE static QgsUnitTypes::VolumeUnit decodeVolumeUnit( const QString &string, bool *ok SIP_OUT = nullptr );
473
479 static QString toString( QgsUnitTypes::VolumeUnit unit );
480
487 static QString toAbbreviatedString( QgsUnitTypes::VolumeUnit unit );
488
497 Q_INVOKABLE static QgsUnitTypes::VolumeUnit stringToVolumeUnit( const QString &string, bool *ok SIP_OUT = nullptr );
498
506 static double fromUnitToUnitFactor( QgsUnitTypes::VolumeUnit fromUnit, QgsUnitTypes::VolumeUnit toUnit );
507
514 Q_INVOKABLE static QgsUnitTypes::VolumeUnit distanceToVolumeUnit( QgsUnitTypes::DistanceUnit distanceUnit );
515
522 Q_INVOKABLE static QgsUnitTypes::DistanceUnit volumeToDistanceUnit( QgsUnitTypes::VolumeUnit volumeUnit );
523
524 // ANGULAR UNITS
525
532 static QString encodeUnit( QgsUnitTypes::AngleUnit unit );
533
541 Q_INVOKABLE static QgsUnitTypes::AngleUnit decodeAngleUnit( const QString &string, bool *ok SIP_OUT = nullptr );
542
547 static QString toString( QgsUnitTypes::AngleUnit unit );
548
555 static double fromUnitToUnitFactor( QgsUnitTypes::AngleUnit fromUnit, QgsUnitTypes::AngleUnit toUnit );
556
564 Q_INVOKABLE static QString formatAngle( double angle, int decimals, QgsUnitTypes::AngleUnit unit );
565
575 Q_INVOKABLE static QgsUnitTypes::DistanceValue scaledDistance( double distance, QgsUnitTypes::DistanceUnit unit, int decimals, bool keepBaseUnit = false );
576
586 Q_INVOKABLE static QgsUnitTypes::AreaValue scaledArea( double area, QgsUnitTypes::AreaUnit unit, int decimals, bool keepBaseUnit = false );
587
599 Q_INVOKABLE static QString formatDistance( double distance, int decimals, QgsUnitTypes::DistanceUnit unit, bool keepBaseUnit = false );
600
612 Q_INVOKABLE static QString formatArea( double area, int decimals, QgsUnitTypes::AreaUnit unit, bool keepBaseUnit = false );
613
614 // RENDER UNITS
615
622 static QString encodeUnit( QgsUnitTypes::RenderUnit unit );
623
631 Q_INVOKABLE static QgsUnitTypes::RenderUnit decodeRenderUnit( const QString &string, bool *ok SIP_OUT = nullptr );
632
633
638 static QString toString( QgsUnitTypes::RenderUnit unit );
639
646 static QString toAbbreviatedString( QgsUnitTypes::RenderUnit unit );
647
648
649 // LAYOUT UNITS
650
658 static QString encodeUnit( QgsUnitTypes::LayoutUnit unit );
659
668 Q_INVOKABLE static QgsUnitTypes::LayoutUnit decodeLayoutUnit( const QString &string, bool *ok SIP_OUT = nullptr );
669
675 Q_INVOKABLE static QgsUnitTypes::LayoutUnitType unitType( QgsUnitTypes::LayoutUnit units );
676
682 static QString toAbbreviatedString( QgsUnitTypes::LayoutUnit unit );
683
689 static QString toString( QgsUnitTypes::LayoutUnit unit );
690
691};
692
693#endif // QGSUNITTYPES_H
Helper functions for various unit types.
DistanceUnit
Units of distance.
@ DistanceDegrees
Degrees, for planar geographic CRS distance measurements.
@ DistanceKilometers
Kilometers.
@ DistanceMiles
Terrestrial miles.
@ DistanceUnknownUnit
Unknown distance unit.
@ DistanceMillimeters
Millimeters.
@ DistanceYards
Imperial yards.
@ DistanceFeet
Imperial feet.
@ DistanceNauticalMiles
Nautical miles.
@ DistanceCentimeters
Centimeters.
LayoutUnit
Layout measurement units.
@ LayoutInches
Inches.
@ LayoutFeet
Feet.
@ LayoutCentimeters
Centimeters.
@ LayoutPicas
Typographic picas.
@ LayoutPoints
Typographic points.
@ LayoutMeters
Meters.
AngleUnit
Units of angles.
@ AngleGon
Gon/gradian.
@ AngleRadians
Square kilometers.
@ AngleMilNATO
Angular mil (NATO definition, 6400 mil = 2PI radians)
@ AngleMilliradiansSI
Angular milliradians (SI definition, 1/1000 of radian)
@ AngleTurn
Turn/revolutions.
@ AngleUnknownUnit
Unknown angle unit.
@ AngleMinutesOfArc
Minutes of arc.
@ AngleSecondsOfArc
Seconds of arc.
SystemOfMeasurement
Systems of unit measurement.
@ MetricSystem
International System of Units (SI)
@ ImperialSystem
British Imperial.
VolumeUnit
Units of volume.
@ VolumeBarrel
Barrels.
@ VolumeCubicYards
Cubic yards.
@ VolumeCubicDecimeter
Cubic decimeters.
@ VolumeCubicCentimeter
Cubic Centimeters.
@ VolumeCubicDegrees
Cubic degrees, for planar geographic CRS volume measurements.
@ VolumeCubicFeet
Cubic feet.
@ VolumeLiters
Litres.
@ VolumeCubicInch
Cubic inches.
@ VolumeUnknownUnit
Unknown volume unit.
@ VolumeGallonUS
US Gallons.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
DistanceUnitType
Types of distance units.
@ Geographic
Unit is a geographic (e.g., degree based) unit.
@ UnknownType
Unknown unit type.
UnitType
Unit types.
@ TypeTemporal
Temporal unit.
@ TypeArea
Area unit.
@ TypeVolume
Volume unit.
@ TypeUnknown
Unknown unit type.
AreaUnit
Units of area.
@ AreaSquareNauticalMiles
Square nautical miles.
@ AreaSquareYards
Square yards.
@ AreaSquareFeet
Square feet.
@ AreaHectares
Hectares.
@ AreaUnknownUnit
Unknown areal unit.
@ AreaSquareMiles
Square miles.
@ AreaSquareCentimeters
Square centimeters.
@ AreaSquareKilometers
Square kilometers.
@ AreaSquareDegrees
Square degrees, for planar geographic CRS area measurements.
@ AreaAcres
Acres.
@ AreaSquareMillimeters
Square millimeters.
TemporalUnit
Temporal units.
@ TemporalMonths
Months.
@ TemporalWeeks
Weeks.
@ TemporalMilliseconds
Milliseconds.
@ TemporalIrregularStep
Special "irregular step" time unit, used for temporal data which uses irregular, non-real-world unit ...
@ TemporalDays
Days.
@ TemporalDecades
Decades.
@ TemporalCenturies
Centuries.
@ TemporalSeconds
Seconds.
@ TemporalMinutes
Minutes.
@ TemporalYears
Years.
@ TemporalHours
Hours.
RenderUnit
Rendering size units.
@ RenderUnknownUnit
Mixed or unknown units.
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
@ RenderPoints
Points (e.g., for font sizes)
@ RenderPixels
Pixels.
@ RenderInches
Inches.
@ RenderMapUnits
Map units.
LayoutUnitType
Types of layout units.
#define SIP_OUT
Definition qgis_sip.h:58
A combination of area value and unit.
double value
The value part of the distance.
QgsUnitTypes::AreaUnit unit
The value part of the distance.
A combination of distance value and unit.
QgsUnitTypes::DistanceUnit unit
The value part of the distance.
double value
The value part of the distance.