[osmium-tool] 01/05: Imported Upstream version 1.5.1

Bas Couwenberg sebastic at debian.org
Thu Jan 19 15:56:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository osmium-tool.

commit 9a6a87d5cd8e18287032efe70147f231cd9fdf67
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Thu Jan 19 16:44:22 2017 +0100

    Imported Upstream version 1.5.1
---
 CHANGELOG.md                          | 18 ++++++-
 CMakeLists.txt                        | 11 +++--
 man/osmium-check-refs.md              |  2 +-
 man/osmium-diff.md                    |  2 +-
 man/osmium-extract.md                 |  2 +-
 man/osmium-file-formats.md            |  4 +-
 man/osmium-fileinfo.md                |  2 +-
 man/osmium-getid.md                   |  4 +-
 man/osmium-show.md                    |  2 +-
 man/osmium.md                         |  4 +-
 man/output-options.md                 |  2 +-
 src/cmd.hpp                           |  8 ++--
 src/command_add_locations_to_ways.cpp |  8 ----
 src/command_add_locations_to_ways.hpp | 13 ++++--
 src/command_apply_changes.cpp         | 10 +---
 src/command_cat.cpp                   |  8 ----
 src/command_changeset_filter.cpp      |  8 ----
 src/command_check_refs.cpp            |  8 ----
 src/command_derive_changes.cpp        | 18 ++-----
 src/command_diff.cpp                  |  8 ----
 src/command_extract.cpp               |  8 ----
 src/command_fileinfo.cpp              |  8 ----
 src/command_getid.cpp                 |  8 ----
 src/command_help.cpp                  |  8 ----
 src/command_merge.cpp                 |  8 ----
 src/command_merge_changes.cpp         |  8 ----
 src/command_renumber.cpp              |  8 ----
 src/command_show.cpp                  |  8 ----
 src/command_sort.cpp                  |  8 ----
 src/command_time_filter.cpp           |  8 ----
 src/commands.cpp                      | 88 +++++++++++++++++++++++++++++++++++
 src/extract/extract_bbox.hpp          |  1 +
 src/extract/geojson_file_parser.cpp   | 21 +++++++++
 src/extract/geojson_file_parser.hpp   |  6 +--
 src/io.cpp                            | 57 +++++++++++++++--------
 src/main.cpp                          |  2 +
 36 files changed, 209 insertions(+), 188 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 57498a5..bf725e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,21 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 ### Fixed
 
 
+## [1.5.1] - 2017-01-19
+
+### Changed
+
+- Build with warnings in all build types, not only "Dev".
+- Better error messages for command line errors.
+
+### Fixed
+
+- Make `--overwrite` and `--fsync` work in `derive_changes` command.
+- A dereference of end iterator in `derive_changes`.
+- You can not specify the special file name "-" (to read from STDIN) several
+  times for commands reading multiple files.
+
+
 ## [1.5.0] - 2017-01-18
 
 ### Added
@@ -198,7 +213,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 - Minor updates to documentation and build system
 
 
-[unreleased]: https://github.com/osmcode/osmium-tool/compare/v1.5.0...HEAD
+[unreleased]: https://github.com/osmcode/osmium-tool/compare/v1.5.1...HEAD
+[1.5.1]: https://github.com/osmcode/osmium-tool/compare/v1.5.0...v1.5.1
 [1.5.0]: https://github.com/osmcode/osmium-tool/compare/v1.4.1...v1.5.0
 [1.4.1]: https://github.com/osmcode/osmium-tool/compare/v1.4.0...v1.4.1
 [1.4.0]: https://github.com/osmcode/osmium-tool/compare/v1.3.1...v1.4.0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bce2dbf..f596dc0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,7 @@ project(osmium)
 
 set(OSMIUM_VERSION_MAJOR 1)
 set(OSMIUM_VERSION_MINOR 5)
-set(OSMIUM_VERSION_PATCH 0)
+set(OSMIUM_VERSION_PATCH 1)
 
 set(OSMIUM_VERSION ${OSMIUM_VERSION_MAJOR}.${OSMIUM_VERSION_MINOR}.${OSMIUM_VERSION_PATCH})
 
