Skip to content
Permalink
Browse files

Merge pull request #3314 from nyalldawson/units

Consolidate unit handling in QgsUnitTypes
  • Loading branch information
nyalldawson committed Jul 26, 2016
2 parents 156c098 + 813ed5e commit 68b621ace6d5ac9ee5753bfbcf058f21d407989d
Showing with 2,562 additions and 2,151 deletions.
  1. +39 −0 doc/api_break.dox
  2. +4 −3 python/core/dxf/qgsdxfexport.sip
  3. +2 −2 python/core/effects/qgsgloweffect.sip
  4. +2 −2 python/core/effects/qgsshadoweffect.sip
  5. +2 −2 python/core/effects/qgstransformeffect.sip
  6. +0 −44 python/core/qgis.sip
  7. +1 −1 python/core/qgscoordinatereferencesystem.sip
  8. +2 −2 python/core/qgsdiagramrendererv2.sip
  9. +5 −5 python/core/qgsdistancearea.sip
  10. +2 −2 python/core/qgsexpression.sip
  11. +2 −2 python/core/qgsmapsettings.sip
  12. +1 −1 python/core/qgsproject.sip
  13. +4 −5 python/core/qgsscalecalculator.sip
  14. +74 −30 python/core/qgsunittypes.sip
  15. +1 −1 python/core/qgsvectorfilewriter.sip
  16. +14 −3 python/core/qgsxmlutils.sip
  17. +8 −8 python/core/symbology-ng/qgsarrowsymbollayer.sip
  18. +36 −8 python/core/symbology-ng/qgsellipsesymbollayerv2.sip
  19. +147 −50 python/core/symbology-ng/qgsfillsymbollayerv2.sip
  20. +2 −2 python/core/symbology-ng/qgsheatmaprenderer.sip
  21. +36 −13 python/core/symbology-ng/qgslinesymbollayerv2.sip
  22. +18 −10 python/core/symbology-ng/qgsmarkersymbollayerv2.sip
  23. +2 −2 python/core/symbology-ng/qgspointdisplacementrenderer.sip
  24. +47 −16 python/core/symbology-ng/qgssymbollayerv2.sip
  25. +31 −11 python/core/symbology-ng/qgssymbollayerv2utils.sip
  26. +36 −22 python/core/symbology-ng/qgssymbolv2.sip
  27. +12 −4 python/core/symbology-ng/qgsvectorfieldsymbollayer.sip
  28. +2 −2 python/gui/qgsmapcanvas.sip
  29. +3 −3 python/gui/qgsmaptoolidentify.sip
  30. +3 −3 python/gui/qgsunitselectionwidget.sip
  31. +9 −2 python/server/qgsmaprenderer.sip
  32. +2 −2 src/analysis/vector/qgstransectsample.cpp
  33. +2 −2 src/app/qgisapp.cpp
  34. +4 −4 src/app/qgsdecorationcopyright.cpp
  35. +1 −1 src/app/qgsdecorationcopyrightdialog.cpp
  36. +6 −6 src/app/qgsdecorationgrid.cpp
  37. +3 −3 src/app/qgsdecorationgrid.h
  38. +3 −3 src/app/qgsdecorationitem.cpp
  39. +2 −2 src/app/qgsdecorationitem.h
  40. +4 −4 src/app/qgsdecorationnortharrow.cpp
  41. +1 −1 src/app/qgsdecorationnortharrowdialog.cpp
  42. +11 −11 src/app/qgsdecorationscalebar.cpp
  43. +1 −1 src/app/qgsdecorationscalebardialog.cpp
  44. +4 −4 src/app/qgsdiagramproperties.cpp
  45. +0 −1 src/app/qgsdiagramproperties.h
  46. +1 −1 src/app/qgsdisplayangle.cpp
  47. +29 −29 src/app/qgslabelinggui.cpp
  48. +1 −1 src/app/qgsmaptoolidentifyaction.cpp
  49. +1 −1 src/app/qgsmaptoolidentifyaction.h
  50. +6 −6 src/app/qgsmaptooloffsetpointsymbol.cpp
  51. +1 −1 src/app/qgsmaptooloffsetpointsymbol.h
  52. +31 −31 src/app/qgsmeasuredialog.cpp
  53. +3 −3 src/app/qgsmeasuredialog.h
  54. +27 −27 src/app/qgsoptions.cpp
  55. +29 −29 src/app/qgsprojectproperties.cpp
  56. +4 −3 src/app/qgsprojectproperties.h
  57. +4 −4 src/core/composer/qgscomposerscalebar.cpp
  58. +1 −1 src/core/diagram/qgsdiagram.cpp
  59. +15 −15 src/core/dxf/qgsdxfexport.cpp
  60. +6 −5 src/core/dxf/qgsdxfexport.h
  61. +3 −3 src/core/effects/qgsgloweffect.cpp
  62. +3 −3 src/core/effects/qgsgloweffect.h
  63. +3 −3 src/core/effects/qgsshadoweffect.cpp
  64. +3 −3 src/core/effects/qgsshadoweffect.h
  65. +3 −3 src/core/effects/qgstransformeffect.cpp
  66. +3 −4 src/core/effects/qgstransformeffect.h
  67. +1 −1 src/core/layertree/qgslayertreemodellegendnode.cpp
  68. +0 −45 src/core/qgis.cpp
  69. +0 −44 src/core/qgis.h
  70. +10 −10 src/core/qgscoordinatereferencesystem.cpp
  71. +2 −2 src/core/qgscoordinatereferencesystem.h
  72. +2 −2 src/core/qgscoordinatereferencesystem_p.h
  73. +5 −6 src/core/qgsdiagramrendererv2.cpp
  74. +5 −5 src/core/qgsdiagramrendererv2.h
  75. +48 −48 src/core/qgsdistancearea.cpp
  76. +6 −6 src/core/qgsdistancearea.h
  77. +2 −2 src/core/qgsexpression.cpp
  78. +2 −2 src/core/qgsexpression.h
  79. +3 −3 src/core/qgsexpressionprivate.h
  80. +4 −4 src/core/qgsmapsettings.cpp
  81. +2 −2 src/core/qgsmapsettings.h
  82. +6 −7 src/core/qgspallabeling.cpp
  83. +4 −4 src/core/qgsproject.cpp
  84. +1 −1 src/core/qgsproject.h
  85. +7 −7 src/core/qgsscalecalculator.cpp
  86. +6 −6 src/core/qgsscalecalculator.h
  87. +414 −425 src/core/qgsunittypes.cpp
  88. +55 −32 src/core/qgsunittypes.h
  89. +10 −10 src/core/qgsvectorfilewriter.cpp
  90. +4 −4 src/core/qgsvectorfilewriter.h
  91. +0 −1 src/core/qgsvectorlayer.cpp
  92. +2 −2 src/core/qgsvectorlayereditutils.cpp
  93. +10 −42 src/core/qgsxmlutils.cpp
  94. +16 −2 src/core/qgsxmlutils.h
  95. +1 −1 src/core/symbology-ng/qgs25drenderer.cpp
  96. +15 −15 src/core/symbology-ng/qgsarrowsymbollayer.cpp
  97. +12 −12 src/core/symbology-ng/qgsarrowsymbollayer.h
  98. +21 −21 src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
  99. +39 −11 src/core/symbology-ng/qgsellipsesymbollayerv2.h
  100. +89 −89 src/core/symbology-ng/qgsfillsymbollayerv2.cpp
  101. +187 −69 src/core/symbology-ng/qgsfillsymbollayerv2.h
  102. +7 −7 src/core/symbology-ng/qgsheatmaprenderer.cpp
  103. +3 −3 src/core/symbology-ng/qgsheatmaprenderer.h
  104. +26 −26 src/core/symbology-ng/qgslinesymbollayerv2.cpp
  105. +39 −16 src/core/symbology-ng/qgslinesymbollayerv2.h
  106. +45 −45 src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
  107. +21 −13 src/core/symbology-ng/qgsmarkersymbollayerv2.h
  108. +4 −4 src/core/symbology-ng/qgspointdisplacementrenderer.cpp
  109. +5 −5 src/core/symbology-ng/qgspointdisplacementrenderer.h
  110. +11 −11 src/core/symbology-ng/qgssymbollayerv2.cpp
  111. +51 −20 src/core/symbology-ng/qgssymbollayerv2.h
  112. +36 −70 src/core/symbology-ng/qgssymbollayerv2utils.cpp
  113. +32 −11 src/core/symbology-ng/qgssymbollayerv2utils.h
  114. +10 −10 src/core/symbology-ng/qgssymbolv2.cpp
  115. +37 −23 src/core/symbology-ng/qgssymbolv2.h
  116. +10 −10 src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp
  117. +13 −5 src/core/symbology-ng/qgsvectorfieldsymbollayer.h
  118. +3 −3 src/gui/effects/qgspainteffectwidget.cpp
  119. +3 −3 src/gui/qgshighlight.cpp
  120. +1 −1 src/gui/qgshighlight.h
  121. +2 −2 src/gui/qgsmapcanvas.cpp
  122. +2 −2 src/gui/qgsmapcanvas.h
  123. +4 −4 src/gui/qgsmaptoolidentify.cpp
  124. +3 −3 src/gui/qgsmaptoolidentify.h
  125. +16 −16 src/gui/qgsunitselectionwidget.cpp
  126. +4 −4 src/gui/qgsunitselectionwidget.h
  127. +5 −5 src/gui/symbology-ng/qgsarrowsymbollayerwidget.cpp
  128. +5 −5 src/gui/symbology-ng/qgsellipsesymbollayerv2widget.cpp
  129. +1 −1 src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
  130. +1 −1 src/gui/symbology-ng/qgsheatmaprendererwidget.cpp
  131. +1 −1 src/gui/symbology-ng/qgslayerpropertieswidget.cpp
  132. +1 −1 src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp
  133. +2 −2 src/gui/symbology-ng/qgsrendererv2widget.cpp
  134. +35 −35 src/gui/symbology-ng/qgssymbollayerv2widget.cpp
  135. +1 −1 src/gui/symbology-ng/qgssymbollevelsv2dialog.cpp
  136. +2 −2 src/gui/symbology-ng/qgssymbolslistwidget.cpp
  137. +1 −1 src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
  138. +1 −1 src/gui/symbology-ng/qgsvectorfieldsymbollayerwidget.cpp
  139. +3 −3 src/plugins/coordinate_capture/coordinatecapture.cpp
  140. +1 −1 src/plugins/grass/qgsgrassnewmapset.cpp
  141. +2 −2 src/plugins/grass/qgsgrassregion.cpp
  142. +1 −1 src/providers/arcgisrest/qgsamsprovider.cpp
  143. +3 −3 src/providers/wcs/qgswcsprovider.cpp
  144. +2 −2 src/providers/wfs/qgswfsshareddata.cpp
  145. +2 −2 src/providers/wms/qgswmscapabilities.cpp
  146. +3 −3 src/providers/wms/qgswmsprovider.cpp
  147. +3 −3 src/server/qgsmaprenderer.cpp
  148. +9 −2 src/server/qgsmaprenderer.h
  149. +1 −1 src/server/qgswmsserver.cpp
  150. +4 −4 tests/src/app/testqgsattributetable.cpp
  151. +4 −4 tests/src/app/testqgsfieldcalculator.cpp
  152. +7 −7 tests/src/app/testqgsmaptoolidentifyaction.cpp
  153. +4 −4 tests/src/app/testqgsmeasuretool.cpp
  154. +1 −1 tests/src/core/testqgsatlascomposition.cpp
  155. +1 −1 tests/src/core/testqgscomposerdd.cpp
  156. +1 −1 tests/src/core/testqgscomposition.cpp
  157. +4 −4 tests/src/core/testqgscoordinatereferencesystem.cpp
  158. +2 −2 tests/src/core/testqgsdiagram.cpp
  159. +18 −18 tests/src/core/testqgsdistancearea.cpp
  160. +15 −15 tests/src/core/testqgsexpression.cpp
  161. +3 −3 tests/src/core/testqgslegendrenderer.cpp
  162. +5 −5 tests/src/core/testqgspainteffect.cpp
  163. +12 −12 tests/src/core/testqgsproject.cpp
  164. +2 −2 tests/src/core/testqgsrasterfill.cpp
  165. +3 −3 tests/src/core/testqgsshapeburst.cpp
  166. +2 −2 tests/src/python/test_qgsatlascomposition.py
  167. +47 −48 tests/src/python/test_qgsdistancearea.py
  168. +46 −46 tests/src/python/test_qgsmapunitscale.py
  169. +2 −1 tests/src/python/test_qgssymbollayerv2.py
  170. +12 −11 tests/src/python/test_qgssymbolv2.py
  171. +130 −132 tests/src/python/test_qgsunittypes.py
  172. +4 −4 tests/src/python/test_qgsvectorlayer.py
