4040#include < exception>
4141#include < memory>
4242
43+ static void run (options_t const &options)
44+ {
45+ auto const files = prepare_input_files (
46+ options.input_files , options.input_format , options.append );
47+
48+ auto middle = create_middle (options);
49+ middle->start ();
50+
51+ auto const outputs =
52+ output_t::create_outputs (middle->get_query_instance (), options);
53+
54+ auto dependency_manager = std::unique_ptr<dependency_manager_t >(
55+ options.with_forward_dependencies
56+ ? new full_dependency_manager_t {middle}
57+ : new dependency_manager_t {});
58+
59+ osmdata_t osmdata{std::move (dependency_manager), middle, outputs,
60+ options};
61+
62+ osmdata.start ();
63+
64+ // Processing: In this phase the input file(s) are read and parsed,
65+ // populating some of the tables.
66+ process_files (files, osmdata, options.append ,
67+ get_logger ().show_progress ());
68+
69+ // Process pending ways and relations. Cluster database tables and
70+ // create indexes.
71+ osmdata.stop ();
72+ }
73+
4374int main (int argc, char *argv[])
4475{
4576 try {
@@ -50,36 +81,11 @@ int main(int argc, char *argv[])
5081 return 0 ;
5182 }
5283
53- check_db (options);
54-
55- auto const files = prepare_input_files (
56- options.input_files , options.input_format , options.append );
57-
58- auto middle = create_middle (options);
59- middle->start ();
60-
61- auto const outputs =
62- output_t::create_outputs (middle->get_query_instance (), options);
63-
64- auto dependency_manager = std::unique_ptr<dependency_manager_t >(
65- options.with_forward_dependencies
66- ? new full_dependency_manager_t {middle}
67- : new dependency_manager_t {});
68-
69- osmdata_t osmdata{std::move (dependency_manager), middle, outputs,
70- options};
71-
7284 util::timer_t timer_overall;
73- osmdata.start ();
7485
75- // Processing: In this phase the input file(s) are read and parsed,
76- // populating some of the tables.
77- process_files (files, osmdata, options.append ,
78- get_logger ().show_progress ());
86+ check_db (options);
7987
80- // Process pending ways and relations. Cluster database tables and
81- // create indexes.
82- osmdata.stop ();
88+ run (options);
8389
8490 // Output overall memory usage. This only works on Linux.
8591 osmium::MemoryUsage mem;
@@ -88,7 +94,7 @@ int main(int argc, char *argv[])
8894 mem.peak (), mem.current ());
8995 }
9096
91- log_info (" Osm2pgsql took {} overall." ,
97+ log_info (" osm2pgsql took {} overall." ,
9298 util::human_readable_duration (timer_overall.stop ()));
9399 } catch (std::exception const &e) {
94100 log_error (" {}" , e.what ());
0 commit comments