2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \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
|
2008-10-10 20:02:22 +00:00
|
|
|
* QGis::UnitType enum (Meters, Feet, Degrees)
|
2007-01-09 02:39:15 +00:00
|
|
|
*/
|
|
|
|
QgsScaleCalculator(int dpi = 0,
|
2008-10-10 20:02:22 +00:00
|
|
|
QGis::UnitType mapUnits = QGis::Meters);
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
//! Destructor
|
|
|
|
~QgsScaleCalculator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the dpi to be used in scale calculations
|
|
|
|
* @param dpi Dots per inch of monitor resolution
|
|
|
|
*/
|
|
|
|
void setDpi(int dpi);
|
|
|
|
|
2008-02-11 10:39:40 +00:00
|
|
|
/**
|
|
|
|
* Accessor for dpi used in scale calculations
|
|
|
|
* @return int the dpi used for scale calculations.
|
|
|
|
*/
|
|
|
|
int dpi();
|
|
|
|
|
2007-01-09 02:39:15 +00:00
|
|
|
/**
|
|
|
|
* Set the map units
|
|
|
|
* @param mapUnits Units of the data on the map. Must match a value from the
|
|
|
|
*/
|
2008-10-10 20:02:22 +00:00
|
|
|
void setMapUnits(QGis::UnitType mapUnits);
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
/** Returns current map units */
|
2008-10-10 20:02:22 +00:00
|
|
|
QGis::UnitType mapUnits() const;
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the scale
|
|
|
|
* @param mapExtent QgsRect containing the current map extent
|
|
|
|
* @param canvasWidth Width of the map canvas in pixel (physical) units
|
|
|
|
* @return scale of current map view
|
|
|
|
*/
|
|
|
|
double calculate(QgsRect &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 QgsRect containing the current map extent
|
|
|
|
*/
|
|
|
|
double calculateGeographicDistance(QgsRect &mapExtent);
|
|
|
|
|
|
|
|
};
|
|
|
|
|