~ubuntu-branches/ubuntu/trusty/qgis/trusty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
 * \class QgsScaleCalculator
 * \brief Calculates scale for a given combination of canvas size, map extent,
 * and monitor dpi.
 */
class QgsScaleCalculator
{
%TypeHeaderCode
#include <qgsscalecalculator.h>
%End
  
  public:

    /**
     * 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)
     */
    QgsScaleCalculator(int dpi = 0, 
                       QGis::UnitType mapUnits = QGis::Meters);

    //! Destructor
    ~QgsScaleCalculator();

    /**
     * Set the dpi to be used in scale calculations
     * @param dpi Dots per inch of monitor resolution
     */
    void setDpi(int dpi);

    /**
     * Accessor for dpi used in scale calculations
     * @return int the dpi used for scale calculations.
     */
    int dpi();
    
    /**
     * Set the map units
     * @param mapUnits Units of the data on the map. Must match a value from the
     */
    void setMapUnits(QGis::UnitType mapUnits);

    /** Returns current map units */
    QGis::UnitType mapUnits() const;
    
    /**
     * Calculate the scale
     * @param mapExtent QgsRectangle containing the current map extent
     * @param canvasWidth Width of the map canvas in pixel (physical) units
     * @return scale of current map view
     */
    double calculate(QgsRectangle &mapExtent, int canvasWidth);

    /**
     * Calculate the distance between to points in geographic coordinates.
     * Used to calculate scale for map views with geographic (decimal degree)
     * data.
     * @param mapExtent QgsRectangle containing the current map extent
     */
    double calculateGeographicDistance(QgsRectangle &mapExtent);

};