From 0d22f3dfeb647a39e5ccdaea3a6425ae5e92312f Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Wed, 2 Apr 2025 14:00:56 -0700 Subject: [PATCH] Add test, fix default --- Makefile | 10 ++++++++++ overzoom.cpp | 4 ++-- tests/pbf/1.json | 3 +++ tests/pbf/2.json | 3 +++ tests/pbf/merged-dedup.pbf.json | 13 +++++++++++++ tests/pbf/merged-nodedup.pbf.json | 15 +++++++++++++++ 6 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/pbf/1.json create mode 100644 tests/pbf/2.json create mode 100644 tests/pbf/merged-dedup.pbf.json create mode 100644 tests/pbf/merged-nodedup.pbf.json diff --git a/Makefile b/Makefile index fc40467b..fefc84f5 100644 --- a/Makefile +++ b/Makefile @@ -443,6 +443,16 @@ overzoom-test: tippecanoe-overzoom ./tippecanoe-overzoom -o tests/pbf/squirrels-13-2413-3077-clip.pbf --clip-polygon-file tests/pbf/squirrels-clip.json tests/pbf/squirrels-13-2413-3077.pbf 13/2413/3077 13/2413/3077 cmp tests/pbf/squirrels-13-2413-3077-clip.pbf /dev/null # clipped away rm tests/pbf/squirrels-13-2413-3077-clip.pbf + # Deduplication by feature ID + ./tippecanoe -z0 -f -e tests/pbf/1.json.dir -l layer tests/pbf/1.json + ./tippecanoe -z0 -f -e tests/pbf/2.json.dir -l layer tests/pbf/2.json + ./tippecanoe-overzoom -o tests/pbf/merged-nodedup.pbf -t 0/0/0 tests/pbf/1.json.dir/0/0/0.pbf 0/0/0 tests/pbf/2.json.dir/0/0/0.pbf 0/0/0 + ./tippecanoe-decode tests/pbf/merged-nodedup.pbf 0 0 0 > tests/pbf/merged-nodedup.pbf.json.check + cmp tests/pbf/merged-nodedup.pbf.json.check tests/pbf/merged-nodedup.pbf.json + ./tippecanoe-overzoom --deduplicate-by-id -o tests/pbf/merged-dedup.pbf -t 0/0/0 tests/pbf/1.json.dir/0/0/0.pbf 0/0/0 tests/pbf/2.json.dir/0/0/0.pbf 0/0/0 + ./tippecanoe-decode tests/pbf/merged-dedup.pbf 0 0 0 > tests/pbf/merged-dedup.pbf.json.check + cmp tests/pbf/merged-dedup.pbf.json.check tests/pbf/merged-dedup.pbf.json + rm -r tests/pbf/1.json.dir tests/pbf/2.json.dir tests/pbf/merged-nodedup.pbf tests/pbf/merged-nodedup.pbf.json.check tests/pbf/merged-dedup.pbf.json.check join-test: tippecanoe tippecanoe-decode tile-join ./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:'Land area' -L'{"file": "tests/join-population/tabblock_06001420.json", "description": "population"}' diff --git a/overzoom.cpp b/overzoom.cpp index aa1be971..7fb4d6fd 100644 --- a/overzoom.cpp +++ b/overzoom.cpp @@ -19,7 +19,7 @@ int detail = 12; // tippecanoe-style: mvt extent == 1 << detail int buffer = 5; // tippecanoe-style: mvt buffer == extent * buffer / 256; bool demultiply = false; bool do_compress = true; -bool deduplicate_by_id = true; +bool deduplicate_by_id = false; std::string filter; bool preserve_input_order = false; @@ -95,7 +95,7 @@ int main(int argc, char **argv) { {"clip-bounding-box", required_argument, 0, 'k' & 0x1F}, {"clip-polygon", required_argument, 0, 'l' & 0x1F}, {"clip-polygon-file", required_argument, 0, 'm' & 0x1F}, - {"deduplicate-by-id", required_argument, 0, 'i' & 0x1F}, + {"deduplicate-by-id", no_argument, 0, 'i' & 0x1F}, {0, 0, 0, 0}, }; diff --git a/tests/pbf/1.json b/tests/pbf/1.json new file mode 100644 index 00000000..14e2e105 --- /dev/null +++ b/tests/pbf/1.json @@ -0,0 +1,3 @@ +{"type":"Feature","properties":{"what":"no id"},"geometry":{"type":"Point","coordinates":[0,0]}} +{"type":"Feature","id":12345,"properties":{"what":"will survive"},"geometry":{"type":"Point","coordinates":[0,0]}} +{"type":"Feature","id":12346,"properties":{"what":"will win over the duplicate"},"geometry":{"type":"Point","coordinates":[0,0]}} diff --git a/tests/pbf/2.json b/tests/pbf/2.json new file mode 100644 index 00000000..9506f22f --- /dev/null +++ b/tests/pbf/2.json @@ -0,0 +1,3 @@ +{"type":"Feature","properties":{"what":"no id again"},"geometry":{"type":"Point","coordinates":[0,0]}} +{"type":"Feature","id":12346,"properties":{"what":"will be lost as a duplicate"},"geometry":{"type":"Point","coordinates":[0,0]}} +{"type":"Feature","id":12347,"properties":{"what":"will be added"},"geometry":{"type":"Point","coordinates":[0,0]}} diff --git a/tests/pbf/merged-dedup.pbf.json b/tests/pbf/merged-dedup.pbf.json new file mode 100644 index 00000000..5727adba --- /dev/null +++ b/tests/pbf/merged-dedup.pbf.json @@ -0,0 +1,13 @@ +{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "layer", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "what": "no id" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "id": 12345, "properties": { "what": "will survive" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "id": 12346, "properties": { "what": "will win over the duplicate" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "what": "no id again" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "id": 12347, "properties": { "what": "will be added" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +] } +] } diff --git a/tests/pbf/merged-nodedup.pbf.json b/tests/pbf/merged-nodedup.pbf.json new file mode 100644 index 00000000..dfd65ab2 --- /dev/null +++ b/tests/pbf/merged-nodedup.pbf.json @@ -0,0 +1,15 @@ +{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [ +{ "type": "FeatureCollection", "properties": { "layer": "layer", "version": 2, "extent": 4096 }, "features": [ +{ "type": "Feature", "properties": { "what": "no id" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "id": 12345, "properties": { "what": "will survive" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "id": 12346, "properties": { "what": "will win over the duplicate" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "properties": { "what": "no id again" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "id": 12346, "properties": { "what": "will be lost as a duplicate" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +, +{ "type": "Feature", "id": 12347, "properties": { "what": "will be added" }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.000000 ] } } +] } +] }