25 : mDpi( dpi ), mMapUnits( mapUnits )
42 QgsDebugMsg( QString(
"Map units set to %1" ).arg( QString::number( mapUnits ) ) );
48 QgsDebugMsgLevel( QString(
"Map units returned as %1" ).arg( QString::number( mMapUnits ) ), 4 );
54 double conversionFactor = 0;
62 conversionFactor = 39.3700787;
66 conversionFactor = 12.0;
71 conversionFactor = 72913.4;
78 conversionFactor = 39.3700787;
82 if ( canvasWidth == 0 || mDpi == 0 )
84 QgsDebugMsg(
"Can't calculate scale from the input values" );
87 double scale = ( delta * conversionFactor ) / ((
double )canvasWidth / mDpi );
88 QgsDebugMsg( QString(
"scale = %1 conversionFactor = %2" ).arg( scale ).arg( conversionFactor ) );
120 const static double rads = ( 4.0 * atan( 1.0 ) ) / 180.0;
121 double a = pow( cos( lat * rads ), 2 );
122 double c = 2.0 * atan2( sqrt( a ), sqrt( 1.0 - a ) );
123 const static double ra = 6378000;
126 const static double e = 0.0810820288;
127 double radius = ra * ( 1.0 - e * e ) /
128 pow( 1.0 - e * e * sin( lat * rads ) * sin( lat * rads ), 1.5 );
129 double meters = ( mapExtent.
xMaximum() - mapExtent.
xMinimum() ) / 180.0 * radius * c;
131 QgsDebugMsg(
"Distance across map extent (m): " + QString::number( meters ) );