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:
authorLev Dragunov <l.dragunov@corp.mail.ru>2016-02-02 18:01:11 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:17:04 +0300
commitecb8d9705d1b90f3dce219b0e34c6c7939319729 (patch)
tree35b0d2ac67f4da9cfbb9acb5fa2bac066ca0ee5b
parent139eebd7e68dd810e82814847004aaa05b6a2bf8 (diff)
Capital filtration enhancements.
-rw-r--r--generator/tag_admixer.hpp24
-rw-r--r--generator/towns_dumper.hpp12
2 files changed, 30 insertions, 6 deletions
diff --git a/generator/tag_admixer.hpp b/generator/tag_admixer.hpp
index a22a2e5b1e..30f4ece48d 100644
--- a/generator/tag_admixer.hpp
+++ b/generator/tag_admixer.hpp
@@ -25,8 +25,9 @@ public:
string oneLine;
while (getline(input, oneLine, '\n'))
{
+ // String format: <<id;tag>>.
auto pos = oneLine.find(';');
- if (pos < oneLine.length())
+ if (pos != string::npos)
{
uint64_t wayId;
CHECK(strings::to_uint64(oneLine.substr(0, pos), wayId),());
@@ -49,12 +50,23 @@ public:
string oneLine;
while (getline(input, oneLine, '\n'))
{
+ // String format: <<lat;lon;id;is_capital>>.
+ // First ';'.
auto pos = oneLine.find(";");
- if (pos < oneLine.length())
+ if (pos != string::npos)
{
- uint64_t nodeId;
- if (strings::to_uint64(oneLine.substr(0, pos), nodeId))
- m_capitals.insert(nodeId);
+ // Second ';'.
+ pos = oneLine.find(";", pos + 1);
+ if (pos != string::npos)
+ {
+ uint64_t nodeId;
+ // Third ';'.
+ auto endPos = oneLine.find(";", pos + 1);
+ if (endPos == string::npos)
+ endPos = oneLine.length() - 1;
+ if (strings::to_uint64(oneLine.substr(pos + 1, endPos - pos), nodeId))
+ m_capitals.insert(nodeId);
+ }
}
}
}
@@ -88,7 +100,7 @@ public:
}
catch (ifstream::failure const &)
{
- LOG(LWARNING, ("Can't read the world level capitals file! Generating world without roads. Path:", capitalsFile));
+ LOG(LWARNING, ("Can't read the world level capitals file! Generating world without towns admixing. Path:", capitalsFile));
return;
}
}
diff --git a/generator/towns_dumper.hpp b/generator/towns_dumper.hpp
index 61ec3d9991..d0fa465517 100644
--- a/generator/towns_dumper.hpp
+++ b/generator/towns_dumper.hpp
@@ -6,6 +6,7 @@
#include "base/string_utils.hpp"
+#include "std/limits.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"
@@ -22,6 +23,7 @@ public:
uint64_t population = 1;
bool town = false;
bool capital = false;
+ int admin_level = numeric_limits<int>::max();
for (auto const & tag : em.Tags())
{
string key(tag.key), value(tag.value);
@@ -30,6 +32,11 @@ public:
if (!strings::to_uint64(value, population))
continue;
}
+ else if (key == "admin_level")
+ {
+ if (!strings::to_int(value, admin_level))
+ continue;
+ }
else if (key == "capital" && value == "yes")
{
capital = true;
@@ -39,6 +46,11 @@ public:
town = true;
}
}
+
+ // Ignore regional capitals.
+ if (capital && admin_level > 2)
+ capital = false;
+
if (town || capital)
m_records.emplace_back(em.lat, em.lon, em.id, capital, population);
}