MCPcopy Create free account
hub / github.com/comaps/comaps / CheckElement

Method CheckElement

generator/towns_dumper.cpp:60–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60void TownsDumper::CheckElement(OsmElement const & em)
61{
62 if (em.m_type != OsmElement::EntityType::Node)
63 return;
64
65 uint64_t population = 1;
66 bool town = false;
67 bool capital = false;
68
69 // OSM goes to moving admin_level tag into boundary=administrative relation only.
70 // So capital=yes should be enough for country capital.
71 int admin_level = -1;
72
73 for (auto const & tag : em.Tags())
74 {
75 auto const & key = tag.m_key;
76 auto const & value = tag.m_value;
77 if (key == "population")
78 UNUSED_VALUE(strings::to_uint64(value, population));
79 else if (key == "admin_level")
80 UNUSED_VALUE(strings::to_int(value, admin_level));
81 else if (key == "capital" && value == "yes")
82 capital = true;
83 else if (key == "place" && (value == "city" || value == "town"))
84 town = true;
85 }
86
87 // Ignore regional capitals.
88 if (capital && admin_level > 2)
89 capital = false;
90
91 if (town || capital)
92 m_records.emplace_back(em.m_lat, em.m_lon, em.m_id, capital, population);
93}
94
95void TownsDumper::Dump(std::string const & filePath)
96{

Callers 1

GenerateIntermediateDataFunction · 0.80

Calls 4

to_uint64Function · 0.85
to_intFunction · 0.85
TagsMethod · 0.80
emplace_backMethod · 0.45

Tested by

no test coverage detected