From 99fec047b33e0ae7c2ec379e531c1492faef8b09 Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Thu, 24 Mar 2016 12:07:59 +0300 Subject: [PATCH] [editor] Review fixes, and a new method HasAnyTags() in XMLFeature --- editor/changeset_wrapper.cpp | 17 ++++++++--------- editor/xml_feature.cpp | 5 +++++ editor/xml_feature.hpp | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/editor/changeset_wrapper.cpp b/editor/changeset_wrapper.cpp index ee167efb6c..c8b7d26a5e 100644 --- a/editor/changeset_wrapper.cpp +++ b/editor/changeset_wrapper.cpp @@ -29,7 +29,11 @@ m2::RectD GetBoundingRect(vector const & geometry) return rect; } -bool OsmFeatureHasTags(pugi::xml_node const & osmFt) { return osmFt.child("tag"); } +bool OsmFeatureHasTags(pugi::xml_node const & osmFt) +{ + return osmFt.child("tag"); +} + vector const static kMainTags = {"amenity", "shop", "tourism", "historic", "craft", "emergency", "barrier", "highway", "office", "entrance", "building"}; @@ -40,7 +44,7 @@ string GetTypeForFeature(XMLFeature const & node) { if (node.HasTag(key)) { - string value = node.GetTagValue(key); + string const value = node.GetTagValue(key); if (value == "yes") return key; else if (key == "shop" || key == "office" || key == "building" || key == "entrance") @@ -51,12 +55,7 @@ string GetTypeForFeature(XMLFeature const & node) } // Did not find any known tags. - bool foundTags = false; - node.ForEachTag([&foundTags](string const & k, string const & v) - { - foundTags = true; - }); - return foundTags ? "unknown object" : "empty object"; + return node.HasAnyTags() ? "unknown object" : "empty object"; } vector NaiveSample(vector const & source, size_t count) @@ -275,7 +274,7 @@ string ChangesetWrapper::TypeCountToString(TTypeCount const & typeCount) const }); ostringstream ss; - auto limit = items.size() > 3 ? 3 : items.size(); + auto const limit = items.size() > 3 ? 3 : items.size(); for (auto i = 0; i < limit; ++i) { if (i > 0) diff --git a/editor/xml_feature.cpp b/editor/xml_feature.cpp index 3b7abad3b6..7117f97de2 100644 --- a/editor/xml_feature.cpp +++ b/editor/xml_feature.cpp @@ -314,6 +314,11 @@ void XMLFeature::SetUploadError(string const & error) SetAttribute(kUploadError, error); } +bool XMLFeature::HasAnyTags() const +{ + return m_document.child("tag"); +} + bool XMLFeature::HasTag(string const & key) const { return FindTag(m_document, key); diff --git a/editor/xml_feature.hpp b/editor/xml_feature.hpp index 09043e9f75..47c82f341b 100644 --- a/editor/xml_feature.hpp +++ b/editor/xml_feature.hpp @@ -138,6 +138,7 @@ public: void SetUploadError(string const & error); //@} + bool HasAnyTags() const; bool HasTag(string const & key) const; bool HasAttribute(string const & key) const; bool HasKey(string const & key) const;