forked from organicmaps/organicmaps
[drape] Fix the ruler to display scales less than 10m on z20
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
parent
c334c5d2a0
commit
e6aa10e5a3
1 changed files with 7 additions and 3 deletions
|
@ -20,7 +20,7 @@ namespace gui
|
|||
namespace
|
||||
{
|
||||
int constexpr kMinPixelWidth = 60;
|
||||
int constexpr kMinMetersWidth = 10;
|
||||
int constexpr kMinMetersWidth = 5;
|
||||
int constexpr kMaxMetersWidth = 1000000;
|
||||
|
||||
int constexpr kMinUnitValue = -1;
|
||||
|
@ -72,6 +72,9 @@ UnitValue g_arrYards[] = {
|
|||
{ "500 mi", 500 * 1760 }
|
||||
};
|
||||
|
||||
// TODO: fix ruler text to the current zoom level, i.e. make it 100m for z16 always
|
||||
// (ruler length will vary still). It'll make debugging and user support easier as
|
||||
// we'll be able to tell zoom level of a screenshot by looking at the ruler.
|
||||
UnitValue g_arrMeters[] = {
|
||||
{ "1 m", 1 },
|
||||
{ "2 m", 2 },
|
||||
|
@ -120,12 +123,12 @@ void RulerHelper::Update(ScreenBase const & screen)
|
|||
double metersDiff = CalcMetersDiff(distanceInMeters);
|
||||
|
||||
bool const higherThanMax = metersDiff > kMaxMetersWidth;
|
||||
bool const lessThanMin = metersDiff < kMinMetersWidth;
|
||||
ASSERT_GREATER_OR_EQUAL(metersDiff, kMinMetersWidth, ());
|
||||
m_pixelLength = static_cast<float>(minPxWidth);
|
||||
|
||||
if (higherThanMax)
|
||||
m_pixelLength = static_cast<float>(minPxWidth) * 3.0f / 2.0f;
|
||||
else if (!lessThanMin)
|
||||
else
|
||||
{
|
||||
double const a = ang::AngleTo(pt1, pt0);
|
||||
pt0 = mercator::GetSmPoint(pt1, cos(a) * metersDiff, sin(a) * metersDiff);
|
||||
|
@ -238,6 +241,7 @@ double RulerHelper::CalcMetersDiff(double value)
|
|||
if (arrU[0].m_i > v)
|
||||
{
|
||||
m_rangeIndex = kMinUnitValue;
|
||||
// TODO: "< X" ruler text seems to be never used.
|
||||
m_rulerText = std::string("< ") + arrU[0].m_s;
|
||||
result = kMinMetersWidth - 1.0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue