Skip to content

Commit

Permalink
Remove need for output_backend_set boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
joto committed Dec 19, 2023
1 parent d9d0d63 commit aa4507f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/command-line-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ options_t parse_command_line(int argc, char *argv[])
break;
case 'O': // --output
options.output_backend = optarg;
options.output_backend_set = true;
break;
case 'x': // --extra-attributes
options.extra_attributes = true;
Expand Down
4 changes: 1 addition & 3 deletions src/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct options_t
/// File name to output expired tiles list to
std::string expire_tiles_filename{"dirty_tiles"};

std::string output_backend{"pgsql"};
std::string output_backend;
std::string input_format; ///< input file format (default: autodetect)

osmium::Box bbox;
Expand Down Expand Up @@ -162,8 +162,6 @@ struct options_t
bool parallel_indexing = true;
bool create = false;
bool pass_prompt = false;

bool output_backend_set = false;
}; // struct options_t

#endif // OSM2PGSQL_OPTIONS_HPP
12 changes: 8 additions & 4 deletions src/osm2pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static void check_output(properties_t const &properties, options_t *options)
{
auto const output = properties.get_string("output", "pgsql");

if (!options->output_backend_set) {
if (options->output_backend.empty()) {
options->output_backend = output;
log_info("Using output '{}' (same as on import).", output);
return;
Expand Down Expand Up @@ -334,8 +334,12 @@ static void check_for_nodes_table(options_t const &options)
}
}

static void check_and_set_style(options_t *options)
static void set_option_defaults(options_t *options)
{
if (options->output_backend.empty()) {
options->output_backend = "pgsql";
}

if (options->style.empty()) {
if (options->output_backend == "flex" ||
options->output_backend == "gazetteer") {
Expand Down Expand Up @@ -375,7 +379,7 @@ int main(int argc, char *argv[])
if (properties.load()) {
check_and_update_properties(&properties, &options);
} else {
check_and_set_style(&options);
set_option_defaults(&options);
check_for_nodes_table(options);
}

Expand All @@ -393,7 +397,7 @@ int main(int argc, char *argv[])
}
}
} else {
check_and_set_style(&options);
set_option_defaults(&options);
store_properties(&properties, options);
auto const finfo = run(options);
store_data_properties(&properties, finfo);
Expand Down
1 change: 1 addition & 0 deletions tests/common-options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class opt_t
public:
opt_t()
{
m_opt.output_backend = "pgsql";
m_opt.prefix = "osm2pgsql_test";
m_opt.style = OSM2PGSQLDATA_DIR "default.style";
m_opt.num_procs = 1;
Expand Down
5 changes: 3 additions & 2 deletions tests/test-options-projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ TEST_CASE("Projection setup")
{
char const* const style_file = OSM2PGSQLDATA_DIR "default.style";

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

std::string proj_name;
char const *srid = "";
Expand Down

0 comments on commit aa4507f

Please sign in to comment.