diff options
author | vng <viktor.govako@gmail.com> | 2012-04-19 16:21:46 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:37:39 +0300 |
commit | 32f645d73204c31b71edcc4938fe5921cc09eedf (patch) | |
tree | 7de646226bef21db849b9598fec9501a48fa122f | |
parent | 0632edae1a22b032251b363d90007c61dbf4b1b3 (diff) |
Rename some functions according to coding style.
-rw-r--r-- | generator/feature_builder.cpp | 4 | ||||
-rw-r--r-- | generator/feature_sorter.cpp | 2 | ||||
-rw-r--r-- | indexer/feature_utils.cpp | 2 | ||||
-rw-r--r-- | indexer/feature_visibility.cpp | 44 | ||||
-rw-r--r-- | indexer/feature_visibility.hpp | 13 | ||||
-rw-r--r-- | indexer/scale_index_builder.hpp | 2 | ||||
-rw-r--r-- | indexer/search_index_builder.cpp | 2 | ||||
-rw-r--r-- | map/address_finder.cpp | 14 |
8 files changed, 54 insertions, 29 deletions
diff --git a/generator/feature_builder.cpp b/generator/feature_builder.cpp index b05f0f26fc..94b5c7e43e 100644 --- a/generator/feature_builder.cpp +++ b/generator/feature_builder.cpp @@ -188,7 +188,7 @@ bool FeatureBuilder1::PreSerialize() // Clear name for features with invisible texts. int64_t dummy; if (!m_Params.name.IsEmpty() && !GetCoastCell(dummy) && - (feature::DrawableScaleRangeForText(GetFeatureBase()).first == -1)) + (feature::GetDrawableScaleRangeForText(GetFeatureBase()).first == -1)) { m_Params.name.Clear(); } @@ -331,7 +331,7 @@ void FeatureBuilder1::AddOsmId(string const & type, uint64_t osmId) int FeatureBuilder1::GetMinFeatureDrawScale() const { - int const minScale = feature::MinDrawableScaleForFeature(GetFeatureBase()); + int const minScale = feature::GetMinDrawableScale(GetFeatureBase()); // some features become invisible after merge processing, so -1 is possible return (minScale == -1 ? 1000 : minScale); diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp index 09a75f3e90..2ded66e3eb 100644 --- a/generator/feature_sorter.cpp +++ b/generator/feature_sorter.cpp @@ -51,7 +51,7 @@ namespace m_midLoc = m_midLoc / m_locCount; uint64_t const pointAsInt64 = PointToInt64(m_midLoc.x, m_midLoc.y, m_coordBits); - uint64_t const minScale = feature::MinDrawableScaleForFeature(ft.GetFeatureBase()); + uint64_t const minScale = feature::GetMinDrawableScale(ft.GetFeatureBase()); CHECK(minScale <= scales::GetUpperScale(), ("Dat file contain invisible feature")); uint64_t const order = (minScale << 59) | (pointAsInt64 >> 5); diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index 9206c050bd..a1220968b3 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -53,7 +53,7 @@ public: void CorrectScaleForVisibility(TypesHolder const & types, int & scale) const { - pair<int, int> const scaleR = feature::DrawableScaleRangeForText(types); + pair<int, int> const scaleR = feature::GetDrawableScaleRangeForText(types); ASSERT_LESS_OR_EQUAL ( scaleR.first, scaleR.second, () ); // Result types can be without visible texts (matched by category). diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp index d75681444d..e451fcce27 100644 --- a/indexer/feature_visibility.cpp +++ b/indexer/feature_visibility.cpp @@ -254,7 +254,7 @@ bool IsDrawableForIndex(FeatureBase const & f, int level) return false; } -int MinDrawableScaleForFeature(FeatureBase const & f) +int GetMinDrawableScale(FeatureBase const & f) { int const upBound = scales::GetUpperScale(); @@ -267,6 +267,21 @@ int MinDrawableScaleForFeature(FeatureBase const & f) namespace { + void AddRange(pair<int, int> & dest, pair<int, int> const & src) + { + if (src.first != -1) + { + ASSERT_GREATER(src.first, -1, ()); + ASSERT_GREATER(src.second, -1, ()); + + dest.first = min(dest.first, src.first); + dest.second = max(dest.second, src.second); + + ASSERT_GREATER(dest.first, -1, ()); + ASSERT_GREATER(dest.second, -1, ()); + } + } + class DoGetScalesRange { pair<int, int> m_scales; @@ -278,14 +293,7 @@ namespace bool operator() (ClassifObject const * p, bool & res) { res = true; - - pair<int, int> scales = p->GetDrawScaleRange(); - if (scales.first != -1) - { - m_scales.first = min(m_scales.first, scales.first); - m_scales.second = max(m_scales.second, scales.second); - } - + AddRange(m_scales, p->GetDrawScaleRange()); return false; } @@ -296,13 +304,23 @@ namespace }; } -pair<int, int> DrawableScaleRangeForType(uint32_t type) +pair<int, int> GetDrawableScaleRange(uint32_t type) { DoGetScalesRange doGet; (void)classif().ProcessObjects(type, doGet); return doGet.GetScale(); } +pair<int, int> GetDrawableScaleRange(TypesHolder const & types) +{ + pair<int, int> res(1000, -1000); + + for (size_t i = 0; i < types.Size(); ++i) + AddRange(res, GetDrawableScaleRange(types[i])); + + return (res.first > res.second ? make_pair(-1, -1) : res); +} + namespace { bool IsDrawable(feature::TypesHolder const & types, int level) @@ -318,7 +336,7 @@ namespace } } -pair<int, int> DrawableScaleRangeForText(feature::TypesHolder const & types) +pair<int, int> GetDrawableScaleRangeForText(feature::TypesHolder const & types) { int const upBound = scales::GetUpperScale(); int lowL = -1; @@ -347,9 +365,9 @@ pair<int, int> DrawableScaleRangeForText(feature::TypesHolder const & types) return make_pair(lowL, highL); } -pair<int, int> DrawableScaleRangeForText(FeatureBase const & f) +pair<int, int> GetDrawableScaleRangeForText(FeatureBase const & f) { - return DrawableScaleRangeForText(TypesHolder(f)); + return GetDrawableScaleRangeForText(TypesHolder(f)); } bool IsHighway(vector<uint32_t> const & types) diff --git a/indexer/feature_visibility.hpp b/indexer/feature_visibility.hpp index 77be9cd9b3..89344bd582 100644 --- a/indexer/feature_visibility.hpp +++ b/indexer/feature_visibility.hpp @@ -26,14 +26,17 @@ namespace feature bool IsDrawableLike(vector<uint32_t> const & type, FeatureGeoType ft); bool IsDrawableForIndex(FeatureBase const & f, int level); - int MinDrawableScaleForFeature(FeatureBase const & f); - pair<int, int> DrawableScaleRangeForType(uint32_t type); + int GetMinDrawableScale(FeatureBase const & f); - /// @name Get scale range when feature's text is visible. /// @return [-1, -1] if no any text exists //@{ - pair<int, int> DrawableScaleRangeForText(TypesHolder const & types); - pair<int, int> DrawableScaleRangeForText(FeatureBase const & f); + /// @name Get scale range when feature is visible. + pair<int, int> GetDrawableScaleRange(uint32_t type); + pair<int, int> GetDrawableScaleRange(TypesHolder const & types); + + /// @name Get scale range when feature's text is visible. + pair<int, int> GetDrawableScaleRangeForText(TypesHolder const & types); + pair<int, int> GetDrawableScaleRangeForText(FeatureBase const & f); //@} /// @return (geometry type, is coastline) diff --git a/indexer/scale_index_builder.hpp b/indexer/scale_index_builder.hpp index 96d7d63e96..ef0911956c 100644 --- a/indexer/scale_index_builder.hpp +++ b/indexer/scale_index_builder.hpp @@ -88,7 +88,7 @@ public: if (f.IsEmptyGeometry(GetGeometryScale())) return false; - uint32_t const minScale = feature::MinDrawableScaleForFeature(f); + uint32_t const minScale = feature::GetMinDrawableScale(f); return (m_ScaleRange.first <= minScale && minScale < m_ScaleRange.second); } diff --git a/indexer/search_index_builder.cpp b/indexer/search_index_builder.cpp index 9ceb7ce923..aebaedb43c 100644 --- a/indexer/search_index_builder.cpp +++ b/indexer/search_index_builder.cpp @@ -306,7 +306,7 @@ public: continue; // Do index only for visible types in mwm. - pair<int, int> const r = feature::DrawableScaleRangeForType(type); + pair<int, int> const r = feature::GetDrawableScaleRange(type); if (my::between_s(m_scales.first, m_scales.second, r.first) || my::between_s(m_scales.first, m_scales.second, r.second)) { diff --git a/map/address_finder.cpp b/map/address_finder.cpp index 94f409cf52..1f985f2db2 100644 --- a/map/address_finder.cpp +++ b/map/address_finder.cpp @@ -1,6 +1,7 @@ #include "framework.hpp" #include "../indexer/classificator.hpp" +#include "../indexer/feature_visibility.hpp" namespace @@ -42,7 +43,11 @@ namespace { protected: virtual double GetResultDistance(double d, feature::TypesHolder const & types) const = 0; - virtual double NeedProcess(feature::TypesHolder const & types) const = 0; + virtual double NeedProcess(feature::TypesHolder const & types) const + { + pair<int, int> const r = feature::GetDrawableScaleRange(types); + return my::between_s(r.first, r.second, m_scale); + } static double GetCompareEpsilonImpl(feature::EGeomType type, double eps) { @@ -109,10 +114,6 @@ namespace { return (d + GetCompareEpsilonImpl(types.GetGeoType(), m_eps)); } - virtual double NeedProcess(feature::TypesHolder const &) const - { - return true; - } public: DoGetFeatureTypes(m2::PointD const & pt, double eps, int scale) @@ -271,6 +272,9 @@ namespace } virtual double NeedProcess(feature::TypesHolder const & types) const { + if (!DoGetFeatureInfoBase::NeedProcess(types)) + return false; + return (!m_doLocalities || (types.GetGeoType() == feature::GEOM_POINT && m_checker.IsLocality(types))); } |