2007-01-09 02:39:15 +00:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/** \ingroup core
|
|
|
|
* Calculates scale for a given combination of canvas size, map extent,
|
2007-01-09 02:39:15 +00:00
|
|
|
* 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
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
QgsScaleCalculator( double dpi = 0,
|
|
|
|
QGis::UnitType mapUnits = QGis::Meters );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the dpi to be used in scale calculations
|
|
|
|
* @param dpi Dots per inch of monitor resolution
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setDpi( double dpi );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2008-02-11 10:39:40 +00:00
|
|
|
/**
|
|
|
|
* Accessor for dpi used in scale calculations
|
|
|
|
* @return int the dpi used for scale calculations.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
double 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
|
|
|
|
*/
|
2012-09-24 02:28:15 +02: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;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2007-01-09 02:39:15 +00:00
|
|
|
/**
|
2014-01-27 09:22:24 +01:00
|
|
|
* Calculate the scale denominator
|
2008-11-09 00:14:12 +00:00
|
|
|
* @param mapExtent QgsRectangle containing the current map extent
|
2007-01-09 02:39:15 +00:00
|
|
|
* @param canvasWidth Width of the map canvas in pixel (physical) units
|
2014-01-27 09:22:24 +01:00
|
|
|
* @return scale denominator of current map view
|
2007-01-09 02:39:15 +00:00
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
double calculate( const QgsRectangle &mapExtent, int canvasWidth );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
/**
|
2012-09-24 02:28:15 +02:00
|
|
|
* Calculate the distance between two points in geographic coordinates.
|
2007-01-09 02:39:15 +00:00
|
|
|
* Used to calculate scale for map views with geographic (decimal degree)
|
|
|
|
* data.
|
2008-11-09 00:14:12 +00:00
|
|
|
* @param mapExtent QgsRectangle containing the current map extent
|
2007-01-09 02:39:15 +00:00
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
double calculateGeographicDistance( const QgsRectangle &mapExtent );
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|