@@ -218,12 +218,13 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${USUAL_COMPILE_OPTIONS}"
 #
 #-----------------------------------------------------------------------------
 
+add_definitions(${OSMIUM_WARNING_OPTIONS})
+
 # In 'Dev' mode: compile with very strict warnings and turn them into errors.
 if(CMAKE_BUILD_TYPE STREQUAL "Dev")
     if(NOT MSVC)
-        add_definitions(-Werror -Wno-unused-variable)
+        add_definitions(-Werror)
     endif()
-    add_definitions(${OSMIUM_WARNING_OPTIONS})
 endif()
 
 # Force RelWithDebInfo build type if none was given
@@ -238,6 +239,8 @@ set(CMAKE_BUILD_TYPE ${build_type}
     "Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}."
     FORCE)
 
+message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
+
 
 #-----------------------------------------------------------------------------
 #
@@ -269,7 +272,7 @@ configure_file(
     ${PROJECT_BINARY_DIR}/osmium
 )
 
-include_directories(include)
+include_directories(SYSTEM include)
 include_directories(${PROJECT_BINARY_DIR}/src)
 
 #-----------------------------------------------------------------------------
diff --git a/man/osmium-check-refs.md b/man/osmium-check-refs.md
index 0b2a4cb..1671df2 100644
--- a/man/osmium-check-refs.md
+++ b/man/osmium-check-refs.md
@@ -33,7 +33,7 @@ change files.
 # OPTIONS
 
 -i, --show-ids
-:   Print all missing IDs to *stdout*. If you don't give this option, only a
+:   Print all missing IDs to STDOUT. If you don't give this option, only a
     summary is shown.
 
 -r, --check-relations
diff --git a/man/osmium-diff.md b/man/osmium-diff.md
index cb75293..5831476 100644
--- a/man/osmium-diff.md
+++ b/man/osmium-diff.md
@@ -61,7 +61,7 @@ None of the output formats print the headers of the input files.
 :   See the **OUTPUT FORMATS** section.
 
 -o, --output=FILE
-:   Name of the output file. Default is '-' (*stdout*).
+:   Name of the output file. Default is '-' (STDOUT).
 
 -O, --overwrite
 :   Allow an existing output file to be overwritten. Normally **osmium** will
diff --git a/man/osmium-extract.md b/man/osmium-extract.md
index 6da2ac1..c426696 100644
--- a/man/osmium-extract.md
+++ b/man/osmium-extract.md
@@ -331,7 +331,7 @@ can be huge, so if you include them, be aware your result might be huge.
 
 Memory usage of **osmium extract** depends on the number of extracts and on the
 strategy used. For the *simple* strategy it will at least be the number of
-extracts times the highest node ID used devided by 8. For the *complete_ways*
+extracts times the highest node ID used divided by 8. For the *complete_ways*
 twice that and for the *smart* strategy a bit more.
 
 
diff --git a/man/osmium-file-formats.md b/man/osmium-file-formats.md
index 4023d3a..e85f675 100644
--- a/man/osmium-file-formats.md
+++ b/man/osmium-file-formats.md
@@ -22,8 +22,8 @@ In addition files in all formats except PBF can be compressed using *gzip* or
 
 Which format a file has is usually autodetected from the file name suffix.
 
-If this doesn't work, either because you are reading from stdin or writing to
-stdout, or because you have an unusual file name, you have to set the format
+If this doesn't work, either because you are reading from STDIN or writing to
+STDOUT, or because you have an unusual file name, you have to set the format
 manually. You can also set the format manually if you want to specify special
 format options.
 
diff --git a/man/osmium-fileinfo.md b/man/osmium-fileinfo.md
index 5d2bcec..8f9e559 100644
--- a/man/osmium-fileinfo.md
+++ b/man/osmium-fileinfo.md
@@ -74,7 +74,7 @@ The following variables are available:
     file.name - STRING
     file.format - STRING: XML|PBF
     file.compression - STRING: none|bzip2|gzip
