[osmium-tool] 14/97: Add/improve verbose output for some commands.
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Tue Jul 21 20:15:29 UTC 2015
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to tag v1.0.0
in repository osmium-tool.
commit 43be77e4082d9e89c25ac99b3a5910506f90752f
Author: Jochen Topf <jochen at topf.org>
Date: Thu Jul 17 18:31:23 2014 +0200
Add/improve verbose output for some commands.
---
src/command_apply_changes.cpp | 28 ++++++++++++++++++++++++++++
src/command_cat.cpp | 10 +++++-----
src/command_merge_changes.cpp | 26 ++++++++++++++++++++++++++
src/command_time_filter.cpp | 7 ++++++-
4 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/src/command_apply_changes.cpp b/src/command_apply_changes.cpp
index 6a702a7..97c1637 100644
--- a/src/command_apply_changes.cpp
+++ b/src/command_apply_changes.cpp
@@ -37,6 +37,7 @@ bool CommandApplyChanges::setup(const std::vector<std::string>& arguments) {
try {
po::options_description cmdline("Allowed options");
cmdline.add_options()
+ ("verbose,v", "Set verbose mode")
("output,o", po::value<std::string>(), "Output file")
("output-format,f", po::value<std::string>(), "Format of output file")
("input-format,F", po::value<std::string>(), "Format of input file")
@@ -98,6 +99,10 @@ bool CommandApplyChanges::setup(const std::vector<std::string>& arguments) {
m_generator = vm["generator"].as<std::string>();
}
+ if (vm.count("verbose")) {
+ m_vout.verbose(true);
+ }
+
} catch (boost::program_options::error& e) {
std::cerr << "Error parsing command line: " << e.what() << std::endl;
return false;
@@ -115,6 +120,19 @@ bool CommandApplyChanges::setup(const std::vector<std::string>& arguments) {
m_output_file = osmium::io::File(m_output_filename, m_output_format);
+ m_vout << "Started osmium apply-changes\n";
+
+ m_vout << "Command line options and default settings:\n";
+ m_vout << " generator: " << m_generator << "\n";
+ m_vout << " input data file name: " << m_input_filename << "\n";
+ m_vout << " input change file names: \n";
+ for (const auto& fn : m_change_filenames) {
+ m_vout << " " << fn << "\n";
+ }
+ m_vout << " output filename: " << m_output_filename << "\n";
+ m_vout << " input format: " << m_input_format << "\n";
+ m_vout << " output format: " << m_output_format << "\n";
+
return true;
}
@@ -122,6 +140,8 @@ bool CommandApplyChanges::run() {
std::vector<osmium::memory::Buffer> changes;
osmium::ObjectPointerCollection objects;
+ m_vout << "Reading change file contents...\n";
+
for (const std::string& change_file_name : m_change_filenames) {
osmium::io::Reader reader(change_file_name, osmium::osm_entity_bits::object);
while (osmium::memory::Buffer buffer = reader.read()) {
@@ -130,11 +150,13 @@ bool CommandApplyChanges::run() {
}
}
+ m_vout << "Opening input file...\n";
osmium::io::Reader reader(m_input_filename, osmium::osm_entity_bits::object);
osmium::io::Header header = reader.header();
header.set("generator", m_generator);
+ m_vout << "Opening output file...\n";
osmium::io::Writer writer(m_output_file, header, m_output_overwrite);
osmium::io::OutputIterator<osmium::io::Writer> out(writer);
@@ -142,6 +164,7 @@ bool CommandApplyChanges::run() {
// If the --simplify option was given we sort with the
// largest version of each object first and then only
// copy this last version of any object to the output_buffer.
+ m_vout << "Sorting change data...\n";
objects.sort(osmium::object_order_type_id_reverse_version());
osmium::object_id_type id = 0;
@@ -156,6 +179,7 @@ bool CommandApplyChanges::run() {
}
});
+ m_vout << "Applying changes and writing them to output...\n";
std::set_union(objects.begin(),
objects.end(),
osmium::io::InputIterator<osmium::io::Reader, osmium::OSMObject> {reader},
@@ -166,8 +190,10 @@ bool CommandApplyChanges::run() {
// If the --simplify option was not given, this
// is a straightforward sort of the change files
// and then a merge with the input file.
+ m_vout << "Sorting change data...\n";
objects.sort(osmium::object_order_type_id_version());
+ m_vout << "Applying changes and writing them to output...\n";
std::set_union(objects.begin(),
objects.end(),
osmium::io::InputIterator<osmium::io::Reader, osmium::OSMObject> {reader},
@@ -178,6 +204,8 @@ bool CommandApplyChanges::run() {
out.flush();
writer.close();
+ m_vout << "Done.\n";
+
return true;
}
diff --git a/src/command_cat.cpp b/src/command_cat.cpp
index 1206c67..1b82e98 100644
--- a/src/command_cat.cpp
+++ b/src/command_cat.cpp
@@ -102,14 +102,14 @@ bool CommandCat::setup(const std::vector<std::string>& arguments) {
m_vout << "Command line options and default settings:\n";
m_vout << " generator: " << m_generator << "\n";
- m_vout << " input-filenames: \n";
+ m_vout << " input filenames: \n";
for (const auto& fn : m_input_filenames) {
m_vout << " " << fn << "\n";
}
- m_vout << " output-filename: " << m_output_filename << "\n";
- m_vout << " input-format: " << m_input_format << "\n";
- m_vout << " output-format: " << m_output_format << "\n";
- m_vout << " output-header: \n";
+ m_vout << " output filename: " << m_output_filename << "\n";
+ m_vout << " input format: " << m_input_format << "\n";
+ m_vout << " output format: " << m_output_format << "\n";
+ m_vout << " output header: \n";
for (const auto& h : m_output_headers) {
m_vout << " " << h << "\n";
}
diff --git a/src/command_merge_changes.cpp b/src/command_merge_changes.cpp
index c1b8a4e..a90a4e0 100644
--- a/src/command_merge_changes.cpp
+++ b/src/command_merge_changes.cpp
@@ -38,6 +38,7 @@ bool CommandMergeChanges::setup(const std::vector<std::string>& arguments) {
try {
po::options_description cmdline("Allowed options");
cmdline.add_options()
+ ("verbose,v", "Set verbose mode")
("output,o", po::value<std::string>(), "Output file")
("output-format,f", po::value<std::string>(), "Format of output file")
("input-format,F", po::value<std::string>(), "Format of input files")
@@ -88,6 +89,10 @@ bool CommandMergeChanges::setup(const std::vector<std::string>& arguments) {
m_generator = vm["generator"].as<std::string>();
}
+ if (vm.count("verbose")) {
+ m_vout.verbose(true);
+ }
+
} catch (boost::program_options::error& e) {
std::cerr << "Error parsing command line: " << e.what() << std::endl;
return false;
@@ -113,6 +118,18 @@ bool CommandMergeChanges::setup(const std::vector<std::string>& arguments) {
m_output_file = osmium::io::File(m_output_filename, m_output_format);
+ m_vout << "Started osmium merge-changes\n";
+
+ m_vout << "Command line options and default settings:\n";
+ m_vout << " generator: " << m_generator << "\n";
+ m_vout << " input change file names: \n";
+ for (const auto& fn : m_input_filenames) {
+ m_vout << " " << fn << "\n";
+ }
+ m_vout << " output filename: " << m_output_filename << "\n";
+ m_vout << " input format: " << m_input_format << "\n";
+ m_vout << " output format: " << m_output_format << "\n";
+
return true;
}
@@ -124,6 +141,7 @@ bool CommandMergeChanges::run() {
// read all input files, keep the buffers around and add pointer
// to each object to objects collection.
+ m_vout << "Reading change file contents...\n";
for (const std::string& change_file_name : m_input_filenames) {
osmium::io::Reader reader(change_file_name, osmium::osm_entity_bits::object);
while (osmium::memory::Buffer buffer = reader.read()) {
@@ -134,6 +152,8 @@ bool CommandMergeChanges::run() {
osmium::io::Header header;
header.set("generator", m_generator);
+
+ m_vout << "Opening output file...\n";
osmium::io::Writer writer(m_output_file, header, m_output_overwrite);
osmium::io::OutputIterator<osmium::io::Writer> out(writer);
@@ -143,18 +163,24 @@ bool CommandMergeChanges::run() {
// If the --simplify option was given we sort with the
// largest version of each object first and then only
// copy this last version of any object to the output_buffer.
+ m_vout << "Sorting change data...\n";
objects.sort(osmium::object_order_type_id_reverse_version());
+ m_vout << "Writing last version of each object to output...\n";
std::unique_copy(objects.cbegin(), objects.cend(), out, osmium::object_equal_type_id());
} else {
// If the --simplify option was not given, this
// is a straightforward sort and copy.
+ m_vout << "Sorting change data...\n";
objects.sort(osmium::object_order_type_id_version());
+ m_vout << "Writing all objects to output...\n";
std::copy(objects.cbegin(), objects.cend(), out);
}
out.flush();
writer.close();
+ m_vout << "Done.\n";
+
return true;
}
diff --git a/src/command_time_filter.cpp b/src/command_time_filter.cpp
index 203dabb..767de03 100644
--- a/src/command_time_filter.cpp
+++ b/src/command_time_filter.cpp
@@ -136,18 +136,20 @@ bool CommandTimeFilter::setup(const std::vector<std::string>& arguments) {
}
}
- m_vout << "Start osmium-time-filter\n";
+ m_vout << "Started osmium time-filter\n";
m_vout << "Filtering from time " << m_from.to_iso() << " to " << m_to.to_iso() << "\n";
return true;
}
bool CommandTimeFilter::run() {
+ m_vout << "Opening input file...\n";
osmium::io::Reader reader(m_input_file, osmium::osm_entity_bits::object);
osmium::io::Header header = reader.header();
header.set("generator", m_generator);
+ m_vout << "Opening output file...\n";
osmium::io::Writer writer(m_output_file, header, m_output_overwrite);
osmium::io::OutputIterator<osmium::io::Writer> out(writer);
@@ -158,6 +160,7 @@ bool CommandTimeFilter::run() {
typedef osmium::DiffIterator<object_iterator> diff_iterator;
+ m_vout << "Filtering data...\n";
std::copy_if(
diff_iterator(object_it, object_end),
diff_iterator(object_end, object_end),
@@ -171,6 +174,8 @@ bool CommandTimeFilter::run() {
out.flush();
writer.close();
+ m_vout << "Done.\n";
+
return true;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osmium-tool.git
More information about the Pkg-grass-devel
mailing list