@@ -53,6 +53,14 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
<li>permissiveToDouble() and permissiveToInt() where moved out of the QGis class and renamed to qgsPermissiveToDouble() and
qgsPermissiveToInt()</li>
<li>The constants DEFAULT_IDENTIFY_RADIUS and MINIMUM_POINT_SIZE were removed</li>
<li>QGis::DecimalDegrees, DegreesMinutesSeconds and DegreesDecimalMinutes have been removed, and have all been replaced
with the general Degrees unit</li>
<li>The distance unit types QGis::UnitType (including QGis::Meters, QGis::Feet, QGis::Degrees, QGis::NauticalMiles,
QGis::Kilometers, QGis::Yards, QGis::Miles and QGis::UnknownUnit have been moved to QgsUnitTypes::DistanceUnit.
Some of these unit types have also been renamed - see the notes on QgsUnitTypes below. All methods which accepted
QGis::UnitType parameters have been updated to take QgsUnitTypes::DistanceUnit instead.</li>
<li>The unit handling methods toLiteral, fromLiteral, tr, fromTr, fromUnitToUnitFactor have been removed. Their
corresponding counterparts in QgsUnitTypes should be used instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsAuthConfigUriEdit QgsAuthConfigUriEdit
@@ -447,13 +455,44 @@ has improved sort capabilities including the ability to set custom sort values f
and for forcing certain items to always sort on top.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolV2 QgsSymbolV2

<ul>
<li>The OutputUnit enum, including QgsSymbolV2::MM, QgsSymbolV2::MapUnit, QgsSymbolV2::Mixed, QgsSymbolV2::Pixel and QgsSymbolV2::Percentage has been moved to QgsUnitTypes
and renamed to RenderUnit. QgsSymbolV2::OutputUnitList was renamed to QgsUnitTypes::RenderUnitList. All methods which previously accepted QgsSymbolV2::OutputUnit
parameters or QgsSymbolV2::OutputUnitList parameters now take QgsUnitTypes::RenderUnit or QgsUnitTypes::RenderUnitList parameters respectively.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolLayerV2Utils QgsSymbolLayerV2Utils

<ul>
<li>encodeOutputUnit() and decodeOutputUnit() were removed. QgsUnitTypes::encodeUnit() and QgsUnitTypes::decodeRenderUnit() should be used instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsTreeWidgetItem QgsTreeWidgetItem

<ul>
<li>QgsTreeWidgetItem is no longer a QObject and does not emit the itemEdited signal. Instead,
use QgsTreeWidgetItemObject which is an upgraded version of the original QgsTreeWidgetItem</li>
</ul>

\subsection qgis_api_break_3_0_QgsUnitTypes QgsUnitTypes

<ul>
<li>All distance enumeration values were renamed to have a "Distance" prefix, including
Meters (to DistanceMeters), Kilometers (to DistanceKilometers), Feet (to DistanceFeet),
NauticalMiles (to DistanceNauticalMiles), Yards (to DistanceYards), Miles (to DistanceMiles),
Degrees (to DistanceDegrees) and UnknownDistanceUnit to DistanceUnknownUnit</li>
<li>All area enumeration values were renamed to have a "Area" prefix, including
SquareMeters (to AreaSquareMeters), SquareKilometers (to AreaSquareKilometers), SquareFeet (to AreaSquareFeet),
SquareYards (to AreaSquareYards), SquareMiles (to AreaSquareMiles), Hectares (to AreaHectares),
Acres (to AreaAcres), SquareNauticalMiles (to AreaSquareNauticalMiles), SquareDegrees (to AreaSquareDegrees)
and UnknownAreaUnit to AreaUnknownUnit</li>
<li>All angle enumeration values were renamed to have a "Angle" prefix, including
Radians (to AngleRadians), Gon (to AngleGon), MinutesOfArc (to AngleMinutesOfArc),
SecondsOfArc (to AngleSecondsOfArc), Turn (to AngleTurn) and UnknownAngleUnit to AngleUnknownUnit</li>
</ul>

\subsection qgis_api_break_3_0_QgsVectorLayer QgsVectorLayer

<ul>
@@ -63,14 +63,14 @@ class QgsDxfExport
* Set map units
* @param u unit
*/
void setMapUnits( Qgis::UnitType u );
void setMapUnits( QgsUnitTypes::DistanceUnit u );

/**
* Retrieve map units
* @returns unit
* @see setMapUnits
*/
Qgis::UnitType mapUnits() const;
QgsUnitTypes::DistanceUnit mapUnits() const;

/**
* Set symbology export mode
@@ -327,7 +327,8 @@ class QgsDxfExport
//! @note added in 2.15
void writeMText( const QString &layer, const QString &text, const QgsPointV2 &pt, double width, double angle, const QColor& color );

static double mapUnitScaleFactor( double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, Qgis::UnitType mapUnits );
//! Calculates a scaling factor to convert from map units to a specified symbol unit.
static double mapUnitScaleFactor( double scaleDenominator, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits );

//! Return cleaned layer name for use in DXF
static QString dxfLayerName( const QString &name );
@@ -50,15 +50,15 @@ class QgsGlowEffect : QgsPaintEffect
* @see setSpread
* @see setSpreadMapUnitScale
*/
void setSpreadUnit( const QgsSymbolV2::OutputUnit unit );
void setSpreadUnit( const QgsUnitTypes::RenderUnit unit );

/** Returns the units used for the glow spread distance.
* @returns units for spread distance
* @see setSpreadUnit
* @see spread
* @see spreadMapUnitScale
*/
QgsSymbolV2::OutputUnit spreadUnit() const;
QgsUnitTypes::RenderUnit spreadUnit() const;

/** Sets the map unit scale used for the spread distance.
* @param scale map unit scale for spread distance
@@ -69,15 +69,15 @@ class QgsShadowEffect : QgsPaintEffect
* @see setOffsetDistance
* @see setOffsetMapUnitScale
*/
void setOffsetUnit( const QgsSymbolV2::OutputUnit unit );
void setOffsetUnit( const QgsUnitTypes::RenderUnit unit );

/** Returns the units used for the shadow offset distance.
* @returns units for offset distance
* @see setOffsetUnit
* @see offsetDistance
* @see offsetMapUnitScale
*/
QgsSymbolV2::OutputUnit offsetUnit() const;
QgsUnitTypes::RenderUnit offsetUnit() const;

/** Sets the map unit scale used for the shadow offset distance.
* @param scale map unit scale for offset distance
@@ -71,7 +71,7 @@ class QgsTransformEffect : QgsPaintEffect
* @see setTranslateY
* @see setTranslateMapUnitScale
*/
void setTranslateUnit( const QgsSymbolV2::OutputUnit unit );
void setTranslateUnit( const QgsUnitTypes::RenderUnit unit );

/** Returns the units used for the transform translation.
* @returns units for translation
@@ -80,7 +80,7 @@ class QgsTransformEffect : QgsPaintEffect
* @see translateY
* @see translateMapUnitScale
*/
QgsSymbolV2::OutputUnit translateUnit() const;
QgsUnitTypes::RenderUnit translateUnit() const;

/** Sets the map unit scale used for the transform translation.
* @param scale map unit scale for translation
@@ -136,50 +136,6 @@ class Qgis
QImage::Format_ARGB32_Premultiplied */ ARGB32_Premultiplied,
};


