[libosmium] 04/07: Imported Upstream version 2.11.3

Bas Couwenberg sebastic at debian.org
Wed May 3 17:00:15 UTC 2017


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

sebastic pushed a commit to branch master
in repository libosmium.

commit 71a1169050d4424972a219eabeba42cf514df6a7
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Wed May 3 18:39:35 2017 +0200

    Imported Upstream version 2.11.3
---
 CHANGELOG.md                                  | 14 +++++++++++++-
 CMakeLists.txt                                |  2 +-
 include/osmium/area/assembler.hpp             | 24 +++++++++++++-----------
 include/osmium/io/detail/opl_input_format.hpp |  5 +++++
 include/osmium/version.hpp                    |  4 ++--
 test/CMakeLists.txt                           |  2 +-
 test/t/io/data-nonl.opl                       |  1 +
 test/t/io/data.opl                            |  1 +
 test/t/io/test_opl_parser.cpp                 | 22 ++++++++++++++++++++++
 9 files changed, 59 insertions(+), 16 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 250ec2e..cc1fdcc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 
 ### Fixed
 
+## [2.11.3] - 2017-05-03
+
+### Fixed
+
+- Two bugs in area assembler affecting very complex multipolygons and
+  multipolygons with overlapping or nearly overlapping lines.
+- Invalid use of iterators leading to undefined behaviour in area assembler
+  code.
+- Read OPL file correctly even if trailing newline in file is missing.
+
+
 ## [2.11.2] - 2017-04-10
 
 ### Fixed
@@ -538,7 +549,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
   Doxygen (up to version 1.8.8). This version contains a workaround to fix
   this.
 
-[unreleased]: https://github.com/osmcode/libosmium/compare/v2.11.2...HEAD
+[unreleased]: https://github.com/osmcode/libosmium/compare/v2.11.3...HEAD
+[2.11.3]: https://github.com/osmcode/libosmium/compare/v2.11.2...v2.11.3
 [2.11.2]: https://github.com/osmcode/libosmium/compare/v2.11.1...v2.11.2
 [2.11.1]: https://github.com/osmcode/libosmium/compare/v2.11.0...v2.11.1
 [2.11.0]: https://github.com/osmcode/libosmium/compare/v2.10.3...v2.11.0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b823d74..e536c34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ project(libosmium)
 
 set(LIBOSMIUM_VERSION_MAJOR 2)
 set(LIBOSMIUM_VERSION_MINOR 11)
-set(LIBOSMIUM_VERSION_PATCH 2)
+set(LIBOSMIUM_VERSION_PATCH 3)
 
 set(LIBOSMIUM_VERSION
     "${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH}")
diff --git a/include/osmium/area/assembler.hpp b/include/osmium/area/assembler.hpp
index 3509b57..78a9d09 100644
--- a/include/osmium/area/assembler.hpp
+++ b/include/osmium/area/assembler.hpp
@@ -474,17 +474,17 @@ namespace osmium {
 
             class rings_stack_element {
 
-                int32_t m_y;
+                double m_y;
                 detail::ProtoRing* m_ring_ptr;
 
             public:
 
-                rings_stack_element(int32_t y, detail::ProtoRing* ring_ptr) :
+                rings_stack_element(double y, detail::ProtoRing* ring_ptr) :
                     m_y(y),
                     m_ring_ptr(ring_ptr) {
                 }
 
-                int32_t y() const noexcept {
+                double y() const noexcept {
                     return m_y;
                 }
 
@@ -504,7 +504,7 @@ namespace osmium {
                     return m_y < rhs.m_y;
                 }
 
-            }; // class ring_stack_element
+            }; // class rings_stack_element
 
             using rings_stack = std::vector<rings_stack_element>;
 
@@ -592,7 +592,7 @@ namespace osmium {
                                 if (debug()) {
                                     std::cerr << "        Segment belongs to outer ring\n";
                                 }
-                                const int32_t y = int32_t(ay + (by - ay) * (lx - ax) / (bx - ax));
+                                const double y = ay + (by - ay) * (lx - ax) / double(bx - ax);
                                 outer_rings.emplace_back(y, segment->ring());
                             }
                         }
