From 3f802920bb77eda8dae5420348ceaecc1cb21c6c Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Mon, 21 Nov 2022 13:52:09 -0800 Subject: [PATCH] Add a test target for flatgeobuf --- Makefile | 12 +++++++++++- main.cpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index abbc1446..aa9761e4 100644 --- a/Makefile +++ b/Makefile @@ -98,9 +98,10 @@ suffixes = json json.gz # Don't test stringids with geobuf, because it fails nogeobuf = tests/overflow/out/-z0.json $(wildcard tests/stringid/out/*.json) geobuf-test: tippecanoe-json-tool $(addsuffix .checkbuf,$(filter-out $(nogeobuf),$(TESTS))) +flatgeobuf-test: tippecanoe-json-tool $(addsuffix .checkflatbuf,$(filter-out $(nogeobuf),$(TESTS))) # For quicker address sanitizer build, hope that regular JSON parsing is tested enough by parallel and join tests -fewer-tests: tippecanoe tippecanoe-decode geobuf-test raw-tiles-test parallel-test pbf-test join-test enumerate-test decode-test join-filter-test unit +fewer-tests: tippecanoe tippecanoe-decode flatgeobuf-test geobuf-test raw-tiles-test parallel-test pbf-test join-test enumerate-test decode-test join-filter-test unit # XXX Use proper makefile rules instead of a for loop %.json.checkbuf: @@ -111,6 +112,15 @@ fewer-tests: tippecanoe tippecanoe-decode geobuf-test raw-tiles-test parallel-te cmp $@.out $(patsubst %.checkbuf,%,$@) rm $@.out $@.mbtiles +# XXX Use proper makefile rules instead of a for loop +%.json.checkflatbuf: + for i in $(wildcard $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/*.json); do rm -f $$i.fgb; ogr2ogr -preserve_fid $$i.fgb $$i; done + for i in $(wildcard $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/*.json.gz); do rm -f $$i.fgb; gzip -dc $$i > /tmp/$$.json && ogr2ogr -preserve_fid $$i.fgb /tmp/$$i.json; done + ./tippecanoe -q -a@ -f -o $@.mbtiles $(subst @,:,$(subst %,/,$(subst _, ,$(patsubst %.json.checkflatbuf,%,$(word 4,$(subst /, ,$@)))))) $(foreach suffix,$(suffixes),$(addsuffix .fgb,$(sort $(wildcard $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/*.$(suffix))))) < /dev/null + ./tippecanoe-decode -x generator $@.mbtiles | sed 's/checkflatbuf/check/g' | sed 's/\.fgb//g' > $@.out + cmp $@.out $(patsubst %.checkflatbuf,%,$@) + rm $@.out $@.mbtiles + parallel-test: mkdir -p tests/parallel perl -e 'for ($$i = 0; $$i < 20; $$i++) { $$lon = rand(360) - 180; $$lat = rand(180) - 90; $$k = rand(1); $$v = rand(1); print "{ \"type\": \"Feature\", \"properties\": { \"yes\": \"no\", \"who\": 1, \"$$k\": \"$$v\" }, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ $$lon, $$lat ] } }\n"; }' > tests/parallel/in1.json diff --git a/main.cpp b/main.cpp index 7f5dc54c..0c49711a 100644 --- a/main.cpp +++ b/main.cpp @@ -1288,6 +1288,7 @@ int read_input(std::vector &sources, char *fname, int maxzoom, int minzo std::vector trim = { ".json", ".geojson", + ".fgb", ".geobuf", ".mbtiles", ".csv",