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:
authorAlex Zolotarev <deathbaba@gmail.com>2011-05-16 03:10:22 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:17:20 +0300
commitcfd16d8c8b9b403c9afd2fc835f5b89ca0f6d607 (patch)
tree17858d250062f2b6f2d59a4a3fcd95f0a8a3c380 /generator
parent7449344cdb66ac2f27ea63f99976e5f9c103fcc9 (diff)
[generator_tool] Added feature types dumper
Usage: ./generator_tool -dump_types -output=<mwmFileWithoutExt>
Diffstat (limited to 'generator')
-rw-r--r--generator/dumper.cpp60
-rw-r--r--generator/dumper.hpp8
-rw-r--r--generator/generator.pro4
-rw-r--r--generator/generator_tool/generator_tool.cpp9
4 files changed, 79 insertions, 2 deletions
diff --git a/generator/dumper.cpp b/generator/dumper.cpp
new file mode 100644
index 0000000000..ca91d3f4de
--- /dev/null
+++ b/generator/dumper.cpp
@@ -0,0 +1,60 @@
+#include "dumper.hpp"
+
+#include "../indexer/feature_processor.hpp"
+#include "../indexer/classificator.hpp"
+
+#include "../std/vector.hpp"
+#include "../std/unordered_map.hpp"
+#include "../std/iostream.hpp"
+
+namespace feature
+{
+ class TypesCollector
+ {
+ vector<uint32_t> m_currFeatureTypes;
+
+ public:
+ typedef unordered_map<vector<uint32_t>, size_t> value_type;
+ value_type m_stats;
+
+ void operator()(FeatureType & f, uint32_t)
+ {
+ m_currFeatureTypes.clear();
+ f.ForEachTypeRef(*this);
+ CHECK(!m_currFeatureTypes.empty(), ("Feature without any type???"));
+ pair<value_type::iterator, bool> found = m_stats.insert(make_pair(m_currFeatureTypes, 1));
+ if (!found.second)
+ found.first->second++;
+ }
+
+ void operator()(uint32_t type)
+ {
+ m_currFeatureTypes.push_back(type);
+ }
+ };
+
+ typedef pair<vector<uint32_t>, size_t> stats_elem_type;
+ static bool SortFunc(stats_elem_type const & first,
+ stats_elem_type const & second)
+ {
+ return first.second > second.second;
+ }
+
+ void DumpTypes(string const & datFile)
+ {
+ TypesCollector doClass;
+ feature::ForEachFromDat(datFile, doClass);
+
+ typedef vector<stats_elem_type> vec_to_sort;
+ vec_to_sort vecToSort(doClass.m_stats.begin(), doClass.m_stats.end());
+ sort(vecToSort.begin(), vecToSort.end(), SortFunc);
+
+ for (vec_to_sort::iterator it = vecToSort.begin(); it != vecToSort.end(); ++it)
+ {
+ cout << it->second << " ";
+ for (size_t i = 0; i < it->first.size(); ++i)
+ cout << classif().GetFullObjectName(it->first[i]) << " ";
+ cout << endl;
+ }
+ }
+}
diff --git a/generator/dumper.hpp b/generator/dumper.hpp
new file mode 100644
index 0000000000..48a4bfcd57
--- /dev/null
+++ b/generator/dumper.hpp
@@ -0,0 +1,8 @@
+#pragma once
+
+#include "../std/string.hpp"
+
+namespace feature
+{
+ void DumpTypes(string const & datFile);
+}
diff --git a/generator/generator.pro b/generator/generator.pro
index 18f09e1efe..670623d63c 100644
--- a/generator/generator.pro
+++ b/generator/generator.pro
@@ -25,7 +25,8 @@ SOURCES += \
borders_generator.cpp \
osm_xml_parser.cpp \
borders_loader.cpp \
- mwm_rect_updater.cpp
+ mwm_rect_updater.cpp \
+ dumper.cpp \
HEADERS += \
feature_merger.hpp \
@@ -49,3 +50,4 @@ HEADERS += \
borders_loader.hpp \
mwm_rect_updater.hpp \
feature_emitter_iface.hpp \
+ dumper.hpp \
diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp
index 02e613e87f..45a62411d3 100644
--- a/generator/generator_tool/generator_tool.cpp
+++ b/generator/generator_tool/generator_tool.cpp
@@ -8,6 +8,7 @@
#include "../classif_routine.hpp"
#include "../borders_generator.hpp"
#include "../mwm_rect_updater.hpp"
+#include "../dumper.hpp"
#include "../../indexer/features_vector.hpp"
#include "../../indexer/index_builder.hpp"
@@ -56,6 +57,7 @@ DEFINE_bool(merge_coastlines, false, "If defined, tries to merge coastlines when
DEFINE_string(generate_borders, "",
"Create binary country .borders file for osm xml file given in 'output' parameter,"
"specify tag name and optional value: ISO3166-1 or admin_level=4");
+DEFINE_bool(dump_types, false, "If defined, prints all types combinations and their total count");
string AddSlashIfNeeded(string const & str)
{
@@ -112,7 +114,7 @@ int main(int argc, char ** argv)
// load classificator only if necessary
if (FLAGS_generate_features || FLAGS_generate_geometry ||
- FLAGS_generate_index || FLAGS_calc_statistics)
+ FLAGS_generate_index || FLAGS_calc_statistics || FLAGS_dump_types)
{
classificator::Read(path + "drawing_rules.bin",
path + "classificator.txt",
@@ -215,5 +217,10 @@ int main(int argc, char ** argv)
}
}
+ if (FLAGS_dump_types)
+ {
+ feature::DumpTypes(path + FLAGS_output + ".mwm");
+ }
+
return 0;
}