Compare commits

..
Author SHA1 Message Date
Erica Fischer ff48cbc76b Restore deleted closing brace 2026-07-31 12:35:57 -07:00
Erica FischerandCopilot Autofix powered by AI 0d243dab1e Remember to delete the temporary files
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-31 12:30:11 -07:00
Erica FischerandCopilot Autofix powered by AI fed221b283 Guard against treating index 0 as a duplicate
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-31 12:29:54 -07:00
Erica Fischer 0ae79d72ec Merge remote-tracking branch 'origin/main' into distiguish-duplicates-merge 2026-07-31 11:27:03 -07:00
Erica Fischer fc40c66551 Bump version and changelog 2025-05-21 14:28:17 -07:00
Erica Fischer f4a58f2805 It's a better test with no feature dropping by rate 2025-05-21 13:18:01 -07:00
Erica Fischer f4717f765c Add more error checks 2025-05-21 12:06:08 -07:00
Erica Fischer f7fb0686de Add documentation 2025-05-21 11:36:21 -07:00
Erica Fischer 36907b5bb2 Add test 2025-05-21 11:14:10 -07:00
Erica Fischer 3ab86d8a7b Only defer duplicates in the first zoom. Limit deferral depth.
Make tmpdir a global to keep from needing to pass it around
2025-05-21 11:01:32 -07:00
Erica Fischer d207d2628a Make it a command-line option 2025-05-20 12:23:03 -07:00
Erica Fischer 7bc75e6050 Reconstitute the deferred features after the main reader loop is done 2025-05-20 12:17:24 -07:00
Erica Fischer 918c57d52d Detect and defer duplicates 2025-05-20 12:05:30 -07:00
30 changed files with 3233 additions and 9532 deletions
-17
View File
@@ -19,20 +19,3 @@ jobs:
run: brew install sqlite3
- run: uname -a; BUILDTYPE=${{ matrix.version }} make
- run: make test
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Pinned, because different go-md2man versions produce different roff
# for the same input, which would make this check fail spuriously.
- name: Install go-md2man
run: go install github.com/cpuguy83/go-md2man/v2@v2.0.7
- name: Regenerate the man page
run: PATH="$PATH:$(go env GOPATH)/bin" make -B docs
- name: Check that the man page is up to date with README.md
run: |
git diff --exit-code man/tippecanoe.1 || {
echo "::error::man/tippecanoe.1 is out of date. Run 'make docs' and commit the result."
exit 1
}
-3
View File
@@ -38,9 +38,6 @@ tippecanoe-json-tool
tippecanoe-overzoom
unit
# Left behind if man page generation fails
man/tippecanoe.1.tmp
# Tests
tests/**/*.mbtiles
tests/**/*.check
+1 -65
View File
@@ -1,70 +1,6 @@
# 2.81.0
* Add `--drop-by-attribute-as-needed=`*attribute* to drop the features with
the lowest values of a numeric attribute from oversized tiles, and
`--drop-by-attribute-order=desc` to drop the highest values instead.
Features exactly at the threshold are kept rather than dropped. (#384, #385)
* Add `--exclude-all-tile-geometries` to tile-join, to produce tiles that
carry only attributes. (#382)
* Generate each tool's usage message from the same option table that
`getopt_long()` reads, so the hand-written lists in tile-join,
tippecanoe-overzoom, tippecanoe-json-tool, tippecanoe-decode, and
tippecanoe-enumerate can no longer fall behind the options actually
accepted. Options previously reachable only by their short names are now
listed. tippecanoe-overzoom reports a missing `-o` instead of passing a
null pointer to `fopen()`, and tippecanoe prints its usage when run with
no arguments. (#409)
* Fix the radix sort used by `--prefer-radix-sort`. A bucket written out
directly rather than through the merge was written one byte longer than
its length prefix claimed, desynchronizing everything read from the
geometry after it. Subdividing could also recurse forever once it ran out
of files to split with, shifting by the full width of the index and
writing past the end of the arrays of buckets. Radix-sorted output is now
checked against the in-memory sort rather than against a stored copy. (#404)
* Read FlatGeobuf integer and float properties as numbers. They were tagged
with types that the rest of tippecanoe does not treat as numeric, so they
were reported in tilestats as "mixed", with quoted values and no min or
max, and warned when used as a feature ID. ULong properties are now also
read as unsigned rather than signed. (#395)
* Respect the `-t` temporary directory option in sorting operations, which
previously always used the system temporary directory. (#368)
* Keep `--generate-variable-depth-tile-pyramid` from silently dropping
features whose explicit per-feature `minzoom` is deeper than the zoom at
which their region becomes a leaf. Such a feature was excluded from the
leaf tile while its children were never generated, so it appeared at no
zoom at all. (#397, #399)
* Drop a polygon hole that no remaining ring can parent, instead of failing
the whole run. Degenerate input could abort tiling over a single
unrepresentable sliver. (#401)
* Clamp the feature extent to the `long long` range before converting it,
at both ends. The previous `extent <= LLONG_MAX` guard was doubly wrong:
`LLONG_MAX` is not representable as a double and rounds up, so an extent
at the very top of the range overflowed the conversion and came out as the
most negative value rather than the largest, and the guard admitted
everything below `LLONG_MIN` as well, which overflowed the other way. Areas
are signed, so holes that outweigh their rings can reach the low end. (#406)
* Initialize the full width of the `mvt_value` numeric union, which left the
bytes of the wider unused member indeterminate even though the implicit
copy constructor copies the union as a whole. (#406)
* Replace all variable-length arrays with `std::vector` and `std::string`,
and build with `-Wvla`. VLAs are a compiler extension rather than standard
C++, and clang warns about every one of them by default. (#406)
* Remove the unused Dockerfiles, Travis configuration, and lambda
directory. (#365)
* Correct README statements that disagreed with the code. Among them, `-aD`
and `-aS` were documented the wrong way round,
`--limit-base-zoom-to-maximum-zoom` was given as `-Pb` rather than `-pb`,
and the dot-dropping description had both the fraction and the zoom
direction backwards: tippecanoe keeps 1/2.5 of the dots at zooms below the
base zoom, rather than dropping that share above it. (#410)
* Generate `man/tippecanoe.1` with go-md2man rather than md2man-roff, which
is packaged only as a Ruby gem and so had let the page drift out of date.
The page now has a proper header and a NAME section, so `man -k` and
`whatis` can find it, and no longer silently drops or mangles text the old
converter mishandled. CI checks it against README.md. (#408)
* Documentation fixes: correct three misspellings in the README and man
page, repair the dead All Streets link, and tag more README code blocks
with their language. (#375, #391, #400)
* Add --distinguish-duplicates option
# 2.80.0
+15 -89
View File
@@ -11,7 +11,7 @@ CXX := $(CXX)
CFLAGS := $(CFLAGS) -fPIE -DBUILD_INFO=$(BUILD_INFO)
CXXFLAGS := $(CXXFLAGS) -std=c++17 -fPIE -DBUILD_INFO=$(BUILD_INFO)
LDFLAGS := $(LDFLAGS)
WARNING_FLAGS := -Wall -Wshadow -Wsign-compare -Wextra -Wunreachable-code -Wuninitialized -Wshadow -Wvla
WARNING_FLAGS := -Wall -Wshadow -Wsign-compare -Wextra -Wunreachable-code -Wuninitialized -Wshadow
RELEASE_FLAGS := -O3 -DNDEBUG
DEBUG_FLAGS := -O0 -DDEBUG -fno-inline-functions -fno-omit-frame-pointer
@@ -48,44 +48,8 @@ install: tippecanoe tippecanoe-enumerate tippecanoe-decode tile-join tippecanoe-
uninstall:
rm $(PREFIX)/bin/tippecanoe $(PREFIX)/bin/tippecanoe-enumerate $(PREFIX)/bin/tippecanoe-decode $(PREFIX)/bin/tile-join $(MANDIR)/tippecanoe.1 $(PREFIX)/bin/tippecanoe-json-tool
# The man page is generated from README.md by go-md2man, which is packaged for
# most systems (`brew install go-md2man`, `apt-get install go-md2man`) or can be
# built with `go install github.com/cpuguy83/go-md2man/v2@v2.0.7`. CI checks that
# the committed man page matches the README, so you don't have to regenerate it
# yourself if you don't have go-md2man installed.
#
# README.md has no .TH or NAME section of its own, since neither would make sense
# on GitHub, so prepend them here. go-md2man reads the leading "%" line as the
# man page's title, section, date, and source. The version deliberately doesn't
# appear there: it would make this page a build product of version.hpp, so every
# release would have to regenerate it just to rewrite that one line, and the docs
# CI job would fail on any version bump that forgot to.
#
# Two fixups on the way out:
#
# - README.md's own title heading becomes the second .SH, right below the NAME
# section added above, which reads as a stray "tippecanoe" section. Rename it
# to DESCRIPTION, where the text under it belongs anyway.
# - go-md2man separates paragraphs with a blank line in addition to the .PP
# macro, and a blank line is itself a break in roff, so the two together
# double-space the whole page. Drop them, except within .EX and .TS blocks,
# where a blank line is part of the example or table rather than spacing.
man/tippecanoe.1: README.md
{ \
echo '% TIPPECANOE 1 "" "tippecanoe"'; \
echo; \
echo '# NAME'; \
echo; \
echo 'tippecanoe - build vector tilesets from GeoJSON, FlatGeobuf, or CSV features'; \
echo; \
cat README.md; \
} | go-md2man \
| awk ' \
/^\.SH / && ++sh == 2 { print ".SH DESCRIPTION"; next } \
/^\.(EX|TS)$$/ { lit = 1 } \
/^\.(EE|TE)$$/ { lit = 0 } \
lit || !/^$$/ \
' > $@.tmp && mv $@.tmp $@
md2man-roff README.md > man/tippecanoe.1
PG=
@@ -95,25 +59,25 @@ C = $(wildcard *.c) $(wildcard *.cpp)
INCLUDES = -I/usr/local/include -I. -Iclipper2/include
LIBS = -L/usr/local/lib
tippecanoe: geojson.o jsonpull/jsonpull.o tile.o pool.o mbtiles.o geometry.o projection.o memfile.o mvt.o serial.o main.o platform.o text.o dirtiles.o pmtiles_file.o plugin.o read_json.o write_json.o geobuf.o flatgeobuf.o evaluator.o geocsv.o csv.o geojson-loop.o json_logger.o visvalingam.o compression.o clip.o sort.o attribute.o thread.o shared_borders.o usage.o clipper2/src/clipper.engine.o
tippecanoe: geojson.o jsonpull/jsonpull.o tile.o pool.o mbtiles.o geometry.o projection.o memfile.o mvt.o serial.o main.o platform.o text.o dirtiles.o pmtiles_file.o plugin.o read_json.o write_json.o geobuf.o flatgeobuf.o evaluator.o geocsv.o csv.o geojson-loop.o json_logger.o visvalingam.o compression.o clip.o sort.o attribute.o thread.o shared_borders.o clipper2/src/clipper.engine.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-enumerate: enumerate.o usage.o
tippecanoe-enumerate: enumerate.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lsqlite3
tippecanoe-decode: decode.o projection.o mvt.o write_json.o text.o jsonpull/jsonpull.o dirtiles.o pmtiles_file.o usage.o
tippecanoe-decode: decode.o projection.o mvt.o write_json.o text.o jsonpull/jsonpull.o dirtiles.o pmtiles_file.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3
tile-join: tile-join.o platform.o projection.o mbtiles.o mvt.o memfile.o dirtiles.o jsonpull/jsonpull.o text.o evaluator.o csv.o write_json.o pmtiles_file.o clip.o attribute.o thread.o read_json.o usage.o clipper2/src/clipper.engine.o
tile-join: tile-join.o platform.o projection.o mbtiles.o mvt.o memfile.o dirtiles.o jsonpull/jsonpull.o text.o evaluator.o csv.o write_json.o pmtiles_file.o clip.o attribute.o thread.o read_json.o clipper2/src/clipper.engine.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o usage.o
tippecanoe-json-tool: jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
unit: unit.o text.o sort.o mvt.o projection.o clip.o attribute.o jsonpull/jsonpull.o evaluator.o read_json.o clipper2/src/clipper.engine.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o text.o attribute.o read_json.o projection.o read_json.o usage.o clipper2/src/clipper.engine.o
tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o text.o attribute.o read_json.o projection.o read_json.o clipper2/src/clipper.engine.o
$(CXX) $(PG) $(LIBS) $(FINAL_FLAGS) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) -lm -lz -lsqlite3 -lpthread
-include $(wildcard *.d)
@@ -133,7 +97,7 @@ indent:
TESTS = $(wildcard tests/*/out/*.json)
SPACE = $(NULL) $(NULL)
test: tippecanoe tippecanoe-decode $(addsuffix .check,$(TESTS)) raw-tiles-test parallel-test radix-sort-test pbf-test join-test enumerate-test decode-test join-filter-test unit json-tool-test allow-existing-test csv-test layer-json-test pmtiles-test decode-pmtiles-test overzoom-test flatgeobuf-test
test: tippecanoe tippecanoe-decode $(addsuffix .check,$(TESTS)) raw-tiles-test parallel-test pbf-test join-test enumerate-test decode-test join-filter-test unit json-tool-test allow-existing-test csv-test layer-json-test pmtiles-test decode-pmtiles-test overzoom-test flatgeobuf-test
./unit
suffixes = json json.gz
@@ -144,7 +108,6 @@ suffixes = json json.gz
# %22 for quoted quote
# %2f for /
# %3a for :
# %3d for =
# %5f for _
# %7b for {
@@ -152,11 +115,10 @@ testargs = \
$(subst %20,' ',\
$(subst %22,'"',\
$(subst %3a,:,\
$(subst %3d,=,\
$(subst %2f,/,\
$(subst %7b,'{',\
$(subst %5f,'_',\
$(subst _, ,$(1)))))))))
$(subst %2f,/,\
$(subst %7b,'{',\
$(subst %5f,'_',\
$(subst _, ,$(1))))))))
%.json.check:
./tippecanoe -q -a@ -f -o $@.mbtiles $(call testargs,$(patsubst %.json.check,%,$(word 4,$(subst /, ,$@)))) $(foreach suffix,$(suffixes),$(sort $(wildcard $(subst $(SPACE),/,$(wordlist 1,2,$(subst /, ,$@)))/*.$(suffix)))) < /dev/null
@@ -170,7 +132,7 @@ nogeobuf = tests/overflow/out/-z0.json $(wildcard tests/stringid/out/*.json)
geobuf-test: tippecanoe-json-tool $(addsuffix .checkbuf,$(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 radix-sort-test pbf-test join-test enumerate-test decode-test join-filter-test unit
fewer-tests: tippecanoe tippecanoe-decode 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:
@@ -181,42 +143,6 @@ fewer-tests: tippecanoe tippecanoe-decode geobuf-test raw-tiles-test parallel-te
cmp $@.out $(patsubst %.checkbuf,%,$@)
rm $@.out $@.mbtiles
# The result of the sort must not depend on how the sort was performed, so instead of
# checking the sorted output against an expected copy of it, check that sorting by radix
# produces the same tiles as sorting in memory. --prefer-radix-sort lowers the memory
# limit to 8K, which radix() then halves again, so the radix subdivision has to recurse
# until each bucket is under 4K. How deeply that recurses depends on how many files the
# machine will let us open at once, but the sorted result is the same either way, so
# this comparison doesn't depend on that.
#
# What sends the sort down its rarely-taken paths is the shape of the input rather than
# the size of it: a feature whose geometry alone is bigger than the memory limit is
# sorted as a bucket of its own, and features that share a long run of leading index
# bits have to be subdivided until there are no bits left. The first two inputs are
# each one of those on purpose -- several separated features too big to sort in memory,
# and many features at one location -- and the rest are for breadth.
radix-sort-test: tippecanoe tippecanoe-decode
mkdir -p tests/radix-sort
perl -e 'for ($$f = 0; $$f < 8; $$f++) { print "{ \"type\": \"Feature\", \"properties\": { \"f\": $$f }, \"geometry\": { \"type\": \"LineString\", \"coordinates\": ["; for ($$i = 0; $$i < 2000; $$i++) { print "," unless $$i == 0; printf "[%f,%f]", $$f * 40 - 175 + $$i * 0.001, $$i % 2 * 0.5 - 20; } print "] } }\n"; }' > tests/radix-sort/bigfeatures.json
perl -e 'for ($$i = 0; $$i < 500; $$i++) { print "{ \"type\": \"Feature\", \"properties\": { \"i\": $$i }, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ 17, 42 ] } }\n"; }' > tests/radix-sort/onelocation.json
$(MAKE) radix-sort-compare RADIXIN="tests/radix-sort/bigfeatures.json" RADIXARGS="-z4"
$(MAKE) radix-sort-compare RADIXIN="tests/radix-sort/onelocation.json" RADIXARGS="-z4"
$(MAKE) radix-sort-compare RADIXIN="tests/feature-filter/in.json" RADIXARGS="-z4"
$(MAKE) radix-sort-compare RADIXIN="tests/ne_110m_ocean/in.json" RADIXARGS="-z4"
$(MAKE) radix-sort-compare RADIXIN="tests/border/in.json" RADIXARGS="-z4"
$(MAKE) radix-sort-compare RADIXIN="tests/loop/in.json" RADIXARGS="-z4"
$(MAKE) radix-sort-compare RADIXIN="tests/tl_2022_11_tract/in.json.gz" RADIXARGS="-z4"
$(MAKE) radix-sort-compare RADIXIN="tests/epsg-3857/in.json" RADIXARGS="-z4 -sEPSG:3857"
rm -r tests/radix-sort
radix-sort-compare:
./tippecanoe -q -f $(RADIXARGS) -o tests/radix-sort/memory.mbtiles $(RADIXIN)
./tippecanoe -q -f $(RADIXARGS) -aR -o tests/radix-sort/radix.mbtiles $(RADIXIN)
./tippecanoe-decode -x generator -x generator_options -x name -x description tests/radix-sort/memory.mbtiles > tests/radix-sort/memory.json
./tippecanoe-decode -x generator -x generator_options -x name -x description tests/radix-sort/radix.mbtiles > tests/radix-sort/radix.json
cmp tests/radix-sort/memory.json tests/radix-sort/radix.json
rm tests/radix-sort/memory.mbtiles tests/radix-sort/radix.mbtiles tests/radix-sort/memory.json tests/radix-sort/radix.json
parallel-test: $(eval SHELL:=$(ADVSHELL))
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
@@ -440,7 +366,7 @@ overzoom-test: tippecanoe-overzoom
./tippecanoe-overzoom -b0 --deduplicate-by-id -o tests/pbf/merged-dedup.pbf -t 1/1/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 1 1 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 tests/pbf/merged-dedup.pbf.json.check
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"}'
+37 -74
View File
@@ -58,7 +58,7 @@ Usage
-----
```
$ tippecanoe -o file.mbtiles [options] [file.json file.json.gz file.fgb file.csv ...]
$ tippecanoe -o file.mbtiles [options] [file.json file.json.gz file.fgb ...]
```
If no files are specified, it reads GeoJSON from the standard input.
@@ -291,11 +291,6 @@ If your features have a lot of attributes, use `-y` to keep only the ones you re
If your input is formatted as newline-delimited GeoJSON, use `-P` to make input parsing a lot faster.
Many of the options below have a short form beginning with `-a` or `-p`. These are the
`-a`_letters_ (`--additional=`_letters_) and `-p`_letters_ (`--prevent=`_letters_) options, and each
accepts several letters at once, so for example `-ansd` is the same as `-an -as -ad`
and `-pkC` is the same as `-pk -pC`.
### Output tileset
* `-o` _file_`.mbtiles`, _file_`.pmtiles` or `--output=`_file_`.mbtiles`: Name the output file.
@@ -306,9 +301,9 @@ and `-pkC` is the same as `-pk -pC`.
### Tileset description and attribution
* `-n` _name_ or `--name=`_name_: Human-readable name for the tileset (default: the name of the output file or directory)
* `-n` _name_ or `--name=`_name_: Human-readable name for the tileset (default file.json)
* `-A` _text_ or `--attribution=`_text_: Attribution (HTML) to be shown with maps that use data from this tileset.
* `-N` _description_ or `--description=`_description_: Description for the tileset (default: the name of the output file or directory)
* `-N` _description_ or `--description=`_description_: Description for the tileset (default file.mbtiles)
### Input files and layer names
@@ -325,7 +320,7 @@ and `-pkC` is the same as `-pk -pC`.
tippecanoe -z5 -o world.mbtiles -L'{"file":"ne_10m_admin_0_countries.json", "layer":"countries", "description":"Natural Earth countries"}'
```
CSV input files currently support only Point geometries, from columns named `lat`, `lon`, `long`, `lng`, `x`, or `y`, or from any column whose name contains `latitude` or `longitude`. Column names are matched without regard to case.
CSV input files currently support only Point geometries, from columns named `latitude`, `longitude`, `lat`, `lon`, `long`, `lng`, `x`, or `y`.
### Parallel processing of input
@@ -357,7 +352,7 @@ Parallel processing will also be automatic if the input file is in FlatGeobuf fo
specified maximum zoom and to any levels added beyond that.
* `--extend-zooms-if-still-dropping-maximum=`_count_: Increase the maxzoom if features are still being dropped at that zoom level
by up to _count_ zoom levels.
* `-at` or `--generate-variable-depth-tile-pyramid`: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with maximum detail, retaining every vertex that is not collinear with its neighbors, but their polygons are still cleaned so that overlapping areas are merged rather than left stacked. Tiles with point features below the basezoom, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles. If any features have to be dropped dynamically at a zoom level, no tile in that zoom level is truncated, so that the whole zoom level is reduced consistently; any tile that was already being skipped because an ancestor had been truncated is written out after all. Tilesets generated with this option are suitable for use only with tile servers that will find the appropriate tile to overzoom from and will simplify the geometries appropriately before serving the tile.
* `-at` or `--generate-variable-depth-tile-pyramid`: Don't produce child tiles for any tile that should be sufficient to be overzoomed to any higher zoom level. Such tiles will be produced with maximum detail and no simplification or polygon cleaning. Tiles with point features below the basezoom or where any features have to be dropped dynamically, or which contain too many features or bytes with full detail, will be written out with normal detail and split into child tiles. Tilesets generated with this option are suitable for use only with tile servers that will find the appropriate tile to overzoom from and will simplify and clean the geometries appropriately before serving the tile.
* `-R` _zoom_`/`_x_`/`_y_ or `--one-tile=`_zoom_`/`_x_`/`_y_: Set the minzoom and maxzoom to _zoom_ and produce only
the single specified tile at that zoom level.
@@ -420,9 +415,8 @@ be reduced to the maximum that can be used with the specified _maxzoom_.
* `-Y`_attribute_`:`_description_ or `--attribute-description=`_attribute_`:`_description_: Set the `description` for the specified attribute in the tileset metadata to _description_ instead of the usual `String`, `Number`, or `Boolean`.
* `-E`_attribute_`:`_operation_ or `--accumulate-attribute=`_attribute_`:`_operation_: Preserve the named _attribute_ from features
that are dropped, coalesced-as-needed, or clustered. The _operation_ may be
`sum`, `product`, `mean`, `max`, `min`, `concat`, `comma`, or `count`
`sum`, `product`, `mean`, `max`, `min`, `concat`, or `comma`
to specify how the named _attribute_ is accumulated onto the attribute of the same name in a feature that does survive.
(The `count` operation replaces the attribute with the number of features, including the survivor, that carried it.)
The attributes and operations may also be specified as JSON keys and values: `--accumulate-attribute='{"attr": "operation", "attr2": "operation2"}'`.
* `--set-attribute` _attribute_`:`_value_: Set the value of the specified _attribute_ in each feature to the specified _value_. This is mostly useful to give an attribute in each feature an initial value for `--accumulate-attribute`.
The attributes and values may also be specified as JSON keys and values: `--set-attribute='{"attr": value, "attr2": value}'`.
@@ -436,6 +430,7 @@ be reduced to the maximum that can be used with the specified _maxzoom_.
* `-j` *filter* or `--feature-filter`=*filter*: Check features against a per-layer filter (as defined in the [Mapbox GL Style Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/#other-filter) or in a Felt filter specification still to be finalized) and only include those that match. Any features in layers that have no filter specified will be passed through. Filters for the layer `"*"` apply to all layers. The special variable `$zoom` refers to the current zoom level.
* `-J` *filter-file* or `--feature-filter-file`=*filter-file*: Like `-j`, but read the filter from a file.
* `--unidecode-data` *file*: Specify transliterations that will be used when evaluating expressions, in the format from https://metacpan.org/pod/Text::Unidecode
Example: to find the Natural Earth countries with low `scalerank` but high `LABELRANK`:
@@ -472,17 +467,18 @@ the same layer, enclose them in an `all` expression so they will all be evaluate
If you use `-Bg`, it will guess a zoom level that will keep at most 50,000 features in the densest tile.
You can also specify a marker-width with `-Bg`*width* to allow fewer features in the densest tile to
compensate for the larger marker, or `-Bf`*number* to allow at most *number* features in the densest tile.
* `--retain-points-multiplier=`_multiple_: Retain the specified multiple of points instead of just the number of points that would ordinarily be retained by the drop rate. These can be thinned out later with the `-m` option to `tippecanoe-overzoom`. The start of each cluster is marked in the feature sequence by the `tippecanoe:retain_points_multiplier_first` attribute. The maximum tile size (`--maximum-tile-bytes`) will also be extended at low zoom levels to allow for the multiplied features.
* `--retain-points-multiplier=`_multiple_: Retain the specified multiple of points instead of just the number of points that would ordinarily be retained by the drop rate. These can be thinned out later with the `-m` option to `tippecanoe-overzoom`. The start of each cluster is marked in the feature sequence by the `tippecanoe:retain_points_multiplier_first` attribute. The `--tile-size-limit` will also be extended at low zoom levels to allow for the multiplied features.
* `--drop-denser=`_percentage_: When dropping dots at zoom levels below the base zoom, give the specified _percentage_
preference to retaining points in sparse areas and dropping points in dense areas.
* `--limit-base-zoom-to-maximum-zoom` or `-pb`: Limit the guessed base zoom not to exceed the maxzoom, even if this would put more than the requested number of features in a base zoom tile.
preference to retaining points in sparse areas and dropping points in dense areas. Use `--preserve-point-density-threshold` instead.
* `--limit-base-zoom-to-maximum-zoom` or `-Pb`: Limit the guessed base zoom not to exceed the maxzoom, even if this would put more than the requested number of features in a base zoom tile.
* `-al` or `--drop-lines`: Let "dot" dropping at lower zooms apply to lines too
* `-ap` or `--drop-polygons`: Let "dot" dropping at lower zooms apply to polygons too
* `-K` _distance_ or `--cluster-distance=`_distance_: Cluster points (as with `--cluster-densest-as-needed`, but without the experimental discovery process) that are approximately within _distance_ of each other. The units are tile coordinates within a nominally 256-pixel tile, so the maximum value of 255 allows only one feature per tile. Values around 10 are probably appropriate for typical marker sizes. See `--cluster-densest-as-needed` below for behavior.
* `-k` _zoom_ or `--cluster-maxzoom=`_zoom_: Max zoom on which to cluster points if clustering is enabled.
* `-kg` or `--cluster-maxzoom=g`: Set `--cluster-maxzoom=` to `maxzoom - 1` so that all features are visible at the maximum zoom level.
* `--keep-point-cluster-position`: Do not average the location of points as they are clustered.
* `--preserve-point-density-threshold=`_level_: At the low zoom levels, do not reduce point density below the specified _level_, even if the specified drop rate would normally call for it, so that low-density areas of the map do not appear blank. The unit is the distance between preserved points, as a fraction of the size of a tile. Values of 32 or 64 are probably appropriate for typical marker sizes.
* `--preserve-multiplier-density-threshold=`_level_: As with `--preserve-point-density-threshold`, but for the additional features retained by `--retain-points-multiplier`: features that would otherwise be dropped are instead added to the multiplier cluster if they are farther than the specified _level_ from the previous retained feature, so that sparse areas still have features available to be thinned to. The unit is the same as for `--preserve-point-density-threshold`.
* `--preserve-multiplier-density-threshold=`_level_: Preserve a minimum point density, but as `--retain-points-multiplier` features, not primary features.
### Dropping a fraction of features to keep under tile size limits
@@ -491,11 +487,11 @@ the same layer, enclose them in an `all` expression so they will all be evaluate
* `-an` or `--drop-smallest-as-needed`: Dynamically drop the smallest features (physically smallest: the shortest lines or the smallest polygons) from each zoom level to keep large tiles under the 500K size limit.
* `--drop-by-attribute-as-needed=`_attribute_: Dynamically drop features with the lowest values of the specified numeric _attribute_ from each zoom level to keep large tiles under the 500K size limit. Use `--drop-by-attribute-order=desc` to instead drop features with the highest values.
* `-aN` or `--coalesce-smallest-as-needed`: Dynamically combine the smallest features (physically smallest: the shortest lines or the smallest polygons or the densest points) from each zoom level into other nearby features to keep large tiles under the 500K size limit. This option will probably not help very much with LineStrings. It is mostly intended for polygons, to maintain the full original area covered by polygons while still reducing the feature count somehow. The attributes of the small polygons are *not* preserved into the combined features (except through `--accumulate-attribute`), only their geometry. Furthermore, the polygons to which nested polygons are coalesced may not necessarily be the immediately enclosing features.
* `-aS` or `--coalesce-densest-as-needed`: Dynamically combine the densest features from each zoom level into other nearby features to keep large tiles under the 500K size limit. (Again, mostly useful for polygons.)
* `-aD` or `--coalesce-fraction-as-needed`: Dynamically combine a fraction of features from each zoom level into other nearby features to keep large tiles under the 500K size limit. (Again, mostly useful for polygons.)
* `-aD` or `--coalesce-densest-as-needed`: Dynamically combine the densest features from each zoom level into other nearby features to keep large tiles under the 500K size limit. (Again, mostly useful for polygons.)
* `-aS` or `--coalesce-fraction-as-needed`: Dynamically combine a fraction of features from each zoom level into other nearby features to keep large tiles under the 500K size limit. (Again, mostly useful for polygons.)
* `-pd` or `--force-feature-limit`: Dynamically drop some fraction of features from large tiles to keep them under the 500K size limit. It will probably look ugly at the tile boundaries. (This is like `-ad` but applies to each tile individually, not to the entire zoom level.) You probably don't want to use this.
* `-aC` or `--cluster-densest-as-needed`: If a tile is too large, try to reduce its size by increasing the minimum spacing between features, and leaving one placeholder feature from each group. The remaining feature will be given a `"clustered": true` attribute to indicate that it represents a cluster, a `"point_count"` attribute to indicate the number of features that were clustered into it, a `"point_count_abbreviated"` attribute containing that count abbreviated for display (for example `1.2k` or `15k`), and a `"sqrt_point_count"` attribute to indicate the relative width of a feature to represent the cluster. If the features being clustered are points, the representative feature will be located at the average of the original points' locations (unless you use `--keep-point-cluster-position`); otherwise, one of the original features will be left as the representative.
* `-aa` or `--keep-point-cluster-position`: When clustering points, leave the representative feature at the location of the first point of the cluster instead of moving it to the average of the clustered points' locations.
* `-aC` or `--cluster-densest-as-needed`: If a tile is too large, try to reduce its size by increasing the minimum spacing between features, and leaving one placeholder feature from each group. The remaining feature will be given a `"clustered": true` attribute to indicate that it represents a cluster, a `"point_count"` attribute to indicate the number of features that were clustered into it, and a `"sqrt_point_count"` attribute to indicate the relative width of a feature to represent the cluster. If the features being clustered are points, the representative feature will be located at the average of the original points' locations; otherwise, one of the original features will be left as the representative.
* `--distinguish-duplicates`: Treat sets of up to 50 exact duplicate locations as sub-layers, which will be accumulated or coalesced into other features of their own sub-layer instead of into their duplicates.
### Dropping tightly overlapping features
@@ -517,7 +513,7 @@ the same layer, enclose them in an `all` expression so they will all be evaluate
### Attempts to improve shared polygon boundaries
* `-ab` or `--detect-shared-borders`: DEPRECATED. In the manner of [TopoJSON](https://github.com/mbostock/topojson/wiki/Introduction), detect borders that are shared between multiple polygons and simplify them identically in each polygon. This takes more time and memory than considering each polygon individually. Use `--no-simplification-of-shared-nodes` instead, which is faster and more correct.
* `-ab` or `--detect-shared-borders`: DEPRECATED. In the manner of [TopoJSON](https://github.com/mbostock/topojson/wiki/Introduction), detect borders that are shared between multiple polygons and simplify them identically in each polygon. This takes more time and memory than considering each polygon individually. Use `no-simplification-of-shared-nodes` instead, which is faster and more correct.
* `-aL` or `--grid-low-zooms`: At all zoom levels below _maxzoom_, snap all lines and polygons to a stairstep grid instead of allowing diagonals. You will also want to specify a tile resolution, probably `-D8`. This option provides a way to display continuous parcel, gridded, or binned data at low zooms without overwhelming the tiles with tiny polygons, since features will either get stretched out to the grid unit or lost entirely, depending on how they happened to be aligned in the original data. You probably don't want to use this.
### Controlling clipping to tile boundaries
@@ -576,16 +572,9 @@ the same layer, enclose them in an `all` expression so they will all be evaluate
* `-q` or `--quiet`: Work quietly instead of reporting progress or warning messages
* `-Q` or `--no-progress-indicator`: Don't report progress, but still give warnings
* `-U` _seconds_ or `--progress-interval=`_seconds_: Don't report progress more often than the specified number of _seconds_.
* `-u` or `--json-progress`: like `--quiet` but logs progress as a JSON object. Use in combination with `-U`.
### Version
* `-u` or `--json-progress`: like `-quiet` but logs progress as a JSON object. Use in combination with `-U`.
* `-v` or `--version`: Report Tippecanoe's version number
### Help
* `-H` or `--help`: List the available options and exit
### Filters
* `-C` _command_ or `--prefilter=`_command_: Specify a shell filter command to be run at the start of assembling each tile
@@ -689,11 +678,11 @@ Geometric simplifications
At every zoom level, line and polygon features are subjected to Douglas-Peucker
simplification to the resolution of the tile.
For point features, it keeps only 1/2.5 of the dots for each zoom level below the
For point features, it drops 1/2.5 of the dots for each zoom level above the
point base zoom (which is normally the same as the `-z` max zoom, but can be
a different zoom specified with `-B` if you have precise but sparse data).
I don't know why 2.5 is the appropriate number, but the densities of many different
data sets fall off at about this same rate. You can use `-r` to specify a different rate.
data sets fall off at about this same rate. You can use -r to specify a different rate.
You can use the gamma option to thin out especially dense clusters of points.
For any area where dots are closer than one pixel together (at whatever zoom level),
@@ -719,13 +708,8 @@ lower resolutions before failing if it still doesn't fit.
Development
-----------
Requires sqlite3 and zlib (should already be installed on MacOS).
The manpage is generated from this README by `make docs`, which uses
[go-md2man](https://github.com/cpuguy83/go-md2man) (`brew install go-md2man` or
`apt-get install go-md2man`). You don't have to run it yourself: CI regenerates the
manpage and fails if the committed copy doesn't match, so it will tell you if an
edit here needs `make docs` run against it.
Requires sqlite3 and zlib (should already be installed on MacOS). Rebuilding the manpage
uses md2man (`gem install md2man`).
Linux:
@@ -739,16 +723,15 @@ and perhaps
make install
Tippecanoe requires features from the 2017 C++ standard (it is built with `-std=c++17`).
If your compiler is older than that, you will need to install a newer one. On MacOS, updating
to the latest XCode should get you a new enough version of `clang++`. On Linux, you should be
able to upgrade `g++` with
Tippecanoe now requires features from the 2011 C++ standard. If your compiler is older than
that, you will need to install a newer one. On MacOS, updating to the latest XCode should
get you a new enough version of `clang++`. On Linux, you should be able to upgrade `g++` with
```sh
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update -y
sudo apt-get install -y g++-9
export CXX=g++-9
sudo apt-get install -y g++-5
export CXX=g++-5
```
Docker Image
@@ -801,14 +784,11 @@ The options are:
* `-o` *out.mbtiles*, *out.pmtiles* or `--output=`*out.mbtiles*: Write the new tiles to the specified .mbtiles file.
* `-e` *directory* or `--output-to-directory=`*directory*: Write the new tiles to the specified directory instead of to an mbtiles file.
* `-f` or `--force`: Remove *out.mbtiles* if it already exists.
### Input tilesets
* `-r` *file* or `--read-from=`*file*: Read the list of input tilesets from the named *file*, one filename per line, instead of naming them all on the command line.
* `-r` or `--read-from`: list of input mbtiles to read from.
### Overzooming
* `-O` or `--overzoom`: If one of the source tilesets has a larger maxzoom than the others, scale up tiles from the tilesets with the lower maxzooms so they will all have the same maxzoom in the output tileset.
* `--overzoom`: If one of the source tilesets has a larger maxzoom than the others, scale up tiles from the tilesets with the lower maxzooms so they will all have the same maxzoom in the output tileset.
* `--buffer=`_pixels_ or `-b` _pixels_: Set the size of the tile buffer in the overzoomed tiles.
### Tileset description and attribution
@@ -837,8 +817,6 @@ The options are:
* `-x` *key* or `--exclude=`*key*: Remove attributes named *key* from the output. You can use this to remove the field you are matching against if you no longer need it after joining, or to remove any other attributes you don't want. You can use multiple `-x` options to remove multiple attributes.
* `-X` or `--exclude-all`: Remove all attributes from the output.
* `-y` *key* or `--include=`*key*: Remove all attributes except for those named *key* from the output. You can use multiple `-y` options to retain multiple attributes.
* `--exclude-all-tile-attributes`: Remove the attributes that were already present in the source tiles, keeping only any that are joined from a CSV with `-c`.
* `--exclude-all-tile-geometries`: Copy the features' attributes but not their geometries, so the output tiles describe the features without locating them.
* `-i` or `--if-matched`: Only include features that matched the CSV.
* `-j` *filter* or `--feature-filter`=*filter*: Check features against a per-layer filter (as defined in the [Mapbox GL Style Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/#other-filter)) and only include those that match. Any features in layers that have no filter specified will be passed through. Filters for the layer `"*"` apply to all layers.
* `-J` *filter-file* or `--feature-filter-file`=*filter-file*: Like `-j`, but read the filter from a file.
@@ -853,10 +831,6 @@ The options are:
* `--tile-stats-sample-values-limit=`*count*: Calculate `tilestats` attribute statistics based on *count* values instead of the default 1000.
* `--tile-stats-values-limit=`*count*: Report *count* unique attribute values in `tilestats` instead of the default 100.
### Progress indicator
* `-q` or `--quiet`: Work quietly instead of reporting progress
Because tile-join just copies the geometries to the new .mbtiles without processing them
(except to rescale the extents if necessary),
it doesn't have any of tippecanoe's recourses if the new tiles are bigger than the 500K tile limit.
@@ -947,10 +921,8 @@ resolutions.
* `-c` or `--tag-layer-and-zoom`: Include each feature's layer and zoom level as part of its `tippecanoe` object rather than as a FeatureCollection wrapper
* `-S` or `--stats`: Just report statistics about each tile's size and the number of features in it, as a JSON structure.
* `-f` or `--force`: Decode tiles even if polygon ring order or closure problems are detected
* `-I` or `--integer-coordinates`: Report coordinates in integer tile coordinates
* `-F` or `--fractional-coordinates`: Report coordinates as a fraction of the tile extent
* `-y` _attribute_ or `--include=`*attribute*: Include only the named attributes in the decoded features, excluding all those not explicitly named. (Multiple `-y` options can be specified.)
* `-x` _name_ or `--exclude-metadata-row=`*name*: Omit the named row from the tileset metadata in the output. (Multiple `-x` options can be specified.)
* `-I` or `--integer`: Report coordinates in integer tile coordinates
* `-F` or `--fraction`: Report coordinates as a fraction of the tile extent
tippecanoe-json-tool
====================
@@ -1037,19 +1009,10 @@ and produces tile `outz/outx/outy` of `out.mvt.gz` from them.
### Options
* `-o` *file* or `--output=`*file*: Write the output tile to the named *file*.
* `-t` _zoom_`/`_x_`/`_y_ or `--source-tile=`_zoom_`/`_x_`/`_y_: Specify the coordinates of the tile to produce, so that several input tiles, each followed by its own _zoom_`/`_x_`/`_y_, can be combined into it, as in the second example above.
* `-b` *buffer* or `--buffer=`*buffer*: Set the tile buffer in the output tile (default 5)
* `-d` *detail* or `--full-detail=`*detail*: Set the detail of the output tile (default 12)
* `-y` *attribute* or `--include=`*attribute*: Retain the specified *attribute* in the output features. All attributes that are not named in a `-y` option will be removed.
* `-x` *attribute* or `--exclude=`*attribute*: Remove the specified *attribute* from the output features.
* `--exclude-prefix=`*prefix*: Remove any attribute whose name begins with the specified *prefix* from the output features.
* `-j` *filter* or `--feature-filter=`*filter*: Filter features using the same expression syntax as in tippecanoe.
* `-J` *filter-file* or `--feature-filter-file=`*filter-file*: Like `-j`, but read the filter from a file.
* `-m` or `--filter-points-multiplier`: If a tile was created with the `--retain-points-multiplier` option, thin the tile back down to its normal feature count during overzooming. The first feature from each cluster will be retained, unless `-j` is used to specify a filter, in which case the first matching filter from each cluster will be retained instead.
* `-S` *scale* or `--line-simplification=`*scale*: Simplify lines and polygons in the output tile, multiplying the standard tolerance by *scale*. The default of 0 means not to simplify at all.
* `--tiny-polygon-size=`*size*: Combine the area of very small polygons into small squares of the specified *size* that represent their combined area, as `tippecanoe` does. The default of 0 means not to do tiny polygon reduction at all.
* `--deduplicate-by-id`: When several input tiles are combined, include only the first feature with any given feature ID within each layer, so that features that appear in more than one input tile are not duplicated in the output.
* `-b` *buffer*: Set the tile buffer in the output tile (default 5)
* `-d` *detail*: Set the detail of the output tile (default 12)
* `-y` *attribute*: Retain the specified *attribute* in the output features. All attributes that are not named in a `-y` option will be removed.
* `-j` *filter*: Filter features using the same expression syntax as in tippecanoe.
* `-m`: If a tile was created with the `--retain-points-multiplier` option, thin the tile back down to its normal feature count during overzooming. The first feature from each cluster will be retained, unless `-j` is used to specify a filter, in which case the first matching filter from each cluster will be retained instead.
* `--preserve-input-order`: Restore a set of filtered features to its original input order
* `-E` *attribute*`:`*operation* or `--accumulate-attribute=`*attribute*`:`*operation*: Behaves as in `tippecanoe` to sum attributes from the features of a multiplier cluster that are not included in the final output. The attributes from features that are filtered away with `-j` are *not* accumulated onto the output feature.
* `--no-tile-compression`: Don't compress the PBF vector tile data in the output tile.
* `--accumulate-attribute`: Behaves as in `tippecanoe` to sum attributes from the features of a multiplier cluster that are not included in the final output. The attributes from features that are filtered away with `-j` are *not* accumulated onto the output feature.
-416
View File
@@ -1,416 +0,0 @@
A tour of Tippecanoe
====================
Tippecanoe has what sounds like a simple job: It takes geographic objects in one file format ([GeoJSON](https://geojson.org/)) and copies them into a different file format ([Mapbox Vector Tiles](https://github.com/mapbox/vector-tile-spec)). But it takes a lot of code to do that. What's really going on?
Even at the surface it is not quite that simple. The input can also be [CSV](https://datatracker.ietf.org/doc/html/rfc4180), [Geobuf](https://github.com/mapbox/geobuf), or [FlatGeobuf](https://flatgeobuf.org/), and the output can be an [mbtiles](https://github.com/mapbox/mbtiles-spec) file, a directory of tiles, or a [PMTiles](https://github.com/protomaps/PMTiles) archive. And Tippecanoe is a family of programs, not one: `tile-join`, `tippecanoe-overzoom`, `tippecanoe-decode`, `tippecanoe-json-tool`, and `tippecanoe-enumerate` all operate on the tiles after the fact. But the core of it is this: read a lot of features, put them in an order that makes them easy to thin out, and then divide and conquer the world into tiles.
All the links below point at [`63fcac72`](https://github.com/felt/tippecanoe/tree/63fcac725abeb841a101abfc64189edd66d1cf14) (version 2.81.0), so the line numbers stay meaningful even as the code moves.
Starting up
-----------
[The main function](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L3168) has the job of processing the list of options and files that the user provides. I'll go into more detail later about what all those options actually do, but the list of them is [spelled out here](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2979) in a single table.
Everything about the options comes from that one table, so that no two descriptions of them can disagree. The entries whose `val` is 0 and whose `flag` is null are not options at all but headings for the usage message, and [`strip_usage_headings()`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/usage.hpp#L29) removes them before the table is handed to `getopt_long()`. [`getopt_string()`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/usage.hpp#L23) derives the short-option string from it, and [`print_usage()`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/usage.cpp#L88) prints the usage message from it. The other programs in the family use the same mechanism.
Most of the options set an entry in the `additional[]` or `prevent[]` arrays, indexed by the single-character codes listed in [`options.hpp`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/options.hpp), which is why so much of the code below reads like `if (additional[A_DROP_DENSEST_AS_NEEDED])`.
After the options are processed we reach the core operations: [create the output tileset](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L3794), [read input into it](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L3841), [close it](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L3847), and then, if the output name ended in `.pmtiles`, [convert what was written into a PMTiles archive](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L3851).
Creating the output tileset
---------------------------
[Creating an mbtiles file](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/mbtiles.cpp#L29) is a series of sqlite operations, most of which I copied from [mbutil](https://github.com/mapbox/mbutil). There is an option (`-F`) to keep going even if these operations fail, to support a geocoding use case that needed to add new, non-conflicting, tiles to an existing mbtiles file.
The schema is a `map` table that maps z/x/y to a content hash, an `images` table that maps a content hash (within a zoom level) to the tile data, and a `tiles` *view* that joins the two back together into what a consumer expects. The point of the indirection is that identical tiles — which are extremely common at low zooms, and in any tileset with a lot of empty ocean — are stored only once. [`mbtiles_write_tile`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/mbtiles.cpp#L104) hashes each tile's contents with [fnv1a](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/text.cpp#L260) to find the key.
There are two other output forms. With `-e`, the output is [a directory of tiles](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/dirtiles.cpp#L28), `z/x/y.pbf`, with a `metadata.json` alongside. If the output name ends in `.pmtiles`, Tippecanoe writes an mbtiles file first and then [repacks it](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/pmtiles_file.cpp#L139) into the single-file PMTiles format at the end, which is described in [its own section](#converting-to-pmtiles) below. From the tiling code's point of view all three are the same: there is an `outdb` or an `outdir`, and it writes tiles to whichever one it has.
Temporary files to read input into
----------------------------------
[Reading input](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1240) is deceptively named because it also ultimately invokes the whole tiling process.
Its first job is to [create as many sets of temporary files](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1245) as your computer has CPUs, so that multiple threads can read input into these files at the same time without interfering with each other. At the end of the actual input stage, the per-thread temporary files will be merged or concatenated together so that tiling will operate on the combined results.
The temporary files are:
* `geom`, which, as the name suggests, contains the feature geometry, plus [other characteristics of each feature](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.hpp#L105).
* `index`, which is an index of the features in `geom` [by their byte offset within the file and their quadkey-encoded location](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.hpp#L13). It will be used later to merge the per-thread `geom` files back together.
* `pool`, which contains one deduplicated instance of each property key or value that appears in any feature.
* `tree`, which is a binary tree of `pool` entries, so that it can look up the existing pooled copy of any keys or values that are duplicated across multiple features, or add a new entry to the pool when a key or value is used for the first time.
* `vertex`, which records, for `--no-simplification-of-shared-nodes`, each vertex of each line or ring together with the two vertices on either side of it, so that the points where features diverge from each other can be found globally.
* `node`, which records the individual points that must not be simplified away.
Features reference their pooled keys and values directly, by their offsets into `pool`; there is no second level of indirection for features that have a lot of properties.
All of this data is in temporary files instead of in memory because it can be very large, and putting it on disk makes it possible to tile data that is too big to fit in memory. Processing will be much faster if the data does fit in memory, though. The `pool` and `tree` in particular use a hybrid: [`memfile`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/memfile.cpp#L11) keeps them as an in-memory `std::string` until they get too big, at which point [`memfile_full`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/memfile.cpp#L71) switches to appending to the real file. Note that data is explicitly copied in and out rather than accessed through a writable memory map, which has bad performance problems in containers.
What is straightforwardly in memory, not on disk, because it is small, is [the "layermap"](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1417) for each CPU, which is a list (by name) of the tile layers and all the property keys that have been used for any features in that layer, plus the sample values and ranges that will become the tileset's [tilestats](https://github.com/mapbox/mbtiles-spec/blob/master/1.3/spec.md). This will eventually end up in the tileset metadata.
Input formats
-------------
Before reading anything, Tippecanoe [makes up a layer name](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1358) for each source that doesn't have one, from the last component of its filename with the recognized suffixes and any characters that can't appear in a selector trimmed off.
Then, for each source in turn, the format is chosen from the file suffix, or from the `format` given in a `-L{"format":"…"}` JSON layer specification:
* [FlatGeobuf](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1469), which is memory-mapped and parsed by [`parse_flatgeobuf`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/flatgeobuf.cpp#L349). Its features are queued up and [handed out to a pool of parser threads](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/flatgeobuf.cpp#L331).
* [Geobuf](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1542), likewise memory-mapped, parsed by [`parse_geobuf`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geobuf.cpp#L535) with the same queue-and-threads arrangement.
* [CSV](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1615), parsed by [`parse_geocsv`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geocsv.cpp#L14), which finds the latitude and longitude columns by name and makes a point feature out of each row.
* GeoJSON, which is everything else, and is the interesting case.
GeoJSON input can also be gzipped: [`streamfdopen`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L599) transparently wraps the file in a `gzdopen` if its name ends in `.gz`.
Whichever frontend reads the features, they all converge on the same place: they fill in a [`serial_feature`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.hpp#L105) and call [`serialize_feature`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L416) to write it to the temporary files. Everything downstream of that point is format-independent.
Three ways to read GeoJSON
--------------------------
Now that the temporary files are in place, it is time to start reading input, either from `stdin` or from the files named on the command line. There are three ways that input files may be read, depending on whether the input is from a file or a stream and whether the user has asked for parallel input processing.
1. If the `--read-parallel` option was specified, Tippecanoe first tries to map the file into memory. If this was successful, it [creates several threads to parse parts of it in parallel](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1703) as will be described below.
2. If the file can't be mapped into memory (which means that it is an input stream, not a file on disk), Tippecanoe [opens it as a stream](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1718). If the user has nevertheless asked for parallel processing of input, Tippecanoe [starts reading the stream into another temporary file](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1733) that it *can* map into memory. Once it has accumulated enough to be worth [starting up several parser threads](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1782), it does that, and the main thread goes back to reading more streaming input into the next temporary file. This back-and-forth continues until the whole input has been consumed. It also [waits for the parsers](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1772) rather than reading indefinitely far ahead of them.
3. If the user didn't ask for parallel input, it just [runs a single JSON parser](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1834) on the streaming input file.
Parallel reading is not strictly opt-in, though: if the stream [begins with an ASCII record separator](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1728) (0x1E), the input is [GeoJSON Text Sequences](https://datatracker.ietf.org/doc/html/rfc8142), which *does* guarantee that features are separated, so Tippecanoe turns parallel parsing on by itself and splits on the separator instead of on newlines.
Parsing GeoJSON in parallel
---------------------------
To avoid massive digression I will first talk about parsing GeoJSON in parallel. The [`do_read_parallel` function](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L451) starts with the file already mapped into memory and knows how many CPUs can work on it simultaneously. It starts by [making a guess](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L456) that each CPU should have an equal-sized fraction of the file to work on, and then adjusts this guess by moving the divisions forward until each of them begins with a separator character (a newline, or a 0x1E if this is a GeoJSON text sequence).
(Note that GeoJSON itself makes no guarantee that feature objects are separated by newlines, or that newlines will never appear in the middle of a feature. This lack of a guarantee is why parallel parsing only happens if the user asks for it, or if the input announces itself as a text sequence, because it will misinterpret many correct GeoJSON inputs that are not designed for line-delimited use.)
It [sets up a parameter block for each CPU](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L485) pointing it to all the global settings and to the per-CPU temporary files and semi-global properties (bounding box, layermaps) and a JSON parser pointed to the portion of the file that was allocated to that CPU, and creates a thread to run the single-stream parsing described immediately below, from that JSON parser. Then it waits for all the threads to finish and is done.
Parsing a single GeoJSON stream
-------------------------------
To parse GeoJSON, whether from a fraction of a memory-mapped file as described immediately above, or from a regular file stream, Tippecanoe uses [a generic JSON pull-parser](https://github.com/felt/tippecanoe/tree/63fcac725abeb841a101abfc64189edd66d1cf14/jsonpull). By pull-parser, I mean that the parser returns JSON tokens and objects one at a time as they are encountered, rather than building up a full JSON object structure in memory for the entire input file and then presenting that to the caller.
[The loop over those tokens](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson-loop.cpp#L39) lives in `geojson-loop.cpp` rather than in `geojson.cpp`, because `tippecanoe-json-tool` needs the same thing. It runs until it encounters either a [bare geometry](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson-loop.cpp#L76) (an object whose `type` is `Point`, `LineString`, `Polygon`, `MultiPoint`, `MultiLineString`, or `MultiPolygon` and is not contained within something that could be a feature) or [a feature](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson-loop.cpp#L129) (an object whose `type` is `Feature`). In either case it calls the `add_feature` method of the `json_feature_action` it was given, which for Tippecanoe proper is [the one that calls `serialize_geojson_feature`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson.cpp#L244).
The checks for whether something that looks like a geometry or a feature really is one are fussier than they first appear: an object is not a feature or geometry of its own if it [appears inside another object's `properties`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson-loop.cpp#L103), and a `GeometryCollection` inside a feature is [expanded into one feature per geometry](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson.cpp#L246) sharing the same attributes.
From GeoJSON feature to internal feature
----------------------------------------
[Turning a GeoJSON feature into a Tippecanoe feature](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson.cpp#L43) starts with some checking: does the geometry have a `coordinates` array? Is the `type` one of the kinds of things that GeoJSON defines? It also [checks the feature](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson.cpp#L85) for a special `tippecanoe` object that can specify a per-feature minzoom, maxzoom, or layer name, and for [the top-level feature `id`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson.cpp#L104) that is independent of the feature properties.
[For each of the feature's properties](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geojson.cpp#L192) it identifies the property's type and, if it is a compound JSON object that can't be natively represented as one of the attribute types that vector tiles supports, [stringifies it](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/read_json.cpp#L124). These are all just in memory for the moment, in the `full_keys` and `full_values` fields of the `serial_feature`. The keys go through a [`key_pool`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.hpp#L89) so that the many features that share an attribute name also share one copy of the string in memory.
It then calls [`parse_coordinates`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/read_json.cpp#L56) to recursively unpack the `coordinates` array from the `geometry`, and hands the whole thing to `serialize_feature`. See below for more about parsing and reprojecting geometry.
Internal representation of a feature
------------------------------------
The [`serial_feature` structure](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.hpp#L105) is the thing that every frontend produces and that every stage of tiling passes around. It is a big structure, but its fields divide into three groups, and the comments in the header say which is which:
* The ones that are actually serialized to the `geom` file: the layer, segment, and sequence numbers; the geometry type `t`; the geometry itself; the feature `id`, if any; the per-feature `tippecanoe_minzoom` and `tippecanoe_maxzoom`, if any; the quadkey `index`; the `extent` (area, or a stand-in for it); the `label_point`; and the pooled `keys` and `values`.
* The ones that only exist during initial serialization: `full_keys` and `full_values`, the string forms of the attributes, which get replaced by the pooled `keys` and `values` offsets.
* The ones that only exist during tiling: the bounding box, the `dropped` state, whether the feature is polygon dust or was coalesced, the current detail and simplification level, and so on.
`dropped` deserves a note, because despite the name it is not a boolean. It is [`FEATURE_DROPPED` (-1), `FEATURE_KEPT` (0), a positive sequence number](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.hpp#L146) meaning "this is the *n*th extra feature retained by `--retain-points-multiplier` alongside its cluster's lead feature," or `INT_MAX` meaning "retained by `--preserve-multiplier-density-threshold`." Much of the dropping logic in `write_tile` is really about keeping these multiplier clusters intact.
Attribute values are represented by [`serial_val`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.hpp#L39): a type tag (one of the `mvt_value` types) plus the value as a string. Every number, integer or floating point, is `mvt_double` here and is stored in its stringified form, which is how integers too large for a double survive with their original precision.
Writing a feature to the temporary files
----------------------------------------
[`serialize_feature`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L416) is where a feature from any frontend actually becomes bytes on disk, and it is where a surprising number of the command line options take effect. In order, it:
* Accumulates the feature's coordinates into the two per-thread file bounding boxes: [one on the normal −180 to 180 plane and one on a 0 to 360 plane](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L425), so that at the end the narrower of the two can be reported as the tileset's antimeridian-aware bounds.
* [Scales the geometry](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L304) down by `geometry_scale`, which also does the `--detect-longitude-wraparound` bookkeeping, with a [special case for jumps of exactly 360°](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L322), which in some data sets are an intentional line across the world rather than an accident.
* Calls [`fix_polygon`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/clip.cpp#L1755) on polygons, to make sure the rings are wound in the correct direction, since GeoJSON identifies parent and child rings by their position in the `coordinates` array but vector tiles represent them by positive or negative area.
* [Clips to any `--clip-bounding-box` or `--clip-polygon` regions](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L467), and gives up on the feature if nothing is left.
* If `--no-simplification-of-shared-nodes` is in effect, [writes out the `vertex` and `node` records](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L507) described above. This is one of the more subtle parts of the program: for each vertex it records the two neighboring vertices, so that after a global sort it can tell the difference between a point where two features merely run alongside each other (same neighbors) and a point where they actually converge, diverge, or cross (different neighbors). Only the latter must be protected from simplification. It also unconditionally protects each ring's start point, its farthest point from the start, and the point farthest from the line between those two, so that polygons can't be simplified out of existence.
* If `-zg` was given, [samples the distances between the vertices within the feature](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L608), which will feed into the maxzoom guess.
* [Calculates the feature's extent](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L636): the area for polygons, and for lines the area of a circle whose diameter is the line's length. Points get theirs later, in `write_tile`, from the distance to the adjacent feature. This is what `--drop-smallest-as-needed` and `--order-largest-first` sort on.
* [Chooses the point that the feature will be indexed by](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L686). For points this is the bounding box center. For lines and polygons it is an arbitrary but predictable vertex, chosen by hashing the geometry, so that a pile of nearly-identical LineStrings that follow the same route don't all land on the same index and make `-zg` think the data is much denser than it is. (Hashing the geometry rather than picking at random means that features with identical geometry still get identical indexes.) Polygons being dropped or coalesced by density instead use their center of mass.
* [Generates a label point](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L734) for polygons, if `--generate-polygon-label-points` was given, using [`polygon_to_anchor`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geometry.cpp#L766), which tries to find a point that is well inside the polygon and not in one of its holes.
* [Decides whether the index is needed at all](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L743) — it is only serialized if some option that uses it is in effect — and [adds a layermap entry](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L763) for the feature's layer. Because layers within each serialized feature are specified by number, not by name, different threads may assign different layer numbers to the same layer name, which will need to be reconciled later.
* Applies the attribute options: [`--set-attribute`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L785), [`--attribute-type` coercion, `--single-precision`, `--use-attribute-for-id`, `--exclude`, `--include`, and `--exclude-all`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L801), and [`--maximum-string-attribute-length`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L870). It also [feeds each surviving attribute into the tilestats](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L863) — unless a shell filter is in use, in which case there is no point, because the filter may change everything.
* [Interns each key and value in the string pool](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L878) with `addpool`, which returns the offset within the per-CPU `pool` file.
* [Writes the feature](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L886) to the `geom` file, prefixed by its length, and [adds it to the `index`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L890).
All that remains is to increase the per-CPU bounding box to encompass the feature bounding box if necessary, and increment the user-visible progress indicator.
The string pool
---------------
[`addpool`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/pool.cpp#L24) is worth its own section, because it is on the hot path for every attribute of every feature and it has been tuned accordingly. It has three layers of defense against being slow:
* A [direct-mapped hash cache](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/pool.cpp#L26) in front of the tree, per reader thread, which catches the overwhelmingly common case of the same handful of keys and values recurring over and over. (It verifies the type and the string on a hit, because a hash cache that trusted the hash would collide.)
* A [depth limit](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/pool.cpp#L62) on the tree search. If a string is so deep in the tree that the search is getting expensive, it is probably unique anyway, so it is appended to the pool without being added to the tree, and future copies of it just won't be deduplicated.
* A [size limit](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/pool.cpp#L90). Once the pool and tree together exceed a fraction of physical memory, the pool switches over to appending to the file, and stops maintaining the tree at all. Deduplication is a nice-to-have; thrashing is not.
The comparison function, [`swizzlecmp`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/pool.cpp#L12), orders by hash first and only compares strings when the hashes match, which keeps the tree from degenerating into a list when the input is sorted.
Serialized representation of a feature
--------------------------------------
Serializing each feature [probably looks familiar](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L173) if you have done any serialization with [protozero](https://github.com/mapbox/protozero). There is not much sanity-checking so you have to be careful if you make changes, especially in the field that [does some bit packing](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L187) to combine the layer number and the flags for the presence of a label point, index, extent, `id`, `minzoom`, and `maxzoom` into the same number.
Serialization goes into a `std::string` and the caller writes that out, rather than going straight to a file. That is what makes it possible for the same function to serve both the frontends, writing to the per-thread `geom` files, and [`rewrite`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L443) during tiling, writing compressed into the next zoom level's files.
All of the primitive serialization types (integers of various sizes and signednesses) are spelled out earlier in the same `serial.cpp` file. They use `protozero`'s zigzag conversion functions to represent signed numbers as unsigned, and use its same variable-length encoding for numbers, with the high bit of each byte indicating that there are more bytes to follow.
Two pieces of magic are worth knowing about, because both are commented as `MAGIC` in the source and both will bite you if you forget them. The first is that [the feature minzoom is the last byte of the serialized feature](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L230), so that the reordering pass can rewrite it in place without decoding anything. The second is that [`deserialize_feature`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L235) checks that it consumed exactly as many bytes as the length prefix promised, which is the check that catches it when the two halves get out of step.
Internal representation of geometry
-----------------------------------
Parsing the GeoJSON coordinates array into Tippecanoe's internal representation of geometry, as mentioned above, deserves a little bit more detail.
Tippecanoe's [internal geometry structure](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geometry.hpp#L26) is called `draw`, and is composed of an operation (moveto, lineto, closepath) and an `x` and `y` coordinate, plus an auxiliary field used during line simplification to track whether a point has been determined to be `necessary`. A series of `draw` operations [is called](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/geometry.hpp#L67) a `drawvec`. The `draw` structure uses some bitfields to keep its size down to 128 bits even with the `op` and `necessary` fields, to avoid eating a lot of unnecessary memory.
The [`parse_coordinates` function](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/read_json.cpp#L56) mostly just builds up a `drawvec` from the GeoJSON coordinate arrays for the feature, after doing some sanity checking to make sure the arrays contain numbers and an appropriate number of elements. It calls itself recursively to parse the multiple points that appear within each LineString, the multiple rings that appear within each Polygon, and so on.
It also [contains the call](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/read_json.cpp#L82) that reprojects the coordinates from their original projection (usually WGS84) to tile coordinates, where the world is a square, 2^32 units on each side.
There is also [a weird special case](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/read_json.cpp#L106) that adds a `closepath` operation after the last ring of each Polygon, so that the following ring can be identified as an outer ring. (Tippecanoe does not otherwise use `closepath`, except in the last stages of writing out the vector tile format, which requires it as part of each polygon ring.) The [`fix_polygon` function](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/clip.cpp#L1755) uses this special tag when it reorders the points in each ring to make sure that inner rings are oriented the opposite direction from outer rings. It also makes sure the ring is closed, with the last point duplicating the first, if it wasn't already.
Separately, in `serialize_feature`, there is a special case (to save space in the temporary files) that shifts each of these world coordinates down by [`geometry_scale`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/serial.cpp#L30), which was set back in the `main` function to correspond to the global `minzoom`, so that coordinates on disk are not stored in more detail than will eventually be used in the final tiles. The reduced coordinates will be shifted back up to world scale during each deserialization during tiling. The shift rounds rather than truncating, which matters for overzooming, and adds a `COORD_OFFSET` first so that features slightly off the edge of the world still shift correctly.
Merging temporary files after parsing
-------------------------------------
At this point Tippecanoe has all of the input from all of its input files parsed and copied into temporary files, but each layer's features are scattered across multiple files, depending on which CPU happened to read the feature. The files have to be consolidated before tiling can begin.
But it is important to note that [back when the temporary files were being opened](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1255), each of them was opened *twice*, and then [deleted](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1321). Each of them was opened as an integer file descriptor with `mkstemp`, and as a C `FILE` with `fopen`, and deleted with `unlink`. The two open file descriptors to each file cause it to continue to exist on disk even though it has been deleted from the temporary directory. Deleting the file before it is written should also serve as a hint to the operating system that there is no need ever to write the file's contents to physical disk if it is small enough to continue to fit in memory, in the operating system's buffer cache. (Using a deleted file for temporary storage is a traditional Unix idiom, and there is a `tmpfile` call in the standard library to create and delete a temporary file if you only need a single `FILE` reference to it.)
So now [the `FILE` for each is closed](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1899), so each temporary file is kept alive by only *one* file descriptor, not two, and any buffering that was being done inside the Tippecanoe process itself, as opposed to in the operating system, will have been flushed out.
Merging the string pool is the easiest. The `tree` files are of no more use and are simply closed and discarded. The `pool` files for each CPU [are concatenated together](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1950) into a new file, with an array to keep track of the offset into the new file where the data for each CPU begins. (Which thread some data originally came from is frequently referred to in the code as its `segment`.) Because the pool may be partly in memory and partly on disk by this point, the merge has to handle both cases. The combined pool is then [mapped back into memory](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2003) so it can be accessed like an array.
Then, if `--no-simplification-of-shared-nodes` was requested, there are two more merges:
* [The vertices are sorted](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2015) with [`fqsort`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/sort.cpp#L9) — a quicksort that partitions into temporary files when the data doesn't fit in memory — and then scanned. Any middle vertex that appears with *different* neighbors in two different records is a place where features diverge, so it becomes a node.
* [The nodes are sorted and deduplicated](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2080) the same way. The result is mapped into memory so that each tile can binary-search it, and, because that search would otherwise be a lot of cache misses, a [34-megabyte Bloom filter](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2075) is built alongside it so that the common "this point is not a shared node" answer can be given without touching the array at all. The nodes are keyed by quadkey so that the nodes for any one tile are adjacent in memory.
Doing this globally, once, is what keeps the memory in bounds: the alternative of assembling the node list separately within each tile is correct but ruinously expensive on large inputs.
Why sort the features?
----------------------
The geometry is going to be much more of a pain to merge, not just because it is typically so much bigger than the other files, but because we also want it in a specific order. In particular we want it to be ordered by quadkey so that
1. when the low zooms are thinned out by dropping some fraction of features, those features are evenly distributed by location rather than clumpy,
2. it is possible to make global estimates of the number of features in each tile, before actually generating those tiles, and
3. within each tile, the density of features near any particular feature can be estimated by the difference between its quadkey index and the numerically adjacent feature's quadkey index.
These characteristics will be used by the `-r` dot dropping rate, the `-Bg` guessing of an appropriate base zoom level, and the `-g` thinning of dense features, respectively. The maxzoom guess of `-zg` uses the same ordering for the same reason.
We can accomplish this by sorting the `index` by quadkey and then copying features from the original files into a new temporary file in index order. This is the user-visible "Reordering geometry" phase.
Sorting and merging
-------------------
The index itself may actually be uncomfortably large to sort. Each [index entry](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.hpp#L13) takes 32 bytes of storage, so on a 4GB laptop, 100 million features will exhaust available memory and grind progress to a halt, sometimes crashing the system in the process. And recopying the geometry in index order after sorting may be even worse, because the original order of the geometry probably has no relationship to the index order, so if it does not fit in memory, retrieving each feature may require a disk access.
Tippecanoe's strategy, then, is to do as much of the reordering as possible in a streaming way, without taking advantage of random access. This is an old, old technique, like people would have used in the 1970s with a computer that had almost no memory but had a lot of tape decks that could read and write at full speed as long as they were going in order. It still works the same way if you read a stream from one file and split it into streams into several output files, because they can all go as fast as the physical disk I/O can go.
The [top-level sort](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1089) is a [radix sort](https://en.wikipedia.org/wiki/Radix_sort). It [checks how many files it can have open at once](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1107), and if the answer is, say, 512, then it tries to split the index and geometry into 128 parts (512/4), based on the leading bits of each feature's quadkey.
It then [goes through each of those parts](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L890) and checks whether it would fit in memory. If it would, it splits that portion of the index up again by however many CPUs it has to work with, [sorts each of those sub-indices](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L413) in its own thread with the system `qsort`, and then [merges those sub-sub-indices](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L352) to copy the sub-geometry to the final geometry file in index order, which should be fast because it's all in memory. If one of the parts *didn't* fit in memory, then it does [another radix sort](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1054) to split it up further, based on the next bits of the quadkey. In at most a few passes of this it will have generated final sorted index and geometry files in quadkey order.
Two invariants here are easy to break and hard to notice. The first is that a bucket small enough to be written out directly, rather than through the merge, must still be [written one byte shorter than the index says](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1014) and then given a fresh minzoom byte, exactly as `merge()` does — the `MAGIC` byte again. Write the original byte as well as the new one and every feature read after it comes out shifted by one. The second is that each level of subdivision must [consume at least one bit of the index](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L746), which means at least two buckets: with only one, the recursion never reaches the prefix width that stops it, and the shift that selects a bucket is by the full width of the index, which is undefined.
Both invariants only matter on inputs large enough to recurse, which is more data than a test wants to handle, so `--prefer-radix-sort` exists to reach them: it [pretends there are only 8 KB of memory](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1103) so that a tiny test input goes down the deep path, and the test checks the radix-sorted output against the in-memory sort of the same data.
Guessing maxzoom
----------------
Once the index is in order, Tippecanoe can [guess a maxzoom](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2279) from the data, if `-zg` was given instead of an explicit `-z`.
The idea is that a good maxzoom is one where most features are distinguishable from each other, so it walks the sorted index and accumulates the mean and standard deviation of the log of the gaps between adjacent quadkeys, using [Welford's algorithm](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2312). Distances between features are typically lognormally distributed, so the geometric mean is the right average, and [1.5 standard deviations below the mean](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2353) is taken as the distance at which features should still be distinguishable. The conversion from quadkey gaps to feet is an empirical fit; the `#if 0` block just above the calculation is the code that produced the data for it.
Several things adjust the result afterward:
* The [distances *within* each feature](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2416), sampled back in `serialize_feature`, can push the maxzoom higher, because a tileset of detailed coastlines needs resolution even if there are only a few features.
* [Duplicate feature locations](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2407) push it higher too, since a pile of features at exactly the same point will never be distinguishable but will be dropped at the drop rate.
* [Clustering](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2377) pushes it higher, so that features eventually become unclustered.
* A [2-million-tile budget](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2439) pulls it back down, estimated from the total polygon area, so that a request that would spend a week filling in the interiors of polygons doesn't.
* `--smallest-maximum-zoom-guess` sets a floor, and the [detail limits](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2432) set a ceiling.
The drop rate can be guessed at the same time, from [a curve fitted by eye](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2390) to the drop rates that looked right for a handful of real point tilesets: evenly spaced features want a large drop rate, clumpy features can get away with a small one.
Guessing base zoom and drop rate
--------------------------------
Independently of `-zg`, Tippecanoe can [calculate a base zoom and drop rate](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2490) if requested to do so with `-Bg` or `-rg`.
It can do this because all the features that are (centered in) the same tile are now guaranteed to be contiguous in the index because it is ordered by quadkey. So Tippecanoe can calculate the densest tile in each zoom level just by running through the index in order, accumulating one count of features for each zoom level, and resetting the counter [every time the tile number at that zoom level changes](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2536).
Now that it knows how many features are in the densest tile at each zoom level, it can calculate [what the lowest zoom level is](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2569) where the densest tile contains an acceptable number of features and [what fraction of features must be dropped](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2617) at lower zoom levels to make the densest tile acceptable at every zoom level. If no base zoom at or below the maxzoom will do, it [works from the other direction](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2589) instead, choosing a drop rate first and then the base zoom that rate implies.
Precalculating the dot dropping
-------------------------------
The per-feature minzoom field is what makes dot-dropping consistent from one zoom to the next, which is what keeps points from popping in and out as you zoom. Deciding it up front, for all the features at once, is what makes that consistency possible: no tile has to work out for itself which features it is entitled to show.
[`calc_feature_minzoom`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L299) assigns each feature the lowest zoom at which it will appear, by keeping a running counter per zoom level that is decremented by that zoom's interval (`droprate^(basezoom - z)`) for each feature that goes by. It is called from inside the merge, as the features are being copied into index order, so it sees them in quadkey order and therefore spreads its choices evenly over space rather than picking a random subset. `--preserve-point-density-threshold` adds an override: if a feature was assigned to a high zoom but is nevertheless very far from the last feature chosen for some low zoom, it gets pushed out at that low zoom anyway, so that sparse areas of the map don't go blank.
If the base zoom or drop rate had to be guessed, they weren't known yet when the merge ran, so there is a [fixup pass](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2672) that goes back and rewrites all the minzoom bytes in place, which is possible precisely because that byte is the last byte of each feature and its position is recorded in the index. `--drop-denser` is implemented [in the same pass](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2692), by sorting a sample of features by the gap to their predecessor and assigning zooms so that the sparsest ones appear first.
Running through the zoom levels
-------------------------------
Now it is finally time for tiling to begin. All that will remain after tiling is complete is to calculate the final bounding box and layer metadata and write it to the tileset.
The [outer loop of tiling](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3301) starts by running through the possible zoom levels. It normally starts at zoom 0 even if some higher `minzoom` was specified, because the entire geometry is now in a single file, not at all split up by tile. If we tried to use the same simple index-based technique as above to split it up into `minzoom` tiles, we would miss some features that are big enough to span (or be buffered into) multiple tiles. Instead, we must "divide and conquer" the low zooms to get to the high zooms correctly, even if some of them will not ultimately be written to the tileset.
The one exception is that [`choose_first_zoom`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L1147) checks whether the bounding box of all the features fits within a single tile at some higher zoom, and if so starts there, since dividing and conquering an empty world is a waste of time.
The basic strategy of tiling is that each zoom level will read through the current set of temporary files and will write out both a set of vector tiles into the tileset and a new set of internal temporary files for the next zoom level. For example, the initial single geometry file will produce the single zoom level 0 tile 0/0/0 as well as the four temporary files that will be used at the next step for tiles 1/0/0, 1/0/1, 1/1/0, and 1/1/1. Alternately, if the minzoom was 2, and we don't care about those zoom level 1 tiles at all, we can declare that the "next" zoom past 0 is 2, and the zoom level 0 processing can produce the right temporary files for tiles 2/0/0, 2/0/1, 2/0/2, 2/0/3, 2/1/0, and so on, and never do any work at all for zoom level 1.
Where it gets complicated is that we want Tippecanoe to be able to do as many of these things at the same time as possible, to take advantage of multiple CPUs. The zoom level 1 processing should be able to vectorize and subdivide all four of the zoom level 1 tiles at the same time rather than sequentially. But the ability to do this is limited by the number of CPUs, the number of files that can be open at one time, and the number of below-minzoom levels we are trying to skip over. Each CPU is going to be reading from one file and producing 4 (or 16, or 64, or maybe even 256, if we are skipping three zoom levels) new files as it tiles. Two CPUs can't write to the same output file without risking stomping on each other's work.
So `traverse_zooms` starts out by [making a new set of temporary files for the next zoom level](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3304) and calculating [how many threads there are](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3336) to split those files among. Then it takes all the current set of temporary files that need to be processed and [allocates them approximately evenly across the threads](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3363). (The assumption is that processing time will be proportional to file size, which may not be exactly right, but is reasonably close.)
Note also the `compressor` wrapped around each of those output files. The feature stream for each tile in the temporary files is zlib-compressed, which reduces both the disk space used and the I/O latency, at the cost of not being able to seek within a tile's data except by starting over. (Zoom 0's input is the exception: it is the file the sort produced, and it has to stay uncompressed so that the minzoom fixup can rewrite bytes in it.)
Once the input files and output files have been allocated to threads, it is time to [make a new set of parameter blocks](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3411) to tell each thread what files it is consuming and what other files it is producing, and to start the thread to do the work.
Each thread, then, [starts going through its list of input files](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3141). From each one, it reads a z/x/y tile number and [then calls the badly-named `write_tile`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3206) to do the work of processing that tile and writing out its children to that thread's set of output files. This loop continues until the thread has exhausted all the tiles in all its input files. The loop also does a little bit of work [to track the densest tile at maxzoom](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3214) which will be used later for the map center in the tileset metadata.
Each tile's data in the temporary file is preceded by an [uncompressed `estimated_complexity`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3148), the number of bytes of feature data that tile contains. It can only be known after the data has been written, so a placeholder is written first and then [rewritten with `pwrite`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2355) once the stream is finished (and likewise [for the initial zoom-0 file](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2227)). It is used by variable-depth pyramids, described below.
Retrying a whole zoom level
---------------------------
There is a loop around the whole zoom level, not just around each tile: [`for (size_t pass = 0;; pass++)`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3392). If any tile in the zoom found that it had to raise one of the as-needed thresholds (the minimum gap, the minimum extent, the minimum drop sequence, the minimum attribute value, or gamma) to make itself fit, that new threshold is [collected from all the threads](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3506), the zoom level is [erased from the output](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3563), and the whole zoom is tiled again with the higher threshold. This is why dropping is consistent across a zoom level rather than varying tile by tile.
Note that the tiles are written before it is known whether they will have to be thrown away, rather than the zoom being preflighted to find its thresholds first. That is the cheaper arrangement, because in the common case nothing has to be thrown away at all.
`--extend-zooms-if-still-dropping` is handled [here too](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3549): if the maxzoom is still dropping features, the maxzoom goes up by one and tiling continues.
The work of each tile
---------------------
The [first task of `write_tile`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1676) is to figure out whether it is actually subdividing the tile that it has been tasked with into children, grandchildren, great-grandchildren, or whatever, based on the minzoom and the number of output files it has to work with.
It then moves on to [a loop that usually only runs once](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1719), from the usual tile detail down to the minimum acceptable detail. In most cases this loop will be short-circuited at the end. It will only run multiple times if the tile is too big and Tippecanoe must try again — either at a higher dropping threshold or, as a last resort, at a lower resolution. If this happens it will also have to [rewind its input file](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1774) back to its original position, and restart the decompressor, so that it can reprocess the data.
Then it reads features one at a time from [`next_feature`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1122), which does the opposite of the feature serialization described above, and rather more besides. For each feature it:
* [Fills in the gap](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1180) to the previous feature, the squared planar distance that `--drop-densest-as-needed` and its relatives sort on. This is computed once, at zoom 0, and then carried along in the serialized feature, so that every zoom has the same idea of which features are in dense company.
* [Clips the feature to the tile](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L974) plus its buffer. `decode_geometry` has already both undone the `geometry_scale` bit shifting *and* adjusted the offset of the geometry so that (0,0) is at the top-left corner of the tile instead of the top-left corner of the earth. Both of these will be undone again when the geometry is reserialized into the child data for the next zoom level. At zoom 0 there is a special case that [duplicates features near the antimeridian](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L977) onto both sides of the world.
* [Writes the feature out to the child tiles](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1211) via [`rewrite`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L443) — but only on the first pass through the detail loop, since retries must not write the children again. `rewrite` works out from the feature's bounding box which children it can touch, and picks the shard for each child by [interleaving the low bits of x and y](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L507), being careful that all the data for any one child tile stays contiguous within one shard.
* Applies the per-feature `tippecanoe.minzoom` and `maxzoom` and the [`-j` feature filter](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1231). Note the ordering: the child tiles are written *before* these tests, so that a feature excluded from this zoom still reaches the zooms where it belongs.
* [Decides whether the feature is dropped by rate at this zoom](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1290), from the precalculated `feature_minzoom`, and if it is dropped, whether it should nevertheless be retained as one of the extra features of a `--retain-points-multiplier` cluster. The comparison uses a [fractional zoom level](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1163) derived from the bit-reversed index, so that the multiplier can target a specific number of features rather than only the powers of the drop rate.
* [Removes null attributes](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1321) — after the filter has run, since a filter may want to test for them.
Back in `write_tile`, each feature that comes back is assigned to its layer and then run through the gauntlet of size-reduction strategies, in a long `else if` chain: [gamma](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1983), [`-K` clustering](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1993), [`--drop-densest-as-needed`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2020), [`--cluster-densest-as-needed`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2028), [`--coalesce-densest-as-needed`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2051), [`--drop-smallest-as-needed`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2065), [`--coalesce-smallest-as-needed`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2075), [`--drop-fraction-as-needed`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2089), [`--coalesce-fraction-as-needed`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2097), and [`--drop-by-attribute-as-needed`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2110). They all have the same shape: sample the relevant quantity into a vector for later, compare it against the threshold for this pass, and either keep the feature or find an already-kept feature to [accumulate its attributes onto](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1544). Only the lead feature of a multiplier cluster can be dropped this way, but if it is, [it drags the rest of its cluster with it](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1970).
Two more things happen per feature before it is accepted:
* Polygons that are too small to be worth drawing at this zoom are [reduced to dust](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2160) by `reduce_tiny_poly`, which accumulates their area and occasionally emits a placeholder square so that the area is still somehow represented.
* If the tile is already hopeless — more features than could possibly fit even at one byte each — Tippecanoe [stops adding features](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2217) and just counts how many it skipped, so that it can extrapolate what the real size would have been without spending the memory to find out exactly. The size and feature limits are [scaled up](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2197) in proportion to the number of multiplier features being carried alongside the lead features, since those are expected to be filtered out by the consumer.
The rest of tiling
------------------
Once all the features have been read, the work becomes per-layer rather than per-feature. In order:
* [Multiplier sequence numbers](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2393) are attached to each feature, so that a consumer can reconstruct the clusters.
* [Cluster attributes](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2420) (`clustered`, `point_count`, `sqrt_point_count`, `point_count_abbreviated`) are added to anything that other features were clustered into, matching what [supercluster](https://github.com/mapbox/supercluster) produces.
* The [tilestats](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2453) are updated, since attribute accumulation may have introduced values that weren't in the input.
* [`--detect-shared-borders`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/shared_borders.cpp#L86) breaks the polygons of the layer into arcs at the points where they meet, so that a border shared between two polygons is simplified identically in both and no gaps open up between them.
* [Simplification](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2467) runs across several threads. Each feature goes through [`simplify_feature`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L595), which is either [Douglas-Peucker](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/clip.cpp#L909) or, with `--visvalingam`, [Visvalingam-Whyatt](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/visvalingam.cpp#L147); then [scales the geometry down to tile coordinates](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L682) and cleans polygons with [Clipper2](https://github.com/AngusJohnson/Clipper2), reviving any that were flattened out of existence as a [rectangle of the right area](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L551). Simplification can also happen [early, mid-tile](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2289), if the unsimplified geometry is piling up in memory.
* [`--reorder` and `--coalesce`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2520) sort features so that identical-attribute features are adjacent, and then merge those runs into single multi-features.
* [`--preserve-input-order`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2583) and [`--order-by`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2589) put the features into their final order. Both work on whole multiplier clusters, assembled and disassembled around the sort, so that a cluster's extra features stay with their lead feature.
* [`--limit-tile-feature-count`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2595) truncates the layer, if asked.
Then the layers are [converted into an `mvt_tile`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2617), with the pooled keys and values turned back into tile attributes by [`decode_meta`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L235), the postfilter is run if there is one, and the tile is [encoded and compressed](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2876).
And now the size checks, which are the reason for the whole loop. If the tile has too many features or too many bytes — extrapolated upward if features were skipped — then Tippecanoe picks the strategy it was told to use and [raises that strategy's threshold](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L2913), aiming at a fraction of the current size, and goes around again. The functions that choose the new threshold ([`choose_mingap`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L754) and its siblings) work on the samples that were collected on the way through. If the threshold can't be raised any further, that is an error: there is nothing left to try, and looping forever is worse than failing. If no dropping strategy was requested at all, the detail is reduced by one and the tile is tried again from the top.
If the tile does fit, it is [written to the database or directory](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3048) under the `db_lock`, the strategies used are folded into the zoom's statistics, and `write_tile` returns.
Variable-depth tile pyramids
----------------------------
`--generate-variable-depth-tile-pyramid` cuts across everything above, so it gets its own section.
The idea is that a tile in an empty or simple part of the map doesn't need children: if all of its features can be included at full precision, a client can overzoom that tile instead of downloading deeper ones. So when it is enabled, `write_tile` [makes an extra first attempt](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1701) at a much higher detail (`30 - z`) with simplification turned off, and only bothers to do so if the `estimated_complexity` recorded with the tile's data suggests it might work. If everything fits at that detail and nothing was dropped, the tile is a leaf: it is [added to `skip_children`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3065) and its descendants are [skipped rather than written](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3179) at the next zoom.
The bookkeeping around that is fiddlier than it sounds:
* The children's geometry is still in the stream even for a skipped tile, so [`skip_tile`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1659) has to read past it rather than seek.
* A zoom that later has to start dropping features [invalidates the truncation](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3180), because a leaf is only legitimate if it is complete. Those revived tiles have never written their children, so they have to do it on [the pass where the dropping started](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3191) rather than on pass 0 as usual.
* A feature with an explicit `tippecanoe.minzoom` deeper than the current zoom [blocks leafing](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1221), because it isn't in this tile and its children would never be generated, so it would appear at no zoom at all.
* The tileset's reported maxzoom is the [deepest zoom actually written](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L3605), not the requested one.
Plugins
-------
Tippecanoe can pipe each tile's contents through a shell command, either before tiling (`-C`, the prefilter) or after (`-c`, the postfilter). In both cases the interchange format is newline-delimited GeoJSON, one feature per line, so the filter can be anything from `grep` to a program of your own.
[`setup_filter`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/plugin.cpp#L376) does the plumbing: two pipes, a `fork`, and an [`execlp` of `sh -c`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/plugin.cpp#L436) with the tile's z, x, and y as `$1`, `$2`, and `$3`.
The prefilter is the more interesting of the two, because it has to interpose itself in the middle of the feature-reading loop. [`run_prefilter`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1381) runs in its own thread — a real thread, not just a subprocess, because Tippecanoe needs to write to and read from the filter at the same time and would otherwise deadlock — calling `next_feature` and writing each feature out as GeoJSON in world coordinates. Meanwhile the main loop in `write_tile` reads the filter's output with [`parse_feature`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1882) instead of calling `next_feature` itself. Note that the features handed to the prefilter have already been clipped to the tile and already had their dot-dropping decision made — whether the feature was dropped is passed through as a top-level [`dropped` member](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/write_json.cpp#L301) of each GeoJSON object, alongside its `index`, `sequence`, and `extent` — so the filter sees what the tile would have contained.
The postfilter is simpler, because by the time it runs the tile is a finished set of `mvt_layer`s: [`filter_layers`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/plugin.cpp#L470) writes them out as GeoJSON from [a writer thread](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/plugin.cpp#L47) and [parses the result back](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/plugin.cpp#L78) into layers, updating the layermap and tilestats from whatever came out, since the filter may have invented layers and attributes that were never in the input.
Both filters are [skipped below the minzoom](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile.cpp#L1801), since those tiles are only being generated to subdivide their way toward real ones.
Feature filters
---------------
Filtering through a subprocess is flexible but slow. For the common cases there is `-j`, which takes a filter expression and applies it in-process. The syntax is [the Mapbox GL Style Specification filter syntax](https://docs.mapbox.com/style-spec/reference/other/#other-filter), extended with `$type`, `$id`, and `$zoom` pseudo-attributes and with an `attribute-filter` form that removes individual attributes rather than whole features.
[`eval`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/evaluator.cpp#L94) is a straightforward recursive interpreter over the parsed JSON of the expression. It also understands a second, Felt-style expression dialect, and `--unidecode-data` lets string comparisons match transliterated forms so that a filter for "Zurich" can find "Zürich".
The same evaluator is used by `tile-join` and `tippecanoe-overzoom`, which is why it lives in its own file.
Writing tileset metadata
------------------------
When tiling is done, `read_input` computes the tileset's bounds and center and writes the metadata.
The center is the center of [the densest tile at maxzoom](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2798), which `traverse_zooms` tracked, [clamped](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2807) to lie within the bounds. The bounds themselves come in two forms: the ordinary one, and an [antimeridian-aware one](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2820) that picks whichever of the two world planes tracked during input gives the narrower box, so that a tileset covering Fiji doesn't claim to span the entire globe.
The per-thread layermaps are [merged](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/main.cpp#L2831) — this is where the differing per-thread layer numbering is finally reconciled, by name — and [`make_metadata`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/mbtiles.cpp#L668) assembles everything into a [`metadata` struct](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/mbtiles.hpp), which is then written either [into the sqlite `metadata` table](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/mbtiles.cpp#L468) or [into a `metadata.json`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/dirtiles.cpp#L288) in the output directory. Having the struct in the middle is what keeps the two output forms from drifting apart, and lets `tile-join` and the PMTiles writer reuse the same code.
The fields are:
* `name`, `description`, `version`, `type`, `format`, `minzoom`, `maxzoom`, `bounds`, `center`, and `attribution`, which are the standard mbtiles metadata.
* `antimeridian_adjusted_bounds`, the alternative bounds described above.
* `generator` and `generator_options`, which record the Tippecanoe version and the entire command line, so that a tileset can say how it was made.
* `strategies`, [an array with one entry per zoom level](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/mbtiles.cpp#L372) recording how many features were dropped by rate, by gamma, or as-needed; how many were coalesced; how many tiles had their detail reduced; how many tiny polygons there were; how many zooms were truncated by variable-depth pyramids; and what the largest tile would have been if nothing had been dropped. If you want to know whether your tileset is losing data, this is where to look.
* `tippecanoe_decisions`, which records the basezoom, drop rate, and multiplier that were actually used, which matters when they were guessed rather than specified.
* `json`, a string containing two things: `vector_layers`, the [per-layer list of attributes and their types](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/mbtiles.cpp#L719) that style editors read, and `tilestats`, the [more detailed statistics](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/mbtiles.cpp#L206) — counts, minimums, maximums, and sample values for every attribute of every layer. The tilestats are bounded by `--tile-stats-attributes-limit` and friends, because for a source with hundreds of millions of features the statistics can otherwise get quite large.
Finally, [`mbtiles_close`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/mbtiles.cpp#L823) runs `ANALYZE` and closes the database.
Converting to PMTiles
---------------------
If the output name ended in `.pmtiles`, everything above has been writing an ordinary mbtiles file, and [`mbtiles_map_image_to_pmtiles`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/pmtiles_file.cpp#L139) now converts it. It reads the tiles back out in tile-id order, writes them into the single-file PMTiles layout, and translates the metadata into [the PMTiles flavor of JSON metadata](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/pmtiles_file.cpp#L86). Because the mbtiles schema already deduplicates tiles by content hash, the PMTiles directory can carry that deduplication straight through.
The other programs
------------------
Tippecanoe proper is only part of what gets built. The rest of the tools in the [Makefile](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/Makefile#L33) share most of their code with it:
**`tile-join`** merges tilesets, joins attributes onto their features from a CSV or a sqlite database, filters layers and attributes, and can overzoom to a deeper maxzoom on the way. Its [main loop](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile-join.cpp#L1059) reads the inputs in parallel through a set of readers, groups the tiles by z/x/y, [hands each group to a worker thread](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile-join.cpp#L895) that [appends each source tile's layers into one output tile](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/tile-join.cpp#L101), and reassembles the metadata from the inputs'. Because it works entirely on already-tiled data, it can do in a few minutes what re-tiling from source would take hours to do.
**`tippecanoe-overzoom`** takes one or more source tiles and produces a single deeper tile from them, doing the clipping, the multiplier de-duplication, the attribute accumulation, the filtering, the simplification, and optionally the binning of points into a supplied set of polygons. [The overzoom function itself](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/clip.cpp#L1453) lives in `clip.cpp` because `tile-join` uses it too. It converts each source feature's geometry back to world coordinates, offsets it into the destination tile, and then runs it through the same clipping code that tiling uses.
**`tippecanoe-decode`** turns tiles back into GeoJSON, which is indispensable for figuring out what actually ended up in a tileset. `--stats` reports the size and feature count of each layer instead of the contents.
**`tippecanoe-json-tool`** does GeoJSON manipulation outside of tiling: sorting features by an attribute (so that `tile-join`-style joins can be done with `sort` and `join`) and joining CSV attributes onto features.
**`tippecanoe-enumerate`** lists the z/x/y of every tile in a tileset, one per line, which is the input to shell pipelines that want to do something to each tile.
Tests
-----
The [test suite](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/Makefile#L136) is mostly of one kind: run Tippecanoe over a small input in [`tests/`](https://github.com/felt/tippecanoe/tree/63fcac725abeb841a101abfc64189edd66d1cf14/tests) with some set of options, decode the result, and compare it against a checked-in expected output. This makes it easy to see the effect of a change — the diff in the expected outputs *is* the change — but it also means that a change to feature ordering shows up as an enormous diff, which is why a few comments in the code apologize for not fixing something because it would churn all the fixtures.
There is also [`unit.cpp`](https://github.com/felt/tippecanoe/blob/63fcac725abeb841a101abfc64189edd66d1cf14/unit.cpp), a small set of [Catch](https://github.com/catchorg/Catch2) unit tests for the pieces that are awkward to test end-to-end.
+27 -39
View File
@@ -24,7 +24,6 @@
#include "dirtiles.hpp"
#include "pmtiles_file.hpp"
#include "errors.hpp"
#include "usage.hpp"
int minzoom = 0;
int maxzoom = 32;
@@ -550,42 +549,8 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> co
}
}
static const struct option long_options[] = {
{"Tiles to decode", 0, 0, 0},
{"minimum-zoom", required_argument, 0, 'Z'},
{"maximum-zoom", required_argument, 0, 'z'},
{"layer", required_argument, 0, 'l'},
{"Output format", 0, 0, 0},
{"projection", required_argument, 0, 's'},
{"fractional-coordinates", no_argument, 0, 'F'},
{"integer-coordinates", no_argument, 0, 'I'},
{"tag-layer-and-zoom", no_argument, 0, 'c'},
{"stats", no_argument, 0, 'S'},
{"Filtering the output", 0, 0, 0},
{"include", required_argument, 0, 'y'},
{"exclude-metadata-row", required_argument, 0, 'x'},
{"Ignoring errors in the input", 0, 0, 0},
{"force", no_argument, 0, 'f'},
{0, 0, 0, 0},
};
// the options above, with the usage message headings removed
static struct option real_long_options[sizeof(long_options) / sizeof(long_options[0])];
void usage(char **argv) {
static const char *const forms[] = {
"[options] tileset",
"[options] tileset zoom x y",
NULL,
};
print_usage(stderr, argv[0], forms, long_options, NULL);
fprintf(stderr, "\nThe tileset can be an .mbtiles or .pmtiles file or a directory of tiles,\n");
fprintf(stderr, "or, if zoom/x/y is specified, a single .pbf tile.\n");
fprintf(stderr, "Usage: %s [-s projection] [-Z minzoom] [-z maxzoom] [-l layer ...] file.mbtiles [zoom x y]\n", argv[0]);
exit(EXIT_ARGS);
}
@@ -599,10 +564,33 @@ int main(int argc, char **argv) {
std::set<std::string> exclude_meta;
int coordinate_mode = 0;
strip_usage_headings(long_options, real_long_options);
std::string getopt_str = getopt_string(real_long_options);
struct option long_options[] = {
{"projection", required_argument, 0, 's'},
{"fractional-coordinates", no_argument, 0, 'F'},
{"integer-coordinates", no_argument, 0, 'I'},
{"maximum-zoom", required_argument, 0, 'z'},
{"minimum-zoom", required_argument, 0, 'Z'},
{"layer", required_argument, 0, 'l'},
{"tag-layer-and-zoom", no_argument, 0, 'c'},
{"stats", no_argument, 0, 'S'},
{"force", no_argument, 0, 'f'},
{"exclude-metadata-row", required_argument, 0, 'x'},
{"include", required_argument, 0, 'y'},
{0, 0, 0, 0},
};
while ((i = getopt_long(argc, argv, getopt_str.c_str(), real_long_options, NULL)) != -1) {
std::string getopt_str;
for (size_t lo = 0; long_options[lo].name != NULL; lo++) {
if (long_options[lo].val > ' ') {
getopt_str.push_back(long_options[lo].val);
if (long_options[lo].has_arg == required_argument) {
getopt_str.push_back(':');
}
}
}
while ((i = getopt_long(argc, argv, getopt_str.c_str(), long_options, NULL)) != -1) {
switch (i) {
case 0:
break;
+2 -19
View File
@@ -1,11 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <string>
#include <sqlite3.h>
#include "errors.hpp"
#include "usage.hpp"
void enumerate(char *fname) {
sqlite3 *db;
@@ -51,20 +48,8 @@ void enumerate(char *fname) {
}
}
// there are no options, but the table is still what the usage message
// and the getopt string are derived from, so that they will keep up
// with any options that are added later
static const struct option long_options[] = {
{0, 0, 0, 0},
};
void usage(char **argv) {
static const char *const forms[] = {
"file.mbtiles ...",
NULL,
};
print_usage(stderr, argv[0], forms, long_options, NULL);
fprintf(stderr, "Usage: %s file.mbtiles ...\n", argv[0]);
exit(EXIT_ARGS);
}
@@ -73,9 +58,7 @@ int main(int argc, char **argv) {
// extern char *optarg;
int i;
std::string getopt_str = getopt_string(long_options);
while ((i = getopt_long(argc, argv, getopt_str.c_str(), long_options, NULL)) != -1) {
while ((i = getopt(argc, argv, "")) != -1) {
usage(argv);
}
+23 -34
View File
@@ -13,7 +13,6 @@
#include "geojson-loop.hpp"
#include "milo/dtoa_milo.h"
#include "errors.hpp"
#include "usage.hpp"
int fail = EXIT_SUCCESS;
bool wrap = false;
@@ -408,45 +407,34 @@ void process(FILE *fp, const char *fname) {
json_end(jp);
}
static const struct option long_options[] = {
{"Wrapping the output", 0, 0, 0},
{"wrap", no_argument, 0, 'w'},
{"Sorting and joining", 0, 0, 0},
{"extract", required_argument, 0, 'e'},
{"csv", required_argument, 0, 'c'},
{"empty-csv-columns-are-null", no_argument, &pe, 1},
{"", 0, 0, 0},
{"prevent", required_argument, 0, 'p'},
{0, 0, 0, 0},
};
// the options above, with the usage message headings removed
static struct option real_long_options[sizeof(long_options) / sizeof(long_options[0])];
void usage(char **argv) {
static const char *const forms[] = {
"[options] [file.json ...]",
NULL,
};
print_usage(stderr, argv[0], forms, long_options, NULL);
fprintf(stderr, "\nIf no files are named, the JSON is read from the standard input.\n");
exit(EXIT_ARGS);
}
int main(int argc, char **argv) {
const char *csv = NULL;
strip_usage_headings(long_options, real_long_options);
std::string getopt_str = getopt_string(real_long_options);
struct option long_options[] = {
{"wrap", no_argument, 0, 'w'},
{"extract", required_argument, 0, 'e'},
{"csv", required_argument, 0, 'c'},
{"empty-csv-columns-are-null", no_argument, &pe, 1},
{"prevent", required_argument, 0, 'p'},
{0, 0, 0, 0},
};
std::string getopt_str;
for (size_t lo = 0; long_options[lo].name != NULL; lo++) {
if (long_options[lo].val > ' ') {
getopt_str.push_back(long_options[lo].val);
if (long_options[lo].has_arg == required_argument) {
getopt_str.push_back(':');
}
}
}
extern int optind;
int i;
while ((i = getopt_long(argc, argv, getopt_str.c_str(), real_long_options, NULL)) != -1) {
while ((i = getopt_long(argc, argv, getopt_str.c_str(), long_options, NULL)) != -1) {
switch (i) {
case 0:
break;
@@ -473,7 +461,8 @@ int main(int argc, char **argv) {
break;
default:
usage(argv);
fprintf(stderr, "Unexpected option -%c\n", i);
exit(EXIT_ARGS);
}
}
+369 -355
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -53,6 +53,7 @@ extern long long extend_zooms_max;
extern int retain_points_multiplier;
extern size_t maximum_string_attribute_length;
extern unsigned long long preserve_multiplier_density_threshold;
extern const char *tmpdir;
struct order_field {
std::string name;
+782 -591
View File
File diff suppressed because it is too large Load Diff
@@ -1296,10 +1296,7 @@ void correct_tree(ring_manager<T>& manager) {
}
if (!found) {
if ((*itr)->is_hole()) {
// No remaining ring contains this hole (degenerate input, e.g. stacked
// duplicate rings from coalesced tiny-polygon placeholders); drop it
// rather than fail the entire tiling run.
remove_ring_and_points(*itr, manager, false);
throw std::runtime_error("Could not properly place hole to a parent.");
} else {
// Assign to base of tree by passing nullptr
reassign_as_child(*itr, static_cast<ring_ptr<T>>(nullptr), manager);
+1 -4
View File
@@ -701,10 +701,7 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla
m.strategies_json = stringify_strategies(strategies);
if (std::isinf(droprate)) {
// JSON has no representation for infinity, so substitute a huge
// finite value. The cast is explicit because LLONG_MAX itself is
// not representable as a double and rounds up to 2^63.
droprate = (double) LLONG_MAX;
droprate = LLONG_MAX;
}
if (basezoom != maxzoom || droprate != 2.5 || retain_points_multiplier != 1) {
m.decisions_json = std::string("{") +
+1 -10
View File
@@ -93,21 +93,12 @@ struct mvt_value {
long long sint_value;
bool bool_value;
int null_value;
// Initializing string_value initializes the union's full width, which
// the static_assert below checks. Setting only a narrower member (a
// double, say) would leave the remaining bytes indeterminate, and the
// implicit copy constructor copies the union as a whole, so those
// bytes get read even when they aren't the member in use.
struct {
size_t off;
size_t len;
} string_value = {0, 0};
} string_value;
} numeric_value;
static_assert(sizeof(numeric_value) == sizeof(numeric_value.string_value),
"string_value must span the whole union, since its default member "
"initializer is what initializes the union");
std::string get_string_value() const {
if (type == mvt_string) {
return std::string(*s, numeric_value.string_value.off, numeric_value.string_value.len);
+1
View File
@@ -29,6 +29,7 @@
#define A_VISVALINGAM ((int) 'v')
#define A_DETECT_WRAPAROUND ((int) 'w')
#define A_KEEP_POINT_CLUSTER_POSITION ((int) 'a')
#define A_DISTINGUISH_DUPLICATES ((int) 'u')
#define A_DROP_BY_ATTRIBUTE_AS_NEEDED ((int) 'A')
#define P_TILE_COMPRESSION ((int) 'C')
+37 -62
View File
@@ -11,7 +11,6 @@
#include "text.hpp"
#include "read_json.hpp"
#include "projection.hpp"
#include "usage.hpp"
extern char *optarg;
extern int optind;
@@ -31,60 +30,11 @@ std::set<std::string> keep;
std::set<std::string> exclude;
std::vector<std::string> exclude_prefix;
static const struct option long_options[] = {
{"Output tile", 0, 0, 0},
{"output", required_argument, 0, 'o'},
{"source-tile", required_argument, 0, 't'},
{"no-tile-compression", no_argument, 0, 'd' & 0x1F},
{"Tile resolution", 0, 0, 0},
{"full-detail", required_argument, 0, 'd'},
{"buffer", required_argument, 0, 'b'},
{"Filtering feature attributes", 0, 0, 0},
{"include", required_argument, 0, 'y'},
{"exclude", required_argument, 0, 'x'},
{"exclude-prefix", required_argument, 0, 'x' & 0x1F},
{"Modifying feature attributes", 0, 0, 0},
{"accumulate-attribute", required_argument, 0, 'E'},
{"Filtering features", 0, 0, 0},
{"feature-filter", required_argument, 0, 'j'},
{"feature-filter-file", required_argument, 0, 'J'},
{"filter-points-multiplier", no_argument, 0, 'm'},
{"deduplicate-by-id", no_argument, 0, 'i' & 0x1F},
{"Line and polygon simplification", 0, 0, 0},
{"line-simplification", required_argument, 0, 'S'},
{"tiny-polygon-size", required_argument, 0, 's' & 0x1F},
{"Reordering features within the tile", 0, 0, 0},
{"preserve-input-order", no_argument, 0, 'o' & 0x1F},
{"", 0, 0, 0},
{"unidecode-data", required_argument, 0, 'u' & 0x1F},
{0, 0, 0, 0},
};
// the options above, with the usage message headings removed
static struct option real_long_options[sizeof(long_options) / sizeof(long_options[0])];
void usage(char **argv) {
static const char *const forms[] = {
"[options] tile.pbf.gz oz/ox/oy nz/nx/ny",
"[options] --source-tile=nz/nx/ny tile.pbf.gz oz/ox/oy ...",
NULL,
};
static const struct usage_required_option required[] = {
{"output", "newtile.pbf.gz", 0},
{NULL, NULL, 0},
};
print_usage(stderr, argv[0], forms, long_options, required);
fprintf(stderr, "\nThe tile nz/nx/ny is created from the tile or tiles oz/ox/oy that contain it.\n");
fprintf(stderr, "In the second form, each source tile is named by a file name and a z/x/y pair.\n");
fprintf(stderr, "Usage: %s -o newtile.pbf.gz tile.pbf.gz oz/ox/oy nz/nx/ny\n", argv[0]);
fprintf(stderr, "to create tile nz/nx/ny from tile oz/ox/oy\n");
fprintf(stderr, "Usage: %s -o newtile.pbf.gz -t nz/nx/ny tile.pbf.gz oz/ox/oy tile2.pbf.gz oz2/ox2/oy2\n", argv[0]);
fprintf(stderr, "to create tile nz/nx/ny from tiles oz/ox/oy and oz2/ox2/oy2\n");
exit(EXIT_FAILURE);
}
@@ -117,11 +67,41 @@ int main(int argc, char **argv) {
std::vector<input_tile> sources;
strip_usage_headings(long_options, real_long_options);
std::string getopt_str = getopt_string(real_long_options);
struct option long_options[] = {
{"include", required_argument, 0, 'y'},
{"exclude", required_argument, 0, 'x'},
{"exclude-prefix", required_argument, 0, 'x' & 0x1F},
{"full-detail", required_argument, 0, 'd'},
{"buffer", required_argument, 0, 'b'},
{"output", required_argument, 0, 'o'},
{"filter-points-multiplier", no_argument, 0, 'm'},
{"feature-filter", required_argument, 0, 'j'},
{"feature-filter-file", required_argument, 0, 'J'},
{"preserve-input-order", no_argument, 0, 'o' & 0x1F},
{"accumulate-attribute", required_argument, 0, 'E'},
{"unidecode-data", required_argument, 0, 'u' & 0x1F},
{"line-simplification", required_argument, 0, 'S'},
{"tiny-polygon-size", required_argument, 0, 's' & 0x1F},
{"source-tile", required_argument, 0, 't'},
{"no-tile-compression", no_argument, 0, 'd' & 0x1F},
{"deduplicate-by-id", no_argument, 0, 'i' & 0x1F},
{0, 0, 0, 0},
};
std::string getopt_str;
for (size_t lo = 0; long_options[lo].name != NULL; lo++) {
if (long_options[lo].val > ' ') {
getopt_str.push_back(long_options[lo].val);
if (long_options[lo].has_arg == required_argument) {
getopt_str.push_back(':');
}
}
}
int option_index = 0;
while ((i = getopt_long(argc, argv, getopt_str.c_str(), real_long_options, &option_index)) != -1) {
while ((i = getopt_long(argc, argv, getopt_str.c_str(), long_options, &option_index)) != -1) {
switch (i) {
case 'y':
keep.insert(optarg);
@@ -201,11 +181,6 @@ int main(int argc, char **argv) {
std::vector<input_tile> its;
int nz, nx, ny;
if (outfile == NULL) {
fprintf(stderr, "%s: must specify -o newtile.pbf.gz\n", argv[0]);
usage(argv);
}
if (outtile == NULL) { // single input
if (argc - optind != 3) {
fprintf(stderr, "Wrong number of arguments\n");
+3 -10
View File
@@ -665,18 +665,10 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
// VT_POINT extent will be calculated in write_tile from the distance between adjacent features.
}
// Clamp before converting, since converting a double that is out of range
// for a long long is undefined. The bounds are asymmetric: LLONG_MAX is not
// representable as a double and rounds up to 2^63, so the upper bound has to
// be exclusive, while LLONG_MIN is exactly -2^63 and so can be included.
// Areas are signed, so holes that outweigh their rings can make this
// negative.
if (extent >= (double) LLONG_MIN && extent < (double) LLONG_MAX) {
if (extent <= LLONG_MAX) {
sf.extent = (long long) extent;
} else if (extent < 0) {
sf.extent = LLONG_MIN;
} else {
sf.extent = LLONG_MAX; // also the NaN case
sf.extent = LLONG_MAX;
}
if (sst->want_dist && sf.t == VT_POLYGON) {
@@ -751,6 +743,7 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf, std::
prevent[P_DYNAMIC_DROP] ||
additional[A_INCREASE_GAMMA_AS_NEEDED] ||
additional[A_GENERATE_POLYGON_LABEL_POINTS] ||
additional[A_DISTINGUISH_DUPLICATES] ||
sst->uses_gamma ||
retain_points_multiplier > 1 ||
preserve_multiplier_density_threshold > 0 ||
+183
View File
@@ -0,0 +1,183 @@
{"type":"Feature","properties":{"a":0},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":0},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":0},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":1},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":1},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":1},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":2},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":2},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":2},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":3},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":3},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":3},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":4},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":4},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":4},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":5},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":5},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":5},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":6},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":6},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":6},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":7},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":7},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":7},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":8},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":8},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":8},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":9},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":9},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":9},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":10},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":10},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":10},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":11},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":11},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":11},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":12},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":12},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":12},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":13},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":13},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":13},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":14},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":14},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":14},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":15},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":15},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":15},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":16},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":16},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":16},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":17},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":17},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":17},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":18},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":18},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":18},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":19},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":19},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":19},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":20},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":20},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":20},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":21},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":21},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":21},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":22},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":22},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":22},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":23},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":23},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":23},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":24},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":24},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":24},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":25},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":25},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":25},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":26},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":26},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":26},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":27},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":27},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":27},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":28},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":28},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":28},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":29},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":29},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":29},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":30},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":30},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":30},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":31},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":31},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":31},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":32},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":32},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":32},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":33},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":33},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":33},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":34},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":34},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":34},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":35},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":35},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":35},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":36},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":36},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":36},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":37},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":37},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":37},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":38},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":38},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":38},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":39},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":39},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":39},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":40},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":40},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":40},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":41},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":41},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":41},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":42},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":42},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":42},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":43},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":43},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":43},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":44},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":44},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":44},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":45},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":45},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":45},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":46},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":46},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":46},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":47},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":47},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":47},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":48},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":48},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":48},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":49},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":49},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":49},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":50},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":50},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":50},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":51},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":51},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":51},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":52},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":52},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":52},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":53},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":53},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":53},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":54},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":54},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":54},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":55},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":55},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":55},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":56},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":56},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":56},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":57},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":57},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":57},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":58},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":58},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":58},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":59},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":59},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":59},"geometry":{"type":"Point","coordinates":[3,1]}}
{"type":"Feature","properties":{"a":60},"geometry":{"type":"Point","coordinates":[1,1]}}
{"type":"Feature","properties":{"b":60},"geometry":{"type":"Point","coordinates":[2,1]}}
{"type":"Feature","properties":{"c":60},"geometry":{"type":"Point","coordinates":[3,1]}}
@@ -0,0 +1,755 @@
{ "type": "FeatureCollection", "properties": {
"antimeridian_adjusted_bounds": "1.000000,1.000000,3.000000,1.000000",
"bounds": "1.000000,1.000000,3.000000,1.000000",
"center": "3.000000,1.000000,1",
"description": "tests/distinguish-duplicates/out/-z1_-r1_-b0_--distinguish-duplicates.json.check.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -a@ -f -o tests/distinguish-duplicates/out/-z1_-r1_-b0_--distinguish-duplicates.json.check.mbtiles -z1 -r1 -b0 --distinguish-duplicates tests/distinguish-duplicates/in.json",
"json": "{\"vector_layers\":[{\"id\":\"in\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":1,\"fields\":{\"a\":\"Number\",\"b\":\"Number\",\"c\":\"Number\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"in\",\"count\":183,\"geometry\":\"Point\",\"attributeCount\":3,\"attributes\":[{\"attribute\":\"a\",\"count\":61,\"type\":\"number\",\"values\":[0,1,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,26,27,28,29,3,30,31,32,33,34,35,36,37,38,39,4,40,41,42,43,44,45,46,47,48,49,5,50,51,52,53,54,55,56,57,58,59,6,60,7,8,9],\"min\":0,\"max\":60},{\"attribute\":\"b\",\"count\":61,\"type\":\"number\",\"values\":[0,1,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,26,27,28,29,3,30,31,32,33,34,35,36,37,38,39,4,40,41,42,43,44,45,46,47,48,49,5,50,51,52,53,54,55,56,57,58,59,6,60,7,8,9],\"min\":0,\"max\":60},{\"attribute\":\"c\",\"count\":61,\"type\":\"number\",\"values\":[0,1,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,26,27,28,29,3,30,31,32,33,34,35,36,37,38,39,4,40,41,42,43,44,45,46,47,48,49,5,50,51,52,53,54,55,56,57,58,59,6,60,7,8,9],\"min\":0,\"max\":60}]}]}}",
"maxzoom": "1",
"minzoom": "0",
"name": "tests/distinguish-duplicates/out/-z1_-r1_-b0_--distinguish-duplicates.json.check.mbtiles",
"tippecanoe_decisions": "{\"basezoom\":1,\"droprate\":1,\"retain_points_multiplier\":1}",
"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": { "a": 0 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 0 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 0 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 1 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 1 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 1 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 2 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 2 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 2 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 3 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 3 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 3 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 4 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 4 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 4 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 5 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 5 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 5 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 6 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 6 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 6 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 7 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 7 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 7 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 8 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 8 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 8 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 9 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 9 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 9 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 10 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 10 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 10 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 11 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 11 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 11 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 12 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 12 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 12 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 13 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 13 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 13 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 14 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 14 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 14 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 15 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 15 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 15 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 16 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 16 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 16 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 17 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 17 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 17 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 18 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 18 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 18 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 19 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 19 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 19 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 20 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 20 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 20 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 21 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 21 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 21 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 22 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 22 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 22 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 23 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 23 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 23 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 24 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 24 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 24 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 25 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 25 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 25 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 26 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 26 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 26 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 27 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 27 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 27 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 28 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 28 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 28 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 29 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 29 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 29 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 30 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 30 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 30 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 31 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 31 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 31 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 32 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 32 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 32 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 33 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 33 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 33 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 34 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 34 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 34 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 35 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 35 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 35 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 36 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 36 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 36 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 37 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 37 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 37 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 38 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 38 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 38 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 39 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 39 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 39 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 40 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 40 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 40 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 41 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 41 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 41 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 42 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 42 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 42 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 43 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 43 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 43 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 44 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 44 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 44 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 45 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 45 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 45 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 46 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 46 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 46 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 47 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 47 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 47 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 48 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 48 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 48 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 49 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 49 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 49 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 50 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 50 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 50 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 51 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 52 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 53 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 54 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 55 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 56 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 57 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 58 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 59 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "a": 60 }, "geometry": { "type": "Point", "coordinates": [ 1.054688, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 51 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 52 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 53 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 54 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 55 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 56 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 57 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 58 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 59 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "b": 60 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 51 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 52 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 53 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 54 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 55 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 56 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 57 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 58 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 59 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
,
{ "type": "Feature", "properties": { "c": 60 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 0.966751 ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 1, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { "a": 0 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 0 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 0 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 1 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 1 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 1 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 2 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 2 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 2 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 3 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 3 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 3 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 4 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 4 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 4 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 5 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 5 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 5 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 6 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 6 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 6 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 7 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 7 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 7 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 8 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 8 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 8 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 9 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 9 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 9 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 10 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 10 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 10 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 11 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 11 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 11 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 12 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 12 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 12 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 13 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 13 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 13 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 14 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 14 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 14 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 15 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 15 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 15 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 16 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 16 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 16 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 17 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 17 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 17 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 18 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 18 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 18 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 19 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 19 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 19 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 20 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 20 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 20 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 21 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 21 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 21 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 22 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 22 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 22 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 23 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 23 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 23 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 24 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 24 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 24 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 25 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 25 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 25 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 26 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 26 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 26 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 27 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 27 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 27 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 28 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 28 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 28 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 29 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 29 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 29 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 30 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 30 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 30 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 31 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 31 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 31 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 32 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 32 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 32 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 33 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 33 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 33 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 34 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 34 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 34 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 35 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 35 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 35 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 36 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 36 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 36 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 37 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 37 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 37 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 38 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 38 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 38 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 39 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 39 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 39 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 40 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 40 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 40 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 41 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 41 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 41 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 42 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 42 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 42 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 43 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 43 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 43 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 44 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 44 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 44 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 45 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 45 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 45 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 46 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 46 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 46 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 47 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 47 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 47 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 48 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 48 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 48 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 49 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 49 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 49 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 50 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 50 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 50 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 51 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 52 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 53 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 54 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 55 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 56 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 57 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 58 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 59 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "a": 60 }, "geometry": { "type": "Point", "coordinates": [ 1.010742, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 51 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 52 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 53 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 54 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 55 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 56 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 57 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 58 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 59 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "b": 60 }, "geometry": { "type": "Point", "coordinates": [ 2.021484, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 51 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 52 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 53 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 54 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 55 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 56 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 57 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 58 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 59 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
,
{ "type": "Feature", "properties": { "c": 60 }, "geometry": { "type": "Point", "coordinates": [ 2.988281, 1.010690 ] } }
] }
] }
] }
+55 -80
View File
@@ -44,7 +44,6 @@
#include "geometry.hpp"
#include "thread.hpp"
#include "platform.hpp"
#include "usage.hpp"
int pk = false;
int pC = false;
@@ -893,7 +892,7 @@ void *join_worker(void *v) {
}
void dispatch_tasks(std::map<zxy, std::vector<std::string>> &tasks, std::vector<std::map<std::string, layermap_entry>> &layermaps, sqlite3 *outdb, const char *outdir, std::vector<std::string> &header, std::map<std::string, std::vector<std::string>> &mapping, sqlite3 *db, std::set<std::string> &exclude, std::set<std::string> &include, int ifmatched, std::set<std::string> &keep_layers, std::set<std::string> &remove_layers, json_object *filter, struct tileset_reader *readers, double *minlat, double *minlon, double *maxlat, double *maxlon, double *minlon2, double *maxlon2) {
std::vector<pthread_t> pthreads(CPUS);
pthread_t pthreads[CPUS];
std::vector<arg> args;
for (size_t i = 0; i < CPUS; i++) {
@@ -1254,81 +1253,8 @@ void decode(struct tileset_reader *readers, std::map<std::string, layermap_entry
}
}
static const struct option long_options[] = {
{"Output tileset", 0, 0, 0},
{"output", required_argument, 0, 'o'},
{"output-to-directory", required_argument, 0, 'e'},
{"force", no_argument, 0, 'f'},
{"Tileset description and attribution", 0, 0, 0},
{"name", required_argument, 0, 'n'},
{"attribution", required_argument, 0, 'A'},
{"description", required_argument, 0, 'N'},
{"Input tilesets", 0, 0, 0},
{"read-from", required_argument, 0, 'r'},
{"Zoom levels", 0, 0, 0},
{"maximum-zoom", required_argument, 0, 'z'},
{"minimum-zoom", required_argument, 0, 'Z'},
{"overzoom", no_argument, 0, 'O'},
{"buffer", required_argument, 0, 'b'},
{"Layer names", 0, 0, 0},
{"layer", required_argument, 0, 'l'},
{"exclude-layer", required_argument, 0, 'L'},
{"rename-layer", required_argument, 0, 'R'},
{"Joining with a CSV file", 0, 0, 0},
{"csv", required_argument, 0, 'c'},
{"if-matched", no_argument, 0, 'i'},
{"empty-csv-columns-are-null", no_argument, &pe, 1},
{"Filtering feature attributes", 0, 0, 0},
{"exclude", required_argument, 0, 'x'},
{"include", required_argument, 0, 'y'},
{"exclude-all", no_argument, 0, 'X'},
{"exclude-all-tile-attributes", no_argument, 0, '~'},
{"exclude-all-tile-geometries", no_argument, 0, '~'},
{"Filtering features by attributes", 0, 0, 0},
{"feature-filter-file", required_argument, 0, 'J'},
{"feature-filter", required_argument, 0, 'j'},
{"Setting or disabling tile size limits", 0, 0, 0},
{"no-tile-size-limit", no_argument, &pk, 1},
{"no-tile-compression", no_argument, &pC, 1},
{"no-tile-stats", no_argument, &pg, 1},
{"tile-stats-attributes-limit", required_argument, 0, '~'},
{"tile-stats-sample-values-limit", required_argument, 0, '~'},
{"tile-stats-values-limit", required_argument, 0, '~'},
{"Progress indicator", 0, 0, 0},
{"quiet", no_argument, 0, 'q'},
{"", 0, 0, 0},
{"prevent", required_argument, 0, 'p'},
{"unidecode-data", required_argument, 0, '~'},
{0, 0, 0, 0},
};
// the options above, with the usage message headings removed
static struct option real_long_options[sizeof(long_options) / sizeof(long_options[0])];
void usage(char **argv) {
static const char *const forms[] = {
"[options] source.mbtiles ...",
"[options] --read-from=inputfile.txt",
NULL,
};
static const struct usage_required_option required[] = {
{"output", "new.mbtiles", 1},
{"output-to-directory", "directory", 1},
{NULL, NULL, 0},
};
print_usage(stderr, argv[0], forms, long_options, required);
fprintf(stderr, "Usage: %s [-f] [-i] [-pk] [-pC] [-c joins.csv] [-X] [-x exclude ...] [-y include ...] [-r inputfile.txt ] -o new.mbtiles source.mbtiles ...\n", argv[0]);
exit(EXIT_ARGS);
}
@@ -1372,8 +1298,57 @@ int main(int argc, char **argv) {
std::string set_name, set_description, set_attribution;
strip_usage_headings(long_options, real_long_options);
std::string getopt_str = getopt_string(real_long_options);
struct option long_options[] = {
{"output", required_argument, 0, 'o'},
{"output-to-directory", required_argument, 0, 'e'},
{"force", no_argument, 0, 'f'},
{"overzoom", no_argument, 0, 'O'},
{"buffer", required_argument, 0, 'b'},
{"if-matched", no_argument, 0, 'i'},
{"attribution", required_argument, 0, 'A'},
{"name", required_argument, 0, 'n'},
{"description", required_argument, 0, 'N'},
{"prevent", required_argument, 0, 'p'},
{"csv", required_argument, 0, 'c'},
{"exclude", required_argument, 0, 'x'},
{"exclude-all", no_argument, 0, 'X'},
{"include", required_argument, 0, 'y'},
{"exclude-all-tile-attributes", no_argument, 0, '~'},
{"exclude-all-tile-geometries", no_argument, 0, '~'},
{"layer", required_argument, 0, 'l'},
{"exclude-layer", required_argument, 0, 'L'},
{"quiet", no_argument, 0, 'q'},
{"maximum-zoom", required_argument, 0, 'z'},
{"minimum-zoom", required_argument, 0, 'Z'},
{"feature-filter-file", required_argument, 0, 'J'},
{"feature-filter", required_argument, 0, 'j'},
{"rename-layer", required_argument, 0, 'R'},
{"read-from", required_argument, 0, 'r'},
{"use-attribute-for-id", required_argument, 0, '~'},
{"no-tile-size-limit", no_argument, &pk, 1},
{"no-tile-compression", no_argument, &pC, 1},
{"empty-csv-columns-are-null", no_argument, &pe, 1},
{"no-tile-stats", no_argument, &pg, 1},
{"tile-stats-attributes-limit", required_argument, 0, '~'},
{"tile-stats-sample-values-limit", required_argument, 0, '~'},
{"tile-stats-values-limit", required_argument, 0, '~'},
{"unidecode-data", required_argument, 0, '~'},
{0, 0, 0, 0},
};
std::string getopt_str;
for (size_t lo = 0; long_options[lo].name != NULL; lo++) {
if (long_options[lo].val > ' ') {
getopt_str.push_back(long_options[lo].val);
if (long_options[lo].has_arg == required_argument) {
getopt_str.push_back(':');
}
}
}
extern int optind;
extern char *optarg;
@@ -1382,7 +1357,7 @@ int main(int argc, char **argv) {
std::string commandline = format_commandline(argc, argv);
int option_index = 0;
while ((i = getopt_long(argc, argv, getopt_str.c_str(), real_long_options, &option_index)) != -1) {
while ((i = getopt_long(argc, argv, getopt_str.c_str(), long_options, &option_index)) != -1) {
switch (i) {
case 0:
break;
@@ -1527,7 +1502,7 @@ int main(int argc, char **argv) {
break;
case '~': {
const char *opt = real_long_options[option_index].name;
const char *opt = long_options[option_index].name;
if (strcmp(opt, "tile-stats-attributes-limit") == 0) {
max_tilestats_attributes = atoi(optarg);
} else if (strcmp(opt, "tile-stats-sample-values-limit") == 0) {
+159 -126
View File
@@ -61,6 +61,9 @@ extern "C" {
#define COORD_OFFSET (4LL << 32)
#define SHIFT_RIGHT(a) ((long long) std::round((double) (a) / (1LL << geometry_scale)))
#define XSTRINGIFY(s) STRINGIFY(s)
#define STRINGIFY(s) #s
pthread_mutex_t db_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t var_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t task_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -538,6 +541,7 @@ struct simplification_worker_arg {
std::vector<std::shared_ptr<serial_feature>> *features = NULL;
int task = 0;
int tasks = 0;
bool trying_to_stop_early = false;
drawvec *shared_nodes;
node *shared_nodes_map;
@@ -672,7 +676,9 @@ static void *simplification_worker(void *v) {
for (size_t i = a->task; i < (*features).size(); i += a->tasks) {
double area = 0;
area = simplify_feature(&*((*features)[i]), *(a->shared_nodes), a->shared_nodes_map, a->nodepos, *(a->shared_nodes_bloom));
if (!a->trying_to_stop_early) {
area = simplify_feature(&*((*features)[i]), *(a->shared_nodes), a->shared_nodes_map, a->nodepos, *(a->shared_nodes_bloom));
}
signed char t = (*features)[i]->t;
int z = (*features)[i]->z;
@@ -687,18 +693,20 @@ static void *simplification_worker(void *v) {
{
drawvec before = geom;
// we can try scaling up because this is now tile scale
coalesce_polygon(geom, true);
if (additional[A_DEBUG_POLYGON]) {
check_polygon(geom);
}
if (!a->trying_to_stop_early) {
// we can try scaling up because this is now tile scale
coalesce_polygon(geom, true);
if (additional[A_DEBUG_POLYGON]) {
check_polygon(geom);
}
if (geom.size() < 3) {
if (area > 0) {
// area is in world coordinates, calculated before scaling down
geom = revive_polygon(before, area, z, out_detail);
} else {
geom.clear();
if (geom.size() < 3) {
if (area > 0) {
// area is in world coordinates, calculated before scaling down
geom = revive_polygon(before, area, z, out_detail);
} else {
geom.clear();
}
}
}
}
@@ -921,12 +929,8 @@ struct write_tile_args {
long long minextent_out = 0;
unsigned long long mindrop_sequence = 0;
unsigned long long mindrop_sequence_out = 0;
// the infinity that excludes nothing, for the ascending order that
// drop_by_attribute_descending also defaults to. dropping_features()
// reads these, so they must not start out at a value that looks like
// a threshold that has already been chosen.
double minattribute = -HUGE_VAL;
double minattribute_out = -HUGE_VAL;
double minattribute = 0;
double minattribute_out = 0;
std::string const *drop_by_attribute_as_needed_attribute = NULL;
bool drop_by_attribute_descending = false;
size_t tile_size_out = 0;
@@ -943,31 +947,14 @@ struct write_tile_args {
atomic_strategy *strategy = NULL;
int zoom = -1;
bool compressed;
bool first_zoom;
node *shared_nodes_map;
size_t nodepos;
std::string const *shared_nodes_bloom;
std::set<zxy> const *skip_children; // what is being skipped at this zoom
std::set<zxy> skip_children_out; // what will be skipped in the next zoom
bool first_dropping_pass = false; // is this the first pass of this zoom that is dropping features?
};
// Is this zoom level discarding features to make its tiles fit? The thresholds
// start out excluding nothing, and only move inward once some tile in the zoom
// fails to fit and the whole zoom is retried with a threshold for discarding
// features. For mingap, minextent, and mindrop_sequence that starting point is
// zero; for minattribute it is the infinity on whichever side is being kept.
//
// Pyramid truncation is disabled while this is true, so that every tile in the
// zoom is reduced consistently, and tiles that were skipped because an ancestor
// truncated its pyramid are revived.
static bool dropping_features(unsigned long long mingap, long long minextent, unsigned long long mindrop_sequence, double minattribute, bool drop_by_attribute_descending) {
bool dropping_by_attribute = drop_by_attribute_descending
? minattribute != HUGE_VAL
: minattribute != -HUGE_VAL;
return mingap != 0 || minextent != 0 || mindrop_sequence != 0 || dropping_by_attribute;
}
// Clips a feature's geometry to the tile bounds at the specified zoom level
// with the specified buffer. Returns true if the feature was entirely clipped away
// by bounding box alone; otherwise returns false.
@@ -1114,42 +1101,128 @@ struct next_feature_state {
// set when a feature excluded by tippecanoe_minzoom first appears beyond the next
// zoom, so variable-depth pyramids don't leaf above the feature's minzoom and prune it away
bool minzoom_feature_pending = false;
std::vector<FILE *> deferrals;
size_t which_deferral = 0;
bool doing_deferrals = false;
};
// This function is called repeatedly from write_tile() to retrieve the next feature
// from the input stream. If the stream is at an end, it returns a feature with the
// geometry type set to -2.
static serial_feature next_feature(decompressor *geoms, std::atomic<long long> *geompos_in, int z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y, long long *original_features, long long *unclipped_features, int nextzoom, int maxzoom, int minzoom, int max_zoom_increment, size_t pass, std::atomic<long long> *along, long long alongminus, int buffer, std::atomic<bool> *within, compressor **geomfile, std::atomic<long long> *geompos, long long start_geompos[], std::atomic<double> *oprogress, double todo, const char *fname, int child_shards, json_object *filter, const char *global_stringpool, long long *pool_off, std::vector<std::vector<std::string>> *layer_unmaps, bool first_time, bool write_children, bool compressed, multiplier_state *multiplier_state, std::shared_ptr<std::string> &tile_stringpool, std::vector<std::string> const &unidecode_data, next_feature_state &next_feature_state, double droprate) {
static serial_feature next_feature(decompressor *geoms, std::atomic<long long> *geompos_in, int z, unsigned tx, unsigned ty, unsigned *initial_x, unsigned *initial_y, long long *original_features, long long *unclipped_features, int nextzoom, int maxzoom, int minzoom, int max_zoom_increment, size_t pass, std::atomic<long long> *along, long long alongminus, int buffer, std::atomic<bool> *within, compressor **geomfile, std::atomic<long long> *geompos, long long start_geompos[], std::atomic<double> *oprogress, double todo, const char *fname, int child_shards, json_object *filter, const char *global_stringpool, long long *pool_off, std::vector<std::vector<std::string>> *layer_unmaps, bool first_time, bool compressed, bool first_zoom, multiplier_state *multiplier_state, std::shared_ptr<std::string> &tile_stringpool, std::vector<std::string> const &unidecode_data, next_feature_state &next_feature_state, double droprate) {
double extra_multiplier_zooms = log(retain_points_multiplier) / log(droprate);
while (1) {
serial_feature sf;
long long len;
std::string s;
if (geoms->deserialize_long_long(&len, geompos_in) == 0) {
fprintf(stderr, "Unexpected physical EOF in feature stream\n");
exit(EXIT_READ);
}
if (len <= 0) {
if (compressed) {
geoms->end(geompos_in);
if (next_feature_state.doing_deferrals) {
if (next_feature_state.which_deferral >= next_feature_state.deferrals.size()) {
// done with direct deserialization, done with deferred deserialization
for (auto const fp : next_feature_state.deferrals) {
if (fclose(fp) != 0) {
perror("fclose deferral");
exit(EXIT_CLOSE);
}
}
sf.t = -2;
return sf;
}
sf.t = -2;
return sf;
}
if (fread(&len, sizeof(len), 1, next_feature_state.deferrals[next_feature_state.which_deferral]) != 1) {
if (ferror(next_feature_state.deferrals[next_feature_state.which_deferral])) {
perror("read deferral");
exit(EXIT_READ);
}
next_feature_state.which_deferral++;
continue;
}
std::string s;
s.resize(len);
size_t n = geoms->fread((void *) s.c_str(), sizeof(char), s.size(), geompos_in);
if (n != s.size()) {
fprintf(stderr, "Short read (%zu for %zu) from geometry\n", n, s.size());
exit(EXIT_READ);
s.resize(len);
if (fread((void *) s.c_str(), 1, len, next_feature_state.deferrals[next_feature_state.which_deferral]) != (size_t) len) {
fprintf(stderr, "short read in deferred deserialization: %s\n", strerror(errno));
exit(EXIT_READ);
}
} else {
if (geoms->deserialize_long_long(&len, geompos_in) == 0) {
fprintf(stderr, "Unexpected physical EOF in feature stream\n");
exit(EXIT_READ);
}
if (len <= 0) {
if (compressed) {
geoms->end(geompos_in);
}
next_feature_state.doing_deferrals = true;
next_feature_state.which_deferral = 0;
for (auto const fp : next_feature_state.deferrals) {
errno = 0;
rewind(fp);
if (errno != 0) {
perror("rewind deferral");
exit(EXIT_SEEK);
}
}
continue;
}
s.resize(len);
size_t n = geoms->fread((void *) s.c_str(), sizeof(char), s.size(), geompos_in);
if (n != s.size()) {
fprintf(stderr, "Short read (%zu for %zu) from geometry\n", n, s.size());
exit(EXIT_READ);
}
}
sf = deserialize_feature(s, z, tx, ty, initial_x, initial_y);
sf.stringpool = global_stringpool + pool_off[sf.segment];
if (!next_feature_state.doing_deferrals && *original_features > 0 && first_zoom && additional[A_DISTINGUISH_DUPLICATES] && sf.index == next_feature_state.previndex) {
if (next_feature_state.which_deferral >= next_feature_state.deferrals.size()) {
std::string tmpname = std::string(tmpdir) + "/deferral.XXXXXX";
std::vector<char> tmpl(tmpname.begin(), tmpname.end());
tmpl.push_back('\0');
int fd = mkstemp_cloexec(tmpl.data());
if (fd < 0) {
fprintf(stderr, "Can't create temporary file %zu for feature deferral: %s\n", next_feature_state.which_deferral, strerror(errno));
exit(EXIT_OPEN);
}
unlink(tmpl.data());
FILE *fp = fdopen(fd, "wb+");
if (fp == NULL) {
fprintf(stderr, "Can't reopen temporary file for feature deferral: %s\n", strerror(errno));
exit(EXIT_OPEN);
}
next_feature_state.deferrals.resize(next_feature_state.which_deferral + 1);
next_feature_state.deferrals[next_feature_state.which_deferral] = fp;
}
if (fwrite(&len, sizeof(len), 1, next_feature_state.deferrals[next_feature_state.which_deferral]) != 1) {
perror("write deferral length");
exit(EXIT_WRITE);
}
if (fwrite(s.c_str(), 1, len, next_feature_state.deferrals[next_feature_state.which_deferral]) != (size_t) len) {
perror("write deferral");
exit(EXIT_WRITE);
}
// limit the maximum depth of deferral,
// because even at z0 we will run out of file descriptors
// (and tile space) if there are large numbers of duplicates
if (next_feature_state.which_deferral < 50) {
next_feature_state.which_deferral++;
}
continue;
} else {
next_feature_state.which_deferral = 0;
}
// with fractional zoom level, so we can target a specific number
// of features to keep with retain-points-multiplier, not just the
// powers of the drop rate
@@ -1208,7 +1281,7 @@ static serial_feature next_feature(decompressor *geoms, std::atomic<long long> *
// XXX should continue, but affects test outputs
}
if (first_time && write_children) { /* only write out the next zoom once, even if we retry */
if (first_time && pass == 0) { /* only write out the next zoom once, even if we retry */
if (sf.tippecanoe_maxzoom == -1 || sf.tippecanoe_maxzoom >= nextzoom) {
rewrite(sf, z, nextzoom, maxzoom, tx, ty, buffer, within, geompos, start_geompos, geomfile, fname, child_shards, max_zoom_increment, sf.segment, initial_x, initial_y);
}
@@ -1373,8 +1446,8 @@ struct run_prefilter_args {
json_object *filter = NULL;
std::vector<std::string> const *unidecode_data;
bool first_time = false;
bool write_children = false;
bool compressed = false;
bool first_zoom = false;
double droprate = 1;
};
@@ -1386,7 +1459,7 @@ void *run_prefilter(void *v) {
next_feature_state next_feature_state;
while (1) {
serial_feature sf = next_feature(rpa->geoms, rpa->geompos_in, rpa->z, rpa->tx, rpa->ty, rpa->initial_x, rpa->initial_y, rpa->original_features, rpa->unclipped_features, rpa->nextzoom, rpa->maxzoom, rpa->minzoom, rpa->max_zoom_increment, rpa->pass, rpa->along, rpa->alongminus, rpa->buffer, rpa->within, rpa->geomfile, rpa->geompos, rpa->start_geompos, rpa->oprogress, rpa->todo, rpa->fname, rpa->child_shards, rpa->filter, rpa->global_stringpool, rpa->pool_off, rpa->layer_unmaps, rpa->first_time, rpa->write_children, rpa->compressed, &multiplier_state, tile_stringpool, *(rpa->unidecode_data), next_feature_state, rpa->droprate);
serial_feature sf = next_feature(rpa->geoms, rpa->geompos_in, rpa->z, rpa->tx, rpa->ty, rpa->initial_x, rpa->initial_y, rpa->original_features, rpa->unclipped_features, rpa->nextzoom, rpa->maxzoom, rpa->minzoom, rpa->max_zoom_increment, rpa->pass, rpa->along, rpa->alongminus, rpa->buffer, rpa->within, rpa->geomfile, rpa->geompos, rpa->start_geompos, rpa->oprogress, rpa->todo, rpa->fname, rpa->child_shards, rpa->filter, rpa->global_stringpool, rpa->pool_off, rpa->layer_unmaps, rpa->first_time, rpa->compressed, rpa->first_zoom, &multiplier_state, tile_stringpool, *(rpa->unidecode_data), next_feature_state, rpa->droprate);
if (sf.t < 0) {
break;
}
@@ -1662,7 +1735,7 @@ void skip_tile(decompressor *geoms, std::atomic<long long> *geompos_in, bool com
}
}
long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, char *global_stringpool, int z, const unsigned tx, const unsigned ty, const int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, compressor **geomfile, std::atomic<long long> *geompos, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, long long *pool_off, unsigned *initial_x, unsigned *initial_y, std::atomic<int> *running, double simplification, std::vector<std::map<std::string, layermap_entry>> *layermaps, std::vector<std::vector<std::string>> *layer_unmaps, size_t tiling_seg, size_t pass, unsigned long long mingap, long long minextent, unsigned long long mindrop_sequence, double minattribute, const char *prefilter, const char *postfilter, json_object *filter, write_tile_args *arg, atomic_strategy *strategy_out, bool compressed_input, node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, std::vector<std::string> const &unidecode_data, long long estimated_complexity, bool write_children, std::set<zxy> &skip_children_out) {
long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, char *global_stringpool, int z, const unsigned tx, const unsigned ty, const int detail, int min_detail, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, compressor **geomfile, std::atomic<long long> *geompos, int minzoom, int maxzoom, double todo, std::atomic<long long> *along, long long alongminus, double gamma, int child_shards, long long *pool_off, unsigned *initial_x, unsigned *initial_y, std::atomic<int> *running, double simplification, std::vector<std::map<std::string, layermap_entry>> *layermaps, std::vector<std::vector<std::string>> *layer_unmaps, size_t tiling_seg, size_t pass, unsigned long long mingap, long long minextent, unsigned long long mindrop_sequence, double minattribute, const char *prefilter, const char *postfilter, json_object *filter, write_tile_args *arg, atomic_strategy *strategy_out, bool compressed_input, bool first_zoom, node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, std::vector<std::string> const &unidecode_data, long long estimated_complexity, std::set<zxy> &skip_children_out) {
double merge_fraction = 1;
double mingap_fraction = 1;
double minextent_fraction = 1;
@@ -1698,7 +1771,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
int first_detail = detail, second_detail = detail - 1;
bool trying_to_stop_early = false;
bool can_stop_early = true;
if (additional[A_VARIABLE_DEPTH_PYRAMID] && !dropping_features(mingap, minextent, mindrop_sequence, minattribute, arg->drop_by_attribute_descending)) {
if (additional[A_VARIABLE_DEPTH_PYRAMID]) {
// If we are trying to stop early, there is an extra first pass with full+extra detail,
// and which loops if everything doesn't fit rather than trying to drop or union features.
@@ -1762,8 +1835,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
key_pool key_pool;
std::vector<std::atomic<bool> > within(child_shards);
std::vector<long long> start_geompos(child_shards);
std::atomic<bool> within[child_shards];
long long start_geompos[child_shards];
for (size_t i = 0; i < (size_t) child_shards; i++) {
within[i] = false;
start_geompos[i] = -1;
@@ -1828,10 +1901,10 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
rpa.along = along;
rpa.alongminus = alongminus;
rpa.buffer = buffer;
rpa.within = within.data();
rpa.within = within;
rpa.geomfile = geomfile;
rpa.geompos = geompos;
rpa.start_geompos = start_geompos.data();
rpa.start_geompos = start_geompos;
rpa.oprogress = &oprogress;
rpa.todo = todo;
rpa.fname = fname;
@@ -1843,8 +1916,8 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
rpa.filter = filter;
rpa.unidecode_data = &unidecode_data;
rpa.first_time = first_time;
rpa.write_children = write_children;
rpa.compressed = compressed_input;
rpa.first_zoom = first_zoom;
rpa.droprate = arg->droprate;
// this does need to be a real thread, so we can pipe both to and from it
@@ -1877,7 +1950,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
ssize_t which_serial_feature = -1;
if (prefilter == NULL) {
sf = next_feature(geoms, geompos_in, z, tx, ty, initial_x, initial_y, &original_features, &unclipped_features, nextzoom, maxzoom, minzoom, max_zoom_increment, pass, along, alongminus, buffer, within.data(), geomfile, geompos, start_geompos.data(), &oprogress, todo, fname, child_shards, filter, global_stringpool, pool_off, layer_unmaps, first_time, write_children, compressed_input, &multiplier_state, tile_stringpool, unidecode_data, next_feature_state, arg->droprate);
sf = next_feature(geoms, geompos_in, z, tx, ty, initial_x, initial_y, &original_features, &unclipped_features, nextzoom, maxzoom, minzoom, max_zoom_increment, pass, along, alongminus, buffer, within, geomfile, geompos, start_geompos, &oprogress, todo, fname, child_shards, filter, global_stringpool, pool_off, layer_unmaps, first_time, compressed_input, first_zoom, &multiplier_state, tile_stringpool, unidecode_data, next_feature_state, arg->droprate);
} else {
sf = parse_feature(prefilter_jp, z, tx, ty, layermaps, tiling_seg, layer_unmaps, postfilter != NULL, key_pool);
}
@@ -2267,12 +2340,6 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
sf.clustered = 0;
sf.tile_stringpool = tile_stringpool;
if (trying_to_stop_early && line_detail == first_detail) {
// only remove collinearities;
// leave all other vertices for extreme overzooming
sf.simplification = 0;
}
if (line_detail == detail && extra_detail >= 0 && z == maxzoom) {
sf.extra_detail = extra_detail;
// maximum allowed coordinate delta in geometries is 2^31 - 1
@@ -2420,7 +2487,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
if (p.clustered > 0) {
serial_val sv, sv2, sv3, sv4;
long long point_count = p.clustered + 1;
char abbrev[24]; // fits "%lld" of any long long, including the sign and the NUL
char abbrev[20]; // to_string(LLONG_MAX).length() / 1000 + 1;
p.full_keys.push_back(key_pool.pool("clustered"));
sv.type = mvt_bool;
@@ -2470,7 +2537,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
}
{
std::vector<pthread_t> pthreads(tasks);
pthread_t pthreads[tasks];
std::vector<simplification_worker_arg> args;
args.resize(tasks);
for (int i = 0; i < tasks; i++) {
@@ -2481,6 +2548,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
args[i].shared_nodes_map = shared_nodes_map;
args[i].nodepos = nodepos;
args[i].shared_nodes_bloom = &shared_nodes_bloom;
args[i].trying_to_stop_early = trying_to_stop_early;
if (tasks > 1) {
if (thread_create(&pthreads[i], NULL, simplification_worker, &args[i]) != 0) {
@@ -2907,6 +2975,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
if (trying_to_stop_early && line_detail == first_detail) {
// didn't work, try a lower detail
detail_reduced++;
continue;
}
@@ -3169,41 +3238,12 @@ exit(EXIT_IMPOSSIBLE);
long long len;
struct zxy parent(z - 1, x / 2, y / 2);
bool skip = false;
// Normally a tile writes the geometry for its children on pass 0, and the
// later passes of the same zoom, which are only retries with new thresholds,
// must not write it again.
bool write_children = (arg->pass == 0);
if (arg->skip_children->count(parent) > 0) {
if (dropping_features(arg->mingap, arg->minextent, arg->mindrop_sequence, arg->minattribute, arg->drop_by_attribute_descending)) {
// The parent truncated its pyramid here, but the zoom has since had to
// start dropping features, so the truncation no longer holds and this
// tile has to be written after all. Its geometry is still in the stream.
skip = false;
// It was skipped on every earlier pass of this zoom, so its children
// have never been written out. Write them on the first pass that
// actually tiles it, rather than on pass 0 as usual. The thresholds
// only ever increase within a zoom, so that is exactly the pass on
// which this zoom started dropping.
write_children = arg->first_dropping_pass;
} else {
// skip if the parent tile finished at the last zoom level and we aren't trying to drop
skip = true;
}
} else {
// do the tile if the parent didn't finish early
skip = false;
}
if (skip) {
skip_tile(&dc, &geompos, arg->compressed);
len = 1;
} else {
arg->wrote_zoom = z;
len = write_tile(&dc, &geompos, arg->global_stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->outdb, arg->outdir, arg->buffer, arg->fname, arg->geomfile, arg->geompos, arg->minzoom, arg->maxzoom, arg->todo, arg->along, geompos, arg->gamma, arg->child_shards, arg->pool_off, arg->initial_x, arg->initial_y, arg->running, arg->simplification, arg->layermaps, arg->layer_unmaps, arg->tiling_seg, arg->pass, arg->mingap, arg->minextent, arg->mindrop_sequence, arg->minattribute, arg->prefilter, arg->postfilter, arg->filter, arg, arg->strategy, arg->compressed, arg->shared_nodes_map, arg->nodepos, *(arg->shared_nodes_bloom), (*arg->unidecode_data), estimated_complexity, write_children, arg->skip_children_out);
len = write_tile(&dc, &geompos, arg->global_stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->outdb, arg->outdir, arg->buffer, arg->fname, arg->geomfile, arg->geompos, arg->minzoom, arg->maxzoom, arg->todo, arg->along, geompos, arg->gamma, arg->child_shards, arg->pool_off, arg->initial_x, arg->initial_y, arg->running, arg->simplification, arg->layermaps, arg->layer_unmaps, arg->tiling_seg, arg->pass, arg->mingap, arg->minextent, arg->mindrop_sequence, arg->minattribute, arg->prefilter, arg->postfilter, arg->filter, arg, arg->strategy, arg->compressed, arg->first_zoom, arg->shared_nodes_map, arg->nodepos, *(arg->shared_nodes_bloom), (*arg->unidecode_data), estimated_complexity, arg->skip_children_out);
}
if (pthread_mutex_lock(&var_lock) != 0) {
@@ -3269,7 +3309,7 @@ exit(EXIT_IMPOSSIBLE);
return err_or_null;
}
int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::atomic<unsigned> *midx, std::atomic<unsigned> *midy, int &maxzoom, int minzoom, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, const char *tmpdir, double gamma, int full_detail, int low_detail, int min_detail, long long *pool_off, unsigned *initial_x, unsigned *initial_y, double simplification, double maxzoom_simplification, std::vector<std::map<std::string, layermap_entry>> &layermaps, const char *prefilter, const char *postfilter, std::unordered_map<std::string, attribute_op> const *attribute_accum, json_object *filter, std::vector<strategy> &strategies, int iz, node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, int basezoom, double droprate, std::vector<std::string> const &unidecode_data, std::string const *drop_by_attribute_as_needed_attribute, bool drop_by_attribute_descending) {
int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::atomic<unsigned> *midx, std::atomic<unsigned> *midy, int &maxzoom, int minzoom, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, double gamma, int full_detail, int low_detail, int min_detail, long long *pool_off, unsigned *initial_x, unsigned *initial_y, double simplification, double maxzoom_simplification, std::vector<std::map<std::string, layermap_entry>> &layermaps, const char *prefilter, const char *postfilter, std::unordered_map<std::string, attribute_op> const *attribute_accum, json_object *filter, std::vector<strategy> &strategies, int iz, node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, int basezoom, double droprate, std::vector<std::string> const &unidecode_data, std::string const *drop_by_attribute_as_needed_attribute, bool drop_by_attribute_descending) {
last_progress = 0;
// The existing layermaps are one table per input thread.
@@ -3301,27 +3341,28 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
for (z = iz; z <= maxzoom; z++) {
std::atomic<long long> most(0);
std::vector<compressor> compressors(TEMP_FILES);
std::vector<compressor *> sub(TEMP_FILES);
std::vector<std::atomic<long long> > subpos(TEMP_FILES);
std::vector<int> subfd(TEMP_FILES);
compressor compressors[TEMP_FILES];
compressor *sub[TEMP_FILES];
std::atomic<long long> subpos[TEMP_FILES];
int subfd[TEMP_FILES];
for (size_t j = 0; j < TEMP_FILES; j++) {
std::string geomname = std::string(tmpdir) + "/geom" + std::to_string(j) + ".XXXXXXXX";
subfd[j] = mkstemp_cloexec(&geomname[0]);
// printf("%s\n", geomname.c_str());
char geomname[strlen(tmpdir) + strlen("/geom.XXXXXXXX" XSTRINGIFY(INT_MAX)) + 1];
snprintf(geomname, sizeof(geomname), "%s/geom%zu.XXXXXXXX", tmpdir, j);
subfd[j] = mkstemp_cloexec(geomname);
// printf("%s\n", geomname);
if (subfd[j] < 0) {
perror(geomname.c_str());
perror(geomname);
exit(EXIT_OPEN);
}
FILE *fp = fopen_oflag(geomname.c_str(), "wb", O_WRONLY | O_CLOEXEC);
FILE *fp = fopen_oflag(geomname, "wb", O_WRONLY | O_CLOEXEC);
if (fp == NULL) {
perror(geomname.c_str());
perror(geomname);
exit(EXIT_OPEN);
}
compressors[j] = compressor(fp);
sub[j] = &compressors[j];
subpos[j] = 0;
unlink(geomname.c_str());
unlink(geomname);
}
size_t useful_threads = 0;
@@ -3387,17 +3428,9 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
size_t zoom_tile_size = 0;
size_t zoom_feature_count = 0;
std::set<zxy> skip_children_out;
bool was_dropping = false;
for (size_t pass = 0;; pass++) {
// Tiles that were skipped because an ancestor truncated its pyramid are
// revived on the pass where this zoom starts dropping features, and that
// is the pass on which they have to write out their children.
bool is_dropping = dropping_features(zoom_mingap, zoom_minextent, zoom_mindrop_sequence, zoom_minattribute, drop_by_attribute_descending);
bool first_dropping_pass = is_dropping && !was_dropping;
was_dropping = is_dropping;
std::vector<pthread_t> pthreads(threads);
pthread_t pthreads[threads];
std::vector<write_tile_args> args;
args.resize(threads);
std::atomic<int> running(threads);
@@ -3416,8 +3449,8 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
args[thread].outdir = outdir;
args[thread].buffer = buffer;
args[thread].fname = fname;
args[thread].geomfile = sub.data() + thread * (TEMP_FILES / threads);
args[thread].geompos = subpos.data() + thread * (TEMP_FILES / threads);
args[thread].geomfile = sub + thread * (TEMP_FILES / threads);
args[thread].geompos = subpos + thread * (TEMP_FILES / threads);
args[thread].todo = todo;
args[thread].along = &along; // locked with var_lock
args[thread].gamma = zoom_gamma;
@@ -3473,12 +3506,12 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *global_stringpool, std::
args[thread].strategy = &strategy;
args[thread].zoom = z;
args[thread].compressed = (z != iz);
args[thread].first_zoom = (z == iz);
args[thread].shared_nodes_map = shared_nodes_map;
args[thread].nodepos = nodepos;
args[thread].shared_nodes_bloom = &shared_nodes_bloom;
args[thread].skip_children = &skip_children;
args[thread].skip_children_out.clear();
args[thread].first_dropping_pass = first_dropping_pass;
if (thread_create(&pthreads[thread], NULL, run_thread, &args[thread]) != 0) {
perror("pthread_create");
+1 -1
View File
@@ -62,7 +62,7 @@ struct strategy {
// long long write_tile(char **geom, char *stringpool, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int min_detail, int basezoom, sqlite3 *outdb, const char *outdir, double droprate, int buffer, const char *fname, FILE **geomfile, int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along, double gamma, int nlayers, std::atomic<strategy> *strategy);
int traverse_zooms(int *geomfd, off_t *geom_size, char *stringpool, std::atomic<unsigned> *midx, std::atomic<unsigned> *midy, int &maxzoom, int minzoom, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, const char *tmpdir, double gamma, int full_detail, int low_detail, int min_detail, long long *pool_off, unsigned *initial_x, unsigned *initial_y, double simplification, double maxzoom_simplification, std::vector<std::map<std::string, layermap_entry> > &layermap, const char *prefilter, const char *postfilter, std::unordered_map<std::string, attribute_op> const *attribute_accum, struct json_object *filter, std::vector<strategy> &strategies, int iz, struct node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, int basezoom, double droprate, std::vector<std::string> const &unidecode_data, std::string const *drop_by_attribute_as_needed_attribute, bool drop_by_attribute_descending);
int traverse_zooms(int *geomfd, off_t *geom_size, char *stringpool, std::atomic<unsigned> *midx, std::atomic<unsigned> *midy, int &maxzoom, int minzoom, sqlite3 *outdb, const char *outdir, int buffer, const char *fname, double gamma, int full_detail, int low_detail, int min_detail, long long *pool_off, unsigned *initial_x, unsigned *initial_y, double simplification, double maxzoom_simplification, std::vector<std::map<std::string, layermap_entry> > &layermap, const char *prefilter, const char *postfilter, std::unordered_map<std::string, attribute_op> const *attribute_accum, struct json_object *filter, std::vector<strategy> &strategies, int iz, struct node *shared_nodes_map, size_t nodepos, std::string const &shared_nodes_bloom, int basezoom, double droprate, std::vector<std::string> const &unidecode_data, std::string const *drop_by_attribute_as_needed_attribute, bool drop_by_attribute_descending);
int manage_gap(unsigned long long index, unsigned long long *previndex, double scale, double gamma, double *gap);
-33
View File
@@ -136,36 +136,3 @@ TEST_CASE("line_is_too_small") {
dv.emplace_back(VT_LINETO, -51864809, 2683873977);
REQUIRE(line_is_too_small(dv, 0, 10));
}
TEST_CASE("Polygon cleaning drops a hole that no ring can parent", "[wagyu]") {
// Two mutually reversed self-intersecting rings whose union leaves a hole
// that wagyu's topology correction cannot assign to any surviving parent
// ring (found by fuzzing; same failure as mapbox/tippecanoe#761). Without
// the fix in mapbox/geometry/wagyu/topology_correction.hpp, this exits
// through the "Could not properly place hole to a parent." handler in
// clean_or_clip_poly instead of returning.
static const std::vector<std::vector<std::pair<long long, long long>>> rings = {
{{0, 5}, {5, 4}, {5, 1}, {4, 4}, {4, 2}, {7, 1}, {0, 5}},
{{0, 5}, {7, 1}, {4, 2}, {4, 4}, {5, 1}, {5, 4}, {0, 0}, {0, 5}},
};
drawvec geom;
for (auto const &ring : rings) {
for (size_t i = 0; i < ring.size(); i++) {
geom.push_back(draw(i == 0 ? VT_MOVETO : VT_LINETO, ring[i].first, ring[i].second));
}
}
drawvec out = clean_or_clip_poly(geom, 0, 0, false, false);
// The regression signal is getting here at all: without the fix,
// clean_or_clip_poly exits the process from its wagyu error handler.
SUCCEED("clean_or_clip_poly returned");
// Anything that survives must be sanely wound: first ring positive.
if (out.size() > 0) {
size_t j = 1;
while (j < out.size() && out[j].op == VT_LINETO) j++;
REQUIRE(get_area(out, 0, j) > 0);
}
}
-133
View File
@@ -1,133 +0,0 @@
#include <string.h>
#include <set>
#include <string>
#include "usage.hpp"
// Options are wrapped to fit within this many columns
#define USAGE_WIDTH 80
// The indentation of the continuation lines of the option list
#define USAGE_INDENT 8
std::string getopt_string(const struct option *long_options) {
std::string getopt_str;
for (size_t lo = 0; long_options[lo].name != NULL; lo++) {
if (long_options[lo].val > ' ') {
getopt_str.push_back(long_options[lo].val);
if (long_options[lo].has_arg == required_argument) {
getopt_str.push_back(':');
}
}
}
return getopt_str;
}
void strip_usage_headings(const struct option *long_options, struct option *real_long_options) {
size_t out = 0;
for (size_t lo = 0; long_options[lo].name != NULL; lo++) {
if (long_options[lo].val != 0) {
real_long_options[out++] = long_options[lo];
}
}
real_long_options[out] = {0, 0, 0, 0};
}
// The entry for `name` in the list of options that must be specified,
// or NULL if it is an optional option
static const struct usage_required_option *required_for(const char *name, const struct usage_required_option *required) {
for (size_t i = 0; required != NULL && required[i].name != NULL; i++) {
if (strcmp(required[i].name, name) == 0) {
return &required[i];
}
}
return NULL;
}
// "--option", or "--option=placeholder" if the option takes an argument
static std::string option_text(const struct option *opt, const struct usage_required_option *req) {
std::string text = std::string("--") + opt->name;
if (opt->has_arg != no_argument) {
text += "=";
text += (req != NULL && req->placeholder != NULL) ? req->placeholder : "...";
}
return text;
}
// The alternatives that `req` belongs to, as "(--this=... | --that=...)"
static std::string alternation_text(const struct option *long_options, const struct usage_required_option *required, int alternation) {
std::string text;
size_t found = 0;
for (size_t lo = 0; long_options[lo].name != NULL && long_options[lo].name[0] != '\0'; lo++) {
const struct usage_required_option *req = required_for(long_options[lo].name, required);
if (req != NULL && req->alternation == alternation) {
if (found++ > 0) {
text += " | ";
}
text += option_text(&long_options[lo], req);
}
}
if (found > 1) {
text = "(" + text + ")";
}
return text;
}
void print_usage(FILE *out, const char *program, const char *const *forms,
const struct option *long_options,
const struct usage_required_option *required) {
for (size_t f = 0; forms[f] != NULL; f++) {
const char *lead = (f == 0) ? "Usage: " : "\n or: ";
fprintf(out, "%s%s %s", lead, program, forms[f]);
}
// whatever the forms took up, the option list starts on a line of its own
size_t width = USAGE_WIDTH;
std::set<int> alternations_listed;
for (size_t lo = 0; long_options[lo].name != NULL && long_options[lo].name[0] != '\0'; lo++) {
if (long_options[lo].val == 0) {
fprintf(out, "\n %s\n%*s", long_options[lo].name, USAGE_INDENT, "");
width = USAGE_INDENT;
continue;
}
const struct usage_required_option *req = required_for(long_options[lo].name, required);
std::string text;
if (req == NULL) {
text = "[" + option_text(&long_options[lo], NULL) + "]";
} else if (req->alternation == 0) {
text = option_text(&long_options[lo], req);
} else {
if (alternations_listed.count(req->alternation) != 0) {
continue; // already listed with the first of its alternatives
}
alternations_listed.insert(req->alternation);
text = alternation_text(long_options, required, req->alternation);
}
if (width + 1 + text.size() >= USAGE_WIDTH) {
fprintf(out, "\n%*s", USAGE_INDENT, "");
width = USAGE_INDENT;
}
fprintf(out, " %s", text.c_str());
width += 1 + text.size();
}
fprintf(out, "\n");
}
-52
View File
@@ -1,52 +0,0 @@
#ifndef USAGE_HPP
#define USAGE_HPP
#include <stdio.h>
#include <getopt.h>
#include <string>
// An option that must be specified rather than being optional, and the
// placeholder to show for its argument in the usage message.
//
// Options that share the same non-zero `alternation` are alternatives to
// each other: one of them must be specified, but not more than one, and
// they are listed together as `(--this=... | --that=...)`.
struct usage_required_option {
const char *name;
const char *placeholder;
int alternation;
};
// Returns the short option string to pass to getopt_long() for the
// options in `long_options`, so that the two can't disagree about
// which short options exist or take arguments.
std::string getopt_string(const struct option *long_options);
// Copies `long_options` to `real_long_options`, leaving out the headings
// of the usage message, which are not real options and so must not be
// passed on to getopt_long(). The destination must be at least as large
// as the source.
void strip_usage_headings(const struct option *long_options, struct option *real_long_options);
// Prints a usage message for `program` to `out`:
//
// Usage: program forms[0]
// or: program forms[1]
// [--some-option] [--another-option=...] ...
//
// where `forms` is a NULL-terminated list of the ways the non-option
// arguments can be given, and the list of options is derived from
// `long_options`, the same table that is passed to getopt_long(), so that
// the message stays in sync with the options that are really accepted.
//
// Options named in `required` (a list terminated by a NULL name, or NULL
// if there are none) are shown without brackets, using the placeholder
// given there for their argument, and grouped with any alternatives to
// them. An entry in `long_options` with no `val` is printed as a heading
// for the options that follow it, and an entry with an empty name ends
// the listing, hiding any options after it.
void print_usage(FILE *out, const char *program, const char *const *forms,
const struct option *long_options,
const struct usage_required_option *required);
#endif