Skip to content

Commit 2ed422f

Browse files
committed
Fix: Always disable expiry if maxzoom==0
maxzoom==0 is the default setting and it is documented to means that there is no expire. That's what the enabled() function checks. But disabling this in from_bbox() only disabled the expire for that case, not for linestrings. Better to do this check in the function that's called from outside the expire code: from_geometry(). We also need to fix some tests that were using maxzoom==0 by changing their setting to use maxzoom==1.
1 parent 7629962 commit 2ed422f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/expire-tiles.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ void expire_tiles_t::from_geometry(geom::multipolygon_t const &geom,
133133
void expire_tiles_t::from_geometry(geom::geometry_t const &geom,
134134
expire_config_t const &expire_config)
135135
{
136+
if (!enabled()) {
137+
return;
138+
}
139+
136140
geom.visit([&](auto const &g) { from_geometry(g, expire_config); });
137141
}
138142

@@ -210,10 +214,6 @@ void expire_tiles_t::from_line_segment(geom::point_t const &a,
210214
int expire_tiles_t::from_bbox(geom::box_t const &box,
211215
expire_config_t const &expire_config)
212216
{
213-
if (!enabled()) {
214-
return 0;
215-
}
216-
217217
double const width = box.width();
218218
double const height = box.height();
219219
if (width > tile_t::HALF_EARTH_CIRCUMFERENCE + 1) {

tests/bdd/flex/expire.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Feature: Changes on way with expire on zoom 0
7171
| 11 |
7272
Then table osm2pgsql_test_expire contains exactly
7373
| zoom | x | y |
74-
| 0 | 0 | 0 |
74+
| 1 | 1 | 0 |
7575

7676

7777
Scenario: change in t1
@@ -88,7 +88,7 @@ Feature: Changes on way with expire on zoom 0
8888
| way_id |
8989
Then table osm2pgsql_test_expire contains exactly
9090
| zoom | x | y |
91-
| 0 | 0 | 0 |
91+
| 1 | 1 | 0 |
9292

9393

9494
Scenario: remove from t1
@@ -105,4 +105,4 @@ Feature: Changes on way with expire on zoom 0
105105
| way_id |
106106
Then table osm2pgsql_test_expire contains exactly
107107
| zoom | x | y |
108-
| 0 | 0 | 0 |
108+
| 1 | 1 | 0 |

tests/data/test_expire.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
-- No maxzoom sets it to 0
32
local eo = osm2pgsql.define_expire_output({
43
table = 'osm2pgsql_test_expire',
4+
maxzoom = 1,
55
})
66

77
local the_table = osm2pgsql.define_way_table('osm2pgsql_test_t1', {

0 commit comments

Comments
 (0)