From 932c524ebc9766713fb07941ca6f421e226d51bb Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Thu, 25 Aug 2022 12:20:58 -0700 Subject: [PATCH] Guard against duplicate points when generating "sizes" for them --- tests/attribute-type/out/-z0_-pN.json | 95 +++++++++++++++++++++++++++ tile.cpp | 11 +++- 2 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 tests/attribute-type/out/-z0_-pN.json diff --git a/tests/attribute-type/out/-z0_-pN.json b/tests/attribute-type/out/-z0_-pN.json new file mode 100644 index 00000000..db45e1d9 --- /dev/null +++ b/tests/attribute-type/out/-z0_-pN.json @@ -0,0 +1,95 @@ +{ "type": "FeatureCollection", "properties": { +"bounds": "0.000000,0.000000,0.000000,0.000000", +"center": "0.000000,0.000000,0", +"description": "tests/attribute-type/out/-z0_-pN.json.check.mbtiles", +"format": "pbf", +"generator_options": "./tippecanoe -q -a@ -f -o tests/attribute-type/out/-z0_-pN.json.check.mbtiles -z0 -pN tests/attribute-type/in.json", +"json": "{\"vector_layers\": [ { \"id\": \"in\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {\"booltype\": \"Mixed\", \"expect\": \"Mixed\", \"floattype\": \"Mixed\", \"inttype\": \"Mixed\", \"stringtype\": \"Mixed\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"in\",\"count\": 39,\"geometry\": \"Point\",\"attributeCount\": 5,\"attributes\": [{\"attribute\": \"booltype\",\"count\": 10,\"type\": \"mixed\",\"values\": [\"\",\"0\",0,1,\"[2,3]\",\"false\",false,\"null\",true,\"yes\"],\"min\": 0,\"max\": 1},{\"attribute\": \"expect\",\"count\": 14,\"type\": \"mixed\",\"values\": [0,\"2\",\"2.5\",3,5,5.599999904632568,6,\"[2,3]\",\"false\",false,\"null\",\"something\",\"true\",true],\"min\": 0,\"max\": 6},{\"attribute\": \"floattype\",\"count\": 9,\"type\": \"mixed\",\"values\": [\"\",\" 3\",\"5\",5.599999904632568,\"5.6\",\"[2,3]\",false,true,\"yes\"],\"min\": 5.599999904632568,\"max\": 5.599999904632568},{\"attribute\": \"inttype\",\"count\": 9,\"type\": \"mixed\",\"values\": [\"\",\" 3\",\"5\",5.599999904632568,\"5.6\",\"[2,3]\",false,true,\"yes\"],\"min\": 5.599999904632568,\"max\": 5.599999904632568},{\"attribute\": \"stringtype\",\"count\": 6,\"type\": \"mixed\",\"values\": [2,2.5,\"[2,3]\",false,\"something\",true],\"min\": 2,\"max\": 2.5}]}]}}", +"maxzoom": "0", +"minzoom": "0", +"name": "tests/attribute-type/out/-z0_-pN.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": { "expect": false }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": "null", "expect": false }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": "", "expect": false }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": 0, "expect": false }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": "0", "expect": false }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": false, "expect": false }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": "false", "expect": false }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": true, "expect": true }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": 1, "expect": true }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": 0, "expect": false }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": "yes", "expect": true }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "booltype": "[2,3]", "expect": true }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "expect": "null" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "stringtype": 2, "expect": "2" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "stringtype": 2.5, "expect": "2.5" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "stringtype": true, "expect": "true" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "stringtype": false, "expect": "false" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "stringtype": "something", "expect": "something" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "stringtype": "[2,3]", "expect": "[2,3]" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "inttype": "5", "expect": 5 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "inttype": "5.6", "expect": 6 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "inttype": 5.599999904632568, "expect": 6 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "inttype": true, "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "inttype": false, "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "inttype": "", "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "inttype": "yes", "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "inttype": " 3", "expect": 3 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "inttype": "[2,3]", "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "floattype": "5", "expect": 5 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "floattype": "5.6", "expect": 5.599999904632568 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "floattype": 5.599999904632568, "expect": 5.599999904632568 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "floattype": true, "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "floattype": false, "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "floattype": "", "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "floattype": "yes", "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "floattype": " 3", "expect": 3 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "floattype": "[2,3]", "expect": 0 }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +] } +] } +] } diff --git a/tile.cpp b/tile.cpp index 1affa8ee..2625c0cf 100644 --- a/tile.cpp +++ b/tile.cpp @@ -1876,8 +1876,15 @@ long long write_tile(FILE *geoms, std::atomic *geompos_in, char *meta } if (sf.t == VT_POINT) { - double radius = sqrt(sf.index - extent_previndex) / 4.0; - sf.extent = M_PI * radius * radius; + if (extent_previndex >= sf.index) { + sf.extent = 1; + } else { + double radius = sqrt(sf.index - extent_previndex) / 4.0; + sf.extent = M_PI * radius * radius; + if (sf.extent < 1) { + sf.extent = 1; + } + } extent_previndex = sf.index; }