QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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.h"
22 
23 /***************************************************************************
24  * This class is considered CRITICAL and any change MUST be accompanied with
25  * full unit tests in test_qgsunittypes.py.
26  * See details in QEP #17
27  ****************************************************************************/
28 
35 class CORE_EXPORT QgsUnitTypes
36 {
37  public:
38 
42  {
43  Standard = 0,
46  };
47 
49  enum AreaUnit
50  {
51  SquareMeters = 0,
61  };
62 
64  enum AngleUnit
65  {
66  AngleDegrees = 0,
68  Gon,
71  Turn,
73  };
74 
75  // DISTANCE UNITS
76 
79  static DistanceUnitType unitType( QGis::UnitType unit );
80 
86  static QString encodeUnit( QGis::UnitType unit );
87 
94  static QGis::UnitType decodeDistanceUnit( const QString& string, bool *ok = 0 );
95 
100  static QString toString( QGis::UnitType unit );
101 
107  static QGis::UnitType stringToDistanceUnit( const QString& string, bool *ok = 0 );
108 
114  static double fromUnitToUnitFactor( QGis::UnitType fromUnit, QGis::UnitType toUnit );
115 
116  // AREAL UNITS
117 
120  static DistanceUnitType unitType( AreaUnit unit );
121 
127  static QString encodeUnit( AreaUnit unit );
128 
135  static AreaUnit decodeAreaUnit( const QString& string, bool *ok = 0 );
136 
141  static QString toString( AreaUnit unit );
142 
148  static AreaUnit stringToAreaUnit( const QString& string, bool *ok = 0 );
149 
155  static double fromUnitToUnitFactor( AreaUnit fromUnit, AreaUnit toUnit );
156 
161  static AreaUnit distanceToAreaUnit( QGis::UnitType distanceUnit );
162 
163  // ANGULAR UNITS
164 
170  static QString encodeUnit( AngleUnit unit );
171 
178  static AngleUnit decodeAngleUnit( const QString& string, bool *ok = 0 );
179 
183  static QString toString( AngleUnit unit );
184 
190  static double fromUnitToUnitFactor( AngleUnit fromUnit, AngleUnit toUnit );
191 
198  static QString formatAngle( double angle, int decimals, AngleUnit unit );
199 
200  //TODO QGIS 3.0 - enable and move symbol units here! Otherwise creates circular dependencies...
201 #if 0
202  // SYMBOL UNITS
203 
209  static QString encodeUnit( QgsSymbolV2::OutputUnit unit );
210 
217  static QgsSymbolV2::OutputUnit decodeSymbolUnit( const QString& string, bool *ok = 0 );
218 #endif
219 
220 };
221 
222 #endif // QGSUNITTYPES_H
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:65
Helper functions for various unit types.
Definition: qgsunittypes.h:35
DistanceUnitType
Types of distance units.
Definition: qgsunittypes.h:41
AngleUnit
Units of angles.
Definition: qgsunittypes.h:64
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
UnitType
Map units that qgis supports.
Definition: qgis.h:159
AreaUnit
Units of area.
Definition: qgsunittypes.h:49