-    file.size - INTEGER (0 for stdout)
+    file.size - INTEGER (always 0 when reading from STDIN)
     header.with_history - BOOL (yes|no)
     header.option.generator - STRING
     header.option.version - STRING
diff --git a/man/osmium-getid.md b/man/osmium-getid.md
index 4d3c280..67d0f9a 100644
--- a/man/osmium-getid.md
+++ b/man/osmium-getid.md
@@ -74,7 +74,7 @@ This command will not work with negative IDs.
 
 -i, --id-file[=FILE]
 :   Read IDs from text file instead of from the command line. Use the special
-    name "-" to read from *stdin*. Each line of the file must start with an
+    name "-" to read from *STDIN*. Each line of the file must start with an
     ID in the format described above. Lines can optionally contain a space
     character or a hash sign ('#') after the ID. This character and all
     following characters are ignored. (This allows files in OPL format to be
@@ -122,7 +122,7 @@ IDs it needs in main memory.
 
 # EXAMPLES
 
-Output nodes 17 and 1234, way 42, and relation 111 to *stdout* in OPL format:
+Output nodes 17 and 1234, way 42, and relation 111 to STDOUT in OPL format:
 
     osmium getid -f opl planet.osm.pbf n1234 w42 n17 r111
 
diff --git a/man/osmium-show.md b/man/osmium-show.md
index 4ac8b40..c1c37dd 100644
--- a/man/osmium-show.md
+++ b/man/osmium-show.md
@@ -11,7 +11,7 @@ osmium-show - show OSM file
 
 # DESCRIPTION
 
-Show the contents of the *OSM-FILE* on *stdout*, usually in a pager. The
+Show the contents of the *OSM-FILE* on STDOUT, usually in a pager. The
 output format can be set using the **-f**, **output-format** option, its
 shortcuts **-d** (debug format with colors), **-o** (OPL), or **-x** (XML),
 or the `OSMIUM_SHOW_FORMAT` environment variable.
diff --git a/man/osmium.md b/man/osmium.md
index d724baa..b6754e4 100644
--- a/man/osmium.md
+++ b/man/osmium.md
@@ -109,12 +109,14 @@ If an osmium command exits with an "Out of memory" error, try running it with
 
 # SEE ALSO
 
-* **osmium-apply-changes**(1),
+* **osmium-add-locations-to-ways**(1),
+  **osmium-apply-changes**(1),
   **osmium-cat**(1),
   **osmium-changeset-filter**(1),
   **osmium-check-refs**(1),
   **osmium-derive-changes**(1),
   **osmium-diff**(1),
+  **osmium-extract**(1),
   **osmium-fileinfo**(1),
   **osmium-getid**(1),
   **osmium-merge**(1),
diff --git a/man/output-options.md b/man/output-options.md
index c6100a3..6df5a54 100644
--- a/man/output-options.md
+++ b/man/output-options.md
@@ -15,7 +15,7 @@
     version of osmium.
 
 -o, --output=FILE
-:   Name of the output file. Default is '-' (*stdout*).
+:   Name of the output file. Default is '-' (STDOUT).
 
 -O, --overwrite
 :   Allow an existing output file to be overwritten. Normally **osmium** will
diff --git a/src/cmd.hpp b/src/cmd.hpp
index 5548df3..2da27a3 100644
--- a/src/cmd.hpp
+++ b/src/cmd.hpp
@@ -132,7 +132,7 @@ class with_single_osm_input {
 
 protected:
 
-    std::string m_input_filename = "-"; // default: stdin
+    std::string m_input_filename;
     std::string m_input_format;
     osmium::io::File m_input_file;
 
@@ -160,7 +160,7 @@ protected:
 
 public:
 
-    void setup_input_files(const boost::program_options::variables_map& vm, bool optional = false);
+    void setup_input_files(const boost::program_options::variables_map& vm);
 
     po::options_description add_multiple_inputs_options();
 
@@ -178,7 +178,7 @@ protected:
 
     std::string m_generator;
     std::vector<std::string> m_output_headers;
-    std::string m_output_filename = "-"; // default: stdout
+    std::string m_output_filename;
     std::string m_output_format;
     osmium::io::File m_output_file;
     osmium::io::overwrite m_output_overwrite = osmium::io::overwrite::no;
@@ -256,4 +256,6 @@ public:
 
 }; // class CommandFactory
 
+void register_commands();
+
 #endif // CMD_HPP
diff --git a/src/command_add_locations_to_ways.cpp b/src/command_add_locations_to_ways.cpp
index 4e8be62..86b8f51 100644
--- a/src/command_add_locations_to_ways.cpp
+++ b/src/command_add_locations_to_ways.cpp
@@ -187,11 +187,3 @@ bool CommandAddLocationsToWays::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_add_locations_to_ways_command = CommandFactory::add("add-locations-to-ways", "Add node locations to ways", []() {
-        return new CommandAddLocationsToWays();
-    });
-
-}
-
diff --git a/src/command_add_locations_to_ways.hpp b/src/command_add_locations_to_ways.hpp
index f3033c6..ff54c11 100644
--- a/src/command_add_locations_to_ways.hpp
+++ b/src/command_add_locations_to_ways.hpp
@@ -32,11 +32,14 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #include <osmium/index/map/sparse_mmap_array.hpp> // IWYU pragma: keep
 #include <osmium/handler/node_locations_for_ways.hpp>
 