/** Map units that qgis supports
* @note that QGIS < 1.4 api had only Meters, Feet, Degrees and UnknownUnit
* @note and QGIS >1.8 returns to that
*/
//TODO QGIS 3.0 - clean up and move to QgsUnitTypes and rename to DistanceUnit
enum UnitType
{
Meters, /*!< meters */
Feet, /*!< imperial feet */
Degrees, /*!< degrees, for planar geographic CRS distance measurements */ //for 1.0 api backwards compatibility
NauticalMiles, /*!< nautical miles */
Kilometers, /*!< kilometers */
Yards, /*!< imperial yards */
Miles, /*!< terrestial miles */

UnknownUnit, /*!< unknown distance unit */

// for [1.4;1.8] api compatibility
DecimalDegrees, // was 2
DegreesMinutesSeconds, // was 4
DegreesDecimalMinutes, // was 5
};

//! Provides the canonical name of the type value
//! @deprecated use QgsUnitTypes::encodeUnit() instead
static QString toLiteral( Qgis::UnitType unit ) /Deprecated/;

//! Converts from the canonical name to the type value
//! @deprecated use QgsUnitTypes::decodeDistanceUnit() instead
static UnitType fromLiteral( const QString& literal, Qgis::UnitType defaultType = UnknownUnit ) /Deprecated/;

