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
path: root/search
diff options
context:
space:
mode:
authortatiana-yan <tatiana.kondakova@gmail.com>2019-03-22 12:35:01 +0300
committermpimenov <mpimenov@users.noreply.github.com>2019-03-25 17:13:24 +0300
commitf0f5e2bf7925b7f34b15d4b3b8b6602efbd71680 (patch)
tree08efde469616a0240cdb6001a05c70bc1a0fb0af /search
parented850339be2de77569b5675bd818da9f077676ba (diff)
[search] Load villages from villages min drawable scale while getting search result locality.
Diffstat (limited to 'search')
-rw-r--r--search/locality_finder.cpp23
-rw-r--r--search/mwm_context.hpp11
2 files changed, 31 insertions, 3 deletions
diff --git a/search/locality_finder.cpp b/search/locality_finder.cpp
index c6c855f36a..4aefe7be4f 100644
--- a/search/locality_finder.cpp
+++ b/search/locality_finder.cpp
@@ -7,6 +7,7 @@
#include "indexer/data_source.hpp"
#include "indexer/feature_algo.hpp"
+#include "indexer/feature_visibility.hpp"
#include "indexer/ftypes_matcher.hpp"
#include "base/assert.hpp"
@@ -117,6 +118,25 @@ private:
LocalityFinder::Holder & m_holder;
unordered_set<uint32_t> & m_loadedIds;
};
+
+int GetVillagesScale()
+{
+ auto currentVillagesMinDrawableScale = 0;
+ ftypes::IsVillageChecker::Instance().ForEachType([&currentVillagesMinDrawableScale](uint32_t type)
+ {
+ feature::TypesHolder th;
+ th.Assign(type);
+ currentVillagesMinDrawableScale = max(currentVillagesMinDrawableScale, GetMinDrawableScaleClassifOnly(th));
+ });
+
+ // Needed for backward compatibility. |kCompatibilityVillagesMinDrawableScale| should be set to
+ // maximal value we have in mwms over all data versions.
+ int const kCompatibilityVillagesMinDrawableScale = 13;
+ ASSERT_LESS_OR_EQUAL(
+ currentVillagesMinDrawableScale, kCompatibilityVillagesMinDrawableScale,
+ ("Set kCompatibilityVillagesMinDrawableScale to", currentVillagesMinDrawableScale));
+ return max(currentVillagesMinDrawableScale, kCompatibilityVillagesMinDrawableScale);
+}
} // namespace
// LocalityItem ------------------------------------------------------------------------------------
@@ -263,8 +283,9 @@ void LocalityFinder::LoadVicinity(m2::PointD const & p, bool loadCities, bool lo
if (!handle.IsAlive())
return;
+ static int const scale = GetVillagesScale();
MwmContext ctx(move(handle));
- ctx.ForEachIndex(vrect,
+ ctx.ForEachIndex(vrect, scale,
LocalitiesLoader(ctx, m_boundariesTable, VillageFilter(ctx, m_villagesCache),
m_villages, m_loadedIds));
});
diff --git a/search/mwm_context.hpp b/search/mwm_context.hpp
index 5857342ccd..4d31746ca6 100644
--- a/search/mwm_context.hpp
+++ b/search/mwm_context.hpp
@@ -17,6 +17,7 @@
#include <cstdint>
#include <memory>
#include <string>
+#include <utility>
class MwmValue;
@@ -51,9 +52,15 @@ public:
void ForEachIndex(m2::RectD const & rect, Fn && fn) const
{
uint32_t const scale = m_value.GetHeader().GetLastScale();
+ ForEachIndex(rect, scale, std::forward<Fn>(fn));
+ }
+
+ template <typename Fn>
+ void ForEachIndex(m2::RectD const & rect, uint32_t scale, Fn && fn) const
+ {
covering::Intervals intervals;
- CoverRect(rect, scale, intervals);
- ForEachIndex(intervals, scale, forward<Fn>(fn));
+ CoverRect(rect, m_value.GetHeader().GetLastScale(), intervals);
+ ForEachIndex(intervals, scale, std::forward<Fn>(fn));
}
template <typename Fn>