-namespace osmium { namespace io {
-    class Header;
-    class Reader;
-    class Writer;
-}}
+namespace osmium {
+    namespace io {
+        class Header;
+        class Reader;
+        class Writer;
+    }
+    class ProgressBar;
+}
 
 #include "cmd.hpp" // IWYU pragma: export
 
diff --git a/src/command_apply_changes.cpp b/src/command_apply_changes.cpp
index 5afe39c..701e883 100644
--- a/src/command_apply_changes.cpp
+++ b/src/command_apply_changes.cpp
@@ -85,6 +85,8 @@ bool CommandApplyChanges::setup(const std::vector<std::string>& arguments) {
 
     if (vm.count("change-filenames")) {
         m_change_filenames = vm["change-filenames"].as<std::vector<std::string>>();
+    } else {
+        throw argument_error{"Need data file and at least one change file on the command line."};
     }
 
     if (vm.count("with-history")) {
@@ -223,11 +225,3 @@ bool CommandApplyChanges::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_apply_changes_command = CommandFactory::add("apply-changes", "Apply OSM change files to OSM data file", []() {
-        return new CommandApplyChanges();
-    });
-
-}
-
diff --git a/src/command_cat.cpp b/src/command_cat.cpp
index 94125e4..bb2e3b3 100644
--- a/src/command_cat.cpp
+++ b/src/command_cat.cpp
@@ -126,11 +126,3 @@ bool CommandCat::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_cat_command = CommandFactory::add("cat", "Concatenate OSM files and convert to different formats", []() {
-        return new CommandCat();
-    });
-
-}
-
diff --git a/src/command_changeset_filter.cpp b/src/command_changeset_filter.cpp
index 06bc9bc..199e7d2 100644
--- a/src/command_changeset_filter.cpp
+++ b/src/command_changeset_filter.cpp
@@ -246,11 +246,3 @@ bool CommandChangesetFilter::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_changeset_filter_command = CommandFactory::add("changeset-filter", "Filter OSM changesets by different criteria", []() {
-        return new CommandChangesetFilter();
-    });
-
-}
-
diff --git a/src/command_check_refs.cpp b/src/command_check_refs.cpp
index 8fc8838..92f62e4 100644
--- a/src/command_check_refs.cpp
+++ b/src/command_check_refs.cpp
@@ -295,11 +295,3 @@ bool CommandCheckRefs::run() {
     return handler.no_errors();
 }
 
