Skip to content

Commit 9e535f8

Browse files
committed
gazetteer OSM metadata: add another validation check, code cleanup
1 parent b280c9e commit 9e535f8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

gazetteer-style.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ gazetteer_style_t::flag_t gazetteer_style_t::parse_flags(std::string const &str)
128128
return out;
129129
}
130130

131-
bool gazetteer_style_t::add_metadata_style_entry(std::string const &key,
132-
std::string const &value)
131+
bool gazetteer_style_t::add_metadata_style_entry(std::string const &key)
133132
{
134133
if (key == "osm_version") {
135134
m_metadata_fields.set_version(true);
@@ -190,11 +189,16 @@ void gazetteer_style_t::add_style_entry(std::string const &key,
190189
}
191190
}
192191

193-
if (add_metadata_style_entry(key, value)) {
192+
if (add_metadata_style_entry(key)) {
194193
if (!value.empty()) {
195194
throw std::runtime_error("Style error. Rules for OSM metadata "
196195
"attributes must have an empty value.\n");
197196
}
197+
if (flags != SF_EXTRA) {
198+
throw std::runtime_error("Style error. Rules for OSM metadata "
199+
"attributes must have the style flag "
200+
"\"extra\" and no other flag.\n");
201+
}
198202
return;
199203
}
200204
if (value.empty()) {

gazetteer-style.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ class gazetteer_style_t
6868
bool has_data() const { return !m_main.empty(); }
6969

7070
private:
71-
bool add_metadata_style_entry(std::string const &key,
72-
std::string const &value);
71+
bool add_metadata_style_entry(std::string const &key);
7372
void add_style_entry(std::string const &key, std::string const &value,
7473
flag_t flags);
7574
flag_t parse_flags(std::string const &str);

0 commit comments

Comments
 (0)