QgsScaleCalculator Class Reference
[QGIS core library]

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

#include <qgsscalecalculator.h>

List of all members.

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.
double calculateGeographicDistance (const QgsRectangle &mapExtent)
 Calculate the distance between two points in geographic coordinates.

Private Attributes

double mDpi
 dpi member
QGis::UnitType mMapUnits
 map unit member


Detailed Description

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

Definition at line 32 of file qgsscalecalculator.h.


Constructor & Destructor Documentation

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

Constructor.

Parameters:
dpi Monitor resolution in dots per inch
mapUnits Units of the data on the map. Must match a value from the QGis::UnitType enum (Meters, Feet, Degrees)

Definition at line 26 of file qgsscalecalculator.cpp.

QgsScaleCalculator::~QgsScaleCalculator (  ) 

Destructor.

Definition at line 30 of file qgsscalecalculator.cpp.


Member Function Documentation

void QgsScaleCalculator::setDpi ( double  dpi  ) 

Set the dpi to be used in scale calculations.

Parameters:
dpi Dots per inch of monitor resolution

Definition at line 33 of file qgsscalecalculator.cpp.

References mDpi.

Referenced by QgsComposerMap::scale(), and QgsMapRenderer::setOutputSize().

double QgsScaleCalculator::dpi (  ) 

Accessor for dpi used in scale calculations.

Returns:
int the dpi used for scale calculations.

Definition at line 37 of file qgsscalecalculator.cpp.

References mDpi.

Referenced by QgsMapRenderer::outputDpi(), and QgsMapRenderer::render().

void QgsScaleCalculator::setMapUnits ( QGis::UnitType  mapUnits  ) 

Set the map units.

Parameters:
mapUnits Units of the data on the map. Must match a value from the

Definition at line 42 of file qgsscalecalculator.cpp.

References mMapUnits, and QgsDebugMsg.

Referenced by QgsComposerMap::scale(), and QgsMapRenderer::setMapUnits().

QGis::UnitType QgsScaleCalculator::mapUnits (  )  const

Returns current map units.

Definition at line 48 of file qgsscalecalculator.cpp.

References mMapUnits, and QgsDebugMsgLevel.

Referenced by QgsMapRenderer::mapUnits(), and QgsMapRenderer::render().

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

Calculate the scale.

Parameters:
mapExtent QgsRectangle containing the current map extent
canvasWidth Width of the map canvas in pixel (physical) units
Returns:
scale of current map view

Definition at line 54 of file qgsscalecalculator.cpp.

References calculateGeographicDistance(), QGis::DecimalDegrees, QGis::DegreesDecimalMinutes, QGis::DegreesMinutesSeconds, QGis::Feet, mDpi, QGis::Meters, mMapUnits, QgsDebugMsg, QgsRectangle::xMaximum(), and QgsRectangle::xMinimum().

Referenced by QgsComposerMap::scale(), and QgsMapRenderer::updateScale().

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:
mapExtent QgsRectangle containing the current map extent

Definition at line 101 of file qgsscalecalculator.cpp.

References QgsDebugMsg, QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().

Referenced by calculate().


Member Data Documentation

double QgsScaleCalculator::mDpi [private]

dpi member

Definition at line 87 of file qgsscalecalculator.h.

Referenced by calculate(), dpi(), and setDpi().

map unit member

Definition at line 90 of file qgsscalecalculator.h.

Referenced by calculate(), mapUnits(), and setMapUnits().


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

Generated on Sat Feb 4 19:17:51 2012 for Quantum GIS API Documentation by  doxygen 1.5.6