-namespace {
-
-    const bool register_check_refs_command = CommandFactory::add("check-refs", "Check referential integrity of an OSM file", []() {
-        return new CommandCheckRefs();
-    });
-
-}
-
diff --git a/src/command_derive_changes.cpp b/src/command_derive_changes.cpp
index 9aab407..e4b58df 100644
--- a/src/command_derive_changes.cpp
+++ b/src/command_derive_changes.cpp
@@ -148,16 +148,16 @@ bool CommandDeriveChanges::run() {
     osmium::io::Header header;
     setup_header(header);
 
-    osmium::io::Writer writer{m_output_file, header};
+    osmium::io::Writer writer{m_output_file, header, m_output_overwrite, m_fsync};
 
     m_vout << "Deriving changes...\n";
     while (it1 != end1 || it2 != end2) {
-        if (it1 == end1 || *it2 < *it1) {
-            writer(*it2);
-            ++it2;
-        } else if (it2 == end2) {
+        if (it2 == end2) {
             write_deleted(writer, *it1);
             ++it1;
+        } else if (it1 == end1 || *it2 < *it1) {
+            writer(*it2);
+            ++it2;
         } else if (*it1 < *it2) {
             if (it2->id() != it1->id()) {
                 write_deleted(writer, *it1);
@@ -179,11 +179,3 @@ bool CommandDeriveChanges::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_derive_changes_command = CommandFactory::add("derive-changes", "Create OSM change files from two OSM data files", []() {
-        return new CommandDeriveChanges();
-    });
-
-}
-
diff --git a/src/command_diff.cpp b/src/command_diff.cpp
index 3920b83..ea488cb 100644
--- a/src/command_diff.cpp
+++ b/src/command_diff.cpp
@@ -331,11 +331,3 @@ bool CommandDiff::run() {
     return count_left == 0 && count_right == 0 && count_different == 0;
 }
 
-namespace {
-
-    const bool register_diff_command = CommandFactory::add("diff", "Display differences between OSM files", []() {
-        return new CommandDiff();
-    });
-
-}
-
diff --git a/src/command_extract.cpp b/src/command_extract.cpp
index b7170aa..6d51212 100644
--- a/src/command_extract.cpp
+++ b/src/command_extract.cpp
@@ -476,11 +476,3 @@ bool CommandExtract::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_extract_command = CommandFactory::add("extract", "Create geographic extract", []() {
-        return new CommandExtract();
-    });
-
-}
-
diff --git a/src/command_fileinfo.cpp b/src/command_fileinfo.cpp
index 3c6aae4..70734c4 100644
--- a/src/command_fileinfo.cpp
+++ b/src/command_fileinfo.cpp
@@ -635,11 +635,3 @@ bool CommandFileinfo::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_fileinfo_command = CommandFactory::add("fileinfo", "Show information about OSM file", []() {
-        return new CommandFileinfo();
-    });
-
-}
-
diff --git a/src/command_getid.cpp b/src/command_getid.cpp
index 68671fd..1c47b34 100644
--- a/src/command_getid.cpp
+++ b/src/command_getid.cpp
@@ -423,11 +423,3 @@ bool CommandGetId::run() {
     return m_work_with_history || no_ids();
 }
 
-namespace {
-
-    const bool register_get_id_command = CommandFactory::add("getid", "Get objects with given ID from OSM file", []() {
-        return new CommandGetId();
-    });
-
-}
-
diff --git a/src/command_help.cpp b/src/command_help.cpp
index 08255bb..58cfc74 100644
--- a/src/command_help.cpp
+++ b/src/command_help.cpp
@@ -88,11 +88,3 @@ bool CommandHelp::run() {
     return false;
 }
 
-namespace {
-
-    const bool register_help_command = CommandFactory::add("help", "Show osmium help", []() {
-        return new CommandHelp();
-    });
-
-}
-
diff --git a/src/command_merge.cpp b/src/command_merge.cpp
index b516e42..7da7193 100644
--- a/src/command_merge.cpp
+++ b/src/command_merge.cpp
@@ -215,11 +215,3 @@ bool CommandMerge::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_merge_command = CommandFactory::add("merge", "Merge several sorted OSM files into one", []() {
-        return new CommandMerge();
-    });
-
-}
-
diff --git a/src/command_merge_changes.cpp b/src/command_merge_changes.cpp
index 65c10b0..73938b8 100644
--- a/src/command_merge_changes.cpp
+++ b/src/command_merge_changes.cpp
@@ -140,11 +140,3 @@ bool CommandMergeChanges::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_merge_changes_command = CommandFactory::add("merge-changes", "Merge several OSM change files into one", []() {
-        return new CommandMergeChanges();
-    });
-
-}
-
diff --git a/src/command_renumber.cpp b/src/command_renumber.cpp
index 85797d1..aa5a527 100644
--- a/src/command_renumber.cpp
+++ b/src/command_renumber.cpp
@@ -330,11 +330,3 @@ bool CommandRenumber::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_renumber_command = CommandFactory::add("renumber", "Renumber IDs in OSM file", []() {
-        return new CommandRenumber();
-    });
-
-}
-
diff --git a/src/command_show.cpp b/src/command_show.cpp
index 9034ecf..5bb18d5 100644
--- a/src/command_show.cpp
+++ b/src/command_show.cpp
@@ -217,11 +217,3 @@ bool CommandShow::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_show_command = CommandFactory::add("show", "Show OSM file contents", []() {
-        return new CommandShow();
-    });
-
-}
-
diff --git a/src/command_sort.cpp b/src/command_sort.cpp
index 6141504..6f87520 100644
--- a/src/command_sort.cpp
+++ b/src/command_sort.cpp
@@ -122,11 +122,3 @@ bool CommandSort::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_sort_command = CommandFactory::add("sort", "Sort OSM data files", []() {
-        return new CommandSort();
-    });
-
-}
-
diff --git a/src/command_time_filter.cpp b/src/command_time_filter.cpp
index 19b44ea..971978b 100644
--- a/src/command_time_filter.cpp
+++ b/src/command_time_filter.cpp
@@ -167,11 +167,3 @@ bool CommandTimeFilter::run() {
     return true;
 }
 
