Skip to content

Commit b7e1712

Browse files
committed
Remove osm_id param from expire_tiles::from_geometry/result
The osm_id is only used for debug logging which isn't that useful. And we'll need to extend the code that does expiry by geometry in the future to allow more options, so its better to make the code simpler now.
1 parent ab77656 commit b7e1712

4 files changed

Lines changed: 20 additions & 32 deletions

File tree

src/expire-tiles.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void expire_tiles::from_point_list(geom::point_list_t const &list)
7878
});
7979
}
8080

81-
void expire_tiles::from_geometry(geom::geometry_t const &geom, osmid_t osm_id)
81+
void expire_tiles::from_geometry(geom::geometry_t const &geom)
8282
{
8383
if (geom.srid() != 3857) {
8484
return;
@@ -96,10 +96,6 @@ void expire_tiles::from_geometry(geom::geometry_t const &geom, osmid_t osm_id)
9696
} else if (geom.is_polygon() || geom.is_multipolygon()) {
9797
auto const box = geom::envelope(geom);
9898
if (from_bbox(box)) {
99-
/* Bounding box too big - just expire tiles on the line */
100-
log_debug("Large polygon ({:.0f} x {:.0f} metres, OSM ID {})"
101-
" - only expiring perimeter",
102-
box.max_x() - box.min_x(), box.max_y() - box.min_y(), osm_id);
10399
if (geom.is_polygon()) {
104100
from_point_list(geom.get<geom::polygon_t>().outer());
105101
for (auto const &inner : geom.get<geom::polygon_t>().inners()) {
@@ -234,7 +230,7 @@ int expire_tiles::from_bbox(geom::box_t const &box)
234230
return 0;
235231
}
236232

237-
int expire_tiles::from_result(pg_result_t const &result, osmid_t osm_id)
233+
int expire_tiles::from_result(pg_result_t const &result)
238234
{
239235
if (!enabled()) {
240236
return -1;
@@ -243,7 +239,7 @@ int expire_tiles::from_result(pg_result_t const &result, osmid_t osm_id)
243239
auto const num_tuples = result.num_tuples();
244240
for (int i = 0; i < num_tuples; ++i) {
245241
char const *const wkb = result.get_value(i, 0);
246-
from_geometry(ewkb_to_geom(decode_hex(wkb)), osm_id);
242+
from_geometry(ewkb_to_geom(decode_hex(wkb)));
247243
}
248244

249245
return num_tuples;

src/expire-tiles.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class expire_tiles
3232

3333
bool enabled() const noexcept { return m_maxzoom != 0; }
3434

35-
void from_geometry(geom::geometry_t const &geom, osmid_t osm_id);
35+
void from_geometry(geom::geometry_t const &geom);
3636

3737
int from_bbox(geom::box_t const &box);
3838

@@ -42,11 +42,9 @@ class expire_tiles
4242
* \param result Result of a database query into some table returning the
4343
* geometries. (This is usually done using the "get_wkb"
4444
* prepared statement.)
45-
* \param osm_id The OSM id to look for.
46-
* \return The number of elements that refer to the osm_id or -1 if
47-
* expire is disabled.
45+
* \return The number of tuples in the result or -1 if expire is disabled.
4846
*/
49-
int from_result(pg_result_t const &result, osmid_t osm_id);
47+
int from_result(pg_result_t const &result);
5048

5149
/**
5250
* Get tiles as a vector of quadkeys and remove them from the expire_tiles

src/output-flex.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -711,17 +711,13 @@ void output_flex_t::write_column(
711711
type == table_column_type::multilinestring ||
712712
type == table_column_type::multipolygon);
713713
if (geom->srid() == column.srid()) {
714-
// OSM id not available here, so use dummy 0, it is used
715-
// for debug messages only anyway.
716-
m_expire.from_geometry(*geom, 0);
714+
m_expire.from_geometry(*geom);
717715
copy_mgr->add_hex_geom(geom_to_ewkb(*geom, wrap_multi));
718716
} else {
719717
auto const proj =
720718
reprojection::create_projection(column.srid());
721719
auto const tgeom = geom::transform(*geom, *proj);
722-
// OSM id not available here, so use dummy 0, it is used
723-
// for debug messages only anyway.
724-
m_expire.from_geometry(tgeom, 0);
720+
m_expire.from_geometry(tgeom);
725721
copy_mgr->add_hex_geom(geom_to_ewkb(tgeom, wrap_multi));
726722
}
727723
} else {
@@ -1685,7 +1681,7 @@ void output_flex_t::add_row(table_connection_t *table_connection,
16851681

16861682
auto const geoms = geom::split_multi(std::move(geom), split_multi);
16871683
for (auto const &sgeom : geoms) {
1688-
m_expire.from_geometry(sgeom, id);
1684+
m_expire.from_geometry(sgeom);
16891685
write_row(table_connection, object.type(), id, sgeom,
16901686
table.geom_column().srid());
16911687
}
@@ -1919,7 +1915,7 @@ void output_flex_t::delete_from_table(table_connection_t *table_connection,
19191915
return;
19201916
}
19211917

1922-
m_expire.from_result(result, id);
1918+
m_expire.from_result(result);
19231919
}
19241920

19251921
table_connection->delete_rows_with(type, id);

src/output-pgsql.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void output_pgsql_t::pgsql_out_way(osmium::Way const &way, taglist_t *tags,
6767

6868
auto const wkb = geom_to_ewkb(projected_geom);
6969
if (!wkb.empty()) {
70-
m_expire.from_geometry(projected_geom, way.id());
70+
m_expire.from_geometry(projected_geom);
7171
if (m_enable_way_area) {
7272
double const area = calculate_area(
7373
get_options()->reproject_area, geom, projected_geom);
@@ -82,7 +82,7 @@ void output_pgsql_t::pgsql_out_way(osmium::Way const &way, taglist_t *tags,
8282
auto const geoms = geom::split_multi(geom::segmentize(
8383
geom::transform(geom::create_linestring(way), *m_proj), split_at));
8484
for (auto const &sgeom : geoms) {
85-
m_expire.from_geometry(sgeom, way.id());
85+
m_expire.from_geometry(sgeom);
8686
auto const wkb = geom_to_ewkb(sgeom);
8787
m_tables[t_line]->write_row(way.id(), *tags, wkb);
8888
if (roads) {
@@ -169,7 +169,7 @@ void output_pgsql_t::node_add(osmium::Node const &node)
169169
}
170170

171171
auto const geom = geom::transform(geom::create_point(node), *m_proj);
172-
m_expire.from_geometry(geom, node.id());
172+
m_expire.from_geometry(geom);
173173
auto const wkb = geom_to_ewkb(geom);
174174
m_tables[t_point]->write_row(node.id(), outtags, wkb);
175175
}
@@ -272,7 +272,7 @@ void output_pgsql_t::pgsql_process_relation(osmium::Relation const &rel)
272272
}
273273
auto const geoms = geom::split_multi(std::move(projected_geom));
274274
for (auto const &sgeom : geoms) {
275-
m_expire.from_geometry(sgeom, -rel.id());
275+
m_expire.from_geometry(sgeom);
276276
auto const wkb = geom_to_ewkb(sgeom);
277277
m_tables[t_line]->write_row(-rel.id(), outtags, wkb);
278278
if (roads) {
@@ -288,7 +288,7 @@ void output_pgsql_t::pgsql_process_relation(osmium::Relation const &rel)
288288
!get_options()->enable_multi);
289289
for (auto const &sgeom : geoms) {
290290
auto const projected_geom = geom::transform(sgeom, *m_proj);
291-
m_expire.from_geometry(projected_geom, -rel.id());
291+
m_expire.from_geometry(projected_geom);
292292
auto const wkb = geom_to_ewkb(projected_geom);
293293
if (m_enable_way_area) {
294294
double const area = calculate_area(
@@ -325,7 +325,7 @@ void output_pgsql_t::relation_add(osmium::Relation const &rel)
325325
* contain the change for that also. */
326326
void output_pgsql_t::node_delete(osmid_t osm_id)
327327
{
328-
if (m_expire.from_result(m_tables[t_point]->get_wkb(osm_id), osm_id) != 0) {
328+
if (m_expire.from_result(m_tables[t_point]->get_wkb(osm_id)) != 0) {
329329
m_tables[t_point]->delete_row(osm_id);
330330
}
331331
}
@@ -343,10 +343,10 @@ void output_pgsql_t::pgsql_delete_way_from_output(osmid_t osm_id)
343343
}
344344

345345
m_tables[t_roads]->delete_row(osm_id);
346-
if (m_expire.from_result(m_tables[t_line]->get_wkb(osm_id), osm_id) != 0) {
346+
if (m_expire.from_result(m_tables[t_line]->get_wkb(osm_id)) != 0) {
347347
m_tables[t_line]->delete_row(osm_id);
348348
}
349-
if (m_expire.from_result(m_tables[t_poly]->get_wkb(osm_id), osm_id) != 0) {
349+
if (m_expire.from_result(m_tables[t_poly]->get_wkb(osm_id)) != 0) {
350350
m_tables[t_poly]->delete_row(osm_id);
351351
}
352352
}
@@ -360,12 +360,10 @@ void output_pgsql_t::way_delete(osmid_t osm_id)
360360
void output_pgsql_t::pgsql_delete_relation_from_output(osmid_t osm_id)
361361
{
362362
m_tables[t_roads]->delete_row(-osm_id);
363-
if (m_expire.from_result(m_tables[t_line]->get_wkb(-osm_id), -osm_id) !=
364-
0) {
363+
if (m_expire.from_result(m_tables[t_line]->get_wkb(-osm_id)) != 0) {
365364
m_tables[t_line]->delete_row(-osm_id);
366365
}
367-
if (m_expire.from_result(m_tables[t_poly]->get_wkb(-osm_id), -osm_id) !=
368-
0) {
366+
if (m_expire.from_result(m_tables[t_poly]->get_wkb(-osm_id)) != 0) {
369367
m_tables[t_poly]->delete_row(-osm_id);
370368
}
371369
}

0 commit comments

Comments
 (0)