diff --git a/CHANGELOG.md b/CHANGELOG.md index bbc227ca..74ddd77d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.18.0 + +* Fix crash when using tile-join to join an empty pmtiles tileset + ## 2.17.0 * Add pmtiles output format diff --git a/Makefile b/Makefile index cff204b8..104794da 100644 --- a/Makefile +++ b/Makefile @@ -329,6 +329,29 @@ 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 diff --git a/tests/join-population/empty.json b/tests/join-population/empty.json new file mode 100644 index 00000000..d52756aa --- /dev/null +++ b/tests/join-population/empty.json @@ -0,0 +1,2 @@ +{ "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 ] ] ] } } diff --git a/tests/join-population/empty.out.json b/tests/join-population/empty.out.json new file mode 100644 index 00000000..7c8bd7bc --- /dev/null +++ b/tests/join-population/empty.out.json @@ -0,0 +1,11 @@ +{ "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": [ +] } diff --git a/tile-join.cpp b/tile-join.cpp index 82eee89d..6ea572b2 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -455,9 +455,10 @@ 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; diff --git a/version.hpp b/version.hpp index d0c098b7..1aefbd5b 100644 --- a/version.hpp +++ b/version.hpp @@ -1,6 +1,6 @@ #ifndef VERSION_HPP #define VERSION_HPP -#define VERSION "v2.17.0" +#define VERSION "v2.18.0" #endif