-namespace {
-
-    const bool register_time_filter_command = CommandFactory::add("time-filter", "Filter OSM data from a point in time or a time span out of a history file", []() {
-        return new CommandTimeFilter();
-    });
-
-}
-
diff --git a/src/commands.cpp b/src/commands.cpp
new file mode 100644
index 0000000..0bc9db6
--- /dev/null
+++ b/src/commands.cpp
@@ -0,0 +1,88 @@
+
+#include "command_add_locations_to_ways.hpp"
+#include "command_apply_changes.hpp"
+#include "command_cat.hpp"
+#include "command_changeset_filter.hpp"
+#include "command_check_refs.hpp"
+#include "command_derive_changes.hpp"
+#include "command_diff.hpp"
+#include "command_extract.hpp"
+#include "command_fileinfo.hpp"
+#include "command_getid.hpp"
+#include "command_help.hpp"
+#include "command_merge_changes.hpp"
+#include "command_merge.hpp"
+#include "command_renumber.hpp"
+#include "command_show.hpp"
+#include "command_sort.hpp"
+#include "command_time_filter.hpp"
+
+void register_commands() {
+    CommandFactory::add("add-locations-to-ways", "Add node locations to ways", []() {
+        return new CommandAddLocationsToWays();
+    });
+
+    CommandFactory::add("apply-changes", "Apply OSM change files to OSM data file", []() {
+        return new CommandApplyChanges();
+    });
+
+    CommandFactory::add("cat", "Concatenate OSM files and convert to different formats", []() {
+        return new CommandCat();
+    });
+
+    CommandFactory::add("changeset-filter", "Filter OSM changesets by different criteria", []() {
+        return new CommandChangesetFilter();
+    });
+
+    CommandFactory::add("check-refs", "Check referential integrity of an OSM file", []() {
+        return new CommandCheckRefs();
+    });
+
+    CommandFactory::add("derive-changes", "Create OSM change files from two OSM data files", []() {
+        return new CommandDeriveChanges();
+    });
+
+    CommandFactory::add("diff", "Display differences between OSM files", []() {
+        return new CommandDiff();
+    });
+
+    CommandFactory::add("extract", "Create geographic extract", []() {
+        return new CommandExtract();
+    });
+
+    CommandFactory::add("fileinfo", "Show information about OSM file", []() {
+        return new CommandFileinfo();
+    });
+
+    CommandFactory::add("getid", "Get objects with given ID from OSM file", []() {
+        return new CommandGetId();
+    });
+
+    CommandFactory::add("help", "Show osmium help", []() {
+        return new CommandHelp();
+    });
+
+    CommandFactory::add("merge-changes", "Merge several OSM change files into one", []() {
+        return new CommandMergeChanges();
+    });
+    CommandFactory::add("merge", "Merge several sorted OSM files into one", []() {
+        return new CommandMerge();
+    });
+
+    CommandFactory::add("renumber", "Renumber IDs in OSM file", []() {
+        return new CommandRenumber();
+    });
+
+    CommandFactory::add("show", "Show OSM file contents", []() {
+        return new CommandShow();
+    });
+
+    CommandFactory::add("sort", "Sort OSM data files", []() {
+        return new CommandSort();
+    });
+
+    CommandFactory::add("time-filter", "Filter OSM data from a point in time or a time span out of a history file", []() {
+        return new CommandTimeFilter();
+    });
+}
+
diff --git a/src/extract/extract_bbox.hpp b/src/extract/extract_bbox.hpp
index 30eee7d..4ccac21 100644
--- a/src/extract/extract_bbox.hpp
+++ b/src/extract/extract_bbox.hpp
@@ -40,4 +40,5 @@ public:
     std::string geometry_as_text() const override final;
 
 }; // class ExtractBBox
