Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarafei Praliaskouski <komzpa@gmail.com>2013-09-13 18:39:47 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:01:21 +0300
commit88875a9de921779205282032d29977a56edd08e9 (patch)
treef0682128d944dd7cd1d0ebb4a1485b899f5be302
parent9aa89881417ba4e6c1c76e203bf6a0e08b8918f4 (diff)
[scales] correct zoom calculation for non-tiled policies
-rw-r--r--indexer/feature_utils.cpp4
-rw-r--r--indexer/indexer_tests/scales_test.cpp6
-rw-r--r--indexer/scales.cpp31
-rw-r--r--indexer/scales.hpp4
-rw-r--r--map/feature_styler.cpp10
-rw-r--r--map/feature_styler.hpp1
-rw-r--r--map/framework.cpp5
-rw-r--r--map/render_policy.hpp1
-rw-r--r--map/scales_processor.cpp6
-rw-r--r--map/scales_processor.hpp2
-rw-r--r--map/simple_render_policy.cpp3
-rw-r--r--search/intermediate_result.cpp2
-rw-r--r--search/search_query.cpp2
13 files changed, 33 insertions, 44 deletions
diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp
index 5e708a9820..8a845cec6d 100644
--- a/indexer/feature_utils.cpp
+++ b/indexer/feature_utils.cpp
@@ -72,7 +72,7 @@ public:
int scaleNew = scale;
CorrectScaleForVisibility(types, scaleNew);
- return ((scale != scaleNew) ? scales::GetRectForLevel(scaleNew, rect.Center(), 1.0) : rect);
+ return ((scale != scaleNew) ? scales::GetRectForLevel(scaleNew, rect.Center()) : rect);
}
m2::RectD GetViewport(TypesHolder const & types, m2::RectD const & limitRect) const
@@ -86,7 +86,7 @@ public:
scale = min(scale, GetScaleForType(types[i]));
CorrectScaleForVisibility(types, scale);
- return scales::GetRectForLevel(scale, limitRect.Center(), 1.0);
+ return scales::GetRectForLevel(scale, limitRect.Center());
}
uint8_t GetSearchRank(TypesHolder const & types, m2::PointD const & pt, uint32_t population) const
diff --git a/indexer/indexer_tests/scales_test.cpp b/indexer/indexer_tests/scales_test.cpp
index f070730973..b9bb5319dd 100644
--- a/indexer/indexer_tests/scales_test.cpp
+++ b/indexer/indexer_tests/scales_test.cpp
@@ -6,14 +6,14 @@ using namespace scales;
UNIT_TEST(ScaleLevel_Smoke)
{
- for (int level = 1; level < GetUpperScale(); ++level)
+ for (int level = 0; level < GetUpperScale(); ++level)
{
double const d = GetRationForLevel(level);
int test = GetScaleLevel(d);
TEST_EQUAL(level, test, ());
- m2::RectD const r = GetRectForLevel(level, m2::PointD(0.0, 0.0), 2.0);
+ m2::RectD const r = GetRectForLevel(level, m2::PointD(0.0, 0.0));
test = GetScaleLevel(r);
TEST_EQUAL(level, test, ());
}
-} \ No newline at end of file
+}
diff --git a/indexer/scales.cpp b/indexer/scales.cpp
index ea483a94df..aa760442ca 100644
--- a/indexer/scales.cpp
+++ b/indexer/scales.cpp
@@ -8,25 +8,10 @@
namespace scales
{
- /// @name This parameters should be tuned.
- //@{
- static const int INITIAL_LEVEL = 1;
-
- double GetM2PFactor(int level)
- {
- int const base_scale = 14;
- int const factor = 1 << my::Abs(level - base_scale);
-
- if (level < base_scale)
- return 1 / double(factor);
- else
- return factor;
- }
- //@}
double GetScaleLevelD(double ratio)
{
- double const level = min(static_cast<double>(GetUpperScale()), log(ratio) / log(2.0) + INITIAL_LEVEL);
+ double const level = min(static_cast<double>(GetUpperScale()), log(ratio) / log(2.0));
return (level < 0.0 ? 0.0 : level);
}
@@ -52,20 +37,18 @@ namespace scales
double GetRationForLevel(double level)
{
- if (level < INITIAL_LEVEL)
- level = INITIAL_LEVEL;
- return pow(2.0, level - INITIAL_LEVEL);
+ return max(0.0, pow(2.0, level));
}
- m2::RectD GetRectForLevel(double level, m2::PointD const & center, double X2YRatio)
+ m2::RectD GetRectForLevel(double level, m2::PointD const & center)
{
- double const dy = 2.0 * GetRationForLevel(level) / (1.0 + X2YRatio);
- double const dx = X2YRatio * dy;
+ double const dy = GetRationForLevel(level);
+ double const dx = dy;
ASSERT_GREATER ( dy, 0.0, () );
ASSERT_GREATER ( dx, 0.0, () );
- double const xL = (MercatorBounds::maxX - MercatorBounds::minX) / (2.0*dx);
- double const yL = (MercatorBounds::maxY - MercatorBounds::minY) / (2.0*dy);
+ double const xL = (MercatorBounds::maxX - MercatorBounds::minX) / (2.0 * dx);
+ double const yL = (MercatorBounds::maxY - MercatorBounds::minY) / (2.0 * dy);
ASSERT_GREATER ( xL, 0.0, () );
ASSERT_GREATER ( yL, 0.0, () );
diff --git a/indexer/scales.hpp b/indexer/scales.hpp
index 88d2182f92..6b6e656836 100644
--- a/indexer/scales.hpp
+++ b/indexer/scales.hpp
@@ -17,8 +17,6 @@ namespace scales
/// Upper scale for user comfort view (e.g. location zoom).
inline int GetUpperComfortScale() { return UPPER_STYLE_SCALE - 2; }
- double GetM2PFactor(int level);
-
double GetScaleLevelD(double ratio);
double GetScaleLevelD(m2::RectD const & r);
int GetScaleLevel(double ratio);
@@ -28,7 +26,7 @@ namespace scales
double GetRationForLevel(double level);
/// @return such rect, that GetScaleLevel(rect) == level
- m2::RectD GetRectForLevel(double level, m2::PointD const & center, double X2YRatio);
+ m2::RectD GetRectForLevel(double level, m2::PointD const & center);
double GetEpsilonForLevel(int level);
double GetEpsilonForSimplify(int level);
diff --git a/map/feature_styler.cpp b/map/feature_styler.cpp
index 317f8797a3..5a6f52c0cc 100644
--- a/map/feature_styler.cpp
+++ b/map/feature_styler.cpp
@@ -114,7 +114,7 @@ namespace di
double priorityModifier;
if (area != 0)
- priorityModifier = min(1., area*10000.); // making area larger so it's not lost on double conversions
+ priorityModifier = min(1., area * 10000.); // making area larger so it's not lost on double conversions
else
priorityModifier = static_cast<double>(population) / 7E9; // dividing by planet population to get priorityModifier < 1
@@ -173,6 +173,9 @@ namespace di
m_rules[i] = di::DrawRule(drule::rules().Find(keys[i]), depth, isTransparent);
+ if (m_rules[i].m_rule->GetCaption(1) != 0)
+ m_hasSecondaryText = true;
+
if ((m_geometryType == feature::GEOM_LINE) && !m_hasPathText && !m_primaryText.empty())
if (m_rules[i].m_rule->GetCaption(0) != 0)
{
@@ -187,6 +190,11 @@ namespace di
hasCaptionWithoutOffset = !(m_rules[i].m_rule->GetCaption(0)->has_offset_y() || m_rules[i].m_rule->GetCaption(0)->has_offset_x());
}
+ if (!m_hasSecondaryText && !m_secondaryText.empty())
+ {
+ m_primaryText.swap(m_secondaryText);
+ }
+
// placing a text on the path
if (m_hasPathText && (m_fontSize != 0))
{
diff --git a/map/feature_styler.hpp b/map/feature_styler.hpp
index 2a544d2023..5de29ee549 100644
--- a/map/feature_styler.hpp
+++ b/map/feature_styler.hpp
@@ -52,6 +52,7 @@ namespace di
bool m_hasLineStyles;
bool m_hasPointStyles;
bool m_hasPathText;
+ bool m_hasSecondaryText;
int m_geometryType;
double m_visualScale;
diff --git a/map/framework.cpp b/map/framework.cpp
index 69cccb7bcf..413b9f32e1 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -676,9 +676,6 @@ void Framework::OnSize(int w, int h)
if (m_renderPolicy)
{
- /// @todo Need to review this logic:
- /// Tile size doesn't change in render policy now, but it depends from screen sizes.
-
m_informationDisplay.setDisplayRect(m2::RectI(0, 0, w, h));
m_renderPolicy->OnSize(w, h);
@@ -687,7 +684,7 @@ void Framework::OnSize(int w, int h)
m_balloonManager.ScreenSizeChanged(w, h);
- m_scales.SetParams(w, h, m_renderPolicy->VisualScale());
+ m_scales.SetParams(m_renderPolicy->VisualScale(), m_renderPolicy->TileSize());
}
m_width = w;
diff --git a/map/render_policy.hpp b/map/render_policy.hpp
index 1872cb2cd6..84ca397911 100644
--- a/map/render_policy.hpp
+++ b/map/render_policy.hpp
@@ -143,6 +143,7 @@ public:
graphics::GlyphCache * GetGlyphCache() const;
double VisualScale() const;
+ size_t TileSize() const { return 256; };
graphics::EDensity Density() const;
string const & SkinName() const;
diff --git a/map/scales_processor.cpp b/map/scales_processor.cpp
index 5862db6dbe..e8ba7d1df8 100644
--- a/map/scales_processor.cpp
+++ b/map/scales_processor.cpp
@@ -7,7 +7,7 @@
ScalesProcessor::ScalesProcessor()
- : m_tileSize(512), m_visualScale(1.0)
+ : m_tileSize(256), m_visualScale(1.0)
{
}
@@ -16,9 +16,9 @@ ScalesProcessor::ScalesProcessor(int tileSize)
{
}
-void ScalesProcessor::SetParams(int width, int height, double visualScale)
+void ScalesProcessor::SetParams(double visualScale, int tileSize)
{
- m_tileSize = CalculateTileSize(width, height);
+ m_tileSize = tileSize;
m_visualScale = visualScale;
}
diff --git a/map/scales_processor.hpp b/map/scales_processor.hpp
index d7dda57db4..f4e0a52abe 100644
--- a/map/scales_processor.hpp
+++ b/map/scales_processor.hpp
@@ -13,7 +13,7 @@ public:
ScalesProcessor();
explicit ScalesProcessor(int tileSize);
- void SetParams(int width, int height, double visualScale);
+ void SetParams(double visualScale, int tileSize);
m2::RectD const & GetWorldRect() const;
inline int GetTileSize() const { return m_tileSize; }
diff --git a/map/simple_render_policy.cpp b/map/simple_render_policy.cpp
index df2240ed8b..b3bd869359 100644
--- a/map/simple_render_policy.cpp
+++ b/map/simple_render_policy.cpp
@@ -59,10 +59,11 @@ SimpleRenderPolicy::SimpleRenderPolicy(Params const & p)
void SimpleRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e,
ScreenBase const & s)
{
- size_t const scaleEtalonSize = 512;
+ size_t const scaleEtalonSize = 256;
m2::RectD glbRect;
m2::PointD const pxCenter = s.PixelRect().Center();
+
s.PtoG(m2::RectD(pxCenter - m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2),
pxCenter + m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2)),
glbRect);
diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp
index 4d032e05cb..ac71ae3a3b 100644
--- a/search/intermediate_result.cpp
+++ b/search/intermediate_result.cpp
@@ -254,7 +254,7 @@ Result PreResult2::GenerateFinalResult(
case RESULT_LATLON:
return Result(m_str, info.m_name, info.m_flag, string(), 0,
- scales::GetRectForLevel(scales::GetUpperScale(), m_center, 1.0), m_distance);
+ scales::GetRectForLevel(scales::GetUpperScale(), m_center), m_distance);
default:
ASSERT_EQUAL ( m_resultType, RESULT_CATEGORY, () );
diff --git a/search/search_query.cpp b/search/search_query.cpp
index f2dbac500c..0dcd3ea53e 100644
--- a/search/search_query.cpp
+++ b/search/search_query.cpp
@@ -1211,7 +1211,7 @@ void Query::SearchAddress()
{
params.ProcessAddressTokens();
- SetViewportByIndex(mwmInfo, scales::GetRectForLevel(ADDRESS_SCALE, city.m_value.m_pt, 1.0), ADDRESS_RECT_ID);
+ SetViewportByIndex(mwmInfo, scales::GetRectForLevel(ADDRESS_SCALE, city.m_value.m_pt), ADDRESS_RECT_ID);
/// @todo Hack - do not search for address in World.mwm; Do it better in future.
bool const b = m_worldSearch;