[Git][debian-gis-team/osmium-tool][master] 5 commits: New upstream version 1.16.0

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Wed Sep 20 18:09:24 BST 2023



Bas Couwenberg pushed to branch master at Debian GIS Project / osmium-tool


Commits:
8df22d30 by Bas Couwenberg at 2023-09-20T18:59:06+02:00
New upstream version 1.16.0
- - - - -
e1e1207a by Bas Couwenberg at 2023-09-20T18:59:09+02:00
Update upstream source from tag 'upstream/1.16.0'

Update to upstream version '1.16.0'
with Debian dir 1201d444b78ea2e2358180aa724ec0e6ffa56c23
- - - - -
b89b1b82 by Bas Couwenberg at 2023-09-20T18:59:30+02:00
New upstream release.

- - - - -
cc74e2b8 by Bas Couwenberg at 2023-09-20T19:05:34+02:00
Update lintian overrides.

- - - - -
873781c9 by Bas Couwenberg at 2023-09-20T19:05:34+02:00
Set distribution to unstable.

- - - - -


11 changed files:

- .github/workflows/ci.yml
- CHANGELOG.md
- CMakeLists.txt
- debian/changelog
- debian/osmium-tool.lintian-overrides
- man/osmium-extract.md
- src/command_export.cpp
- src/command_extract.cpp
- src/extract/extract_polygon.cpp
- src/extract/strategy_smart.cpp
- src/extract/strategy_smart.hpp


Changes:

=====================================
.github/workflows/ci.yml
=====================================
@@ -12,14 +12,16 @@ jobs:
         image:
           - "ubuntu:18.04"        # gcc  7.5.0, clang  6.0.0, cmake 3.10.2
           - "ubuntu:20.04"        # gcc  9.3.0, clang 10.0.0, cmake 3.16.3
-          - "ubuntu:22.04"        # gcc 11.2.0, clang 14.0.0, cmake 3.22.1
-          - "debian:stretch"      # gcc  6.3.0, clang  3.8.1, cmake 3.7.2
+          - "ubuntu:22.04"        # gcc 12.2.0, clang 15.0.7, cmake 3.24.2
           - "debian:buster"       # gcc  8.3.0, clang  7.0.1, cmake 3.13.4
           - "debian:bullseye"     # gcc 10.2.1, clang 11.0.1, cmake 3.18.4
+          - "debian:bookworm"     # gcc 12.2.0, clang 15.0.6, cmake 3.25.1
           - "debian:testing"
           - "debian:experimental"
           - "fedora:35"           # gcc 11.2.1, clang 13.0.0, cmake 3.22.0
-          - "fedora:36"           # gcc 12.2.0, clang 14.0.5, cmake 3.24.2
+          - "fedora:36"           # gcc 12.2.1, clang 14.0.5, cmake 3.26.3
+          - "fedora:37"           # gcc 12.3.1, clang 15.0.7, cmake 3.26.4
+          - "fedora:38"           # gcc 13.0.1, clang 16.0.5, cmake 3.26.4
         build_type: [Dev]
         cpp_compiler: [g++]
         cpp_version: [c++14]
@@ -28,6 +30,9 @@ jobs:
             cpp_version: c++17
           - image: "debian:bullseye"
             cpp_version: c++20
+          - image: "debian:bullseye"
+            c_compiler: clang
+            cpp_compiler: clang++
           - image: "debian:bullseye"
             c_compiler: clang
             cpp_compiler: clang++
@@ -38,9 +43,28 @@ jobs:
             cpp_version: c++20
           - image: "debian:bullseye"
             build_type: RelWithDebInfo
-          - image: "debian:bullseye"
+          - image: "debian:bookworm"
+            CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
+          - image: "debian:bookworm"
+            cpp_version: c++17
+            CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
+          - image: "debian:bookworm"
+            cpp_version: c++20
+            CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
+          - image: "debian:bookworm"
+            c_compiler: clang
+            cpp_compiler: clang++
+          - image: "debian:bookworm"
             c_compiler: clang
             cpp_compiler: clang++
+            cpp_version: c++17
+          - image: "debian:bookworm"
+            c_compiler: clang
+            cpp_compiler: clang++
+            cpp_version: c++20
+          - image: "debian:bookworm"
+            build_type: RelWithDebInfo
+            CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
           - image: "debian:testing"
             CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
           - image: "debian:testing"
