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:
authorvng <viktor.govako@gmail.com>2012-10-17 04:14:33 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:45:40 +0300
commitc0b3220afbd3dfcfa1ee3efe8b7ad92c558a2f91 (patch)
tree6428d6427d14ce4880ca010c73dbf7e504c06559 /indexer
parent68e41fba0d99b71543316d909d5f078f80712e41 (diff)
Return better feature type than "building" if feature has many choices.
Diffstat (limited to 'indexer')
-rw-r--r--indexer/feature_data.cpp32
-rw-r--r--indexer/feature_data.hpp3
2 files changed, 35 insertions, 0 deletions
diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp
index 6decfe5e83..868c7aeb08 100644
--- a/indexer/feature_data.cpp
+++ b/indexer/feature_data.cpp
@@ -7,6 +7,10 @@
using namespace feature;
+////////////////////////////////////////////////////////////////////////////////////
+// TypesHolder implementation
+////////////////////////////////////////////////////////////////////////////////////
+
TypesHolder::TypesHolder(FeatureBase const & f)
: m_size(0), m_geoType(f.GetFeatureType())
{
@@ -33,6 +37,34 @@ void TypesHolder::Remove(uint32_t t)
}
}
+void TypesHolder::SortBySpec()
+{
+ if (m_size < 2)
+ return;
+
+ // do very simple thing - put "very common" types to the end
+ /// @todo Make this function usefull for many "common" types.
+
+ // initialize common types
+ Classificator const & c = classif();
+ vector<string> path(1);
+ path[0] = "building";
+ uint32_t const buildingT = c.GetTypeByPath(path);
+
+ // do swaps with "common" types
+ size_t end = m_size-1;
+ for (size_t i = 0; i < end; ++i)
+ if (m_types[i] == buildingT)
+ {
+ swap(m_types[i], m_types[end]);
+ ASSERT_NOT_EQUAL(m_types[i], buildingT, ());
+ break;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////
+// FeatureParamsBase implementation
+////////////////////////////////////////////////////////////////////////////////////
void FeatureParamsBase::MakeZero()
{
diff --git a/indexer/feature_data.hpp b/indexer/feature_data.hpp
index 35b70c2a8c..850a0d70f9 100644
--- a/indexer/feature_data.hpp
+++ b/indexer/feature_data.hpp
@@ -89,6 +89,9 @@ namespace feature
void Remove(uint32_t t);
string DebugPrint() const;
+
+ /// Sort types by it's specification (more detailed type goes first).
+ void SortBySpec();
};
inline string DebugPrint(TypesHolder const & t)