From 900738dba14cf70f8837b6448c61c1bef0b491c5 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 14 Aug 2018 15:56:52 -0700 Subject: [PATCH] Pass compound objects through the prefilter --- tests/object/out/-Ccat_-z0.json | 18 ++++++++++++++++++ tile.cpp | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/object/out/-Ccat_-z0.json diff --git a/tests/object/out/-Ccat_-z0.json b/tests/object/out/-Ccat_-z0.json new file mode 100644 index 0000000..8e901a5 --- /dev/null +++ b/tests/object/out/-Ccat_-z0.json @@ -0,0 +1,18 @@ +{ "type": "FeatureCollection", "properties": { +"bounds": "0.000000,0.000000,0.000000,0.000000", +"center": "0.000000,0.000000,0", +"description": "tests/object/out/-Ccat_-z0.json.check.mbtiles", +"format": "pbf", +"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"compound\": \"Mixed\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 1,\"geometry\": \"Point\",\"attributeCount\": 1,\"attributes\": [{\"attribute\": \"compound\",\"count\": 1,\"type\": \"mixed\",\"values\": [\"{\\\"string\\\":\\\"string\\\",\\\"number\\\":10,\\\"null\\\":null,\\\"true\\\":true,\\\"false\\\":false,\\\"array\\\":[\\\"string\\\",10,null,true,false,[1,2,3],{\\\"this\\\":\\\"that\\\"}],\\\"emptylist\\\":[],\\\"emptyhash\\\":{},\\\"nest\\\":{\\\"something\\\":\\\"else\\\"}}\"]}]}]}}", +"maxzoom": "0", +"minzoom": "0", +"name": "tests/object/out/-Ccat_-z0.json.check.mbtiles", +"type": "overlay", +"version": "2" +}, "features": [ +{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "compound": {"string":"string","number":10,"null":null,"true":true,"false":false,"array":["string",10,null,true,false,[1,2,3],{"this":"that"}],"emptylist":[],"emptyhash":{},"nest":{"something":"else"}} }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +] } +] } +] } diff --git a/tile.cpp b/tile.cpp index 08663e1..a6bb9f8 100644 --- a/tile.cpp +++ b/tile.cpp @@ -2277,11 +2277,25 @@ long long write_tile(FILE *geoms, std::atomic *geompos_in, char *meta feature.has_id = layer_features[x].has_id; decode_meta(layer_features[x].keys, layer_features[x].values, layer_features[x].stringpool, layer, feature, true); + for (size_t a = 0; a < layer_features[x].full_keys.size(); a++) { serial_val sv = layer_features[x].full_values[a]; mvt_value v = stringified_to_mvt_value(sv.type, sv.s.c_str()); - if (v.type != mvt_null) { + if (v.type == mvt_hash) { + json_pull *jp = json_begin_string((char *) v.string_value.c_str()); + json_object *jo = json_read_tree(jp); + if (jo == NULL) { + fprintf(stderr, "Internal error: failed to reconstruct JSON %s\n", v.string_value.c_str()); + exit(EXIT_FAILURE); + } + size_t ko = layer.tag_key(layer_features[x].full_keys[a]); + size_t vo = tag_object(layer, jo); + feature.tags.push_back(ko); + feature.tags.push_back(vo); + json_free(jo); + json_end(jp); + } else if (v.type != mvt_null) { layer.tag(feature, layer_features[x].full_keys[a], v); } }