[osmium-tool] 03/97: Add output-header option to osmium cat
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Tue Jul 21 20:15:28 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 0f9b8768847a504fcf9487154339c250b2845293
Author: Jochen Topf <jochen at topf.org>
Date: Thu Feb 20 17:44:25 2014 +0100
Add output-header option to osmium cat
---
doc/osmium-cat.md | 5 ++++-
src/command_cat.cpp | 17 ++++++++++++++++-
src/command_cat.hpp | 3 ++-
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/doc/osmium-cat.md b/doc/osmium-cat.md
index cd31c00..50b7998 100644
--- a/doc/osmium-cat.md
+++ b/doc/osmium-cat.md
@@ -33,7 +33,7 @@ can be used to convert OSM files from one format into another.
all input files, there is no way to set the format for some input files
only. See the FILE FORMATS section for details.
---output-file, -o
+--output, -o
: Name of the output file. Default is '-' (*stdout*).
--output-format, -f
@@ -41,6 +41,9 @@ can be used to convert OSM files from one format into another.
if it can't be autodetected from the output file name. See the FILE FORMATS
section for details.
+--output-header
+: Add output header. This option can be given several times.
+
--overwrite, -O
: Allow an existing output file to be overwritten. Normally **osmium** will
refuse to write over an existing file.
diff --git a/src/command_cat.cpp b/src/command_cat.cpp
index ef05dba..75f623f 100644
--- a/src/command_cat.cpp
+++ b/src/command_cat.cpp
@@ -3,7 +3,7 @@
Osmium -- OpenStreetMap data manipulation command line tool
http://osmcode.org/osmium
-Copyright (C) 2013 Jochen Topf <jochen at topf.org>
+Copyright (C) 2013, 2014 Jochen Topf <jochen at topf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -41,6 +41,7 @@ bool CommandCat::setup(const std::vector<std::string>& arguments) {
("output-format,f", po::value<std::string>(), "Format of output file")
("input-format,F", po::value<std::string>(), "Format of input files")
("generator", po::value<std::string>(), "Generator setting for file header")
+ ("output-header", po::value<std::vector<std::string>>(), "Add output header")
("overwrite,O", "Allow existing output file to be overwritten")
;
@@ -84,6 +85,10 @@ bool CommandCat::setup(const std::vector<std::string>& arguments) {
m_output_format = vm["output-format"].as<std::string>();
}
+ if (vm.count("output-header")) {
+ m_output_headers = vm["output-header"].as<std::vector<std::string>>();
+ }
+
if (vm.count("overwrite")) {
m_output_overwrite = true;
}
@@ -104,6 +109,10 @@ bool CommandCat::setup(const std::vector<std::string>& arguments) {
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";
+ }
if ((m_output_filename == "-" || m_output_filename == "") && m_output_format.empty()) {
std::cerr << "When writing to STDOUT you need to use the --output-format,f option to declare the file format.\n";
@@ -141,6 +150,9 @@ bool CommandCat::run() {
osmium::io::Reader reader(m_input_files[0]);
osmium::io::Header header = reader.header();
header.set("generator", m_generator);
+ for (const auto& h : m_output_headers) {
+ header.set(h);
+ }
osmium::io::Writer writer(m_output_file, header, m_output_overwrite);
while (osmium::memory::Buffer buffer = reader.read()) {
writer(std::move(buffer));
@@ -148,6 +160,9 @@ bool CommandCat::run() {
writer.close();
} else { // multiple input files
osmium::io::Header header({{"generator", m_generator}});
+ for (const auto& h : m_output_headers) {
+ header.set(h);
+ }
osmium::io::Writer writer(m_output_file, header, m_output_overwrite);
for (const auto& input_file : m_input_files) {
m_vout << "Copying input file '" << input_file.filename() << "'\n";
diff --git a/src/command_cat.hpp b/src/command_cat.hpp
index 4f8aa54..9b9004e 100644
--- a/src/command_cat.hpp
+++ b/src/command_cat.hpp
@@ -6,7 +6,7 @@
Osmium -- OpenStreetMap data manipulation command line tool
http://osmcode.org/osmium
-Copyright (C) 2013 Jochen Topf <jochen at topf.org>
+Copyright (C) 2013, 2014 Jochen Topf <jochen at topf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@ class CommandCat : public Command {
std::string m_output_filename = "-"; // default: stdout
std::string m_input_format;
std::string m_output_format;
+ std::vector<std::string> m_output_headers;
osmium::io::File m_output_file;
std::vector<osmium::io::File> m_input_files;
bool m_output_overwrite = false;
--
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