diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2019-04-17 14:12:52 +0300 |
---|---|---|
committer | Tatiana Yan <tatiana.kondakova@gmail.com> | 2019-04-18 16:53:21 +0300 |
commit | 0b9a22ea84872625ef8a5c90cbdf3ae0c51a5e6c (patch) | |
tree | e4766d9b8f96ac02c80b2a395b1024ee70e64c93 /indexer | |
parent | 585e1eec5af5b868e958a862724cfedd1b49f1be (diff) |
[indexer] enum feature::EGeomType is changed to enum class feature::GeomType
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/classificator.cpp | 12 | ||||
-rw-r--r-- | indexer/classificator.hpp | 4 | ||||
-rw-r--r-- | indexer/data_source_helpers.cpp | 10 | ||||
-rw-r--r-- | indexer/displacement_manager.hpp | 2 | ||||
-rw-r--r-- | indexer/drules_selector.cpp | 2 | ||||
-rw-r--r-- | indexer/editable_map_object.cpp | 6 | ||||
-rw-r--r-- | indexer/feature.cpp | 44 | ||||
-rw-r--r-- | indexer/feature.hpp | 4 | ||||
-rw-r--r-- | indexer/feature_algo.cpp | 40 | ||||
-rw-r--r-- | indexer/feature_data.cpp | 18 | ||||
-rw-r--r-- | indexer/feature_data.hpp | 13 | ||||
-rw-r--r-- | indexer/feature_decl.cpp | 26 | ||||
-rw-r--r-- | indexer/feature_decl.hpp | 14 | ||||
-rw-r--r-- | indexer/feature_utils.cpp | 2 | ||||
-rw-r--r-- | indexer/feature_visibility.cpp | 59 | ||||
-rw-r--r-- | indexer/feature_visibility.hpp | 10 | ||||
-rw-r--r-- | indexer/locality_object.cpp | 6 | ||||
-rw-r--r-- | indexer/map_object.cpp | 8 | ||||
-rw-r--r-- | indexer/map_object.hpp | 4 |
19 files changed, 141 insertions, 143 deletions
diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index 026f53dffd..21d484457d 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -283,9 +283,9 @@ namespace }; } // namespace -void ClassifObject::GetSuitable(int scale, feature::EGeomType ft, drule::KeysT & keys) const +void ClassifObject::GetSuitable(int scale, feature::GeomType gt, drule::KeysT & keys) const { - ASSERT(ft >= 0 && ft <= 2, ()); + ASSERT(static_cast<int>(gt) >= 0 && static_cast<int>(gt) <= 2, ()); // 2. Check visibility criterion for scale first. if (!m_visibility[scale]) @@ -293,7 +293,7 @@ void ClassifObject::GetSuitable(int scale, feature::EGeomType ft, drule::KeysT & // find rules for 'scale' suitable_getter rulesGetter(m_drawRule, keys); - rulesGetter.find(ft, scale); + rulesGetter.find(static_cast<int>(gt), scale); } bool ClassifObject::IsDrawable(int scale) const @@ -306,9 +306,9 @@ bool ClassifObject::IsDrawableAny() const return (m_visibility != VisibleMask() && !m_drawRule.empty()); } -bool ClassifObject::IsDrawableLike(feature::EGeomType ft, bool emptyName) const +bool ClassifObject::IsDrawableLike(feature::GeomType gt, bool emptyName) const { - ASSERT(ft >= 0 && ft <= 2, ()); + ASSERT(static_cast<int>(gt) >= 0 && static_cast<int>(gt) <= 2, ()); // check the very common criterion first if (!IsDrawableAny()) @@ -325,7 +325,7 @@ bool ClassifObject::IsDrawableLike(feature::EGeomType ft, bool emptyName) const ASSERT_LESS(k.m_type, drule::count_of_rules, ()); // In case when feature name is empty we don't take into account caption drawing rules. - if ((visible[ft][k.m_type] == 1) && + if ((visible[static_cast<int>(gt)][k.m_type] == 1) && (!emptyName || (k.m_type != drule::caption && k.m_type != drule::pathtext))) { return true; diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index a2ddcbd31a..f798becd5c 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -82,12 +82,12 @@ public: void ConcatChildNames(std::string & s) const; - void GetSuitable(int scale, feature::EGeomType ft, drule::KeysT & keys) const; + void GetSuitable(int scale, feature::GeomType gt, drule::KeysT & keys) const; inline std::vector<drule::Key> const & GetDrawingRules() const { return m_drawRule; } bool IsDrawable(int scale) const; bool IsDrawableAny() const; - bool IsDrawableLike(feature::EGeomType ft, bool emptyName = false) const; + bool IsDrawableLike(feature::GeomType gt, bool emptyName = false) const; std::pair<int, int> GetDrawScaleRange() const; diff --git a/indexer/data_source_helpers.cpp b/indexer/data_source_helpers.cpp index e805280f89..461249e59a 100644 --- a/indexer/data_source_helpers.cpp +++ b/indexer/data_source_helpers.cpp @@ -18,17 +18,17 @@ void ForEachFeatureAtPoint(DataSource const & dataSource, function<void(FeatureT MercatorBounds::RectByCenterXYAndSizeInMeters(mercator, kSelectRectWidthInMeters); auto const emitter = [&fn, &rect, &mercator, toleranceInMeters](FeatureType & ft) { - switch (ft.GetFeatureType()) + switch (ft.GetGeomType()) { - case feature::GEOM_POINT: + case feature::GeomType::Point: if (rect.IsPointInside(ft.GetCenter())) fn(ft); break; - case feature::GEOM_LINE: + case feature::GeomType::Line: if (feature::GetMinDistanceMeters(ft, mercator) < kMetersToLinearFeature) fn(ft); break; - case feature::GEOM_AREA: + case feature::GeomType::Area: { auto limitRect = ft.GetLimitRect(kScale); // Be a little more tolerant. When used by editor mercator is given @@ -41,7 +41,7 @@ void ForEachFeatureAtPoint(DataSource const & dataSource, function<void(FeatureT } } break; - case feature::GEOM_UNDEFINED: ASSERT(false, ("case feature::GEOM_UNDEFINED")); break; + case feature::GeomType::Undefined: ASSERT(false, ("case feature::GeomType::Undefined")); break; } }; diff --git a/indexer/displacement_manager.hpp b/indexer/displacement_manager.hpp index 0a34f7d58b..12fc29aef0 100644 --- a/indexer/displacement_manager.hpp +++ b/indexer/displacement_manager.hpp @@ -198,7 +198,7 @@ private: static bool IsDisplaceable(Feature & ft) { feature::TypesHolder const types(ft); - return types.GetGeoType() == feature::GEOM_POINT; + return types.GetGeomType() == feature::GeomType::Point; } float CalculateDeltaForZoom(int32_t zoom) const diff --git a/indexer/drules_selector.cpp b/indexer/drules_selector.cpp index 1feee628ab..79f3de077a 100644 --- a/indexer/drules_selector.cpp +++ b/indexer/drules_selector.cpp @@ -148,7 +148,7 @@ bool GetName(FeatureType & ft, string & name) // Feature tag value evaluator for tag 'bbox_area' (bounding box area in sq.meters) bool GetBoundingBoxArea(FeatureType & ft, double & sqM) { - if (feature::GEOM_AREA != ft.GetFeatureType()) + if (feature::GeomType::Area != ft.GetGeomType()) return false; m2::RectD const rect = ft.GetLimitRect(scales::GetUpperScale()); diff --git a/indexer/editable_map_object.cpp b/indexer/editable_map_object.cpp index 5685e46cc4..cbff1bfad6 100644 --- a/indexer/editable_map_object.cpp +++ b/indexer/editable_map_object.cpp @@ -411,10 +411,10 @@ void EditableMapObject::SetMercator(m2::PointD const & center) { m_mercator = ce void EditableMapObject::SetType(uint32_t featureType) { - if (m_types.GetGeoType() == feature::EGeomType::GEOM_UNDEFINED) + if (m_types.GetGeomType() == feature::GeomType::Undefined) { // Support only point type for newly created features. - m_types = feature::TypesHolder(feature::EGeomType::GEOM_POINT); + m_types = feature::TypesHolder(feature::GeomType::Point); m_types.Assign(featureType); } else @@ -550,7 +550,7 @@ void EditableMapObject::SetOpeningHours(string const & openingHours) m_metadata.Set(feature::Metadata::FMD_OPEN_HOURS, openingHours); } -void EditableMapObject::SetPointType() { m_geomType = feature::EGeomType::GEOM_POINT; } +void EditableMapObject::SetPointType() { m_geomType = feature::GeomType::Point; } void EditableMapObject::RemoveBlankAndDuplicationsForDefault() { diff --git a/indexer/feature.cpp b/indexer/feature.cpp index 89f63c4c0e..52e33e5c09 100644 --- a/indexer/feature.cpp +++ b/indexer/feature.cpp @@ -201,21 +201,21 @@ FeatureType::FeatureType(osm::MapObject const & emo) switch (emo.GetGeomType()) { - case feature::GEOM_UNDEFINED: - // It is not possible because of FeatureType::GetFeatureType() never returns GEOM_UNDEFINED. + case feature::GeomType::Undefined: + // It is not possible because of FeatureType::GetGeomType() never returns GeomType::Undefined. UNREACHABLE(); - case feature::GEOM_POINT: + case feature::GeomType::Point: headerGeomType = HeaderGeomType::Point; m_center = emo.GetMercator(); m_limitRect.Add(m_center); break; - case feature::GEOM_LINE: + case feature::GeomType::Line: headerGeomType = HeaderGeomType::Line; m_points = Points(emo.GetPoints().begin(), emo.GetPoints().end()); for (auto const & p : m_points) m_limitRect.Add(p); break; - case feature::GEOM_AREA: + case feature::GeomType::Area: headerGeomType = HeaderGeomType::Area; m_triangles = Points(emo.GetTriangesAsPoints().begin(), emo.GetTriangesAsPoints().end()); for (auto const & p : m_triangles) @@ -246,16 +246,16 @@ FeatureType::FeatureType(osm::MapObject const & emo) m_id = emo.GetID(); } -feature::EGeomType FeatureType::GetFeatureType() const +feature::GeomType FeatureType::GetGeomType() const { // FeatureType::FeatureType(osm::MapObject const & emo) expects - // that GEOM_UNDEFINED is never be returned. + // that GeomType::Undefined is never be returned. auto const headerGeomType = static_cast<HeaderGeomType>(m_header & HEADER_GEOTYPE_MASK); switch (headerGeomType) { - case HeaderGeomType::Line: return GEOM_LINE; - case HeaderGeomType::Area: return GEOM_AREA; - default: return GEOM_POINT; + case HeaderGeomType::Line: return GeomType::Line; + case HeaderGeomType::Area: return GeomType::Area; + default: return GeomType::Point; } } @@ -302,7 +302,7 @@ void FeatureType::ParseCommon() uint8_t const h = Header(m_data); m_params.Read(source, h); - if (GetFeatureType() == GEOM_POINT) + if (GetGeomType() == GeomType::Point) { m_center = serial::LoadPoint(source, m_loadInfo->GetDefGeometryCodingParams()); m_limitRect.Add(m_center); @@ -314,7 +314,7 @@ void FeatureType::ParseCommon() m2::PointD FeatureType::GetCenter() { - ASSERT_EQUAL(GetFeatureType(), feature::GEOM_POINT, ()); + ASSERT_EQUAL(GetGeomType(), feature::GeomType::Point, ()); ParseCommon(); return m_center; } @@ -405,7 +405,7 @@ void FeatureType::ResetGeometry() m_points.clear(); m_triangles.clear(); - if (GetFeatureType() != GEOM_POINT) + if (GetGeomType() != GeomType::Point) m_limitRect = m2::RectD(); m_parsed.m_header2 = m_parsed.m_points = m_parsed.m_triangles = false; @@ -574,21 +574,21 @@ string FeatureType::DebugString(int scale) res += m_params.DebugString(); ParseGeometryAndTriangles(scale); - switch (GetFeatureType()) + switch (GetGeomType()) { - case GEOM_POINT: res += (" Center:" + DebugPrint(m_center)); break; + case GeomType::Point: res += (" Center:" + DebugPrint(m_center)); break; - case GEOM_LINE: + case GeomType::Line: res += " Points:"; Points2String(res, m_points); break; - case GEOM_AREA: + case GeomType::Area: res += " Triangles:"; Points2String(res, m_triangles); break; - case GEOM_UNDEFINED: + case GeomType::Undefined: ASSERT(false, ("Assume that we have valid feature always")); break; } @@ -600,7 +600,7 @@ m2::RectD FeatureType::GetLimitRect(int scale) { ParseGeometryAndTriangles(scale); - if (m_triangles.empty() && m_points.empty() && (GetFeatureType() != GEOM_POINT)) + if (m_triangles.empty() && m_points.empty() && (GetGeomType() != GeomType::Point)) { // This function is called during indexing, when we need // to check visibility according to feature sizes. @@ -615,10 +615,10 @@ bool FeatureType::IsEmptyGeometry(int scale) { ParseGeometryAndTriangles(scale); - switch (GetFeatureType()) + switch (GetGeomType()) { - case GEOM_AREA: return m_triangles.empty(); - case GEOM_LINE: return m_points.empty(); + case GeomType::Area: return m_triangles.empty(); + case GeomType::Line: return m_points.empty(); default: return false; } } diff --git a/indexer/feature.hpp b/indexer/feature.hpp index 15786e4508..d95dfe46e2 100644 --- a/indexer/feature.hpp +++ b/indexer/feature.hpp @@ -37,7 +37,7 @@ public: FeatureType(feature::SharedLoadInfo const * loadInfo, Buffer buffer); FeatureType(osm::MapObject const & emo); - feature::EGeomType GetFeatureType() const; + feature::GeomType GetGeomType() const; FeatureParamsBase & GetParams() { return m_params; } uint8_t GetTypesCount() const { return (m_header & feature::HEADER_TYPE_MASK) + 1; } @@ -97,7 +97,7 @@ public: if (m_points.empty()) { // it's a point feature - if (GetFeatureType() == feature::GEOM_POINT) + if (GetGeomType() == feature::GeomType::Point) f(m_center); } else diff --git a/indexer/feature_algo.cpp b/indexer/feature_algo.cpp index eda2e16457..52af2e5840 100644 --- a/indexer/feature_algo.cpp +++ b/indexer/feature_algo.cpp @@ -16,26 +16,26 @@ namespace feature /// logic if you really-really know what you are doing. m2::PointD GetCenter(FeatureType & f, int scale) { - EGeomType const type = f.GetFeatureType(); + GeomType const type = f.GetGeomType(); switch (type) { - case GEOM_POINT: + case GeomType::Point: + { return f.GetCenter(); - - case GEOM_LINE: - { - m2::CalculatePolyLineCenter doCalc; - f.ForEachPoint(doCalc, scale); - return doCalc.GetResult(); - } - + } + case GeomType::Line: + { + m2::CalculatePolyLineCenter doCalc; + f.ForEachPoint(doCalc, scale); + return doCalc.GetResult(); + } default: - { - ASSERT_EQUAL(type, GEOM_AREA, ()); - m2::CalculatePointOnSurface doCalc(f.GetLimitRect(scale)); - f.ForEachTriangle(doCalc, scale); - return doCalc.GetResult(); - } + { + ASSERT_EQUAL(type, GeomType::Area, ()); + m2::CalculatePointOnSurface doCalc(f.GetLimitRect(scale)); + f.ForEachTriangle(doCalc, scale); + return doCalc.GetResult(); + } } } @@ -51,14 +51,14 @@ double GetMinDistanceMeters(FeatureType & ft, m2::PointD const & pt, int scale) res = d; }; - EGeomType const type = ft.GetFeatureType(); + GeomType const type = ft.GetGeomType(); switch (type) { - case GEOM_POINT: + case GeomType::Point: updateDistanceFn(ft.GetCenter()); break; - case GEOM_LINE: + case GeomType::Line: { ft.ParseGeometry(scale); size_t const count = ft.GetPointsCount(); @@ -71,7 +71,7 @@ double GetMinDistanceMeters(FeatureType & ft, m2::PointD const & pt, int scale) } default: - ASSERT_EQUAL(type, GEOM_AREA, ()); + ASSERT_EQUAL(type, GeomType::Area, ()); ft.ForEachTriangle([&](m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3) { if (res == 0.0) diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp index a98e742670..9289f55adc 100644 --- a/indexer/feature_data.cpp +++ b/indexer/feature_data.cpp @@ -36,7 +36,7 @@ string DebugPrint(TypesHolder const & holder) return s; } -TypesHolder::TypesHolder(FeatureType & f) : m_size(0), m_geoType(f.GetFeatureType()) +TypesHolder::TypesHolder(FeatureType & f) : m_size(0), m_geomType(f.GetGeomType()) { f.ForEachType([this](uint32_t type) { @@ -381,13 +381,13 @@ string FeatureParams::GetStreet() const return m_addrTags.Get(AddressData::STREET); } -void FeatureParams::SetGeomType(feature::EGeomType t) +void FeatureParams::SetGeomType(feature::GeomType t) { switch (t) { - case GEOM_POINT: m_geomType = HeaderGeomType::Point; break; - case GEOM_LINE: m_geomType = HeaderGeomType::Line; break; - case GEOM_AREA: m_geomType = HeaderGeomType::Area; break; + case GeomType::Point: m_geomType = HeaderGeomType::Point; break; + case GeomType::Line: m_geomType = HeaderGeomType::Line; break; + case GeomType::Area: m_geomType = HeaderGeomType::Area; break; default: ASSERT(false, ()); } } @@ -401,14 +401,14 @@ void FeatureParams::SetGeomTypePointEx() m_geomType = HeaderGeomType::PointEx; } -feature::EGeomType FeatureParams::GetGeomType() const +feature::GeomType FeatureParams::GetGeomType() const { CheckValid(); switch (m_geomType) { - case HeaderGeomType::Line: return GEOM_LINE; - case HeaderGeomType::Area: return GEOM_AREA; - default: return GEOM_POINT; + case HeaderGeomType::Line: return GeomType::Line; + case HeaderGeomType::Area: return GeomType::Area; + default: return GeomType::Point; } } diff --git a/indexer/feature_data.hpp b/indexer/feature_data.hpp index bf3175f466..4f578321c0 100644 --- a/indexer/feature_data.hpp +++ b/indexer/feature_data.hpp @@ -58,7 +58,7 @@ namespace feature using Types = std::array<uint32_t, kMaxTypesCount>; TypesHolder() = default; - explicit TypesHolder(EGeomType geoType) : m_geoType(geoType) {} + explicit TypesHolder(GeomType geomType) : m_geomType(geomType) {} explicit TypesHolder(FeatureType & f); void Assign(uint32_t type) @@ -75,9 +75,7 @@ namespace feature m_types[m_size++] = type; } - /// @name Selectors. - //@{ - EGeomType GetGeoType() const { return m_geoType; } + GeomType GetGeomType() const { return m_geomType; } size_t Size() const { return m_size; } bool Empty() const { return (m_size == 0); } @@ -94,7 +92,6 @@ namespace feature } bool Has(uint32_t t) const { return std::find(begin(), end(), t) != end(); } - //@} template <typename Fn> bool RemoveIf(Fn && fn) @@ -122,7 +119,7 @@ namespace feature Types m_types; size_t m_size = 0; - EGeomType m_geoType = GEOM_UNDEFINED; + GeomType m_geomType = GeomType::Undefined; }; std::string DebugPrint(TypesHolder const & holder); @@ -263,9 +260,9 @@ public: } bool IsValid() const { return !m_types.empty(); } - void SetGeomType(feature::EGeomType t); + void SetGeomType(feature::GeomType t); void SetGeomTypePointEx(); - feature::EGeomType GetGeomType() const; + feature::GeomType GetGeomType() const; void AddType(uint32_t t) { m_types.push_back(t); } diff --git a/indexer/feature_decl.cpp b/indexer/feature_decl.cpp index a1fc055371..56ef2ce06f 100644 --- a/indexer/feature_decl.cpp +++ b/indexer/feature_decl.cpp @@ -4,25 +4,27 @@ using namespace std; -string DebugPrint(FeatureID const & id) +namespace feature { - ostringstream ss; - ss << "{ " << DebugPrint(id.m_mwmId) << ", " << id.m_index << " }"; - return ss.str(); -} - -string DebugPrint(feature::EGeomType type) +string DebugPrint(GeomType type) { - using feature::EGeomType; switch (type) { - case EGeomType::GEOM_UNDEFINED: return "GEOM_UNDEFINED"; - case EGeomType::GEOM_POINT: return "GEOM_POINT"; - case EGeomType::GEOM_LINE: return "GEOM_LINE"; - case EGeomType::GEOM_AREA: return "GEOM_AREA"; + case GeomType::Undefined: return "Undefined"; + case GeomType::Point: return "Point"; + case GeomType::Line: return "Line"; + case GeomType::Area: return "Area"; } UNREACHABLE(); } +} // namespace feature + +string DebugPrint(FeatureID const & id) +{ + ostringstream ss; + ss << "{ " << DebugPrint(id.m_mwmId) << ", " << id.m_index << " }"; + return ss.str(); +} // static char const * const FeatureID::kInvalidFileName = "INVALID"; diff --git a/indexer/feature_decl.hpp b/indexer/feature_decl.hpp index 417997de54..bd09450f0a 100644 --- a/indexer/feature_decl.hpp +++ b/indexer/feature_decl.hpp @@ -7,17 +7,17 @@ namespace feature { -enum EGeomType +enum class GeomType { - GEOM_UNDEFINED = -1, + Undefined = -1, // Note! do not change this values. Should be equal with FeatureGeoType. - GEOM_POINT = 0, - GEOM_LINE = 1, - GEOM_AREA = 2 + Point = 0, + Line = 1, + Area = 2 }; -} // namespace feature -std::string DebugPrint(feature::EGeomType type); +std::string DebugPrint(GeomType type); +} // namespace feature struct FeatureID { diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index 70e8ff7e3d..eee3a41131 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -214,7 +214,7 @@ public: { int scale = GetDefaultScale(); - if (types.GetGeoType() == GEOM_POINT) + if (types.GetGeomType() == GeomType::Point) for (uint32_t t : types) scale = min(scale, GetScaleForType(t)); diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp index d7480d3cdd..6fdd2f730f 100644 --- a/indexer/feature_visibility.cpp +++ b/indexer/feature_visibility.cpp @@ -70,12 +70,12 @@ namespace class DrawRuleGetter { int m_scale; - EGeomType m_ft; + GeomType m_gt; drule::KeysT & m_keys; public: - DrawRuleGetter(int scale, EGeomType ft, drule::KeysT & keys) - : m_scale(scale), m_ft(ft), m_keys(keys) + DrawRuleGetter(int scale, GeomType gt, drule::KeysT & keys) + : m_scale(scale), m_gt(gt), m_keys(keys) { } @@ -87,7 +87,7 @@ namespace bool operator() (ClassifObject const * p, bool & res) { res = true; - p->GetSuitable(min(m_scale, scales::GetUpperStyleScale()), m_ft, m_keys); + p->GetSuitable(min(m_scale, scales::GetUpperStyleScale()), m_gt, m_keys); return false; } }; @@ -99,21 +99,20 @@ pair<int, bool> GetDrawRule(TypesHolder const & types, int level, ASSERT ( keys.empty(), () ); Classificator const & c = classif(); - DrawRuleGetter doRules(level, types.GetGeoType(), keys); + DrawRuleGetter doRules(level, types.GetGeomType(), keys); for (uint32_t t : types) (void)c.ProcessObjects(t, doRules); - return make_pair(types.GetGeoType(), types.Has(c.GetCoastType())); + return make_pair(static_cast<int>(types.GetGeomType()), types.Has(c.GetCoastType())); } -void GetDrawRule(vector<uint32_t> const & types, int level, int geoType, - drule::KeysT & keys) +void GetDrawRule(vector<uint32_t> const & types, int level, GeomType geomType, drule::KeysT & keys) { ASSERT ( keys.empty(), () ); Classificator const & c = classif(); - DrawRuleGetter doRules(level, EGeomType(geoType), keys); + DrawRuleGetter doRules(level, geomType, keys); for (uint32_t t : types) (void)c.ProcessObjects(t, doRules); @@ -155,11 +154,11 @@ namespace class IsDrawableLikeChecker { - EGeomType m_geomType; + GeomType m_geomType; bool m_emptyName; public: - IsDrawableLikeChecker(EGeomType geomType, bool emptyName = false) + IsDrawableLikeChecker(GeomType geomType, bool emptyName = false) : m_geomType(geomType), m_emptyName(emptyName) { } @@ -181,12 +180,12 @@ namespace class IsDrawableRulesChecker { int m_scale; - EGeomType m_ft; + GeomType m_gt; bool m_arr[3]; public: - IsDrawableRulesChecker(int scale, EGeomType ft, int rules) - : m_scale(scale), m_ft(ft) + IsDrawableRulesChecker(int scale, GeomType gt, int rules) + : m_scale(scale), m_gt(gt) { m_arr[0] = rules & RULE_CAPTION; m_arr[1] = rules & RULE_PATH_TEXT; @@ -199,7 +198,7 @@ namespace bool operator() (ClassifObject const * p, bool & res) { drule::KeysT keys; - p->GetSuitable(m_scale, m_ft, keys); + p->GetSuitable(m_scale, m_gt, keys); for (auto const & k : keys) { @@ -224,18 +223,18 @@ namespace /// Add here all exception classificator types: needed for algorithms, /// but don't have drawing rules. - bool TypeAlwaysExists(uint32_t type, EGeomType g = GEOM_UNDEFINED) + bool TypeAlwaysExists(uint32_t type, GeomType g = GeomType::Undefined) { if (!classif().IsTypeValid(type)) return false; static uint32_t const internet = classif().GetTypeByPath({"internet_access"}); - if ((g == GEOM_LINE || g == GEOM_UNDEFINED) && HasRoutingExceptionType(type)) + if ((g == GeomType::Line || g == GeomType::Undefined) && HasRoutingExceptionType(type)) return true; ftype::TruncValue(type, 1); - if (g != GEOM_LINE && type == internet) + if (g != GeomType::Line && type == internet) return true; return false; @@ -243,7 +242,7 @@ namespace /// Add here all exception classificator types: needed for algorithms, /// but don't have drawing rules. - bool IsUsefulNondrawableType(uint32_t type, EGeomType g = GEOM_UNDEFINED) + bool IsUsefulNondrawableType(uint32_t type, GeomType g = GeomType::Undefined) { if (!classif().IsTypeValid(type)) return false; @@ -263,11 +262,11 @@ namespace // Caching type length to exclude generic [wheelchair]. uint8_t const typeLength = ftype::GetLevel(type); - if ((g == GEOM_LINE || g == GEOM_UNDEFINED) && type == roundabout) + if ((g == GeomType::Line || g == GeomType::Undefined) && type == roundabout) return true; ftype::TruncValue(type, 1); - if (g == GEOM_LINE || g == GEOM_UNDEFINED) + if (g == GeomType::Line || g == GeomType::Undefined) { if (type == hwtag || type == psurface) return true; @@ -279,7 +278,7 @@ namespace if (type == cuisine) return true; - if (g != GEOM_LINE && type == sponsored) + if (g != GeomType::Line && type == sponsored) return true; // Reserved for custom event processing, e.g. fc2018. @@ -295,7 +294,7 @@ bool TypeIsUseful(uint32_t type) return IsUsefulNondrawableType(type) || classif().GetObject(type)->IsDrawableAny(); } -bool IsDrawableLike(vector<uint32_t> const & types, EGeomType geomType) +bool IsDrawableLike(vector<uint32_t> const & types, GeomType geomType) { Classificator const & c = classif(); @@ -329,7 +328,7 @@ bool IsDrawableForIndexGeometryOnly(TypesHolder const & types, m2::RectD limitRe static uint32_t const buildingPartType = c.GetTypeByPath({"building:part"}); - if (types.GetGeoType() == GEOM_AREA && !types.Has(c.GetCoastType()) && + if (types.GetGeomType() == GeomType::Area && !types.Has(c.GetCoastType()) && !types.Has(buildingPartType) && !scales::IsGoodForLevel(level, limitRect)) return false; @@ -349,7 +348,7 @@ bool IsDrawableForIndexClassifOnly(TypesHolder const & types, int level) return false; } -bool IsUsefulType(uint32_t t, EGeomType geomType, bool emptyName) +bool IsUsefulType(uint32_t t, GeomType geomType, bool emptyName) { Classificator const & c = classif(); @@ -362,9 +361,9 @@ bool IsUsefulType(uint32_t t, EGeomType geomType, bool emptyName) // IsDrawableLikeChecker checks only unique area styles, // so we need to take into account point styles too. - if (geomType == GEOM_AREA) + if (geomType == GeomType::Area) { - IsDrawableLikeChecker doCheck(GEOM_POINT, emptyName); + IsDrawableLikeChecker doCheck(GeomType::Point, emptyName); if (c.ProcessObjects(t, doCheck)) return true; } @@ -372,7 +371,7 @@ bool IsUsefulType(uint32_t t, EGeomType geomType, bool emptyName) return false; } -bool HasUsefulType(vector<uint32_t> const & types, EGeomType geomType, bool emptyName) +bool HasUsefulType(vector<uint32_t> const & types, GeomType geomType, bool emptyName) { if (types.empty()) return false; @@ -382,7 +381,7 @@ bool HasUsefulType(vector<uint32_t> const & types, EGeomType geomType, bool empt }); } -bool RemoveUselessTypes(vector<uint32_t> & types, EGeomType geomType, bool emptyName) +bool RemoveUselessTypes(vector<uint32_t> & types, GeomType geomType, bool emptyName) { base::EraseIf(types, [&] (uint32_t t) { return !IsUsefulType(t, geomType, emptyName); @@ -496,7 +495,7 @@ namespace { Classificator const & c = classif(); - IsDrawableRulesChecker doCheck(level, types.GetGeoType(), rules); + IsDrawableRulesChecker doCheck(level, types.GetGeomType(), rules); for (uint32_t t : types) if (c.ProcessObjects(t, doCheck)) return true; diff --git a/indexer/feature_visibility.hpp b/indexer/feature_visibility.hpp index 400ee5b0e1..10c202acbe 100644 --- a/indexer/feature_visibility.hpp +++ b/indexer/feature_visibility.hpp @@ -31,14 +31,14 @@ namespace feature bool IsDrawableForIndexGeometryOnly(TypesHolder const & types, m2::RectD limitRect, int level); /// For FEATURE_TYPE_AREA need to have at least one area-filling type. - bool IsDrawableLike(std::vector<uint32_t> const & types, EGeomType geomType); + bool IsDrawableLike(std::vector<uint32_t> const & types, GeomType geomType); /// For FEATURE_TYPE_AREA removes line-drawing only types. - bool RemoveUselessTypes(std::vector<uint32_t> & types, EGeomType geomType, - bool emptyName = false); + bool RemoveUselessTypes(std::vector<uint32_t> & types, GeomType geomType, bool emptyName = false); // Returns true, if there is at least one type that is needed for the application. // This can be specified either by the drawing rule or by other rules. - bool HasUsefulType(std::vector<uint32_t> const & types, EGeomType geomType, bool emptyName = false); + bool HasUsefulType(std::vector<uint32_t> const & types, GeomType geomType, + bool emptyName = false); int GetMinDrawableScale(FeatureType & ft); int GetMinDrawableScale(TypesHolder const & types, m2::RectD limitRect); @@ -65,7 +65,7 @@ namespace feature /// @return (geometry type, is coastline) std::pair<int, bool> GetDrawRule(TypesHolder const & types, int level, drule::KeysT & keys); - void GetDrawRule(std::vector<uint32_t> const & types, int level, int geoType, + void GetDrawRule(std::vector<uint32_t> const & types, int level, GeomType geomType, drule::KeysT & keys); void FilterRulesByRuntimeSelector(FeatureType & f, int zoomLevel, drule::KeysT & keys); diff --git a/indexer/locality_object.cpp b/indexer/locality_object.cpp index a4e21f50a1..a8263ccf0c 100644 --- a/indexer/locality_object.cpp +++ b/indexer/locality_object.cpp @@ -12,16 +12,16 @@ void LocalityObject::Deserialize(char const * data) ArrayByteSource src(data); serial::GeometryCodingParams cp = {}; ReadPrimitiveFromSource(src, m_id); - uint8_t type; + feature::GeomType type; ReadPrimitiveFromSource(src, type); - if (type == feature::GEOM_POINT) + if (type == feature::GeomType::Point) { m_points.push_back(serial::LoadPoint(src, cp)); return; } - ASSERT_EQUAL(type, feature::GEOM_AREA, ("Only supported types are GEOM_POINT and GEOM_AREA.")); + ASSERT_EQUAL(type, feature::GeomType::Area, ("Only supported types are Point and Area.")); uint32_t trgCount; ReadPrimitiveFromSource(src, trgCount); CHECK_GREATER(trgCount, 0, ()); diff --git a/indexer/map_object.cpp b/indexer/map_object.cpp index c3e1d9203a..7186f73180 100644 --- a/indexer/map_object.cpp +++ b/indexer/map_object.cpp @@ -76,12 +76,12 @@ void MapObject::SetFromFeatureType(FeatureType & ft) m_metadata = ft.GetMetadata(); m_houseNumber = ft.GetHouseNumber(); m_featureID = ft.GetID(); - m_geomType = ft.GetFeatureType(); - if (m_geomType == feature::GEOM_AREA) + m_geomType = ft.GetGeomType(); + if (m_geomType == feature::GeomType::Area) { m_triangles = ft.GetTriangesAsPoints(FeatureType::BEST_GEOMETRY); } - else if (m_geomType == feature::GEOM_LINE) + else if (m_geomType == feature::GeomType::Line) { ft.ParseGeometry(FeatureType::BEST_GEOMETRY); m_points.reserve(ft.GetPointsCount()); @@ -236,7 +236,7 @@ string MapObject::GetAirportIata() const } feature::Metadata const & MapObject::GetMetadata() const { return m_metadata; } -bool MapObject::IsPointType() const { return m_geomType == feature::EGeomType::GEOM_POINT; } +bool MapObject::IsPointType() const { return m_geomType == feature::GeomType::Point; } bool MapObject::IsBuilding() const { return ftypes::IsBuildingChecker::Instance()(m_types); } } // namespace osm diff --git a/indexer/map_object.hpp b/indexer/map_object.hpp index 60950ef58c..d87d94d077 100644 --- a/indexer/map_object.hpp +++ b/indexer/map_object.hpp @@ -102,7 +102,7 @@ public: feature::Metadata const & GetMetadata() const; bool IsPointType() const; - feature::EGeomType GetGeomType() const { return m_geomType; }; + feature::GeomType GetGeomType() const { return m_geomType; }; /// @returns true if object is of building type. bool IsBuilding() const; @@ -121,7 +121,7 @@ protected: feature::TypesHolder m_types; feature::Metadata m_metadata; - feature::EGeomType m_geomType = feature::EGeomType::GEOM_UNDEFINED; + feature::GeomType m_geomType = feature::GeomType::Undefined; }; /// Helper to convert internal feature::Metadata::FMD_* enum into a users-visible one. |