Skip to content

Commit b077265

Browse files
committed
Flip remaining scale API from real to denominators
1 parent 463e722 commit b077265

21 files changed

+200
-89
lines changed

doc/api_break.dox

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,8 @@ QgsMapToPixel {#qgis_api_break_3_0_QgsMapToPixel}
15821582

15831583
- The constructor now uses the map center x and y, and requires both height and width in pixels and a rotation value
15841584
- setYMaximum(), setYMinimum(), setXMinimum() were removed. Use setParameters() instead
1585+
- fromScale now accepts the scale as a scale denominator, not actual scale (e.g. 2000 for 1:2000). This change
1586+
was made to make all scale based API calls uniform in behavior.
15851587

15861588

15871589
QgsMapToPixelGeometrySimplifier {#qgis_api_break_3_0_QgsMapToPixelGeometrySimplifier}
@@ -1605,6 +1607,12 @@ plugins calling this method will need to be updated.
16051607
- the default destination CRS has changed from WGS 84 to invalid CRS (i.e. undefined, no reprojection will be done).
16061608
- setMapUnits() was removed. The map units are dictated by the units for the destination CRS.
16071609

1610+
QgsMapUnitScale {#qgis_api_break_3_0_QgsMapUnitScale}
1611+
---------------
1612+
1613+
- minScale and maxScale now represent the scale as a scale denominator, not actual scale (e.g. 2000 for 1:2000). This change
1614+
was made to make all scale based API calls uniform in behavior.
1615+
16081616

16091617
QgsMarkerSymbolLayer {#qgis_api_break_3_0_QgsMarkerSymbolLayer}
16101618
--------------------

python/core/qgslegendsettings.sip

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,18 @@ Returns style
193193

194194
double mapScale() const;
195195
%Docstring
196+
Returns the legend map scale.
197+
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
198+
.. seealso:: setMapScale()
196199
:rtype: float
197200
%End
201+
198202
void setMapScale( double scale );
203+
%Docstring
204+
Sets the legend map ``scale``.
205+
The ``scale`` value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
206+
.. seealso:: mapScale()
207+
%End
199208

200209
int dpi() const;
201210
%Docstring

python/core/qgsmapsettings.sip

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,11 @@ Return the actual extent derived from requested extent that takes takes output i
238238
Return the distance in geographical coordinates that equals to one pixel in the map
239239
:rtype: float
240240
%End
241+
241242
double scale() const;
242243
%Docstring
243-
Return the calculated scale of the map
244+
Returns the calculated map scale.
245+
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
244246
:rtype: float
245247
%End
246248

python/core/qgsmaptopixel.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class QgsMapToPixel
4242

4343
static QgsMapToPixel fromScale( double scale, QgsUnitTypes::DistanceUnit mapUnits, double dpi = 96 );
4444
%Docstring
45-
Returns a new QgsMapToPixel created using a specified scale and distance unit.
46-
\param scale map scale
45+
Returns a new QgsMapToPixel created using a specified ``scale`` and distance unit.
46+
\param scale map scale denominator, e.g. 1000.0 for a 1:1000 map.
4747
\param dpi screen DPI
4848
\param mapUnits map units
4949
:return: matching QgsMapToPixel

python/core/qgsmapunitscale.sip

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,19 @@ class QgsMapUnitScale
3030
Constructor for QgsMapUnitScale
3131
\param minScale minimum allowed scale, or 0.0 if no minimum scale set
3232
\param maxScale maximum allowed scale, or 0.0 if no maximum scale set
33+
The scale values indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
3334
%End
3435

3536
double minScale;
3637
%Docstring
37-
The minimum scale, or 0.0 if unset
38+
The minimum scale, or 0.0 if unset.
39+
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
3840
%End
41+
3942
double maxScale;
4043
%Docstring
41-
The maximum scale, or 0.0 if unset
44+
The maximum scale, or 0.0 if unset.
45+
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
4246
%End
4347

4448
bool minSizeMMEnabled;

python/core/qgsscalecalculator.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Returns current map units
6060
Calculate the scale denominator
6161
\param mapExtent QgsRectangle containing the current map extent
6262
\param canvasWidth Width of the map canvas in pixel (physical) units
63-
:return: scale denominator of current map view
63+
:return: scale denominator of current map view, e.g. 1000.0 for a 1:1000 map.
6464
:rtype: float
6565
%End
6666

src/core/qgslegendsettings.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,18 @@ class CORE_EXPORT QgsLegendSettings
154154
bool useAdvancedEffects() const { return mUseAdvancedEffects; }
155155
void setUseAdvancedEffects( bool use ) { mUseAdvancedEffects = use; }
156156

157+
/**
158+
* Returns the legend map scale.
159+
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
160+
* \see setMapScale()
161+
*/
157162
double mapScale() const { return mMapScale; }
163+
164+
/**
165+
* Sets the legend map \a scale.
166+
* The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
167+
* \see mapScale()
168+
*/
158169
void setMapScale( double scale ) { mMapScale = scale; }
159170

160171
int dpi() const { return mDpi; }

src/core/qgsmapsettings.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,11 @@ class CORE_EXPORT QgsMapSettings
198198
QPolygonF visiblePolygon() const;
199199
//! Return the distance in geographical coordinates that equals to one pixel in the map
200200
double mapUnitsPerPixel() const;
201-
//! Return the calculated scale of the map
201+
202+
/**
203+
* Returns the calculated map scale.
204+
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
205+
*/
202206
double scale() const;
203207

204208
/** Sets the expression context. This context is used for all expression evaluation

src/core/qgsmaptopixel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ QgsMapToPixel QgsMapToPixel::fromScale( double scale, QgsUnitTypes::DistanceUnit
6161
{
6262
double metersPerPixel = 25.4 / dpi / 1000.0;
6363
double mapUnitsPerPixel = metersPerPixel * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::DistanceMeters, mapUnits );
64-
return QgsMapToPixel( mapUnitsPerPixel / scale );
64+
return QgsMapToPixel( mapUnitsPerPixel * scale );
6565
}
6666

6767
QgsMapToPixel::QgsMapToPixel()

src/core/qgsmaptopixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class CORE_EXPORT QgsMapToPixel
5454
*/
5555
QgsMapToPixel( double mapUnitsPerPixel );
5656

57-
/** Returns a new QgsMapToPixel created using a specified scale and distance unit.
58-
* \param scale map scale
57+
/** Returns a new QgsMapToPixel created using a specified \a scale and distance unit.
58+
* \param scale map scale denominator, e.g. 1000.0 for a 1:1000 map.
5959
* \param dpi screen DPI
6060
* \param mapUnits map units
6161
* \returns matching QgsMapToPixel

0 commit comments

Comments
 (0)