diff --git a/generator/osm_translator.hpp b/generator/osm_translator.hpp index 78dd6af16f..24cf203362 100644 --- a/generator/osm_translator.hpp +++ b/generator/osm_translator.hpp @@ -1,24 +1,26 @@ #pragma once +#include "generator/feature_builder.hpp" #include "generator/osm2type.hpp" #include "generator/osm_element.hpp" -#include "generator/feature_builder.hpp" #include "generator/ways_merger.hpp" -#include "indexer/ftypes_matcher.hpp" -#include "indexer/feature_visibility.hpp" #include "indexer/classificator.hpp" +#include "indexer/feature_visibility.hpp" +#include "indexer/ftypes_matcher.hpp" #include "geometry/tree4d.hpp" -#include "base/string_utils.hpp" +#include "coding/file_writer.hpp" + +#include "base/cache.hpp" #include "base/logging.hpp" #include "base/stl_add.hpp" -#include "base/cache.hpp" +#include "base/string_utils.hpp" -#include "std/unordered_set.hpp" #include "std/list.hpp" #include "std/type_traits.hpp" +#include "std/unordered_set.hpp" namespace { @@ -27,8 +29,7 @@ class Place FeatureBuilder1 m_ft; m2::PointD m_pt; uint32_t m_type; - - static constexpr double EQUAL_PLACE_SEARCH_RADIUS_M = 20000.0; + double m_thresholdM; bool IsPoint() const { return (m_ft.GetGeomType() == feature::GEOM_POINT); } static bool IsEqualTypes(uint32_t t1, uint32_t t2) @@ -41,13 +42,26 @@ class Place } public: - Place(FeatureBuilder1 const & ft, uint32_t type) : m_ft(ft), m_pt(ft.GetKeyPoint()), m_type(type) {} + Place(FeatureBuilder1 const & ft, uint32_t type) : m_ft(ft), m_pt(ft.GetKeyPoint()), m_type(type) + { + using namespace ftypes; + + switch (IsLocalityChecker::Instance().GetType(m_type)) + { + case COUNTRY: m_thresholdM = 300000.0; break; + case STATE: m_thresholdM = 100000.0; break; + case CITY: m_thresholdM = 30000.0; break; + case TOWN: m_thresholdM = 20000.0; break; + case VILLAGE: m_thresholdM = 10000.0; break; + default: m_thresholdM = 10000.0; break; + } + } FeatureBuilder1 const & GetFeature() const { return m_ft; } m2::RectD GetLimitRect() const { - return MercatorBounds::RectByCenterXYAndSizeInMeters(m_pt, EQUAL_PLACE_SEARCH_RADIUS_M); + return MercatorBounds::RectByCenterXYAndSizeInMeters(m_pt, m_thresholdM); } bool IsEqual(Place const & r) const @@ -55,7 +69,7 @@ public: return (IsEqualTypes(m_type, r.m_type) && m_ft.GetName() == r.m_ft.GetName() && (IsPoint() || r.IsPoint()) && - MercatorBounds::DistanceOnEarth(m_pt, r.m_pt) < EQUAL_PLACE_SEARCH_RADIUS_M); + MercatorBounds::DistanceOnEarth(m_pt, r.m_pt) < m_thresholdM); } /// Check whether we need to replace place @r with place @this. @@ -75,6 +89,8 @@ public: return (l2 < l1); // Assume that area places has better priority than point places at the very end ... + /// @todo It was usefull when place=XXX type has any area fill style. + /// Need to review priority logic here (leave the native osm label). return !IsPoint(); } }; diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 798a168fca..898327a180 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -290,26 +290,34 @@ bool IsTunnelChecker::IsMatched(uint32_t type) const return IsTypeConformed(type, {"highway", "*", "tunnel"}); } -Type IsLocalityChecker::GetType(feature::TypesHolder const & types) const +Type IsLocalityChecker::GetType(uint32_t t) const { - for (uint32_t t : types) - { - ftype::TruncValue(t, 2); + ftype::TruncValue(t, 2); - size_t j = COUNTRY; - for (; j < LOCALITY_COUNT; ++j) - if (t == m_types[j]) - return static_cast(j); + size_t j = COUNTRY; + for (; j < LOCALITY_COUNT; ++j) + if (t == m_types[j]) + return static_cast(j); - for (; j < m_types.size(); ++j) - if (t == m_types[j]) - return VILLAGE; - } + for (; j < m_types.size(); ++j) + if (t == m_types[j]) + return VILLAGE; return NONE; } -Type IsLocalityChecker::GetType(const FeatureType & f) const +Type IsLocalityChecker::GetType(feature::TypesHolder const & types) const +{ + for (uint32_t t : types) + { + Type const type = GetType(t); + if (type != NONE) + return type; + } + return NONE; +} + +Type IsLocalityChecker::GetType(FeatureType const & f) const { feature::TypesHolder types(f); return GetType(types); diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index d93d06a50a..d2a11b24b2 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -165,6 +165,7 @@ class IsLocalityChecker : public BaseChecker { IsLocalityChecker(); public: + Type GetType(uint32_t t) const; Type GetType(feature::TypesHolder const & types) const; Type GetType(FeatureType const & f) const;