QGIS API Documentation 3.43.0-Master (c67cf405802)
qgsscalecalculator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsscalecalculator.h
3 Calculates scale based on map extent and units
4 -------------------
5 begin : May 18, 2004
6 copyright : (C) 2004 by Gary E.Sherman
7 email : sherman at mrcc.com
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#ifndef QGSSCALECALCULATOR_H
20#define QGSSCALECALCULATOR_H
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
24#include "qgis.h"
25
26class QString;
27class QgsRectangle;
28
37class CORE_EXPORT QgsScaleCalculator
38{
39 public:
40
46 QgsScaleCalculator( double dpi = 0,
48
49
56 Qgis::ScaleCalculationMethod method() const { return mMethod; }
57
64 void setMethod( Qgis::ScaleCalculationMethod method );
65
70 void setDpi( double dpi );
71
76 double dpi() const;
77
83 void setMapUnits( Qgis::DistanceUnit mapUnits );
84
90 Qgis::DistanceUnit mapUnits() const;
91
100 double calculate( const QgsRectangle &mapExtent, double canvasWidth ) const;
101
111 QSizeF calculateImageSize( const QgsRectangle &mapExtent, double scale ) const;
112
124 double calculateGeographicDistance( const QgsRectangle &mapExtent ) const;
125
140 double calculateGeographicDistanceAtLatitude( double latitude, double longitude1, double longitude2 ) const;
141
142 private:
143
145 void calculateMetrics( const QgsRectangle &mapExtent, double &delta, double &conversionFactor ) const;
146
147 // Must be horizontal middle by default, for stable API compatibility
149
151 double mDpi = 96;
152
155};
156
157#endif // #ifndef QGSSCALECALCULATOR_H
DistanceUnit
Units of distance.
Definition qgis.h:4843
@ Unknown
Unknown distance unit.
ScaleCalculationMethod
Scale calculation logic.
Definition qgis.h:5080
@ HorizontalMiddle
Calculate horizontally, across midle of map.
A rectangle specified with double values.
Calculates scale for a given combination of canvas size, map extent, and monitor dpi.
Qgis::ScaleCalculationMethod method() const
Returns the method to use for map scale calculations.