Skip to content

Commit 11cc485

Browse files
authored
Merge pull request #1838 from joto/remove-copy-thread-param
Remove copy_thread parameter from output constructors
2 parents 8680f69 + 75a3f19 commit 11cc485

File tree

6 files changed

+35
-37
lines changed

6 files changed

+35
-37
lines changed

src/output-flex.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,14 +1997,15 @@ output_flex_t::clone(std::shared_ptr<middle_query_t> const &mid,
19971997
return std::make_shared<output_flex_t>(this, mid, copy_thread);
19981998
}
19991999

2000-
output_flex_t::output_flex_t(
2001-
std::shared_ptr<middle_query_t> const &mid,
2002-
std::shared_ptr<thread_pool_t> thread_pool, options_t const &o,
2003-
std::shared_ptr<db_copy_thread_t> const &copy_thread)
2004-
: output_t(mid, std::move(thread_pool), o), m_copy_thread(copy_thread),
2005-
m_expire(o.expire_tiles_zoom, o.expire_tiles_max_bbox, o.projection)
2006-
{
2007-
init_lua(get_options()->style);
2000+
output_flex_t::output_flex_t(std::shared_ptr<middle_query_t> const &mid,
2001+
std::shared_ptr<thread_pool_t> thread_pool,
2002+
options_t const &options)
2003+
: output_t(mid, std::move(thread_pool), options),
2004+
m_copy_thread(std::make_shared<db_copy_thread_t>(options.conninfo)),
2005+
m_expire(options.expire_tiles_zoom, options.expire_tiles_max_bbox,
2006+
options.projection)
2007+
{
2008+
init_lua(options.style);
20082009

20092010
// If the osm2pgsql.select_relation_members() Lua function is defined
20102011
// it means we need two-stage processing which in turn means we need

src/output-flex.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ class output_flex_t : public output_t
9999
{
100100
public:
101101
/// Constructor for new objects
102-
output_flex_t(
103-
std::shared_ptr<middle_query_t> const &mid,
104-
std::shared_ptr<thread_pool_t> thread_pool, options_t const &options,
105-
std::shared_ptr<db_copy_thread_t> const &copy_thread);
102+
output_flex_t(std::shared_ptr<middle_query_t> const &mid,
103+
std::shared_ptr<thread_pool_t> thread_pool,
104+
options_t const &options);
106105

107106
/// Constructor for cloned objects
108107
output_flex_t(output_flex_t const *other,

src/output-gazetteer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class output_gazetteer_t : public output_t
3232
/// Constructor for new objects
3333
output_gazetteer_t(std::shared_ptr<middle_query_t> const &mid,
3434
std::shared_ptr<thread_pool_t> thread_pool,
35-
options_t const &options,
36-
std::shared_ptr<db_copy_thread_t> const &copy_thread)
37-
: output_t(mid, std::move(thread_pool), options), m_copy(copy_thread),
35+
options_t const &options)
36+
: output_t(mid, std::move(thread_pool), options),
37+
m_copy(std::make_shared<db_copy_thread_t>(options.conninfo)),
3838
m_proj(options.projection)
3939
{
4040
m_style.load_style(options.style);

src/output-pgsql.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -418,23 +418,25 @@ std::shared_ptr<output_t> output_pgsql_t::clone(
418418
return std::make_shared<output_pgsql_t>(this, mid, copy_thread);
419419
}
420420

421-
output_pgsql_t::output_pgsql_t(
422-
std::shared_ptr<middle_query_t> const &mid,
423-
std::shared_ptr<thread_pool_t> thread_pool, options_t const &o,
424-
std::shared_ptr<db_copy_thread_t> const &copy_thread)
425-
: output_t(mid, std::move(thread_pool), o), m_proj(o.projection),
426-
m_expire(o.expire_tiles_zoom, o.expire_tiles_max_bbox, o.projection),
421+
output_pgsql_t::output_pgsql_t(std::shared_ptr<middle_query_t> const &mid,
422+
std::shared_ptr<thread_pool_t> thread_pool,
423+
options_t const &options)
424+
: output_t(mid, std::move(thread_pool), options), m_proj(options.projection),
425+
m_expire(options.expire_tiles_zoom, options.expire_tiles_max_bbox,
426+
options.projection),
427427
m_buffer(32768, osmium::memory::Buffer::auto_grow::yes),
428428
m_rels_buffer(1024, osmium::memory::Buffer::auto_grow::yes)
429429
{
430-
log_debug("Using projection SRS {} ({})", o.projection->target_srs(),
431-
o.projection->target_desc());
430+
log_debug("Using projection SRS {} ({})", options.projection->target_srs(),
431+
options.projection->target_desc());
432432

433433
export_list exlist;
434434

435-
m_enable_way_area = read_style_file(get_options()->style, &exlist);
435+
m_enable_way_area = read_style_file(options.style, &exlist);
436+
437+
m_tagtransform = tagtransform_t::make_tagtransform(&options, exlist);
436438

437-
m_tagtransform = tagtransform_t::make_tagtransform(get_options(), exlist);
439+
auto copy_thread = std::make_shared<db_copy_thread_t>(options.conninfo);
438440

439441
//for each table
440442
for (size_t i = 0; i < t_MAX; ++i) {
@@ -444,7 +446,7 @@ output_pgsql_t::output_pgsql_t(
444446
(i == t_point) ? osmium::item_type::node : osmium::item_type::way);
445447

446448
//figure out what name we are using for this and what type
447-
std::string name = get_options()->prefix;
449+
std::string name = options.prefix;
448450
std::string type;
449451
switch (i) {
450452
case t_point:
@@ -469,10 +471,9 @@ output_pgsql_t::output_pgsql_t(
469471
}
470472

471473
m_tables[i] = std::make_unique<table_t>(
472-
name, type, columns, get_options()->hstore_columns,
473-
get_options()->projection->target_srs(), get_options()->append,
474-
get_options()->hstore_mode, copy_thread,
475-
get_options()->output_dbschema);
474+
name, type, columns, options.hstore_columns,
475+
options.projection->target_srs(), options.append,
476+
options.hstore_mode, copy_thread, options.output_dbschema);
476477
}
477478
}
478479

src/output-pgsql.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ class output_pgsql_t : public output_t
4040
/// Constructor for new objects
4141
output_pgsql_t(std::shared_ptr<middle_query_t> const &mid,
4242
std::shared_ptr<thread_pool_t> thread_pool,
43-
options_t const &options,
44-
std::shared_ptr<db_copy_thread_t> const &copy_thread);
43+
options_t const &options);
4544

4645
/// Constructor for cloned objects
4746
output_pgsql_t(output_pgsql_t const *other,

src/output.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,21 @@ output_t::create_output(std::shared_ptr<middle_query_t> const &mid,
3030
std::shared_ptr<thread_pool_t> thread_pool,
3131
options_t const &options)
3232
{
33-
auto copy_thread = std::make_shared<db_copy_thread_t>(options.conninfo);
34-
3533
if (options.output_backend == "pgsql") {
3634
return std::make_shared<output_pgsql_t>(mid, std::move(thread_pool),
37-
options, copy_thread);
35+
options);
3836
}
3937

4038
#ifdef HAVE_LUA
4139
if (options.output_backend == "flex") {
4240
return std::make_shared<output_flex_t>(mid, std::move(thread_pool),
43-
options, copy_thread);
41+
options);
4442
}
4543
#endif
4644

4745
if (options.output_backend == "gazetteer") {
4846
return std::make_shared<output_gazetteer_t>(mid, std::move(thread_pool),
49-
options, copy_thread);
47+
options);
5048
}
5149

5250
if (options.output_backend == "null") {

0 commit comments

Comments
 (0)