QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
26 , mMapUnits( mapUnits )
46 QgsDebugMsgLevel( QStringLiteral(
"Map units returned as %1" ).arg( QString::number( mMapUnits ) ), 4 );
52 double conversionFactor = 0;
60 conversionFactor = 39.3700787;
64 conversionFactor = 12.0;
69 conversionFactor = 72913.4;
76 conversionFactor = 39.3700787;
82 QgsDebugMsg( QStringLiteral(
"Can't calculate scale from the input values" ) );
85 double scale = ( delta * conversionFactor ) / (
static_cast< double >( canvasWidth ) / mDpi );
86 QgsDebugMsgLevel( QStringLiteral(
"scale = %1 conversionFactor = %2" ).arg( scale ).arg( conversionFactor ), 4 );
118 static const double RADS = ( 4.0 * std::atan( 1.0 ) ) / 180.0;
119 double a = std::pow( std::cos( lat * RADS ), 2 );
120 double c = 2.0 * std::atan2( std::sqrt( a ), std::sqrt( 1.0 - a ) );
121 static const double RA = 6378000;
124 static const double E = 0.0810820288;
125 double radius = RA * ( 1.0 - E * E ) /
126 std::pow( 1.0 - E * E * std::sin( lat * RADS ) * std::sin( lat * RADS ), 1.5 );
127 double meters = ( mapExtent.
xMaximum() - mapExtent.
xMinimum() ) / 180.0 * radius *
c;
129 QgsDebugMsgLevel(
"Distance across map extent (m): " + QString::number( meters ), 4 );
void setMapUnits(QgsUnitTypes::DistanceUnit mapUnits)
Set the map units.
void setDpi(double dpi)
Sets the dpi (dots per inch) for the output resolution, to be used in scale calculations.
#define QgsDebugMsgLevel(str, level)
double calculate(const QgsRectangle &mapExtent, double canvasWidth) const
Calculate the scale denominator.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
double dpi()
Returns the DPI (dots per inch) used in scale calculations.
QgsUnitTypes::DistanceUnit mapUnits() const
Returns current map units.
DistanceUnit
Units of distance.
double calculateGeographicDistance(const QgsRectangle &mapExtent) const
Calculate the distance between two points in geographic coordinates.
@ DistanceDegrees
Degrees, for planar geographic CRS distance measurements.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
@ DistanceFeet
Imperial feet.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
@ DistanceNauticalMiles
Nautical miles.
QgsScaleCalculator(double dpi=0, QgsUnitTypes::DistanceUnit mapUnits=QgsUnitTypes::DistanceMeters)
Constructor.
double xMinimum() const
Returns the x minimum value (left side of rectangle).