@@ -859,8 +859,8 @@ namespace osmium {
             }
 
             void merge_two_rings(open_ring_its_type& open_ring_its, const location_to_ring_map& m1, const location_to_ring_map& m2) {
-                auto& r1 = *m1.ring_it;
-                auto& r2 = *m2.ring_it;
+                std::list<detail::ProtoRing>::iterator r1 = *m1.ring_it;
+                std::list<detail::ProtoRing>::iterator r2 = *m2.ring_it;
 
                 if (r1->get_node_ref_stop().location() == r2->get_node_ref_start().location()) {
                     r1->join_forward(*r2);
@@ -876,11 +876,11 @@ namespace osmium {
                     assert(false);
                 }
 
+                open_ring_its.erase(std::find(open_ring_its.begin(), open_ring_its.end(), r2));
                 m_rings.erase(r2);
-                open_ring_its.remove(r2);
 
                 if (r1->closed()) {
-                    open_ring_its.remove(r1);
+                    open_ring_its.erase(std::find(open_ring_its.begin(), open_ring_its.end(), r1));
                 }
             }
 
@@ -988,6 +988,7 @@ namespace osmium {
                             }
                             loc_done.insert(c.stop_location);
                             find_candidates(candidates, loc_done, xrings, c);
+                            loc_done.erase(c.stop_location);
                             if (debug()) {
                                 std::cerr << "          ...back\n";
                             }
@@ -1085,12 +1086,13 @@ namespace osmium {
                 // Join all (open) rings in the candidate to get one closed ring.
                 assert(chosen_cand->rings.size() > 1);
                 const auto& first_ring = chosen_cand->rings.front().first;
-                for (auto it = chosen_cand->rings.begin() + 1; it != chosen_cand->rings.end(); ++it) {
+                const detail::ProtoRing& remaining_ring = first_ring.ring();
+                for (auto it = std::next(chosen_cand->rings.begin()); it != chosen_cand->rings.end(); ++it) {
                     merge_two_rings(open_ring_its, first_ring, it->first);
                 }
 
                 if (debug()) {
-                    std::cerr << "    Merged to " << first_ring.ring() << "\n";
+                    std::cerr << "    Merged to " << remaining_ring << "\n";
                 }
 
                 return true;
diff --git a/include/osmium/io/detail/opl_input_format.hpp b/include/osmium/io/detail/opl_input_format.hpp
index 135f1a5..62598f7 100644
--- a/include/osmium/io/detail/opl_input_format.hpp
+++ b/include/osmium/io/detail/opl_input_format.hpp
@@ -123,6 +123,11 @@ namespace osmium {
                         rest = input.substr(ppos);
                     }
 
+                    if (!rest.empty()) {
+                        m_data = rest.data();
+                        parse_line();
+                    }
+
                     if (m_buffer.committed() > 0) {
                         send_to_output_queue(std::move(m_buffer));
                     }
diff --git a/include/osmium/version.hpp b/include/osmium/version.hpp
index 56b7e94..a36a4d9 100644
--- a/include/osmium/version.hpp
+++ b/include/osmium/version.hpp
@@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
 
 #define LIBOSMIUM_VERSION_MAJOR 2
 #define LIBOSMIUM_VERSION_MINOR 11
-#define LIBOSMIUM_VERSION_PATCH 2
+#define LIBOSMIUM_VERSION_PATCH 3
 
-#define LIBOSMIUM_VERSION_STRING "2.11.2"
+#define LIBOSMIUM_VERSION_STRING "2.11.3"
 
 #endif // OSMIUM_VERSION_HPP
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 61376e7..68f8887 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -170,7 +170,7 @@ add_unit_test(io test_reader LIBS "${OSMIUM_XML_LIBRARIES};${OSMIUM_PBF_LIBRARIE
 add_unit_test(io test_reader_fileformat ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
 add_unit_test(io test_reader_with_mock_decompression ENABLE_IF ${Threads_FOUND} LIBS ${OSMIUM_XML_LIBRARIES})
 add_unit_test(io test_reader_with_mock_parser ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
-add_unit_test(io test_opl_parser)
+add_unit_test(io test_opl_parser ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
 add_unit_test(io test_output_utils)
 add_unit_test(io test_output_iterator ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
 add_unit_test(io test_string_table)
diff --git a/test/t/io/data-nonl.opl b/test/t/io/data-nonl.opl
new file mode 100644
index 0000000..db23544
--- /dev/null
+++ b/test/t/io/data-nonl.opl
@@ -0,0 +1 @@
+n1 v1 dV c1 t2014-01-01T00:00:00Z i1 utest T x1.02 y1.02
\ No newline at end of file
diff --git a/test/t/io/data.opl b/test/t/io/data.opl
new file mode 100644
index 0000000..2c7e2a3
--- /dev/null
+++ b/test/t/io/data.opl
@@ -0,0 +1 @@
+n1 v1 dV c1 t2014-01-01T00:00:00Z i1 utest T x1.02 y1.02
diff --git a/test/t/io/test_opl_parser.cpp b/test/t/io/test_opl_parser.cpp
index 9ad6eeb..dad2238 100644
--- a/test/t/io/test_opl_parser.cpp
+++ b/test/t/io/test_opl_parser.cpp
@@ -3,8 +3,10 @@
 #include <cstring>
 
 #include "catch.hpp"
+#include "utils.hpp"
 
 #include <osmium/io/detail/opl_input_format.hpp>
+#include <osmium/io/opl_input.hpp>
 #include <osmium/opl.hpp>
 
 namespace oid = osmium::io::detail;
@@ -1073,3 +1075,23 @@ TEST_CASE("Parse line with external interface") {
 
 }
 
+TEST_CASE("Parse OPL using Reader") {
+    osmium::io::File file{with_data_dir("t/io/data.opl")};
+    osmium::io::Reader reader{file};
+
+    const auto buffer = reader.read();
+    REQUIRE(buffer);
+    const auto& node = buffer.get<osmium::Node>(0);
+    REQUIRE(node.id() == 1);
+}
+
+TEST_CASE("Parse OPL with missing newline using Reader") {
+    osmium::io::File file{with_data_dir("t/io/data-nonl.opl")};
+    osmium::io::Reader reader{file};
+
+    const auto buffer = reader.read();
+    REQUIRE(buffer);
+    const auto& node = buffer.get<osmium::Node>(0);
+    REQUIRE(node.id() == 1);
+}
+

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



More information about the Pkg-grass-devel mailing list