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:
-rw-r--r--indexer/feature_utils.cpp29
-rw-r--r--indexer/feature_utils.hpp2
-rw-r--r--indexer/search_index_builder.cpp12
-rw-r--r--search/intermediate_result.cpp16
4 files changed, 40 insertions, 19 deletions
diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp
index a72ec90090..9cbfc28550 100644
--- a/indexer/feature_utils.cpp
+++ b/indexer/feature_utils.cpp
@@ -83,7 +83,7 @@ public:
return scales::GetRectForLevel(scale, centerXY, 1.0);
}
- uint8_t GetSearchRank(TypesHolder const & types, uint32_t population) const
+ uint8_t GetSearchRank(TypesHolder const & types, m2::PointD const & pt, uint32_t population) const
{
for (size_t i = 0; i < types.Size(); ++i)
{
@@ -93,8 +93,27 @@ public:
population = max(population, static_cast<uint32_t>(1000));
else if (types[i] == m_TypeTown || IsEqual(types[i], m_TypeCounty))
population = max(population, static_cast<uint32_t>(10000));
- else if (types[i] == m_TypeCity || types[i] == m_TypeState)
- population = max(population, static_cast<uint32_t>(100000));
+ else if (types[i] == m_TypeState)
+ {
+ m2::RectD const usaRect(-125.73195962769162293, 25.168771674082393019,
+ -66.925073086214325713, 56.956377399113392812);
+ if (usaRect.IsPointInside(pt))
+ {
+ //LOG(LINFO, ("USA state population = ", population));
+ // Get rank equal to city for USA's states.
+ population = max(population, static_cast<uint32_t>(500000));
+ }
+ else
+ {
+ //LOG(LINFO, ("Other state population = ", population));
+ // Reduce rank for other states.
+ population = population / 10;
+ population = max(population, static_cast<uint32_t>(10000));
+ population = min(population, static_cast<uint32_t>(500000));
+ }
+ }
+ else if (types[i] == m_TypeCity)
+ population = max(population, static_cast<uint32_t>(500000));
else if (types[i] == m_TypeCityCapital)
population = max(population, static_cast<uint32_t>(1000000));
else if (types[i] == m_TypeCountry)
@@ -174,9 +193,9 @@ m2::RectD GetFeatureViewport(TypesHolder const & types, m2::RectD const & limitR
return impl::GetFeatureEstimator().GetViewport(types, limitRect);
}
-uint8_t GetSearchRank(TypesHolder const & types, uint32_t population)
+uint8_t GetSearchRank(TypesHolder const & types, m2::PointD const & pt, uint32_t population)
{
- return impl::GetFeatureEstimator().GetSearchRank(types, population);
+ return impl::GetFeatureEstimator().GetSearchRank(types, pt, population);
}
} // namespace feature
diff --git a/indexer/feature_utils.hpp b/indexer/feature_utils.hpp
index e380f25d8d..a4f07d27ef 100644
--- a/indexer/feature_utils.hpp
+++ b/indexer/feature_utils.hpp
@@ -14,5 +14,5 @@ namespace feature
/// Get search rank for a feature.
/// Roughly, rank + 1 means that feature is 1.x times more popular.
- uint8_t GetSearchRank(TypesHolder const & types, uint32_t population);
+ uint8_t GetSearchRank(TypesHolder const & types, m2::PointD const & pt, uint32_t population);
} // namespace feature
diff --git a/indexer/search_index_builder.cpp b/indexer/search_index_builder.cpp
index 3ece446110..2e40f3b9db 100644
--- a/indexer/search_index_builder.cpp
+++ b/indexer/search_index_builder.cpp
@@ -66,18 +66,18 @@ struct FeatureInserter
explicit FeatureInserter(StringsFile & names) : m_names(names) {}
- void operator() (FeatureType const & feature, uint64_t pos) const
+ void operator() (FeatureType const & f, uint64_t pos) const
{
- feature::TypesHolder types(feature);
+ feature::TypesHolder types(f);
// Add names of the feature.
- FeatureNameInserter f(m_names, static_cast<uint32_t>(pos),
- feature::GetSearchRank(types, feature.GetPopulation()));
- feature.ForEachNameRef(f);
+ uint8_t const rank = feature::GetSearchRank(types, f.GetLimitRect(-2).Center(), f.GetPopulation());
+ FeatureNameInserter toDo(m_names, static_cast<uint32_t>(pos), rank);
+ f.ForEachNameRef(toDo);
// Add names of categories of the feature.
for (size_t i = 0; i < types.Size(); ++i)
- f.AddToken(0, search::FeatureTypeToString(types[i]));
+ toDo.AddToken(0, search::FeatureTypeToString(types[i]));
}
};
diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp
index f055e1b713..f2ca140021 100644
--- a/search/intermediate_result.cpp
+++ b/search/intermediate_result.cpp
@@ -40,10 +40,11 @@ IntermediateResult::IntermediateResult(m2::RectD const & viewportRect, m2::Point
}
// get common params
- m_distance = ResultDistance(pos, m_rect.Center());
- m_direction = ResultDirection(pos, m_rect.Center());
- m_searchRank = feature::GetSearchRank(m_types, f.GetPopulation());
- m_viewportDistance = ViewportDistance(viewportRect, m_rect.Center());
+ m2::PointD const center = m_rect.Center();
+ m_distance = ResultDistance(pos, center);
+ m_direction = ResultDirection(pos, center);
+ m_searchRank = feature::GetSearchRank(m_types, center, f.GetPopulation());
+ m_viewportDistance = ViewportDistance(viewportRect, center);
}
IntermediateResult::IntermediateResult(m2::RectD const & viewportRect, m2::PointD const & pos,
@@ -54,9 +55,10 @@ IntermediateResult::IntermediateResult(m2::RectD const & viewportRect, m2::Point
m_resultType(RESULT_LATLON), m_searchRank(0)
{
// get common params
- m_distance = ResultDistance(pos, m_rect.Center());
- m_direction = ResultDirection(pos, m_rect.Center());
- m_viewportDistance = ViewportDistance(viewportRect, m_rect.Center());
+ m2::PointD const center = m_rect.Center();
+ m_distance = ResultDistance(pos, center);
+ m_direction = ResultDirection(pos, center);
+ m_viewportDistance = ViewportDistance(viewportRect, center);
// get region info
m_region.SetPoint(m2::PointD(MercatorBounds::LonToX(lon),