26 , mMapUnits( mapUnits )
52 double conversionFactor = 0;
60 conversionFactor = 39.3700787;
64 conversionFactor = 12.0;
69 conversionFactor = 72913.4;
76 conversionFactor = 39.3700787;
82 QgsDebugMsg(
"Can't calculate scale from the input values" );
85 double scale = ( delta * conversionFactor ) / ( static_cast< double >( canvasWidth ) / mDpi );
86 QgsDebugMsg(
QString(
"scale = %1 conversionFactor = %2" ).arg( scale ).arg( conversionFactor ) );
118 const static double rads = ( 4.0 * atan( 1.0 ) ) / 180.0;
119 double a = pow( cos( lat * rads ), 2 );
120 double c = 2.0 * atan2( sqrt( a ), sqrt( 1.0 - a ) );
121 const static double ra = 6378000;
124 const static double e = 0.0810820288;
125 double radius = ra * ( 1.0 - e * e ) /
126 pow( 1.0 - e * e * sin( lat * rads ) * sin( lat * rads ), 1.5 );
127 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.
void setDpi(double dpi)
Set the dpi to be used in scale calculations.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
QString number(int n, int base)
double calculate(const QgsRectangle &mapExtent, int canvasWidth)
Calculate the scale denominator.
#define QgsDebugMsgLevel(str, level)
QGis::UnitType mapUnits() const
Returns current map units.
double dpi()
Accessor for dpi used in scale calculations.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
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)
double yMaximum() const
Get the y maximum value (top side of rectangle)