Skip to content

Commit 3d1eab5

Browse files
authored
Merge pull request #1196 from joto/rename-file-format-option
Rename file format option and simplify default (auto) case
2 parents a05209a + 4111a12 commit 3d1eab5

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/options.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,9 @@ options_t::options_t(int argc, char *argv[]) : options_t()
488488
enable_multi = true;
489489
break;
490490
case 'r':
491-
input_reader = optarg;
491+
if (std::strcmp(optarg, "auto") != 0) {
492+
input_format = optarg;
493+
}
492494
break;
493495
case 'h':
494496
long_usage_bool = true;

src/options.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class options_t
124124

125125
database_options_t database_options;
126126
std::string output_backend{"pgsql"};
127-
std::string input_reader{"auto"};
127+
std::string input_format; ///< input file format (default: autodetect)
128128
osmium::Box bbox;
129129
bool extra_attributes = false;
130130

src/osm2pgsql.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
9191
util::timer_t timer_parse;
9292

9393
parse_osmium_t parser{options.bbox, options.append, &osmdata};
94-
parser.stream_file(filename, options.input_reader);
94+
parser.stream_file(filename, options.input_format);
9595

9696
stats.update(parser.stats());
9797

src/parse-osmium.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ parse_osmium_t::parse_osmium_t(osmium::Box const &bbox, bool append,
7878
{}
7979

8080
void parse_osmium_t::stream_file(std::string const &filename,
81-
std::string const &fmt)
81+
std::string const &format)
8282
{
83-
std::string const &osmium_format = (fmt == "auto" ? "" : fmt);
84-
osmium::io::File infile{filename, osmium_format};
83+
osmium::io::File infile{filename, format};
8584

8685
if (!m_append && infile.has_multiple_object_versions()) {
8786
throw std::runtime_error{
@@ -90,9 +89,9 @@ void parse_osmium_t::stream_file(std::string const &filename,
9089

9190
if (infile.format() == osmium::io::file_format::unknown) {
9291
throw std::runtime_error{
93-
fmt == "auto"
92+
format.empty()
9493
? std::string{"Cannot detect file format. Try using -r."}
95-
: "Unknown file format '{}'."_format(fmt)};
94+
: "Unknown file format '{}'."_format(format)};
9695
}
9796

9897
fmt::print(stderr, "Using {} parser.\n",

0 commit comments

Comments
 (0)