-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathosmium_benchmark_write_pbf.cpp
44 lines (33 loc) · 1.11 KB
/
osmium_benchmark_write_pbf.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
The code in this file is released into the Public Domain.
*/
#include <osmium/io/any_input.hpp>
#include <osmium/io/any_output.hpp>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <string>
#include <utility>
int main(int argc, char* argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " INPUT-FILE OUTPUT-FILE\n";
return 1;
}
try {
const std::string input_filename{argv[1]};
const std::string output_filename{argv[2]};
osmium::io::Reader reader{input_filename};
const osmium::io::File output_file{output_filename, "pbf"};
const osmium::io::Header header;
osmium::io::Writer writer{output_file, header, osmium::io::overwrite::allow};
while (osmium::memory::Buffer buffer = reader.read()) { // NOLINT(bugprone-use-after-move) Bug in clang-tidy https://bugs.llvm.org/show_bug.cgi?id=36516
writer(std::move(buffer));
}
writer.close();
reader.close();
} catch (const std::exception& e) {
std::cerr << e.what() << '\n';
return 1;
}
return 0;
}