@@ -49,12 +73,16 @@ jobs:
           - image: "debian:experimental"
             CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
           - image: "debian:experimental"
-            c_compiler: clang-14
-            cpp_compiler: clang++-14
+            c_compiler: clang
+            cpp_compiler: clang++
           - image: "fedora:35"
             CXXFLAGS: -Wno-stringop-overread
           - image: "fedora:36"
             CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
+          - image: "fedora:37"
+            CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
+          - image: "fedora:38"
+            CXXFLAGS: -Wno-stringop-overread -Wno-array-bounds
     container:
       image: ${{ matrix.image }}
       env:
@@ -138,9 +166,11 @@ jobs:
       matrix:
         os:
           - "macos-11"
+          - "macos-12"
+          - "macos-13"
         build_type: [Dev]
         include:
-          - os: "macos-11"
+          - os: "macos-12"
             build_type: Release
     runs-on: ${{ matrix.os }}
     env:


=====================================
CHANGELOG.md
=====================================
@@ -12,6 +12,24 @@ This project adheres to [Semantic Versioning](https://semver.org/).
 
 ### Fixed
 
+## [1.16.0] - 2023-09-20
+
+### Added
+
+- Add "tags" strategy option for smart extract strategy. This checks relations
+  for the specified keys/tags. For a relation to be completed it has to match
+  the keys/tags.
+
+### Changed
+
+- Limit the number of extracts possible with osmium extract to 500. Prevents
+  us from running out of file descriptors.
+
+### Fixed
+
+- Extract with a polygon could fail in some circumstances.
+- Compile problem on Windows due to our use of `GetObject()` function from
+  RapidJSON.
 
 ## [1.15.0] - 2023-01-19
 
@@ -693,7 +711,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
 - Minor updates to documentation and build system
 
 
-[unreleased]: https://github.com/osmcode/osmium-tool/compare/v1.15.0...HEAD
+[unreleased]: https://github.com/osmcode/osmium-tool/compare/v1.16.0...HEAD
+[1.16.0]: https://github.com/osmcode/osmium-tool/compare/v1.15.0...v1.16.0
 [1.15.0]: https://github.com/osmcode/osmium-tool/compare/v1.14.0...v1.15.0
 [1.14.0]: https://github.com/osmcode/osmium-tool/compare/v1.13.2...v1.14.0
 [1.13.2]: https://github.com/osmcode/osmium-tool/compare/v1.13.1...v1.13.2


=====================================
CMakeLists.txt
=====================================
@@ -8,7 +8,7 @@
 
 cmake_minimum_required(VERSION 3.5.0)
 
-project(osmium VERSION 1.15.0 LANGUAGES CXX C)
+project(osmium VERSION 1.16.0 LANGUAGES CXX C)
 
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
 


=====================================
debian/changelog
=====================================
@@ -1,11 +1,13 @@
-osmium-tool (1.15.0-2) UNRELEASED; urgency=medium
+osmium-tool (1.16.0-1) unstable; urgency=medium
 
+  * New upstream release.
   * Bump debhelper compat to 13.
   * Enable Salsa CI.
   * Add architecture-is-little-endian to build depends.
     https://github.com/osmcode/osmium-tool/issues/176
+  * Update lintian overrides.
 
- -- Bas Couwenberg <sebastic at debian.org>  Mon, 12 Jun 2023 18:14:00 +0200
+ -- Bas Couwenberg <sebastic at debian.org>  Wed, 20 Sep 2023 18:59:57 +0200
 
 osmium-tool (1.15.0-1) unstable; urgency=medium
 


=====================================
debian/osmium-tool.lintian-overrides
=====================================
@@ -1,3 +1,6 @@
 # False positive, lat/lon
 spelling-error-in-binary lon long *
 
+# False positive
+groff-message * warning: cannot select font *
+


=====================================
man/osmium-extract.md
=====================================
@@ -338,20 +338,31 @@ Strategy **smart**
 For the **complete_ways** strategy you can set the option "-S relations=false"
 in which case no relations will be written to the output file.
 
-For the **smart** strategy you can change the types of relations that should be
+The **smart** strategy allows the following strategy options:
+
+Use "-S types=TYPE,..." to change the types of relations that should be
 reference-complete. Instead of just relations tagged "type=multipolygon", you
 can either get all relations (use "-S types=any") or give a list of types to
 the -S option: "-S types=multipolygon,route". Note that especially boundary
 relations can be huge, so if you include them, be aware your result might be
 huge.
 
-The **smart** strategy allows another option "-S complete-partial-relations=X".
-If this is set, all relations that have more than X percent of their members
-already in the extract will have their full set of members in the extract. So
-this allows completing almost complete relations. It can be useful for instance
-to make sure a boundary relation is complete even if some of it is outside the
-polygon used for extraction.
+Use "-S complete-partial-relations=X" to force completion of partly completed
+relations. If this is set, all relations that have more than X percent of their
+members already in the extract will have their full set of members in the
+extract. So this allows completing almost complete relations. It can be useful
+for instance to make sure a boundary relation is complete even if some of it is
+outside the polygon used for extraction.
+
+Use "-S tags=PATTERN,..." to only complete relations that have a tag matching
+one of the PATTERNs. So for example if you use "-S
+tags=landuse,natural=wood,natural=water" everything tagged `landuse=*` or
+`natural=wood` or `natural=water` is added to the result, but no other
+relations.
 
+You can combine the "-S types", "-S complete-partial-relations", and "-S tags"
+options. The options will be interpreted as "(types OR
+complete-partial-relations) AND tags".
 
 # DIAGNOSTICS
 