+
 #endif // EXTRACT_EXTRACT_BBOX_HPP
diff --git a/src/extract/geojson_file_parser.cpp b/src/extract/geojson_file_parser.cpp
index 7fed255..6a8d8e4 100644
--- a/src/extract/geojson_file_parser.cpp
+++ b/src/extract/geojson_file_parser.cpp
@@ -1,3 +1,24 @@
+/*
+
+Osmium -- OpenStreetMap data manipulation command line tool
+http://osmcode.org/osmium-tool/
+
+Copyright (C) 2013-2017  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
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+*/
 
 #include <cassert>
 #include <fstream>
diff --git a/src/extract/geojson_file_parser.hpp b/src/extract/geojson_file_parser.hpp
index 0a7c5e7..de06118 100644
--- a/src/extract/geojson_file_parser.hpp
+++ b/src/extract/geojson_file_parser.hpp
@@ -32,9 +32,9 @@ namespace osmium { namespace memory {
     class Buffer;
 }}
 
-extern std::string get_value_as_string(const rapidjson::Value& object, const char* key);
-extern std::size_t parse_polygon_array(const rapidjson::Value& value, osmium::memory::Buffer& buffer);
-extern std::size_t parse_multipolygon_array(const rapidjson::Value& value, osmium::memory::Buffer& buffer);
+std::string get_value_as_string(const rapidjson::Value& object, const char* key);
+std::size_t parse_polygon_array(const rapidjson::Value& value, osmium::memory::Buffer& buffer);
+std::size_t parse_multipolygon_array(const rapidjson::Value& value, osmium::memory::Buffer& buffer);
 
 /**
  * Gets areas from OSM files.
diff --git a/src/io.cpp b/src/io.cpp
index c9df0f1..7c2b4fe 100644
--- a/src/io.cpp
+++ b/src/io.cpp
@@ -47,11 +47,19 @@ void with_single_osm_input::setup_input_file(const boost::program_options::varia
         m_input_format = vm["input-format"].as<std::string>();
     }
 
-    if ((m_input_filename == "-" || m_input_filename == "") && m_input_format.empty()) {
-        throw argument_error{"When reading from STDIN you need to use the --input-format/-F option to declare the file format."};
+    if (m_input_format.empty()) {
+        if (m_input_filename == "-") {
+            throw argument_error{"When reading from STDIN you need to use the --input-format/-F option\n"
+                                 "to specify the file format."};
+        }
+
+        if (m_input_filename == "") {
+            throw argument_error{"Missing input file. Use '-' to read from STDIN and add the --input-format/-F\n"
+                                 "option to specify the file format or specify the input file name."};
+        }
     }
 
-    m_input_file = osmium::io::File(m_input_filename, m_input_format);
+    m_input_file = osmium::io::File{m_input_filename, m_input_format};
 }
 
 po::options_description with_single_osm_input::add_single_input_options() {
@@ -70,31 +78,34 @@ void with_single_osm_input::show_single_input_arguments(osmium::util::VerboseOut
     vout << "    file format: " << m_input_format << "\n";
 }
 
-void with_multiple_osm_inputs::setup_input_files(const boost::program_options::variables_map& vm, bool optional) {
+void with_multiple_osm_inputs::setup_input_files(const boost::program_options::variables_map& vm) {
     if (vm.count("input-filenames")) {
         m_input_filenames = vm["input-filenames"].as<std::vector<std::string>>();
-    } else if (!optional) {
+    } else {
         m_input_filenames.push_back("-"); // default is stdin
     }
 
+    bool uses_stdin = false;
+    for (auto& filename : m_input_filenames) {
+        if (filename == "-") {
+            if (uses_stdin) {
+                throw argument_error{"Can read at most one file from STDIN."};
+            }
+            uses_stdin = true;
+        }
+    }
+
     if (vm.count("input-format")) {
         m_input_format = vm["input-format"].as<std::string>();
     }
 
-    if (m_input_format.empty()) {
-        bool uses_stdin = false;
-        for (auto& filename : m_input_filenames) {
-            if (filename.empty() || filename == "-") {
-                uses_stdin = true;
-            }
-        }
-        if (uses_stdin) {
-            throw argument_error{"When reading from STDIN you need to use the --input-format/-F option to declare the file format."};
-        }
+    if (uses_stdin && m_input_format.empty()) {
+        throw argument_error{"When reading from STDIN you need to use the --input-format/-F option\n"
+                             "to specify the file format. Or are you missing a file name argument?"};
     }
 
     for (const std::string& input_filename : m_input_filenames) {
-        osmium::io::File input_file(input_filename, m_input_format);
+        osmium::io::File input_file{input_filename, m_input_format};
         m_input_files.push_back(input_file);
     }
 }
@@ -146,12 +157,18 @@ void with_osm_output::init_output_file(const po::variables_map& vm) {
 }
 
 void with_osm_output::check_output_file() {
-    if ((m_output_filename == "-" || m_output_filename == "") && m_output_format.empty()) {
-        throw argument_error{"When writing to STDOUT you need to use the --output-format/-f option\n"
-                             "to declare the file format. Or did you miss the --output/-O option?"};
+    if (m_output_format.empty()) {
+        if (m_output_filename == "-") {
+            throw argument_error{"When writing to STDOUT you need to use the --output-format/-f\n"
+                                 "option to specify the file format."};
+        }
+        if (m_output_filename == "") {
+            throw argument_error{"Missing output file. Set the output file with --output/-o and/or\n"
+                                 "add the --input-format/-F option to specify the file format."};
+        }
     }
 
-    m_output_file = osmium::io::File(m_output_filename, m_output_format);
+    m_output_file = osmium::io::File{m_output_filename, m_output_format};
     m_output_file.check();
 }
 
diff --git a/src/main.cpp b/src/main.cpp
index deb30ba..47afd27 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -50,6 +50,8 @@ int main(int argc, char *argv[]) {
     _setmode(1, _O_BINARY);
 #endif
 
+    register_commands();
+
     std::string command = argv[0];
 
     // remove path from command

-- 
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