[Marble-commits] KDE/kdeedu/marble/src/plugins/render/mapscale
Torsten Rahn
tackat at kde.org
Fri Jan 8 01:08:29 CET 2010
SVN commit 1071424 by rahn:
- More accurate approximation of the scalebar length for flat maps.
It takes the latitude in the map's center into account.
M +13 -1 MapScaleFloatItem.cpp
--- trunk/KDE/kdeedu/marble/src/plugins/render/mapscale/MapScaleFloatItem.cpp #1071423:1071424
@@ -15,6 +15,7 @@
#include "MarbleDebug.h"
#include "global.h"
+#include "Projections/AbstractProjection.h"
#include "MarbleLocale.h"
#include "MarbleDataFacade.h"
#include "GeoPainter.h"
@@ -125,8 +126,19 @@
int fontHeight = QFontMetrics( font() ).ascent();
- m_scaleBarDistance = (qreal)(m_scaleBarWidth) * dataFacade()->planetRadius() /
+ qreal pixel2Length = dataFacade()->planetRadius() /
(qreal)(viewport->radius());
+
+ if ( viewport->currentProjection()->surfaceType() == AbstractProjection::Cylindrical )
+ {
+ qreal centerLatitude = viewport->viewLatLonAltBox().center().latitude();
+ // For flat maps we calculate the length of the 90 deg section of the
+ // central latitude circle. For flat maps this distance matches
+ // the pixel based radius propertyy.
+ pixel2Length *= M_PI / 2 * cos( centerLatitude );
+ }
+
+ m_scaleBarDistance = (qreal)(m_scaleBarWidth) * pixel2Length;
Marble::DistanceUnit distanceUnit;
distanceUnit = MarbleGlobal::getInstance()->locale()->distanceUnit();
More information about the Marble-commits
mailing list