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 ad49155a5d80b5037b0f8757bd341450038298b7
Author: Jochen Topf <joc...@topf.org>
Date:   Wed Dec 17 10:50:03 2014 +0100

    Detect if objects in OSM file are ordered and if there are mulitple 
versions.
---
 doc/osmium-fileinfo.md   |  7 +++++--
 src/command_fileinfo.cpp | 26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/doc/osmium-fileinfo.md b/doc/osmium-fileinfo.md
index d5a09fc..1eabfaf 100644
--- a/doc/osmium-fileinfo.md
+++ b/doc/osmium-fileinfo.md
@@ -37,8 +37,11 @@ Data
     file. It is only shown if the **--extended** option was used. It
     shows the actual bounding box calculated from the nodes in the file,
     the first and last timestamp of all objects in the file, a SHA1
-    checksum of the data in the file and the number of changesets,
-    nodes, ways, and relations found in the file.
+    checksum of the data in the file, the number of changesets, nodes,
+    ways, and relations found in the file, whether the objects in the
+    file were ordered by type (nodes, then ways, then relations) and
+    id, and whether there were multiple versions of the same object in
+    the file (history files and change files can have that).
 
 
 # OPTIONS
diff --git a/src/command_fileinfo.cpp b/src/command_fileinfo.cpp
index f1e1c42..5edc1df 100644
--- a/src/command_fileinfo.cpp
+++ b/src/command_fileinfo.cpp
@@ -107,6 +107,11 @@ struct InfoHandler : public osmium::handler::Handler {
     osmium::Timestamp last_timestamp = osmium::start_of_time();
     CryptoPP::SHA hash;
 
+    bool ordered = true;
+    bool multiple_versions = false;
+    osmium::item_type last_type = osmium::item_type::undefined;
+    osmium::object_id_type last_id = 0;
+
     void changeset(const osmium::Changeset& changeset) {
         hash.Update(changeset.data(), changeset.byte_size());
         ++changesets;
@@ -119,6 +124,20 @@ struct InfoHandler : public osmium::handler::Handler {
         if (object.timestamp() > last_timestamp) {
             last_timestamp = object.timestamp();
         }
+
+        if (last_type == object.type()) {
+            if (last_id == object.id()) {
+                multiple_versions = true;
+            }
+            if (last_id > object.id()) {
+                ordered = false;
+            }
+        } else if (last_type > object.type()) {
+            ordered = false;
+        }
+
+        last_type = object.type();
+        last_id = object.id();
     }
 
     void node(const osmium::Node& node) {
@@ -187,6 +206,13 @@ bool CommandFileinfo::run() {
                 std::cout << "  Last timestamp: " << 
info_handler.last_timestamp << "\n";
             }
 
+            std::cout << "  Objects ordered (by type and id): " << 
(info_handler.ordered ? "yes\n" : "no\n");
+
+            std::cout << "  Multiple versions of same object: " << 
(info_handler.multiple_versions ? "yes\n" : "no\n");
+            if (info_handler.multiple_versions != 
header.has_multiple_object_versions()) {
+                std::cout << "    WARNING! This is different from the setting 
in the header.\n";
+            }
+
             unsigned char digest[CryptoPP::SHA::DIGESTSIZE];
             info_handler.hash.Final(digest);
             std::cout << "  SHA: " << std::hex;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-grass/osmium-tool.git

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to