Factor out duplicated tilestats code

This commit is contained in:
Eric Fischer
2017-07-19 14:45:15 -07:00
parent 7b03e1ee87
commit 3cafef89f1
4 changed files with 47 additions and 78 deletions
+8 -42
View File
@@ -154,28 +154,11 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::map<std::st
types.insert(std::pair<std::string, int>(key, type));
key_order.push_back(key);
auto st = file_keys->second.file_keys.find(key);
if (st == file_keys->second.file_keys.end()) {
file_keys->second.file_keys.insert(std::pair<std::string, type_and_string_stats>(key, type_and_string_stats()));
st = file_keys->second.file_keys.find(key);
}
type_and_string tas;
tas.type = type;
tas.string = value;
if (type == mvt_double) {
double d = atof(value.c_str());
if (d < st->second.min) {
st->second.min = d;
}
if (d > st->second.max) {
st->second.max = d;
}
}
if (st->second.sample_values.size() < 1000) {
type_and_string tas;
tas.type = type;
tas.string = value;
st->second.sample_values.insert(tas);
}
add_to_file_keys(file_keys->second.file_keys, key, tas);
}
if (header.size() > 0 && strcmp(key, header[0].c_str()) == 0) {
@@ -223,28 +206,11 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::map<std::st
types.insert(std::pair<std::string, int>(sjoinkey, attr_type));
key_order.push_back(sjoinkey);
auto st = file_keys->second.file_keys.find(joinkey);
if (st == file_keys->second.file_keys.end()) {
file_keys->second.file_keys.insert(std::pair<std::string, type_and_string_stats>(joinkey, type_and_string_stats()));
st = file_keys->second.file_keys.find(joinkey);
}
type_and_string tas;
tas.type = outval.type;
tas.string = joinval;
if (st->second.sample_values.size() < 1000) {
type_and_string tas;
tas.type = outval.type;
tas.string = joinval;
st->second.sample_values.insert(tas);
}
if (outval.type == mvt_double) {
double d = atof(joinval.c_str());
if (d < st->second.min) {
st->second.min = d;
}
if (d > st->second.max) {
st->second.max = d;
}
}
add_to_file_keys(file_keys->second.file_keys, joinkey, tas);
}
}
}