| 58 | } |
| 59 | |
| 60 | void 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 | |
| 95 | void TownsDumper::Dump(std::string const & filePath) |
| 96 | { |
no test coverage detected