Skip to content

Commit 3549a3c

Browse files
committed
Cleanup process_file(s) functions
1 parent 62f9607 commit 3549a3c

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

src/input.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ static void apply(osmium::OSMObject &object, osmdata_t &osmdata,
223223
osmium::apply_item(object, osmdata, progress);
224224
}
225225

226-
void process_file(osmium::io::File const &file, osmdata_t &osmdata,
227-
progress_display_t &progress, bool append)
226+
static void process_single_file(osmium::io::File const &file,
227+
osmdata_t &osmdata,
228+
progress_display_t &progress, bool append)
228229
{
229230
osmium::io::Reader reader{file};
230231
type_id_version last{osmium::item_type::node, 0, 0};
@@ -241,22 +242,13 @@ void process_file(osmium::io::File const &file, osmdata_t &osmdata,
241242
}
242243
}
243244

244-
osmdata.after_relations();
245-
progress.print_summary();
246-
247245
reader.close();
248246
}
249247

250-
void process_files(std::vector<osmium::io::File> const &files,
251-
osmdata_t &osmdata, bool append, bool show_progress)
248+
static void process_multiple_files(std::vector<osmium::io::File> const &files,
249+
osmdata_t &osmdata,
250+
progress_display_t &progress, bool append)
252251
{
253-
progress_display_t progress{show_progress};
254-
255-
if (files.size() == 1) {
256-
process_file(files.front(), osmdata, progress, append);
257-
return;
258-
}
259-
260252
std::vector<data_source_t> data_sources;
261253
data_sources.reserve(files.size());
262254

@@ -288,10 +280,22 @@ void process_files(std::vector<osmium::io::File> const &files,
288280
}
289281
}
290282

291-
osmdata.after_relations();
292-
progress.print_summary();
293-
294283
for (auto &data_source : data_sources) {
295284
data_source.close();
296285
}
297286
}
287+
288+
void process_files(std::vector<osmium::io::File> const &files,
289+
osmdata_t &osmdata, bool append, bool show_progress)
290+
{
291+
progress_display_t progress{show_progress};
292+
293+
if (files.size() == 1) {
294+
process_single_file(files.front(), osmdata, progress, append);
295+
} else {
296+
process_multiple_files(files, osmdata, progress, append);
297+
}
298+
299+
osmdata.after_relations();
300+
progress.print_summary();
301+
}

src/input.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* It contains the functions reading and checking the input data.
1010
*/
1111

12+
#include <string>
1213
#include <vector>
1314

1415
#include <osmium/fwd.hpp>

src/progress-display.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ class progress_display_t : public osmium::handler::Handler
3737
m_node.start = std::time(nullptr);
3838
}
3939

40-
void node(osmium::Node const &node)
40+
void node(osmium::Node const &)
4141
{
4242
if (++m_node.count % 10000 == 0) {
4343
possibly_print_status();
4444
}
4545
}
4646

47-
void way(osmium::Way const &way)
47+
void way(osmium::Way const &)
4848
{
4949
if (++m_way.count % 1000 == 0) {
5050
possibly_print_status();
5151
}
5252
}
5353

5454

55-
void relation(osmium::Relation const &relation)
55+
void relation(osmium::Relation const &)
5656
{
5757
if (++m_rel.count % 10 == 0) {
5858
possibly_print_status();

0 commit comments

Comments
 (0)