mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Factor out duplicated tilestats code
This commit is contained in:
+8
-42
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user