mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-24 02:41:15 +00:00
Decode Blake-style lists and hashes
This commit is contained in:
parent
bfc211adc7
commit
a5e1153bbd
6
mvt.cpp
6
mvt.cpp
@ -562,7 +562,7 @@ static std::string quote(std::string const &s) {
|
|||||||
|
|
||||||
std::string mvt_value::toString() const {
|
std::string mvt_value::toString() const {
|
||||||
if (type == mvt_string) {
|
if (type == mvt_string) {
|
||||||
return quote(string_value);
|
return std::string("\"") + quote(string_value) + "\"";
|
||||||
} else if (type == mvt_int) {
|
} else if (type == mvt_int) {
|
||||||
return std::to_string(numeric_value.int_value);
|
return std::to_string(numeric_value.int_value);
|
||||||
} else if (type == mvt_double) {
|
} else if (type == mvt_double) {
|
||||||
@ -585,6 +585,8 @@ std::string mvt_value::toString() const {
|
|||||||
return std::to_string(numeric_value.uint_value);
|
return std::to_string(numeric_value.uint_value);
|
||||||
} else if (type == mvt_bool) {
|
} else if (type == mvt_bool) {
|
||||||
return numeric_value.bool_value ? "true" : "false";
|
return numeric_value.bool_value ? "true" : "false";
|
||||||
|
} else if ((type == mvt_list || type == mvt_hash) && string_value.size() > 0) {
|
||||||
|
return string_value;
|
||||||
} else if (type == mvt_null) {
|
} else if (type == mvt_null) {
|
||||||
return "null";
|
return "null";
|
||||||
} else {
|
} else {
|
||||||
@ -982,7 +984,6 @@ mvt_value mvt_layer::decode_property(std::vector<unsigned long> const &property,
|
|||||||
if (((property[off] >> 4) & 1) == 0) {
|
if (((property[off] >> 4) & 1) == 0) {
|
||||||
ret.type = mvt_hash;
|
ret.type = mvt_hash;
|
||||||
size_t len = property[off] >> 5;
|
size_t len = property[off] >> 5;
|
||||||
fprintf(stderr, "hash %zu\n", len);
|
|
||||||
off++;
|
off++;
|
||||||
|
|
||||||
ret.string_value = "{";
|
ret.string_value = "{";
|
||||||
@ -1008,7 +1009,6 @@ mvt_value mvt_layer::decode_property(std::vector<unsigned long> const &property,
|
|||||||
} else {
|
} else {
|
||||||
ret.type = mvt_list;
|
ret.type = mvt_list;
|
||||||
size_t len = property[off] >> 5;
|
size_t len = property[off] >> 5;
|
||||||
fprintf(stderr, "array %zu\n", len);
|
|
||||||
off++;
|
off++;
|
||||||
|
|
||||||
ret.string_value = "[";
|
ret.string_value = "[";
|
||||||
|
@ -322,6 +322,9 @@ void stringify_val(std::string &out, mvt_feature const &feature, mvt_layer const
|
|||||||
} else if (val.type == mvt_bool) {
|
} else if (val.type == mvt_bool) {
|
||||||
out.append(val.numeric_value.bool_value ? "true" : "false");
|
out.append(val.numeric_value.bool_value ? "true" : "false");
|
||||||
} else if (val.type == mvt_list) {
|
} else if (val.type == mvt_list) {
|
||||||
|
if (val.string_value.size() != 0) {
|
||||||
|
out.append(val.string_value);
|
||||||
|
} else {
|
||||||
out.push_back('[');
|
out.push_back('[');
|
||||||
for (size_t i = 0; i < val.list_value.size(); i++) {
|
for (size_t i = 0; i < val.list_value.size(); i++) {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
@ -335,7 +338,11 @@ void stringify_val(std::string &out, mvt_feature const &feature, mvt_layer const
|
|||||||
stringify_val(out, feature, layer, layer.values[val.list_value[i]], val.list_value[i]);
|
stringify_val(out, feature, layer, layer.values[val.list_value[i]], val.list_value[i]);
|
||||||
}
|
}
|
||||||
out.push_back(']');
|
out.push_back(']');
|
||||||
|
}
|
||||||
} else if (val.type == mvt_hash) {
|
} else if (val.type == mvt_hash) {
|
||||||
|
if (val.string_value.size() != 0) {
|
||||||
|
out.append(val.string_value);
|
||||||
|
} else {
|
||||||
out.push_back('{');
|
out.push_back('{');
|
||||||
for (size_t i = 0; i + 1 < val.list_value.size(); i += 2) {
|
for (size_t i = 0; i + 1 < val.list_value.size(); i += 2) {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
@ -355,6 +362,7 @@ void stringify_val(std::string &out, mvt_feature const &feature, mvt_layer const
|
|||||||
stringify_val(out, feature, layer, layer.values[val.list_value[i + 1]], val.list_value[i + 1]);
|
stringify_val(out, feature, layer, layer.values[val.list_value[i + 1]], val.list_value[i + 1]);
|
||||||
}
|
}
|
||||||
out.push_back('}');
|
out.push_back('}');
|
||||||
|
}
|
||||||
} else if (val.type == mvt_null) {
|
} else if (val.type == mvt_null) {
|
||||||
out.append("null");
|
out.append("null");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user