Compare commits

..
Author SHA1 Message Date
Erica Fischer d4234d5b2c Remove unnecessary sort (and make indent) 2022-12-28 11:49:50 -08:00
Erica Fischer fa37859adb Pmtiles tests pass now too 2022-12-27 14:18:59 -08:00
Erica Fischer 1cb467a382 Update more tests 2022-12-27 13:46:31 -08:00
Erica Fischer 3dddc7b2f1 Eradicate spaces from more test fixtures 2022-12-27 13:39:55 -08:00
Erica Fischer dacff83386 Eradicate spaces from tileset metadata JSON fields 2022-12-27 13:35:44 -08:00
Erica Fischer a4f4b1f7c6 Pmtiles should also pass the raw tiles tests 2022-12-27 13:15:30 -08:00
Erica Fischer 4266dc3de1 Fix some ordering problems with pmtiles decode 2022-12-27 11:58:40 -08:00
Brandon Liu 1ac6afa543 update pmtiles.hpp with z>15 fix 2022-12-22 07:57:12 +08:00
Brandon Liu f8319ee5f1 add base GitHub CI action for compiling and test suite. 2022-12-21 15:03:08 +08:00
Brandon Liu f1c0bf50b1 pmtiles test suite for decode and tile-join [#10] 2022-12-21 15:02:44 +08:00
Brandon Liu e958f1adf9 tile-join reads and writes pmtiles. [#10] 2022-12-21 14:58:49 +08:00
Brandon Liu 64a5a684b0 tippecanoe-decode reads pmtiles input. [#10] 2022-12-21 14:57:54 +08:00
Brandon Liu fedebec55a tippecanoe main writes pmtiles output. [#10]
* detect output format using suffix
* after mbtiles is done writing, replace with pmtiles based on map/image tables.
* add method to write_json for writing json sub-object.
2022-12-21 14:56:46 +08:00
Brandon Liu f6332f302a add pmtiles.hpp from github.com/protomaps/PMTiles [#10] 2022-12-21 14:53:34 +08:00
13 changed files with 24 additions and 2360 deletions
-13
View File
@@ -1,16 +1,3 @@
## 2.19.0
* Don't guess an excessively large maxzoom when there is only one feature
* Set the base zoom for -Bg as part of the --smallest-maximum-zoom-guess logic
## 2.18.0
* Fix crash when using tile-join to join an empty pmtiles tileset
## 2.17.0
* Add pmtiles output format
## 2.16.0
* During tiling, limit the size of the statistics that are kept for -as-needed calculations, because they can get quite large for sources with hundreds of millions of features.
+8 -30
View File
@@ -82,7 +82,7 @@ indent:
TESTS = $(wildcard tests/*/out/*.json)
SPACE = $(NULL) $(NULL)
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
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
./unit
suffixes = json json.gz
@@ -329,29 +329,6 @@ join-test: tile-join
./tippecanoe-decode -x generator tests/join-population/concat.mbtiles > tests/join-population/concat.mbtiles.json.check
cmp tests/join-population/concat.mbtiles.json.check tests/join-population/concat.mbtiles.json
rm tests/join-population/concat.mbtiles.json.check tests/join-population/concat.mbtiles tests/join-population/macarthur.mbtiles
#`
# Make sure empty tilesets work
#
# mbtiles:
./tippecanoe -q -z0 -f -o tests/join-population/empty.mbtiles tests/join-population/empty.json
./tile-join -f -o tests/join-population/empty.out.mbtiles tests/join-population/empty.mbtiles
./tippecanoe-decode -x generator -x generator_options -x name -x description tests/join-population/empty.mbtiles > tests/join-population/empty.out.json.check
cmp tests/join-population/empty.out.json.check tests/join-population/empty.out.json
rm -f tests/join-population/empty.mbtiles tests/join-population/empty.out.mbtiles tests/join-population/empty.out.json.check
# pmtiles:
./tippecanoe -q -z0 -f -o tests/join-population/empty.pmtiles tests/join-population/empty.json
./tile-join -f -o tests/join-population/empty.out.pmtiles tests/join-population/empty.pmtiles
./tippecanoe-decode -x generator -x generator_options -x name -x description tests/join-population/empty.pmtiles > tests/join-population/empty.out.json.check
cmp tests/join-population/empty.out.json.check tests/join-population/empty.out.json
rm -f tests/join-population/empty.pmtiles tests/join-population/empty.out.pmtiles tests/join-population/empty.out.json.check
# dirtiles:
./tippecanoe -q -z0 -f -e tests/join-population/empty.dirtiles tests/join-population/empty.json
./tile-join -f -e tests/join-population/empty.out.dirtiles tests/join-population/empty.dirtiles
./tippecanoe-decode -x generator -x generator_options -x name -x description tests/join-population/empty.dirtiles > tests/join-population/empty.out.json.check
cmp tests/join-population/empty.out.json.check tests/join-population/empty.out.json
rm -rf tests/join-population/empty.dirtiles tests/join-population/empty.out.dirtiles tests/join-population/empty.out.json.check
join-filter-test:
# Comes out different from the direct tippecanoe run because null attributes are lost
@@ -396,14 +373,15 @@ allow-existing-test:
./tippecanoe-decode -x generator -x generator_options tests/allow-existing/both.dir | sed 's/both\.dir/both.mbtiles/g' > tests/allow-existing/both.dir.json.check
cmp tests/allow-existing/both.dir.json.check tests/allow-existing/both.mbtiles.json
# Make a tileset
./tippecanoe -q -Z0 -z0 -f -o tests/allow-existing/both.pmtiles tests/coalesce-tract/tl_2010_06001_tract10.json
./tippecanoe -q -Z0 -z0 -f -e tests/allow-existing/both.pmtiles tests/coalesce-tract/tl_2010_06001_tract10.json
# Writing to existing should fail
if ./tippecanoe -q -Z1 -z1 -o tests/allow-existing/both.pmtiles tests/coalesce-tract/tl_2010_06001_tract10.json; then exit 1; else exit 0; fi
if ./tippecanoe -q -Z1 -z1 -e tests/allow-existing/both.pmtiles tests/coalesce-tract/tl_2010_06001_tract10.json; then exit 1; else exit 0; fi
# Replace existing
./tippecanoe -q -Z8 -z9 -f -o tests/allow-existing/both.pmtiles tests/coalesce-tract/tl_2010_06001_tract10.json
# Allow-existing is not supported for pmtiles
if ./tippecanoe -q -Z10 -z11 -F -o tests/allow-existing/both.pmtiles tests/coalesce-tract/tl_2010_06001_tract10.json; then exit 1; else exit 0; fi
rm -r tests/allow-existing/both.pmtiles tests/allow-existing/both.dir.json.check tests/allow-existing/both.dir tests/allow-existing/both.mbtiles.json.check tests/allow-existing/both.mbtiles
./tippecanoe -q -Z8 -z9 -f -e tests/allow-existing/both.pmtiles tests/coalesce-tract/tl_2010_06001_tract10.json
./tippecanoe -q -Z10 -z11 -F -e tests/allow-existing/both.pmtiles tests/coalesce-tract/tl_2010_06001_tract10.json
./tippecanoe-decode -x generator -x generator_options tests/allow-existing/both.pmtiles | sed 's/both\.pmtiles/both.mbtiles/g' > tests/allow-existing/both.pmtiles.json.check
cmp tests/allow-existing/both.pmtiles.json.check tests/allow-existing/both.mbtiles.json
rm -r tests/allow-existing/both.pmtiles.json.check tests/allow-existing/both.pmtiles tests/allow-existing/both.dir.json.check tests/allow-existing/both.dir tests/allow-existing/both.mbtiles.json.check tests/allow-existing/both.mbtiles
csv-test:
# Reading from named CSV
+6 -3
View File
@@ -4,9 +4,12 @@ tippecanoe
Builds [vector tilesets](https://github.com/mapbox/vector-tile-spec/) from large (or small) collections of [GeoJSON](http://geojson.org/), [FlatGeobuf](https://github.com/flatgeobuf/flatgeobuf), or [CSV](https://en.wikipedia.org/wiki/Comma-separated_values) features,
[like these](MADE_WITH.md).
This is the official home of Tippecanoe, developed and actively maintained by [Erica Fischer](https://github.com/e-n-f) at [Felt](https://felt.com).
This intends to be an actively maintained fork of [tippecanoe](https://github.com/mapbox/tippecanoe) originally developed by [Erica Fischer](https://github.com/e-n-f) at Mapbox. Version 2.0.0 is equivalent to [1.36.0](https://github.com/mapbox/tippecanoe/tree/1.36.0) in the original repository. Thank you Mapbox and Erica for an incredible tool!
Key features of this fork include:
* Support for [FlatGeobuf](https://github.com/flatgeobuf/flatgeobuf) input which is more compact and 5-10x faster than GeoJsonSeq input.
Version 2.0.0 is equivalent to [1.36.0](https://github.com/mapbox/tippecanoe/tree/1.36.0) in the original repository. Thank you Mapbox for the many years of early support.
Intent
------
@@ -336,7 +339,7 @@ Parallel processing will also be automatic if the input file is in FlatGeobuf fo
* `-z` _zoom_ or `--maximum-zoom=`_zoom_: Maxzoom: the highest zoom level for which tiles are generated (default 14)
* `-zg` or `--maximum-zoom=g`: Guess what is probably a reasonable maxzoom based on the spacing of features.
* `--smallest-maximum-zoom-guess=`_zoom_: Guess what is probably a reasonable maxzoom based on the spacing of features, but using the specified _zoom_ if a lower maxzoom is guessed. If `-Bg` is also set, the base zoom will be set to the guessed maxzoom, with all the points carried forward into additional zooms through the one specified.
* `--smallest-maximum-zoom-guess=`_zoom_: Guess what is probably a reasonable maxzoom based on the spacing of features, but using the specified _zoom_ if a lower maxzoom is guessed.
* `-Z` _zoom_ or `--minimum-zoom=`_zoom_: Minzoom: the lowest zoom level for which tiles are generated (default 0)
* `-ae` or `--extend-zooms-if-still-dropping`: Increase the maxzoom if features are still being dropped at that zoom level.
The detail and simplification options that ordinarily apply only to the maximum zoom level will apply both to the originally
+4 -16
View File
@@ -2095,12 +2095,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
exit(EXIT_NODATA);
}
if (count == 0 && dist_count == 0) {
maxzoom = minimum_maxzoom;
if (droprate < 0) {
droprate = 1;
}
} else if (count > 0) {
if (count > 0) {
double stddev = sqrt(m2 / count);
// Geometric mean is appropriate because distances between features
@@ -2211,13 +2206,6 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
}
}
if (basezoom == -2 && basezoom_marker_width == 1) { // -Bg, not -Bg###
basezoom = maxzoom;
if (!quiet) {
fprintf(stderr, "Using base zoom of -z%d\n", basezoom);
}
}
if (maxzoom < minimum_maxzoom) {
if (!quiet) {
fprintf(stderr, "Using minimum maxzoom of -z%d\n", minimum_maxzoom);
@@ -2234,7 +2222,7 @@ std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, i
fix_dropping = true;
if (basezoom == -1) { // basezoom unspecified
if (basezoom == -1) {
basezoom = maxzoom;
}
}
@@ -3446,7 +3434,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "%s: Reducing minimum detail to match low detail %d\n", argv[0], min_detail);
}
if (basezoom == -1) { // basezoom unspecified
if (basezoom == -1) {
if (!guess_maxzoom) {
basezoom = maxzoom;
}
@@ -3487,7 +3475,7 @@ int main(int argc, char **argv) {
unlink(out_mbtiles);
} else {
if (pmtiles_has_suffix(out_mbtiles)) {
check_pmtiles(out_mbtiles, argv, forcetable);
check_pmtiles(out_mbtiles, argv);
}
}
+1 -6
View File
@@ -25,16 +25,11 @@ bool pmtiles_has_suffix(const char *filename) {
return false;
}
void check_pmtiles(const char *filename, char **argv, bool forcetable) {
void check_pmtiles(const char *filename, char **argv) {
struct stat st;
if (stat(filename, &st) == 0) {
fprintf(stderr, "%s: Tileset \"%s\" already exists. You can use --force if you want to delete the old tileset.\n", argv[0], filename);
fprintf(stderr, "%s: %s: file exists\n", argv[0], filename);
if (forcetable) {
fprintf(stderr, "%s: --allow-existing is not supported for pmtiles\n", argv[0]);
}
exit(EXIT_EXISTS);
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
#include "mbtiles.hpp"
bool pmtiles_has_suffix(const char *filename);
void check_pmtiles(const char *filename, char **argv, bool forcetable);
void check_pmtiles(const char *filename, char **argv);
void mbtiles_map_image_to_pmtiles(char *dbname, metadata m, bool tile_compression, bool quiet, bool quiet_progress);
-2
View File
@@ -1,2 +0,0 @@
{ "type": "Feature", "properties": { "id": 1 }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 417.4513514, -299.1709459 ], [ 415.1435811, -288.1915541 ], [ 421.1577703, -286.2334459 ], [ 431.5077703, -317.4932432 ], [ 471.2293919, -312.2483108 ] ] ] } }
{ "type": "Feature", "properties": { "id": 2 }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 423.6753378, -364.5577703 ], [ 426.3327703, -334.0672297 ], [ 512.3496622, -321.7591216 ], [ 510.2516892, -347.4942568 ] ] ] } }
-11
View File
@@ -1,11 +0,0 @@
{ "type": "FeatureCollection", "properties": {
"bounds": "-180.000000,-85.051129,180.000000,-85.051129",
"center": "0.000000,-85.051129,0",
"format": "pbf",
"json": "{\"vector_layers\":[{\"id\":\"empty\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":0,\"fields\":{\"id\":\"Number\"}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"empty\",\"count\":2,\"geometry\":\"LineString\",\"attributeCount\":1,\"attributes\":[{\"attribute\":\"id\",\"count\":2,\"type\":\"number\",\"values\":[1,2],\"min\":1,\"max\":2}]}]}}",
"maxzoom": "0",
"minzoom": "0",
"type": "overlay",
"version": "2"
}, "features": [
] }
File diff suppressed because one or more lines are too long
-1
View File
@@ -1 +0,0 @@
{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-122,37]}}
@@ -1,37 +0,0 @@
{ "type": "FeatureCollection", "properties": {
"bounds": "-122.000000,37.000000,-122.000000,37.000000",
"center": "-122.000000,37.000000,3",
"description": "tests/onefeature-point/out/--smallest-maximum-zoom-guess_3.json.check.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -a@ -f -o tests/onefeature-point/out/--smallest-maximum-zoom-guess_3.json.check.mbtiles --smallest-maximum-zoom-guess 3 tests/onefeature-point/in.json",
"json": "{\"vector_layers\":[{\"id\":\"in\",\"description\":\"\",\"minzoom\":0,\"maxzoom\":3,\"fields\":{}}],\"tilestats\":{\"layerCount\":1,\"layers\":[{\"layer\":\"in\",\"count\":1,\"geometry\":\"Point\",\"attributeCount\":0,\"attributes\":[]}]}}",
"maxzoom": "3",
"minzoom": "0",
"name": "tests/onefeature-point/out/--smallest-maximum-zoom-guess_3.json.check.mbtiles",
"type": "overlay",
"version": "2"
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -122.080078, 37.020098 ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -122.036133, 37.020098 ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 0, "y": 1 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -122.014160, 37.002553 ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 3, "x": 1, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -122.003174, 37.002553 ] } }
] }
] }
] }
+3 -4
View File
@@ -456,10 +456,9 @@ struct reader *begin_reading(char *fname) {
r->x = r->pmtiles_entries.back().x;
r->y = r->pmtiles_entries.back().y;
r->sorty = (1LL << r->zoom) - 1 - r->y;
r->data = std::string(r->pmtiles_map + r->pmtiles_entries.back().offset, r->pmtiles_entries.back().length);
r->pmtiles_entries.pop_back();
}
r->data = std::string(r->pmtiles_map + r->pmtiles_entries.back().offset, r->pmtiles_entries.back().length);
r->pmtiles_entries.pop_back();
} else {
sqlite3 *db;
@@ -1191,7 +1190,7 @@ int main(int argc, char **argv) {
unlink(out_mbtiles);
} else {
if (pmtiles_has_suffix(out_mbtiles)) {
check_pmtiles(out_mbtiles, argv, false);
check_pmtiles(out_mbtiles, argv);
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
#define VERSION "v2.19.0"
#define VERSION "v2.16.0"
#endif