diff --git a/Makefile b/Makefile index 5c13cf7f8..b7a6ce22a 100644 --- a/Makefile +++ b/Makefile @@ -413,7 +413,6 @@ join-test: tile-join ./tile-join --overzoom -f -o tests/ne_110m_ocean/join/joined.mbtiles tests/ne_110m_ocean/join/ocean.mbtiles tests/ne_110m_ocean/join/countries.mbtiles ./tippecanoe-decode tests/ne_110m_ocean/join/joined.mbtiles > tests/ne_110m_ocean/join/joined.mbtiles.json.check cmp tests/ne_110m_ocean/join/joined.mbtiles.json.check tests/ne_110m_ocean/join/joined.mbtiles.json - # BUG: tiles 4/15/3, 4/15/2, 4/15/1, and 4/15/0 should be ocean, but are currently missing rm -f tests/ne_110m_ocean/join/ocean.mbtiles tests/ne_110m_ocean/join/countries.mbtiles tests/ne_110m_ocean/join/joined.mbtiles tests/ne_110m_ocean/join/joined.mbtiles.json.check join-filter-test: diff --git a/tile-join.cpp b/tile-join.cpp index 8b388cbab..ef7d664c3 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -423,6 +423,7 @@ struct reader { long long x = 0; long long y = 0; std::string data = ""; + bool current_tile_is_overzoomed = false; // "done" means we have read all of the real tiles from the source. // The iterator will continue to produce overzoomed tiles after it is "done." @@ -432,6 +433,7 @@ struct reader { int maxzoom_so_far = -1; std::vector> tiles_at_maxzoom_so_far; std::vector> overzoomed_tiles; + bool overzoom_consumed_at_this_zoom = false; // for iterating mbtiles sqlite3 *db = NULL; @@ -498,25 +500,35 @@ struct reader { } // Checks the done status not only of this reader but also - // the others chained to it in the queue + // the others chained to it in the queue. // - // Does this actually also need to check whether there are overzoomed - // tiles that have not yet been returned for a zoom level that has been - // started? FIXME + // Also claims not to be done if at least one overzoomed tile + // has been consumed at this zoom level, in which case they should + // all allowed to be consumed before stopping. bool all_done() { if (!done) { return false; } + if (overzoom_consumed_at_this_zoom) { + return false; + } for (struct reader *r = next; r != NULL; r = r->next) { if (!r->done) { return false; } + if (r->overzoom_consumed_at_this_zoom) { + return false; + } } return true; } std::pair current() { + if (current_tile_is_overzoomed) { + overzoom_consumed_at_this_zoom = true; + } + return std::pair(zxy(zoom, x, y), data); } @@ -529,6 +541,7 @@ struct reader { if (overzoomed_tiles.size() == 0) { next_overzoom(); + overzoom_consumed_at_this_zoom = false; } auto xy = overzoomed_tiles.front(); @@ -536,11 +549,14 @@ struct reader { x = xy.first; y = xy.second; - data = retrieve_overzoom(zxy(zoom, x, y)); + current_tile_is_overzoomed = true; + return; } + current_tile_is_overzoomed = false; + if (db != NULL) { if (sqlite3_step(stmt) == SQLITE_ROW) { zoom = sqlite3_column_int(stmt, 0); @@ -623,6 +639,7 @@ struct reader { } std::sort(overzoomed_tiles.begin(), overzoomed_tiles.end(), tilecmp); + overzoom_consumed_at_this_zoom = false; } std::string get_tile(zxy tile) {