Skip to content

Commit aa4507f

Browse files
committed
Remove need for output_backend_set boolean
1 parent d9d0d63 commit aa4507f

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

Diff for: src/command-line-parser.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,6 @@ options_t parse_command_line(int argc, char *argv[])
646646
break;
647647
case 'O': // --output
648648
options.output_backend = optarg;
649-
options.output_backend_set = true;
650649
break;
651650
case 'x': // --extra-attributes
652651
options.extra_attributes = true;

Diff for: src/options.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct options_t
9292
/// File name to output expired tiles list to
9393
std::string expire_tiles_filename{"dirty_tiles"};
9494

95-
std::string output_backend{"pgsql"};
95+
std::string output_backend;
9696
std::string input_format; ///< input file format (default: autodetect)
9797

9898
osmium::Box bbox;
@@ -162,8 +162,6 @@ struct options_t
162162
bool parallel_indexing = true;
163163
bool create = false;
164164
bool pass_prompt = false;
165-
166-
bool output_backend_set = false;
167165
}; // struct options_t
168166

169167
#endif // OSM2PGSQL_OPTIONS_HPP

Diff for: src/osm2pgsql.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static void check_output(properties_t const &properties, options_t *options)
256256
{
257257
auto const output = properties.get_string("output", "pgsql");
258258

259-
if (!options->output_backend_set) {
259+
if (options->output_backend.empty()) {
260260
options->output_backend = output;
261261
log_info("Using output '{}' (same as on import).", output);
262262
return;
@@ -334,8 +334,12 @@ static void check_for_nodes_table(options_t const &options)
334334
}
335335
}
336336

337-
static void check_and_set_style(options_t *options)
337+
static void set_option_defaults(options_t *options)
338338
{
339+
if (options->output_backend.empty()) {
340+
options->output_backend = "pgsql";
341+
}
342+
339343
if (options->style.empty()) {
340344
if (options->output_backend == "flex" ||
341345
options->output_backend == "gazetteer") {
@@ -375,7 +379,7 @@ int main(int argc, char *argv[])
375379
if (properties.load()) {
376380
check_and_update_properties(&properties, &options);
377381
} else {
378-
check_and_set_style(&options);
382+
set_option_defaults(&options);
379383
check_for_nodes_table(options);
380384
}
381385

@@ -393,7 +397,7 @@ int main(int argc, char *argv[])
393397
}
394398
}
395399
} else {
396-
check_and_set_style(&options);
400+
set_option_defaults(&options);
397401
store_properties(&properties, options);
398402
auto const finfo = run(options);
399403
store_data_properties(&properties, finfo);

Diff for: tests/common-options.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class opt_t
2222
public:
2323
opt_t()
2424
{
25+
m_opt.output_backend = "pgsql";
2526
m_opt.prefix = "osm2pgsql_test";
2627
m_opt.style = OSM2PGSQLDATA_DIR "default.style";
2728
m_opt.num_procs = 1;

Diff for: tests/test-options-projection.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ TEST_CASE("Projection setup")
2222
{
2323
char const* const style_file = OSM2PGSQLDATA_DIR "default.style";
2424

25-
std::vector<char const *> option_params = {"osm2pgsql", "-S", style_file,
26-
"--number-processes", "1"};
25+
std::vector<char const *> option_params = {"osm2pgsql", "--output=pgsql",
26+
"-S", style_file,
27+
"--number-processes=1"};
2728

2829
std::string proj_name;
2930
char const *srid = "";

0 commit comments

Comments
 (0)