From 4de675fbb9d95dc1046bd495a49e9caaa3e74c87 Mon Sep 17 00:00:00 2001 From: Denis Koronchik Date: Fri, 12 Sep 2014 18:09:48 +0300 Subject: [PATCH] Pretty print of FeatureType. --- indexer/feature.cpp | 38 ++++++++++++++++++++++++++------------ indexer/feature.hpp | 1 + indexer/feature_data.cpp | 16 ++++++++-------- indexer/feature_decl.hpp | 9 +++++++++ 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/indexer/feature.cpp b/indexer/feature.cpp index e3165fedbc..22e0c647e9 100644 --- a/indexer/feature.cpp +++ b/indexer/feature.cpp @@ -1,6 +1,7 @@ #include "feature.hpp" #include "feature_visibility.hpp" #include "feature_loader_base.hpp" +#include "classificator.hpp" #include "../geometry/distance.hpp" #include "../geometry/robust_orientation.hpp" @@ -60,17 +61,14 @@ string FeatureBase::DebugString() const { ASSERT(m_bCommonParsed, ()); - string res("FEATURE: "); + Classificator const & c = classif(); + string res = "Types"; for (size_t i = 0; i < GetTypesCount(); ++i) - res += "Type:" + DebugPrint(m_types[i]) + " "; + res += (" : " + c.GetReadableObjectName(m_types[i])); + res += "\n"; - res += m_params.DebugString(); - - if (GetFeatureType() == GEOM_POINT) - res += "Center:" + DebugPrint(m_center) + " "; - - return res; + return (res + m_params.DebugString()); } @@ -142,15 +140,31 @@ string FeatureType::DebugString(int scale) const string s = base_type::DebugString(); - s += "Points:"; - Points2String(s, m_points); + switch (GetFeatureType()) + { + case FEATURE_TYPE_POINT: + s += (" Center:" + DebugPrint(m_center)); + break; - s += "Triangles:"; - Points2String(s, m_triangles); + case FEATURE_TYPE_LINE: + s += " Points:"; + Points2String(s, m_points); + break; + + case FEATURE_TYPE_AREA: + s += " Triangles:"; + Points2String(s, m_triangles); + break; + } return s; } +string DebugPrint(FeatureType const & ft) +{ + return ft.DebugString(FeatureType::BEST_GEOMETRY); +} + bool FeatureType::IsEmptyGeometry(int scale) const { ParseAll(scale); diff --git a/indexer/feature.hpp b/indexer/feature.hpp index 89396f6f9b..94b89613de 100644 --- a/indexer/feature.hpp +++ b/indexer/feature.hpp @@ -231,6 +231,7 @@ public: /// For test cases only. string DebugString(int scale) const; + friend string DebugPrint(FeatureType const & ft); string GetHouseNumber() const; diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp index 5009ee23b6..fae0aa29b3 100644 --- a/indexer/feature_data.cpp +++ b/indexer/feature_data.cpp @@ -110,12 +110,13 @@ bool FeatureParamsBase::CheckValid() const string FeatureParamsBase::DebugString() const { string utf8name; - name.GetString(0, utf8name); + name.GetString(StringUtf8Multilang::DEFAULT_CODE, utf8name); - return ("'" + utf8name + "' Layer:" + DebugPrint(layer) + + return ((!utf8name.empty() ? "Name:" + utf8name : "") + + (" Layer:" + DebugPrint(layer)) + (rank != 0 ? " Rank:" + DebugPrint(rank) : "") + (!house.IsEmpty() ? " House:" + house.Get() : "") + - (!ref.empty() ? " Ref:" + ref : "") + " "); + (!ref.empty() ? " Ref:" + ref : "")); } namespace @@ -352,11 +353,10 @@ string DebugPrint(FeatureParams const & p) { Classificator const & c = classif(); - ostringstream out; - - out << "Types: "; + string res = "Types"; for (size_t i = 0; i < p.m_Types.size(); ++i) - out << c.GetReadableObjectName(p.m_Types[i]) << "; "; + res += (" : " + c.GetReadableObjectName(p.m_Types[i])); + res += "\n"; - return (p.DebugString() + out.str()); + return (res + p.DebugString()); } diff --git a/indexer/feature_decl.hpp b/indexer/feature_decl.hpp index 8e2db502f0..8fa8ffc110 100644 --- a/indexer/feature_decl.hpp +++ b/indexer/feature_decl.hpp @@ -1,5 +1,7 @@ #pragma once +#include "../std/sstream.hpp" +#include "../std/string.hpp" #include "../std/stdint.hpp" @@ -31,3 +33,10 @@ struct FeatureID return !(*this == r); } }; + +inline string DebugPrint(FeatureID const & id) +{ + ostringstream ss; + ss << "{ " << id.m_mwm << ", " << id.m_offset << " }"; + return ss.str(); +}