@@ -52,7 +52,7 @@ class expire_tiles
5252 * Get tiles as a vector of quadkeys and remove them from the expire_tiles
5353 * object.
5454 */
55- std::vector< uint64_t > get_tiles ();
55+ quadkey_list_t get_tiles ();
5656
5757 /* *
5858 * Merge the list of expired tiles in the other object into this
@@ -80,7 +80,7 @@ class expire_tiles
8080 void from_point_list (geom::point_list_t const &list);
8181
8282 // / This is where we collect all the expired tiles.
83- std::unordered_set<uint64_t > m_dirty_tiles;
83+ std::unordered_set<quadkey_t > m_dirty_tiles;
8484
8585 // / The tile which has been added last to the unordered set.
8686 tile_t m_prev_tile;
@@ -104,7 +104,7 @@ class expire_tiles
104104 * \param output Output function
105105 */
106106template <class OUTPUT >
107- std::size_t for_each_tile (std::vector< uint64_t > const &tiles, uint32_t minzoom,
107+ std::size_t for_each_tile (quadkey_list_t const &tiles, uint32_t minzoom,
108108 uint32_t maxzoom, OUTPUT &&output)
109109{
110110 assert (minzoom <= maxzoom);
@@ -119,30 +119,24 @@ std::size_t for_each_tile(std::vector<uint64_t> const &tiles, uint32_t minzoom,
119119
120120 /* *
121121 * Loop over all requested zoom levels (from maximum down to the minimum
122- * zoom level). Tile IDs of the tiles enclosing this tile at lower zoom
123- * levels are calculated using bit shifts.
124- *
125- * last_quadkey is initialized with a value which is not expected to exist
126- * (larger than largest possible quadkey).
122+ * zoom level).
127123 */
128- uint64_t last_quadkey = 1ULL << ( 2 * maxzoom) ;
124+ quadkey_t last_quadkey{} ;
129125 std::size_t count = 0 ;
130126 for (auto const quadkey : tiles) {
131127 for (uint32_t dz = 0 ; dz <= maxzoom - minzoom; ++dz) {
132- // scale down to the current zoom level
133- uint64_t const qt_current = quadkey >> (dz * 2 );
128+ auto const qt_current = quadkey.down (dz);
134129 /* *
135130 * If dz > 0, there are probably multiple elements whose quadkey
136131 * is equal because they are all sub-tiles of the same tile at the
137132 * current zoom level. We skip all of them after we have written
138133 * the first sibling.
139134 */
140- if (qt_current == last_quadkey >> (dz * 2 )) {
141- continue ;
135+ if (qt_current != last_quadkey.down (dz)) {
136+ std::forward<OUTPUT>(output)(
137+ tile_t::from_quadkey (qt_current, maxzoom - dz));
138+ ++count;
142139 }
143- auto const tile = tile_t::from_quadkey (qt_current, maxzoom - dz);
144- std::forward<OUTPUT>(output)(tile);
145- ++count;
146140 }
147141 last_quadkey = quadkey;
148142 }
@@ -157,7 +151,7 @@ std::size_t for_each_tile(std::vector<uint64_t> const &tiles, uint32_t minzoom,
157151 * \param minzoom Minimum zoom level
158152 * \param maxzoom Maximum zoom level
159153 */
160- std::size_t output_tiles_to_file (std::vector< uint64_t > const &tiles,
154+ std::size_t output_tiles_to_file (quadkey_list_t const &tiles,
161155 char const *filename, uint32_t minzoom,
162156 uint32_t maxzoom);
163157
0 commit comments