QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | List of all members
QgsScaleCalculator Class Reference

Calculates scale for a given combination of canvas size, map extent, and monitor dpi. More...

#include <qgsscalecalculator.h>

Public Member Functions

 QgsScaleCalculator (double dpi=0, QGis::UnitType mapUnits=QGis::Meters)
 Constructor.
 ~QgsScaleCalculator ()
 Destructor.
void setDpi (double dpi)
 Set the dpi to be used in scale calculations.
double dpi ()
 Accessor for dpi used in scale calculations.
void setMapUnits (QGis::UnitType mapUnits)
 Set the map units.
QGis::UnitType mapUnits () const
 Returns current map units.
double calculate (const QgsRectangle &mapExtent, int canvasWidth)
 Calculate the scale denominator.
double calculateGeographicDistance (const QgsRectangle &mapExtent)
 Calculate the distance between two points in geographic coordinates.

Detailed Description

Calculates scale for a given combination of canvas size, map extent, and monitor dpi.

Constructor & Destructor Documentation

QgsScaleCalculator::QgsScaleCalculator ( double  dpi = 0,
QGis::UnitType  mapUnits = QGis::Meters 
)

Constructor.

Parameters
dpiMonitor resolution in dots per inch
mapUnitsUnits of the data on the map. Must match a value from the QGis::UnitType enum (Meters, Feet, Degrees)
QgsScaleCalculator::~QgsScaleCalculator ( )

Destructor.

Member Function Documentation

double QgsScaleCalculator::calculate ( const QgsRectangle mapExtent,
int  canvasWidth 
)

Calculate the scale denominator.

Parameters
mapExtentQgsRectangle containing the current map extent
canvasWidthWidth of the map canvas in pixel (physical) units
Returns
scale denominator of current map view
double QgsScaleCalculator::calculateGeographicDistance ( const QgsRectangle mapExtent)

Calculate the distance between two points in geographic coordinates.

Used to calculate scale for map views with geographic (decimal degree) data.

Parameters
mapExtentQgsRectangle containing the current map extent
double QgsScaleCalculator::dpi ( )

Accessor for dpi used in scale calculations.

Returns
int the dpi used for scale calculations.
QGis::UnitType QgsScaleCalculator::mapUnits ( ) const

Returns current map units.

void QgsScaleCalculator::setDpi ( double  dpi)

Set the dpi to be used in scale calculations.

Parameters
dpiDots per inch of monitor resolution
void QgsScaleCalculator::setMapUnits ( QGis::UnitType  mapUnits)

Set the map units.

Parameters
mapUnitsUnits of the data on the map. Must match a value from the

The documentation for this class was generated from the following files: