Work in the direction of tracking representative attribute values

This commit is contained in:
Eric Fischer
2017-07-14 17:59:24 -07:00
parent 62ee53992b
commit 7445feb845
2 changed files with 19 additions and 5 deletions
+13
View File
@@ -349,6 +349,7 @@ int serialize_geometry(json_object *geometry, json_object *properties, json_obje
metakey[m] = properties->keys[i]->string; metakey[m] = properties->keys[i]->string;
bool track = false;
if (properties->values[i] != NULL) { if (properties->values[i] != NULL) {
int vt = properties->values[i]->type; int vt = properties->values[i]->type;
std::string val; std::string val;
@@ -407,20 +408,24 @@ int serialize_geometry(json_object *geometry, json_object *properties, json_obje
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
m++; m++;
track = true;
} else if (vt == JSON_NUMBER) { } else if (vt == JSON_NUMBER) {
tas.type = metatype[m] = mvt_double; tas.type = metatype[m] = mvt_double;
metaval[m] = val; metaval[m] = val;
m++; m++;
track = true;
} else if (vt == JSON_TRUE || vt == JSON_FALSE) { } else if (vt == JSON_TRUE || vt == JSON_FALSE) {
tas.type = metatype[m] = mvt_bool; tas.type = metatype[m] = mvt_bool;
metaval[m] = val; metaval[m] = val;
m++; m++;
track = true;
} else if (vt == JSON_NULL) { } else if (vt == JSON_NULL) {
; ;
} else { } else {
tas.type = metatype[m] = mvt_string; tas.type = metatype[m] = mvt_string;
metaval[m] = val; metaval[m] = val;
m++; m++;
track = true;
} }
} }
@@ -428,6 +433,14 @@ int serialize_geometry(json_object *geometry, json_object *properties, json_obje
auto fk = layermap->find(layername); auto fk = layermap->find(layername);
fk->second.file_keys.insert(tas); fk->second.file_keys.insert(tas);
} }
if (track) {
type_and_string attrib;
attrib.type = metatype[m - 1];
attrib.string = metaval[m - 1];
// XXX increment in type_and_string_stats.sample_values
}
} }
} }
+6 -5
View File
@@ -8,17 +8,18 @@ struct type_and_string {
int type; int type;
std::string string; std::string string;
size_t attribute_count = 0; bool operator<(const type_and_string &o) const;
std::set<mvt_value> sample_values; };
struct type_and_string_stats {
std::set<type_and_string> sample_values;
double min = INFINITY; double min = INFINITY;
double max = -INFINITY; double max = -INFINITY;
bool operator<(const type_and_string &o) const;
}; };
struct layermap_entry { struct layermap_entry {
size_t id; size_t id;
std::set<type_and_string> file_keys; std::set<type_and_string> file_keys; // XXX map to type_and_string_stats
int minzoom; int minzoom;
int maxzoom; int maxzoom;