25 : mDpi( dpi ), mMapUnits( mapUnits )
51 double conversionFactor = 0;
59 conversionFactor = 39.3700787;
63 conversionFactor = 12.0;
68 conversionFactor = 72913.4;
75 conversionFactor = 39.3700787;
81 QgsDebugMsg(
"Can't calculate scale from the input values" );
84 double scale = ( delta * conversionFactor ) / ( static_cast< double >( canvasWidth ) / mDpi );
85 QgsDebugMsg(
QString(
"scale = %1 conversionFactor = %2" ).arg( scale ).arg( conversionFactor ) );
117 const static double rads = ( 4.0 * atan( 1.0 ) ) / 180.0;
118 double a = pow( cos( lat * rads ), 2 );
119 double c = 2.0 * atan2( sqrt( a ), sqrt( 1.0 - a ) );
120 const static double ra = 6378000;
123 const static double e = 0.0810820288;
124 double radius = ra * ( 1.0 - e * e ) /
125 pow( 1.0 - e * e * sin( lat * rads ) * sin( lat * rads ), 1.5 );
126 double meters = ( mapExtent.
xMaximum() - mapExtent.
xMinimum() ) / 180.0 * radius * c;
void setMapUnits(QGis::UnitType mapUnits)
Set the map units.
double calculateGeographicDistance(const QgsRectangle &mapExtent)
Calculate the distance between two points in geographic coordinates.
A rectangle specified with double values.
double yMaximum() const
Get the y maximum value (top side of rectangle)
void setDpi(double dpi)
Set the dpi to be used in scale calculations.
QGis::UnitType mapUnits() const
Returns current map units.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
QString number(int n, int base)
double calculate(const QgsRectangle &mapExtent, int canvasWidth)
Calculate the scale denominator.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
#define QgsDebugMsgLevel(str, level)
double dpi()
Accessor for dpi used in scale calculations.
QgsScaleCalculator(double dpi=0, QGis::UnitType mapUnits=QGis::Meters)
Constructor.
UnitType
Map units that qgis supports.
double xMinimum() const
Get the x minimum value (left side of rectangle)