Factor out conversion from JSON types to vector tile attribute types

This commit is contained in:
Eric Fischer
2016-12-07 16:17:17 -08:00
parent 5554b9cbba
commit 3f14a0dd55
7 changed files with 118 additions and 107 deletions
+6 -12
View File
@@ -182,20 +182,14 @@ mvt_layer parse_layer(int fd, unsigned z, unsigned x, unsigned y, mvt_layer cons
}
for (size_t i = 0; i < properties->length; i++) {
mvt_value v;
int tp = -1;
std::string s;
// XXX reconcile with JSON property parsing
if (properties->values[i]->type == JSON_STRING) {
v.type = mvt_string;
v.string_value = std::string(properties->values[i]->string);
} else if (properties->values[i]->type == JSON_NUMBER) {
v.type = mvt_double;
v.numeric_value.double_value = atof(properties->values[i]->string);
} else {
continue;
stringify_value(properties->values[i], tp, s, "Filter output", jp->line, j);
if (tp >= 0) {
mvt_value v = stringified_to_mvt_value(tp, s.c_str());
ret.tag(feature, std::string(properties->keys[i]->string), v);
}
ret.tag(feature, std::string(properties->keys[i]->string), v);
}
ret.features.push_back(feature);