QgsScaleCalculator class
Calculates scale for a given combination of canvas size, map extent, and monitor dpi.
Contents
Constructors, destructors, conversion operators
-
QgsScaleCalculator(double dpi = 0,
QgsUnitTypes::
DistanceUnit mapUnits = QgsUnitTypes:: DistanceMeters) - Constructor.
Public functions
- auto calculate(const QgsRectangle& mapExtent, double canvasWidth) -> double
- Calculate the scale denominator.
- auto calculateGeographicDistance(const QgsRectangle& mapExtent) -> double
- Calculate the distance between two points in geographic coordinates.
- auto dpi() -> double
- Returns the DPI (dots per inch) used in scale calculations.
-
auto mapUnits() const -> QgsUnitTypes::
DistanceUnit - Returns current map units.
- void setDpi(double dpi)
- Sets the dpi (dots per inch) for the output resolution, to be used in scale calculations.
-
void setMapUnits(QgsUnitTypes::
DistanceUnit mapUnits) - Set the map units.
Function documentation
QgsScaleCalculator:: QgsScaleCalculator(double dpi = 0,
QgsUnitTypes:: DistanceUnit mapUnits = QgsUnitTypes:: DistanceMeters)
Constructor.
| Parameters | |
|---|---|
| dpi | Monitor resolution in dots per inch |
| mapUnits | Units of the data on the map |
double QgsScaleCalculator:: calculate(const QgsRectangle& mapExtent,
double canvasWidth)
Calculate the scale denominator.
| Parameters | |
|---|---|
| mapExtent | QgsRectangle containing the current map extent |
| canvasWidth | Width of the map canvas in pixel (physical) units |
| Returns | scale denominator of current map view, e.g. 1000.0 for a 1:1000 map. |
double QgsScaleCalculator:: calculateGeographicDistance(const QgsRectangle& mapExtent)
Calculate the distance between two points in geographic coordinates.
| Parameters | |
|---|---|
| mapExtent | QgsRectangle containing the current map extent |
Used to calculate scale for map views with geographic (decimal degree) data.
double QgsScaleCalculator:: dpi()
Returns the DPI (dots per inch) used in scale calculations.
void QgsScaleCalculator:: setDpi(double dpi)
Sets the dpi (dots per inch) for the output resolution, to be used in scale calculations.
void QgsScaleCalculator:: setMapUnits(QgsUnitTypes:: DistanceUnit mapUnits)
Set the map units.
| Parameters | |
|---|---|
| mapUnits | Units of the data on the map. Must match a value from the |