//! Provides translated version of the type value
//! @deprecated use QgsUnitTypes::toString() instead
static QString tr( Qgis::UnitType unit ) /Deprecated/;

//! Provides type value from translated version
//! @deprecated use QgsUnitTypes::stringToDistanceUnit() instead
static UnitType fromTr( const QString& literal, Qgis::UnitType defaultType = UnknownUnit ) /Deprecated/;

//! Returns the conversion factor between the specified units
//! @deprecated use QgsUnitTyoes::fromUnitToUnitFactor() instead
static double fromUnitToUnitFactor( Qgis::UnitType fromUnit, Qgis::UnitType toUnit ) /Deprecated/;

//! User defined event types
enum UserEvent
{
@@ -479,7 +479,7 @@ class QgsCoordinateReferenceSystem

/** Returns the units for the projection used by the CRS.
*/
Qgis::UnitType mapUnits() const;
QgsUnitTypes::DistanceUnit mapUnits() const;


// Mutators -----------------------------------
@@ -285,7 +285,7 @@ class QgsDiagramSettings

/** Diagram size unit
*/
QgsSymbolV2::OutputUnit sizeType;
QgsUnitTypes::RenderUnit sizeType;

/** Diagram size unit scale
* @note added in 2.16
@@ -295,7 +295,7 @@ class QgsDiagramSettings
/** Line unit index
* @note added in 2.16
*/
QgsSymbolV2::OutputUnit lineSizeUnit;
QgsUnitTypes::RenderUnit lineSizeUnit;

/** Line unit scale
* @note added in 2.16
@@ -155,7 +155,7 @@ class QgsDistanceArea
* @note added in QGIS 2.14
* @see areaUnits()
*/
Qgis::UnitType lengthUnits() const;
QgsUnitTypes::DistanceUnit lengthUnits() const;

/** Returns the units of area for areal calculations made by this object.
* @note added in QGIS 2.14
@@ -179,7 +179,7 @@ class QgsDistanceArea
* @return formatted measurement string
* @deprecated use formatDistance() or formatArea() instead
*/
static QString textUnit( double value, int decimals, Qgis::UnitType u, bool isArea, bool keepBaseUnit = false ) /Deprecated/;
static QString textUnit( double value, int decimals, QgsUnitTypes::DistanceUnit u, bool isArea, bool keepBaseUnit = false ) /Deprecated/;

/** Returns an distance formatted as a friendly string.
* @param distance distance to format
@@ -191,7 +191,7 @@ class QgsDistanceArea
* @note added in QGIS 2.16
* @see formatArea()
*/
static QString formatDistance( double distance, int decimals, Qgis::UnitType unit, bool keepBaseUnit = false );
static QString formatDistance( double distance, int decimals, QgsUnitTypes::DistanceUnit unit, bool keepBaseUnit = false );

/** Returns an area formatted as a friendly string.
* @param area area to format
@@ -208,7 +208,7 @@ class QgsDistanceArea

//! Helper for conversion between physical units
// TODO QGIS 3.0 - remove this method, as its behaviour is non-intuitive.
void convertMeasurement( double &measure /In,Out/, Qgis::UnitType &measureUnits /In,Out/, Qgis::UnitType displayUnits, bool isArea ) const;
void convertMeasurement( double &measure /In,Out/, QgsUnitTypes::DistanceUnit &measureUnits /In,Out/, QgsUnitTypes::DistanceUnit displayUnits, bool isArea ) const;

/** Takes a length measurement calculated by this QgsDistanceArea object and converts it to a
* different distance unit.
@@ -219,7 +219,7 @@ class QgsDistanceArea
* @see convertAreaMeasurement()
* @note added in QGIS 2.14
*/
double convertLengthMeasurement( double length, Qgis::UnitType toUnits ) const;
double convertLengthMeasurement( double length, QgsUnitTypes::DistanceUnit toUnits ) const;

/** Takes an area measurement calculated by this QgsDistanceArea object and converts it to a
* different areal unit.
@@ -167,14 +167,14 @@ class QgsExpression
* @note added in QGIS 2.14
* @see setDistanceUnits()
*/
Qgis::UnitType distanceUnits() const;
QgsUnitTypes::DistanceUnit distanceUnits() const;

/** Sets the desired distance units for calculations involving geomCalculator(), eg "$length" and "$perimeter".
* @note distances are only converted when a geomCalculator() has been set
* @note added in QGIS 2.14
* @see distanceUnits()
*/
void setDistanceUnits( Qgis::UnitType unit );
void setDistanceUnits( QgsUnitTypes::DistanceUnit unit );

/** Returns the desired areal units for calculations involving geomCalculator(), eg "$area".
* @note areas are only converted when a geomCalculator() has been set
@@ -91,9 +91,9 @@ class QgsMapSettings
QgsCoordinateReferenceSystem destinationCrs() const;

//! Get units of map's geographical coordinates - used for scale calculation
Qgis::UnitType mapUnits() const;
QgsUnitTypes::DistanceUnit mapUnits() const;
//! Set units of map's geographical coordinates - used for scale calculation
void setMapUnits( Qgis::UnitType u );
void setMapUnits( QgsUnitTypes::DistanceUnit u );

//! Set the background color of the map
void setBackgroundColor( const QColor& color );
@@ -246,7 +246,7 @@ class QgsProject : QObject
* @note added in QGIS 2.14
* @see areaUnits()
*/
Qgis::UnitType distanceUnits() const;
QgsUnitTypes::DistanceUnit distanceUnits() const;

/** Convenience function to query default area measurement units for project.
* @note added in QGIS 2.14
@@ -13,11 +13,10 @@ class QgsScaleCalculator
/**
* Constructor
* @param dpi Monitor resolution in dots per inch
* @param mapUnits Units of the data on the map. Must match a value from the
* Qgis::UnitType enum (Meters, Feet, Degrees)
* @param mapUnits Units of the data on the map
*/
QgsScaleCalculator( double dpi = 0,
Qgis::UnitType mapUnits = Qgis::Meters );
QgsUnitTypes::DistanceUnit mapUnits = QgsUnitTypes::DistanceMeters );

/**
* Set the dpi to be used in scale calculations
@@ -35,10 +34,10 @@ class QgsScaleCalculator
* Set the map units
* @param mapUnits Units of the data on the map. Must match a value from the
*/
void setMapUnits( Qgis::UnitType mapUnits );
void setMapUnits( QgsUnitTypes::DistanceUnit mapUnits );

/** Returns current map units */
Qgis::UnitType mapUnits() const;
QgsUnitTypes::DistanceUnit mapUnits() const;

/**
* Calculate the scale denominator

0 comments on commit 68b621a

Please sign in to comment.
You can’t perform that action at this time.