@@ -380,6 +391,12 @@ steps. First create several larger extracts and then split them again and
 again into smaller pieces.
 
 
+# LIMITS
+
+You can not have more than 500 extracts. Although chances are that you will be
+running out of memory long before that. See MEMORY USAGE.
+
+
 # EXAMPLES
 
 See the example config files in the *extract-example-config* directory. To


=====================================
src/command_export.cpp
=====================================
@@ -95,9 +95,9 @@ void CommandExport::parse_format_options(const rapidjson::Value& options) {
     if (!options.IsObject()) {
         throw config_error{"'format_options' member must be an object."};
     }
-    for (const auto& kv : options.GetObject()) {
-        const auto type = kv.value.GetType();
-        const char* key = kv.name.GetString();
+    for (auto it = options.MemberBegin(); it != options.MemberEnd(); it++) {
+        const auto type = it->value.GetType();
+        const char* key = it->name.GetString();
         switch (type) {
             case rapidjson::kNullType:
                 m_options.format_options.set(key, false);
@@ -114,10 +114,10 @@ void CommandExport::parse_format_options(const rapidjson::Value& options) {
                 throw config_error{"Option value for key '" + std::string(key) + "' can not be an array."};
                 break;
             case rapidjson::kStringType:
-                m_options.format_options.set(key, kv.value.GetString());
+                m_options.format_options.set(key, it->value.GetString());
                 break;
             case rapidjson::kNumberType:
-                m_options.format_options.set(key, std::to_string(kv.value.GetInt64()));
+                m_options.format_options.set(key, std::to_string(it->value.GetInt64()));
                 break;
         }
     }


=====================================
src/command_extract.cpp
=====================================
@@ -72,6 +72,8 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # include <unistd.h>
 #endif
 
+static constexpr const std::size_t max_extracts = 500;
+
 static osmium::Box parse_bbox(const rapidjson::Value& value) {
     if (value.IsArray()) {
         if (value.Size() != 4) {
@@ -622,6 +624,10 @@ bool CommandExtract::run() {
         throw config_error{"No extract specified in config file or on the command line."};
     }
 
+    if (m_extracts.size() > max_extracts) {
+        throw config_error{"Too many extracts specified in config file (Maximum: " + std::to_string(max_extracts) + ")."};
+    }
+
     show_extracts();
 
     m_strategy = make_strategy(m_strategy_name);


=====================================
src/extract/extract_polygon.cpp
=====================================
@@ -81,7 +81,7 @@ ExtractPolygon::ExtractPolygon(const osmium::io::File& output_file, const std::s
 
     m_bands.resize(num_bands + 1);
 
-    m_dy = (y_max() - y_min()) / num_bands;
+    m_dy = (y_max() - y_min() + num_bands - 1) / num_bands;
 
     // put segments into the bands they overlap
     for (const auto& segment : segments) {


=====================================
src/extract/strategy_smart.cpp
=====================================
@@ -25,6 +25,7 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #include "../util.hpp"
 
 #include <osmium/handler/check_order.hpp>
+#include <osmium/tags/taglist.hpp>
 #include <osmium/util/misc.hpp>
 #include <osmium/util/string.hpp>
 
@@ -78,6 +79,19 @@ namespace strategy_smart {
                         m_complete_partial_relations_percentage = 100;
                     }
                 }
+            } else if (option.first == "tags") {
+                m_filter_tags = osmium::split_string(option.second, ',', true);
+                m_filter.set_default_result(false);
+                for (const auto &tag : m_filter_tags) {
+                    const auto pos = tag.find('=');
+                    if (pos == std::string::npos) {
+                        m_filter.add_rule(true, osmium::TagMatcher{tag});
+                    } else {
+                        const auto key = tag.substr(0, pos);
+                        const auto value = tag.substr(pos + 1);
+                        m_filter.add_rule(true, osmium::TagMatcher{key, value});
+                    }
+                }
             } else {
                 warning(std::string{"Ignoring unknown option '"} + option.first + "' for 'smart' strategy.\n");
             }
@@ -105,6 +119,10 @@ namespace strategy_smart {
         return it != m_types.end();
     }
 
+    bool Strategy::check_tags(const osmium::Relation& relation) const noexcept {
+        return osmium::tags::match_any_of(relation.tags(), m_filter);
+    }
+
     void Strategy::show_arguments(osmium::VerboseOutput& vout) {
         vout << "Additional strategy options:\n";
         if (m_types.empty()) {
@@ -124,6 +142,18 @@ namespace strategy_smart {
         } else {
             vout << "  - [complete-partial-relations] complete partial relations when " << m_complete_partial_relations_percentage << "% or more members are in extract\n";
         }
+        if (m_filter_tags.empty()) {
+            vout << "  - [tags] no tags defined\n";
+        } else {
+            std::string filterlist;
+            for (const auto& tag : m_filter_tags) {
+                if (!filterlist.empty()) {
+                    filterlist += ",";
+                }
+                filterlist += tag;
+            }
+            vout << "  - [tags] " << filterlist << '\n';
+        }
         vout << '\n';
     }
 
@@ -174,7 +204,7 @@ namespace strategy_smart {
                         if (e->node_ids.get(member.positive_ref())) {
                             if (wanted_members == 0) {
                                 e->relation_ids.set(relation.positive_id());
-                                if (strategy().check_type(relation)) {
+                                if (strategy().check_type(relation) && strategy().check_tags(relation)) {
                                     e->add_relation_members(relation);
                                     return;
                                 }
@@ -186,7 +216,7 @@ namespace strategy_smart {
                         if (e->way_ids.get(member.positive_ref())) {
                             if (wanted_members == 0) {
                                 e->relation_ids.set(relation.positive_id());
-                                if (strategy().check_type(relation)) {
+                                if (strategy().check_type(relation) && strategy().check_tags(relation)) {
                                     e->add_relation_members(relation);
                                     return;
                                 }
@@ -199,7 +229,7 @@ namespace strategy_smart {
                 }
             }
 
-            if (strategy().check_members_count(relation.members().size(), wanted_members)) {
+            if (strategy().check_members_count(relation.members().size(), wanted_members) && strategy().check_tags(relation)) {
                 e->add_relation_members(relation);
             }
         }


=====================================
src/extract/strategy_smart.hpp
=====================================
@@ -27,6 +27,7 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 #include <osmium/index/id_set.hpp>
 #include <osmium/index/relations_map.hpp>
+#include <osmium/tags/tags_filter.hpp>
 
 #include <memory>
 #include <string>
@@ -59,8 +60,12 @@ namespace strategy_smart {
 
         std::size_t m_complete_partial_relations_percentage = 100;
 
+        std::vector<std::string> m_filter_tags;
+        osmium::TagsFilter m_filter{true};
+
         bool check_members_count(const std::size_t size, const std::size_t wanted_members) const noexcept;
         bool check_type(const osmium::Relation& relation) const noexcept;
+        bool check_tags(const osmium::Relation& relation) const noexcept;
 
     public:
 



View it on GitLab: https://salsa.debian.org/debian-gis-team/osmium-tool/-/compare/0cae8bd71e3acd6198fb64b3529a468022e8820f...873781c99ad9d87d118041a4bf5dd0f232460c4c

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/osmium-tool/-/compare/0cae8bd71e3acd6198fb64b3529a468022e8820f...873781c99ad9d87d118041a4bf5dd0f232460c4c
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20230920/59f5ceeb/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list