25 : mDpi( dpi ), mMapUnits( mapUnits )
42 QgsDebugMsg( QString(
"Map units set to %1" ).arg( QString::number( mapUnits ) ) );
54 double conversionFactor = 0;
62 conversionFactor = 39.3700787;
66 conversionFactor = 12.0;
73 conversionFactor = 39.3700787;
77 if ( canvasWidth == 0 ||
mDpi == 0 )
79 QgsDebugMsg(
"Can't calculate scale from the input values" );
82 double scale = ( delta * conversionFactor ) / ((
double )canvasWidth /
mDpi );
83 QgsDebugMsg( QString(
"scale = %1 conversionFactor = %2" ).arg( scale ).arg( conversionFactor ) );
115 const static double rads = ( 4.0 * atan( 1.0 ) ) / 180.0;
116 double a = pow( cos( lat * rads ), 2 );
117 double c = 2.0 * atan2( sqrt( a ), sqrt( 1.0 - a ) );
118 const static double ra = 6378000;
121 const static double e = 0.0810820288;
122 double radius = ra * ( 1.0 - e * e ) /
123 pow( 1.0 - e * e * sin( lat * rads ) * sin( lat * rads ), 1.5 );
124 double meters = ( mapExtent.
xMaximum() - mapExtent.
xMinimum() ) / 180.0 * radius * c;
126 QgsDebugMsg(
"Distance across map extent (m): " + QString::number( meters ) );