Skip to content

Commit 69a53b1

Browse files
authored
Merge pull request #2423 from joto/expire-points
Implement expire of points in its own code
2 parents 7629962 + c98b02a commit 69a53b1

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/expire-tiles.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,22 @@ void expire_tiles_t::from_point_list(geom::point_list_t const &list,
7171
void expire_tiles_t::from_geometry(geom::point_t const &geom,
7272
expire_config_t const &expire_config)
7373
{
74-
geom::box_t const box = geom::envelope(geom);
75-
from_bbox(box, expire_config);
74+
auto const tilec = coords_to_tile(geom);
75+
76+
auto const ymin =
77+
std::max(0U, static_cast<uint32_t>(tilec.y() - expire_config.buffer));
78+
79+
auto const ymax =
80+
std::min(m_map_width - 1U,
81+
static_cast<uint32_t>(tilec.y() + expire_config.buffer));
82+
83+
for (int x = static_cast<int>(tilec.x() - expire_config.buffer);
84+
x <= static_cast<int>(tilec.x() + expire_config.buffer); ++x) {
85+
uint32_t const norm_x = normalise_tile_x_coord(x);
86+
for (uint32_t y = ymin; y <= ymax; ++y) {
87+
expire_tile(norm_x, y);
88+
}
89+
}
7690
}
7791

7892
void expire_tiles_t::from_geometry(geom::linestring_t const &geom,

tests/test-expire-tiles.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,10 @@ TEST_CASE("simple expire z10 bounds 1023, 0", "[NoDB]")
189189
expire_config_t{});
190190

191191
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
192-
CHECK(tiles.size() == 1);
192+
CHECK(tiles.size() == 2);
193193

194194
auto itr = tiles.cbegin();
195+
CHECK(*(itr++) == tile_t(10, 0, 0));
195196
CHECK(*(itr++) == tile_t(10, 1023, 0));
196197
}
197198

@@ -205,9 +206,10 @@ TEST_CASE("simple expire z10 bounds 1023, 1023", "[NoDB]")
205206
expire_config_t{});
206207

207208
auto const tiles = get_tiles_ordered(&et, minzoom, maxzoom);
208-
CHECK(tiles.size() == 1);
209+
CHECK(tiles.size() == 2);
209210

210211
auto itr = tiles.cbegin();
212+
CHECK(*(itr++) == tile_t(10, 0, 1023));
211213
CHECK(*(itr++) == tile_t(10, 1023, 1023));
212214
}
213215

0 commit comments

Comments
 (0)