diff --git a/contrib/libosmium/README.contrib b/contrib/libosmium/README.contrib index 810369d18..9f7e2eff7 100644 --- a/contrib/libosmium/README.contrib +++ b/contrib/libosmium/README.contrib @@ -1,2 +1,2 @@ Source: https://github.com/osmcode/libosmium -Revision: v2.19.0 +Revision: v2.20.0 diff --git a/contrib/libosmium/README.md b/contrib/libosmium/README.md index fbb4f62bb..4d73ed7a8 100644 --- a/contrib/libosmium/README.md +++ b/contrib/libosmium/README.md @@ -7,8 +7,6 @@ A fast and flexible C++ library for working with OpenStreetMap data. Libosmium works on Linux, macOS and Windows. [![Github Build Status](https://github.com/osmcode/libosmium/workflows/CI/badge.svg?branch=master)](https://github.com/osmcode/libosmium/actions) -[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/yy099a4vxcb604rn/branch/master?svg=true)](https://ci.appveyor.com/project/lonvia/libosmium-eq41p/branch/master) -[![Coverage Status](https://codecov.io/gh/osmcode/libosmium/branch/master/graph/badge.svg)](https://codecov.io/gh/osmcode/libosmium) [![Packaging status](https://repology.org/badge/tiny-repos/libosmium.svg)](https://repology.org/metapackage/libosmium) Please see the [Libosmium manual](https://osmcode.org/libosmium/manual.html) @@ -17,9 +15,8 @@ for more details than this README can provide. ## Prerequisites -Because Libosmium uses many C++11 features you need a modern compiler and -standard C++ library. Osmium needs at least GCC 4.8 or clang (LLVM) 3.4. -(Some parts may work with older versions.) +You need a C++11 compiler and standard C++ library. Osmium needs at least GCC +4.8 or clang (LLVM) 3.4. (Some parts may work with older versions.) Different parts of Libosmium (and the applications built on top of it) need different libraries. You DO NOT NEED to install all of them, just install those @@ -88,16 +85,9 @@ See the for instructions. -## Switching from the old Osmium - -If you have been using the old version of Osmium at -https://github.com/joto/osmium you might want to read about the [changes -needed](https://osmcode.org/libosmium/manual.html#changes-from-old-versions-of-osmium). - - ## License -Libosmium is available under the Boost Software License. See LICENSE.txt. +Libosmium is available under the Boost Software License. See LICENSE. ## Authors diff --git a/contrib/libosmium/include/osmium/area/detail/node_ref_segment.hpp b/contrib/libosmium/include/osmium/area/detail/node_ref_segment.hpp index 6ceb32450..8da4f8ccf 100644 --- a/contrib/libosmium/include/osmium/area/detail/node_ref_segment.hpp +++ b/contrib/libosmium/include/osmium/area/detail/node_ref_segment.hpp @@ -193,7 +193,7 @@ namespace osmium { const char* role_name() const noexcept { static const std::array names = {{"unknown", "outer", "inner", "empty"}}; - return names[int(m_role)]; + return names[static_cast(m_role)]; } const osmium::Way* way() const noexcept { @@ -327,9 +327,9 @@ namespace osmium { if ((d > 0 && na >= 0 && na <= d && nb >= 0 && nb <= d) || (d < 0 && na <= 0 && na >= d && nb <= 0 && nb >= d)) { - const double ua = double(na) / double(d); + const double ua = static_cast(na) / static_cast(d); const vec i = p0 + ua * (p1 - p0); - return osmium::Location{int32_t(i.x), int32_t(i.y)}; + return osmium::Location{static_cast(i.x), static_cast(i.y)}; } return osmium::Location{}; diff --git a/contrib/libosmium/include/osmium/area/detail/proto_ring.hpp b/contrib/libosmium/include/osmium/area/detail/proto_ring.hpp index d6b2b0820..9b773a0a9 100644 --- a/contrib/libosmium/include/osmium/area/detail/proto_ring.hpp +++ b/contrib/libosmium/include/osmium/area/detail/proto_ring.hpp @@ -86,16 +86,16 @@ namespace osmium { int64_t m_num; #endif - int64_t m_sum; + int64_t m_sum = 0; public: explicit ProtoRing(NodeRefSegment* segment) noexcept : - m_min_segment(segment), + m_min_segment(segment) #ifdef OSMIUM_DEBUG_RING_NO - m_num(next_num()), + , m_num(next_num()) #endif - m_sum(0) { + { add_segment_back(segment); } diff --git a/contrib/libosmium/include/osmium/area/detail/vector.hpp b/contrib/libosmium/include/osmium/area/detail/vector.hpp index 50e1cf247..e52a65cc5 100644 --- a/contrib/libosmium/include/osmium/area/detail/vector.hpp +++ b/contrib/libosmium/include/osmium/area/detail/vector.hpp @@ -89,12 +89,12 @@ namespace osmium { // scale vector constexpr inline vec operator*(double s, const vec& v) noexcept { - return vec{int64_t(s * double(v.x)), int64_t(s * double(v.y))}; + return vec{static_cast(s * static_cast(v.x)), static_cast(s * static_cast(v.y))}; } // scale vector constexpr inline vec operator*(const vec& v, double s) noexcept { - return vec{int64_t(s * double(v.x)), int64_t(s * double(v.y))}; + return vec{static_cast(s * static_cast(v.x)), static_cast(s * static_cast(v.y))}; } // equality diff --git a/contrib/libosmium/include/osmium/area/problem_reporter_ogr.hpp b/contrib/libosmium/include/osmium/area/problem_reporter_ogr.hpp index dc02cda32..bad49f89c 100644 --- a/contrib/libosmium/include/osmium/area/problem_reporter_ogr.hpp +++ b/contrib/libosmium/include/osmium/area/problem_reporter_ogr.hpp @@ -75,15 +75,15 @@ namespace osmium { void set_object(gdalcpp::Feature& feature) { const char t[2] = {osmium::item_type_to_char(m_object_type), '\0'}; feature.set_field("obj_type", t); - feature.set_field("obj_id", int32_t(m_object_id)); - feature.set_field("nodes", int32_t(m_nodes)); + feature.set_field("obj_id", static_cast(m_object_id)); + feature.set_field("nodes", static_cast(m_nodes)); } void write_point(const char* problem_type, osmium::object_id_type id1, osmium::object_id_type id2, osmium::Location location) { gdalcpp::Feature feature{m_layer_perror, m_ogr_factory.create_point(location)}; set_object(feature); - feature.set_field("id1", double(id1)); - feature.set_field("id2", double(id2)); + feature.set_field("id1", static_cast(id1)); + feature.set_field("id2", static_cast(id2)); feature.set_field("problem", problem_type); feature.add_to_layer(); } @@ -176,7 +176,7 @@ namespace osmium { try { gdalcpp::Feature feature{m_layer_lerror, m_ogr_factory.create_linestring(way)}; set_object(feature); - feature.set_field("id1", int32_t(way.id())); + feature.set_field("id1", static_cast(way.id())); feature.set_field("id2", 0); feature.set_field("problem", "way_in_multiple_rings"); feature.add_to_layer(); @@ -192,7 +192,7 @@ namespace osmium { try { gdalcpp::Feature feature{m_layer_lerror, m_ogr_factory.create_linestring(way)}; set_object(feature); - feature.set_field("id1", int32_t(way.id())); + feature.set_field("id1", static_cast(way.id())); feature.set_field("id2", 0); feature.set_field("problem", "inner_with_same_tags"); feature.add_to_layer(); @@ -208,7 +208,7 @@ namespace osmium { try { gdalcpp::Feature feature{m_layer_lerror, m_ogr_factory.create_linestring(way)}; set_object(feature); - feature.set_field("id1", int32_t(way.id())); + feature.set_field("id1", static_cast(way.id())); feature.set_field("id2", 0); feature.set_field("problem", "duplicate_way"); feature.add_to_layer(); @@ -229,7 +229,7 @@ namespace osmium { try { gdalcpp::Feature feature{m_layer_ways, m_ogr_factory.create_linestring(way)}; set_object(feature); - feature.set_field("way_id", int32_t(way.id())); + feature.set_field("way_id", static_cast(way.id())); feature.add_to_layer(); } catch (const osmium::geometry_error&) { // XXX diff --git a/contrib/libosmium/include/osmium/builder/builder_helper.hpp b/contrib/libosmium/include/osmium/builder/builder_helper.hpp deleted file mode 100644 index 97445cb6b..000000000 --- a/contrib/libosmium/include/osmium/builder/builder_helper.hpp +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef OSMIUM_BUILDER_BUILDER_HELPER_HPP -#define OSMIUM_BUILDER_BUILDER_HELPER_HPP - -/* - -This file is part of Osmium (https://osmcode.org/libosmium). - -Copyright 2013-2022 Jochen Topf and others (see README). - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -*/ - -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace osmium { - - class NodeRef; - class TagList; - class WayNodeList; - - namespace builder { - - /** - * @deprecated - * Use osmium::builder::add_way_node_list() instead. - */ - OSMIUM_DEPRECATED inline const osmium::WayNodeList& build_way_node_list(osmium::memory::Buffer& buffer, const std::initializer_list& nodes) { - const size_t pos = buffer.committed(); - { - osmium::builder::WayNodeListBuilder wnl_builder(buffer); - for (const auto& node_ref : nodes) { - wnl_builder.add_node_ref(node_ref); - } - } - buffer.commit(); - return buffer.get(pos); - } - - /** - * @deprecated - * Use osmium::builder::add_tag_list() instead. - */ - OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list(osmium::memory::Buffer& buffer, const std::initializer_list>& tags) { - const size_t pos = buffer.committed(); - { - osmium::builder::TagListBuilder tl_builder(buffer); - for (const auto& p : tags) { - tl_builder.add_tag(p.first, p.second); - } - } - buffer.commit(); - return buffer.get(pos); - } - - /** - * @deprecated - * Use osmium::builder::add_tag_list() instead. - */ - OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list_from_map(osmium::memory::Buffer& buffer, const std::map& tags) { - const size_t pos = buffer.committed(); - { - osmium::builder::TagListBuilder tl_builder(buffer); - for (const auto& p : tags) { - tl_builder.add_tag(p.first, p.second); - } - } - buffer.commit(); - return buffer.get(pos); - } - - /** - * @deprecated - * Use osmium::builder::add_tag_list() instead. - */ - OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list_from_func(osmium::memory::Buffer& buffer, const std::function& func) { - const size_t pos = buffer.committed(); - { - osmium::builder::TagListBuilder tl_builder(buffer); - func(tl_builder); - } - buffer.commit(); - return buffer.get(pos); - } - - } // namespace builder - -} // namespace osmium - -#endif // OSMIUM_BUILDER_BUILDER_HELPER_HPP diff --git a/contrib/libosmium/include/osmium/builder/osm_object_builder.hpp b/contrib/libosmium/include/osmium/builder/osm_object_builder.hpp index 589cf3f79..c3228ca7d 100644 --- a/contrib/libosmium/include/osmium/builder/osm_object_builder.hpp +++ b/contrib/libosmium/include/osmium/builder/osm_object_builder.hpp @@ -125,8 +125,8 @@ namespace osmium { if (value_length > osmium::max_osm_string_length) { throw std::length_error{"OSM tag value is too long"}; } - add_size(append_with_zero(key, osmium::memory::item_size_type(key_length))); - add_size(append_with_zero(value, osmium::memory::item_size_type(value_length))); + add_size(append_with_zero(key, static_cast(key_length))); + add_size(append_with_zero(value, static_cast(value_length))); } /** @@ -142,8 +142,8 @@ namespace osmium { if (value.size() > osmium::max_osm_string_length) { throw std::length_error{"OSM tag value is too long"}; } - add_size(append(key.data(), osmium::memory::item_size_type(key.size()) + 1)); - add_size(append(value.data(), osmium::memory::item_size_type(value.size()) + 1)); + add_size(append(key.data(), static_cast(key.size()) + 1)); + add_size(append(value.data(), static_cast(value.size()) + 1)); } /** @@ -240,8 +240,8 @@ namespace osmium { if (length > osmium::max_osm_string_length) { throw std::length_error{"OSM relation member role is too long"}; } - member.set_role_size(osmium::string_size_type(length) + 1); - add_size(append_with_zero(role, osmium::memory::item_size_type(length))); + member.set_role_size(static_cast(length) + 1); + add_size(append_with_zero(role, static_cast(length))); add_padding(true); } @@ -330,16 +330,16 @@ namespace osmium { if (length > osmium::max_osm_string_length) { throw std::length_error{"OSM user name is too long"}; } - comment.set_user_size(osmium::string_size_type(length) + 1); - add_size(append_with_zero(user, osmium::memory::item_size_type(length))); + comment.set_user_size(static_cast(length) + 1); + add_size(append_with_zero(user, static_cast(length))); } void add_text(osmium::ChangesetComment& comment, const char* text, const std::size_t length) { if (length > std::numeric_limits::max() - 1) { throw std::length_error{"OSM changeset comment is too long"}; } - comment.set_text_size(osmium::changeset_comment_size_type(length) + 1); - add_size(append_with_zero(text, osmium::memory::item_size_type(length))); + comment.set_text_size(static_cast(length) + 1); + add_size(append_with_zero(text, static_cast(length))); add_padding(true); } diff --git a/contrib/libosmium/include/osmium/geom/factory.hpp b/contrib/libosmium/include/osmium/geom/factory.hpp index a3004118b..07c7f2e67 100644 --- a/contrib/libosmium/include/osmium/geom/factory.hpp +++ b/contrib/libosmium/include/osmium/geom/factory.hpp @@ -166,7 +166,7 @@ namespace osmium { public: - GeometryFactory() : + GeometryFactory() : m_projection(), m_impl(m_projection.epsg()) { } @@ -175,7 +175,7 @@ namespace osmium { * Constructor for default initialized projection. */ template - explicit GeometryFactory(TArgs&&... args) : + explicit GeometryFactory(TArgs&&... args) : m_projection(), m_impl(m_projection.epsg(), std::forward(args)...) { } @@ -185,7 +185,7 @@ namespace osmium { * projection is moved into the GeometryFactory. */ template - explicit GeometryFactory(TProjection&& projection, TArgs&&... args) : + explicit GeometryFactory(TProjection&& projection, TArgs&&... args) : m_projection(std::move(projection)), m_impl(m_projection.epsg(), std::forward(args)...) { } diff --git a/contrib/libosmium/include/osmium/index/bool_vector.hpp b/contrib/libosmium/include/osmium/index/bool_vector.hpp deleted file mode 100644 index 529063565..000000000 --- a/contrib/libosmium/include/osmium/index/bool_vector.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef OSMIUM_INDEX_BOOL_VECTOR_HPP -#define OSMIUM_INDEX_BOOL_VECTOR_HPP - -/* - -This file is part of Osmium (https://osmcode.org/libosmium). - -Copyright 2013-2022 Jochen Topf and others (see README). - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -*/ - -#include - -namespace osmium { - - namespace index { - - /// @deprecated Use osmium::index::IdSet instead. - template - using BoolVector = IdSet; - - } // namespace index - -} // namespace osmium - -#endif // OSMIUM_INDEX_BOOL_VECTOR_HPP diff --git a/contrib/libosmium/include/osmium/index/map/sparse_mem_table.hpp b/contrib/libosmium/include/osmium/index/map/sparse_mem_table.hpp deleted file mode 100644 index d92af4de0..000000000 --- a/contrib/libosmium/include/osmium/index/map/sparse_mem_table.hpp +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef OSMIUM_INDEX_MAP_SPARSE_MEM_TABLE_HPP -#define OSMIUM_INDEX_MAP_SPARSE_MEM_TABLE_HPP - -/* - -This file is part of Osmium (https://osmcode.org/libosmium). - -Copyright 2013-2022 Jochen Topf and others (see README). - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -*/ - -#ifdef OSMIUM_WITH_SPARSEHASH - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_TABLE - -namespace osmium { - - namespace index { - - namespace map { - - /** - * The SparseMemTable index stores elements in a Google sparsetable, - * a data structure that can hold sparsly filled tables in a - * space efficient way. It will resize automatically. - * - * Use this index if the ID space is only sparsly - * populated, such as when working with smaller OSM files (like - * country extracts). - * - * This will only work on 64 bit machines. - * - * @deprecated - * Use one of the other indexes instead. - */ - template - class OSMIUM_DEPRECATED SparseMemTable : public osmium::index::map::Map { - - TId m_grow_size; - - google::sparsetable m_elements; - - static_assert(sizeof(typename google::sparsetable::size_type) >= 8, "google::sparsetable needs 64bit machine"); - - public: - - /** - * Constructor. - * - * @param grow_size The initial size of the index (ie number of - * elements that fit into the index). - * The storage will grow by at least this size - * every time it runs out of space. - */ - explicit SparseMemTable(const TId grow_size = 10000) : - m_grow_size(grow_size), - m_elements(grow_size) { - } - - void set(const TId id, const TValue value) final { - if (id >= m_elements.size()) { - m_elements.resize(id + m_grow_size); - } - m_elements[id] = value; - } - - TValue get(const TId id) const final { - if (id >= m_elements.size()) { - throw osmium::not_found{id}; - } - const TValue value = m_elements[id]; - if (value == osmium::index::empty_value()) { - throw osmium::not_found{id}; - } - return value; - } - - TValue get_noexcept(const TId id) const noexcept final { - if (id >= m_elements.size()) { - return osmium::index::empty_value(); - } - return m_elements[id]; - } - - size_t size() const final { - return m_elements.size(); - } - - size_t used_memory() const final { - // unused elements use 1 bit, used elements sizeof(TValue) bytes - // https://github.com/sparsehash/sparsehash/blob/master/doc/sparsetable.html - return (m_elements.size() / 8) + (m_elements.num_nonempty() * sizeof(TValue)); - } - - void clear() final { - m_elements.clear(); - } - - void dump_as_list(const int fd) final { - std::vector> v; - v.reserve(m_elements.size()); - int n = 0; - for (const TValue value : m_elements) { - if (value != osmium::index::empty_value()) { - v.emplace_back(n, value); - } - ++n; - } - osmium::io::detail::reliable_write(fd, reinterpret_cast(v.data()), sizeof(std::pair) * v.size()); - } - - }; // class SparseMemTable - - } // namespace map - - } // namespace index - -} // namespace osmium - -#ifdef OSMIUM_WANT_NODE_LOCATION_MAPS - REGISTER_MAP(osmium::unsigned_object_id_type, osmium::Location, osmium::index::map::SparseMemTable, sparse_mem_table) -#endif - -#endif // OSMIUM_WITH_SPARSEHASH - -#endif // OSMIUM_INDEX_MAP_SPARSE_MEM_TABLE_HPP diff --git a/contrib/libosmium/include/osmium/io/compression.hpp b/contrib/libosmium/include/osmium/io/compression.hpp index de7bbfacc..cd45791fd 100644 --- a/contrib/libosmium/include/osmium/io/compression.hpp +++ b/contrib/libosmium/include/osmium/io/compression.hpp @@ -357,7 +357,7 @@ namespace osmium { osmium::io::detail::remove_buffered_pages(m_fd, m_offset); } const auto nread = detail::reliable_read(m_fd, &*buffer.begin(), osmium::io::Decompressor::input_buffer_size); - buffer.resize(std::string::size_type(nread)); + buffer.resize(static_cast(nread)); } m_offset += buffer.size(); diff --git a/contrib/libosmium/include/osmium/io/detail/debug_output_format.hpp b/contrib/libosmium/include/osmium/io/detail/debug_output_format.hpp index 518029a27..d2a09598f 100644 --- a/contrib/libosmium/include/osmium/io/detail/debug_output_format.hpp +++ b/contrib/libosmium/include/osmium/io/detail/debug_output_format.hpp @@ -392,7 +392,7 @@ namespace osmium { *m_out += " (open)\n"; } - const int width = int(std::log10(way.nodes().size())) + 1; + const int width = static_cast(std::log10(way.nodes().size())) + 1; int n = 0; for (const auto& node_ref : way.nodes()) { write_diff(); @@ -427,7 +427,7 @@ namespace osmium { output_int(relation.members().size()); *m_out += '\n'; - const int width = int(std::log10(relation.members().size())) + 1; + const int width = static_cast(std::log10(relation.members().size())) + 1; int n = 0; for (const auto& member : relation.members()) { write_diff(); @@ -485,7 +485,7 @@ namespace osmium { output_int(changeset.num_comments()); *m_out += '\n'; - const int width = int(std::log10(changeset.num_comments())) + 1; + const int width = static_cast(std::log10(changeset.num_comments())) + 1; int n = 0; for (const auto& comment : changeset.discussion()) { write_counter(width, n++); diff --git a/contrib/libosmium/include/osmium/io/detail/opl_parser_functions.hpp b/contrib/libosmium/include/osmium/io/detail/opl_parser_functions.hpp index 56f9f5c12..3ce11b44c 100644 --- a/contrib/libosmium/include/osmium/io/detail/opl_parser_functions.hpp +++ b/contrib/libosmium/include/osmium/io/detail/opl_parser_functions.hpp @@ -243,7 +243,7 @@ namespace osmium { } } - return T(value); + return static_cast(value); } inline osmium::object_id_type opl_parse_id(const char** s) { diff --git a/contrib/libosmium/include/osmium/io/detail/pbf_decoder.hpp b/contrib/libosmium/include/osmium/io/detail/pbf_decoder.hpp index 9d2589dfe..804dd5831 100644 --- a/contrib/libosmium/include/osmium/io/detail/pbf_decoder.hpp +++ b/contrib/libosmium/include/osmium/io/detail/pbf_decoder.hpp @@ -168,7 +168,7 @@ namespace osmium { const std::string start_of_string(str_view.data(), 20); throw osmium::pbf_error{"overlong string (" + start_of_string + "...) in string table"}; } - m_stringtable.emplace_back(str_view.data(), osmium::string_size_type(str_view.size())); + m_stringtable.emplace_back(str_view.data(), static_cast(str_view.size())); } } @@ -314,11 +314,11 @@ namespace osmium { } int32_t convert_pbf_lon(const int64_t c) const noexcept { - return int32_t((c * m_granularity + m_lon_offset) / resolution_convert); + return static_cast((c * m_granularity + m_lon_offset) / resolution_convert); } int32_t convert_pbf_lat(const int64_t c) const noexcept { - return int32_t((c * m_granularity + m_lat_offset) / resolution_convert); + return static_cast((c * m_granularity + m_lat_offset) / resolution_convert); } void decode_node(const data_view& data) { @@ -503,7 +503,7 @@ namespace osmium { throw osmium::pbf_error{"unknown relation member type"}; } rml_builder.add_member( - osmium::item_type(type + 1), + static_cast(type + 1), ref.update(refs.next_sint64()), r.first, r.second @@ -788,7 +788,7 @@ namespace osmium { } case protozero::tag_and_type(FileFormat::Blob::optional_int32_raw_size, protozero::pbf_wire_type::varint): raw_size = pbf_blob.get_int32(); - if (raw_size <= 0 || uint32_t(raw_size) > max_uncompressed_blob_size) { + if (raw_size <= 0 || static_cast(raw_size) > max_uncompressed_blob_size) { throw osmium::pbf_error{"illegal blob size"}; } break; @@ -809,37 +809,41 @@ namespace osmium { case protozero::tag_and_type(FileFormat::Blob::optional_bytes_zstd_data, protozero::pbf_wire_type::length_delimited): throw osmium::pbf_error{"zstd blobs not supported"}; default: - throw osmium::pbf_error{"unknown compression"}; + pbf_blob.skip(); } } - if (!compressed_data.empty() && raw_size != 0) { - switch (use_compression) { - case pbf_compression::none: - break; - case pbf_compression::zlib: - return osmium::io::detail::zlib_uncompress_string( - compressed_data.data(), - static_cast(compressed_data.size()), // NOLINT(google-runtime-int) - static_cast(raw_size), // NOLINT(google-runtime-int) - output - ); - case pbf_compression::lz4: + if (compressed_data.empty()) { + throw osmium::pbf_error{"blob contains no data or unknown compression method"}; + } + + if (raw_size == 0) { + throw osmium::pbf_error{"missing raw_size in compressed blob"}; + } + + switch (use_compression) { + case pbf_compression::none: + break; + case pbf_compression::zlib: + return osmium::io::detail::zlib_uncompress_string( + compressed_data.data(), + static_cast(compressed_data.size()), // NOLINT(google-runtime-int) + static_cast(raw_size), // NOLINT(google-runtime-int) + output + ); + case pbf_compression::lz4: #ifdef OSMIUM_WITH_LZ4 - return osmium::io::detail::lz4_uncompress_string( - compressed_data.data(), - static_cast(compressed_data.size()), // NOLINT(google-runtime-int) - static_cast(raw_size), // NOLINT(google-runtime-int) - output - ); + return osmium::io::detail::lz4_uncompress_string( + compressed_data.data(), + static_cast(compressed_data.size()), // NOLINT(google-runtime-int) + static_cast(raw_size), // NOLINT(google-runtime-int) + output + ); #else - break; + break; #endif - } - std::abort(); // should never be here } - - throw osmium::pbf_error{"blob contains no data"}; + std::abort(); // should never be here } inline osmium::Box decode_header_bbox(const data_view& data) { diff --git a/contrib/libosmium/include/osmium/io/detail/pbf_output_format.hpp b/contrib/libosmium/include/osmium/io/detail/pbf_output_format.hpp index 065014c0e..f6e0f6dcc 100644 --- a/contrib/libosmium/include/osmium/io/detail/pbf_output_format.hpp +++ b/contrib/libosmium/include/osmium/io/detail/pbf_output_format.hpp @@ -206,7 +206,7 @@ namespace osmium { m_versions.push_back(static_cast(node.version())); } if (m_options->add_metadata.timestamp()) { - m_timestamps.push_back(m_delta_timestamp.update(uint32_t(node.timestamp()))); + m_timestamps.push_back(m_delta_timestamp.update(static_cast(node.timestamp()))); } if (m_options->add_metadata.changeset()) { m_changesets.push_back(m_delta_changeset.update(node.changeset())); @@ -435,12 +435,12 @@ namespace osmium { pbf_blob.add_bytes(FileFormat::Blob::optional_bytes_raw, m_msg); break; case pbf_compression::zlib: - pbf_blob.add_int32(FileFormat::Blob::optional_int32_raw_size, int32_t(m_msg.size())); + pbf_blob.add_int32(FileFormat::Blob::optional_int32_raw_size, static_cast(m_msg.size())); pbf_blob.add_bytes(FileFormat::Blob::optional_bytes_zlib_data, osmium::io::detail::zlib_compress(m_msg, m_compression_level)); break; case pbf_compression::lz4: #ifdef OSMIUM_WITH_LZ4 - pbf_blob.add_int32(FileFormat::Blob::optional_int32_raw_size, int32_t(m_msg.size())); + pbf_blob.add_int32(FileFormat::Blob::optional_int32_raw_size, static_cast(m_msg.size())); pbf_blob.add_bytes(FileFormat::Blob::optional_bytes_lz4_data, osmium::io::detail::lz4_compress(m_msg, m_compression_level)); break; #else @@ -511,14 +511,14 @@ namespace osmium { template void add_meta(const osmium::OSMObject& object, T& pbf_object) { { - protozero::packed_field_uint32 field{pbf_object, protozero::pbf_tag_type(T::enum_type::packed_uint32_keys)}; + protozero::packed_field_uint32 field{pbf_object, static_cast(T::enum_type::packed_uint32_keys)}; for (const auto& tag : object.tags()) { field.add_element(m_primitive_block->store_in_stringtable_unsigned(tag.key())); } } { - protozero::packed_field_uint32 field{pbf_object, protozero::pbf_tag_type(T::enum_type::packed_uint32_vals)}; + protozero::packed_field_uint32 field{pbf_object, static_cast(T::enum_type::packed_uint32_vals)}; for (const auto& tag : object.tags()) { field.add_element(m_primitive_block->store_in_stringtable_unsigned(tag.value())); } @@ -532,7 +532,7 @@ namespace osmium { pbf_info.add_int32(OSMFormat::Info::optional_int32_version, static_cast(object.version())); } if (m_options.add_metadata.timestamp()) { - pbf_info.add_int64(OSMFormat::Info::optional_int64_timestamp, uint32_t(object.timestamp())); + pbf_info.add_int64(OSMFormat::Info::optional_int64_timestamp, static_cast(object.timestamp())); } if (m_options.add_metadata.changeset()) { pbf_info.add_int64(OSMFormat::Info::optional_int64_changeset, object.changeset()); @@ -617,10 +617,10 @@ namespace osmium { protozero::pbf_builder pbf_header_bbox{pbf_header_block, OSMFormat::HeaderBlock::optional_HeaderBBox_bbox}; osmium::Box box = header.joined_boxes(); - pbf_header_bbox.add_sint64(OSMFormat::HeaderBBox::required_sint64_left, int64_t(box.bottom_left().lon() * lonlat_resolution)); - pbf_header_bbox.add_sint64(OSMFormat::HeaderBBox::required_sint64_right, int64_t(box.top_right().lon() * lonlat_resolution)); - pbf_header_bbox.add_sint64(OSMFormat::HeaderBBox::required_sint64_top, int64_t(box.top_right().lat() * lonlat_resolution)); - pbf_header_bbox.add_sint64(OSMFormat::HeaderBBox::required_sint64_bottom, int64_t(box.bottom_left().lat() * lonlat_resolution)); + pbf_header_bbox.add_sint64(OSMFormat::HeaderBBox::required_sint64_left, static_cast(box.bottom_left().lon() * lonlat_resolution)); + pbf_header_bbox.add_sint64(OSMFormat::HeaderBBox::required_sint64_right, static_cast(box.top_right().lon() * lonlat_resolution)); + pbf_header_bbox.add_sint64(OSMFormat::HeaderBBox::required_sint64_top, static_cast(box.top_right().lat() * lonlat_resolution)); + pbf_header_bbox.add_sint64(OSMFormat::HeaderBBox::required_sint64_bottom, static_cast(box.bottom_left().lat() * lonlat_resolution)); } pbf_header_block.add_string(OSMFormat::HeaderBlock::repeated_string_required_features, "OsmSchema-V0.6"); @@ -646,7 +646,7 @@ namespace osmium { const std::string osmosis_replication_timestamp{header.get("osmosis_replication_timestamp")}; if (!osmosis_replication_timestamp.empty()) { const osmium::Timestamp ts{osmosis_replication_timestamp.c_str()}; - pbf_header_block.add_int64(OSMFormat::HeaderBlock::optional_int64_osmosis_replication_timestamp, uint32_t(ts)); + pbf_header_block.add_int64(OSMFormat::HeaderBlock::optional_int64_osmosis_replication_timestamp, static_cast(ts)); } const std::string osmosis_replication_sequence_number{header.get("osmosis_replication_sequence_number")}; @@ -700,7 +700,7 @@ namespace osmium { { osmium::DeltaEncode delta_id; - protozero::packed_field_sint64 field{pbf_way, protozero::pbf_tag_type(OSMFormat::Way::packed_sint64_refs)}; + protozero::packed_field_sint64 field{pbf_way, static_cast(OSMFormat::Way::packed_sint64_refs)}; for (const auto& node_ref : way.nodes()) { field.add_element(delta_id.update(node_ref.ref())); } @@ -709,14 +709,14 @@ namespace osmium { if (m_options.locations_on_ways) { { osmium::DeltaEncode delta; - protozero::packed_field_sint64 field{pbf_way, protozero::pbf_tag_type(OSMFormat::Way::packed_sint64_lon)}; + protozero::packed_field_sint64 field{pbf_way, static_cast(OSMFormat::Way::packed_sint64_lon)}; for (const auto& node_ref : way.nodes()) { field.add_element(delta.update(node_ref.location().x())); } } { osmium::DeltaEncode delta; - protozero::packed_field_sint64 field{pbf_way, protozero::pbf_tag_type(OSMFormat::Way::packed_sint64_lat)}; + protozero::packed_field_sint64 field{pbf_way, static_cast(OSMFormat::Way::packed_sint64_lat)}; for (const auto& node_ref : way.nodes()) { field.add_element(delta.update(node_ref.location().y())); } @@ -732,7 +732,7 @@ namespace osmium { add_meta(relation, pbf_relation); { - protozero::packed_field_int32 field{pbf_relation, protozero::pbf_tag_type(OSMFormat::Relation::packed_int32_roles_sid)}; + protozero::packed_field_int32 field{pbf_relation, static_cast(OSMFormat::Relation::packed_int32_roles_sid)}; for (const auto& member : relation.members()) { field.add_element(m_primitive_block->store_in_stringtable(member.role())); } @@ -740,16 +740,16 @@ namespace osmium { { osmium::DeltaEncode delta_id; - protozero::packed_field_sint64 field{pbf_relation, protozero::pbf_tag_type(OSMFormat::Relation::packed_sint64_memids)}; + protozero::packed_field_sint64 field{pbf_relation, static_cast(OSMFormat::Relation::packed_sint64_memids)}; for (const auto& member : relation.members()) { field.add_element(delta_id.update(member.ref())); } } { - protozero::packed_field_int32 field{pbf_relation, protozero::pbf_tag_type(OSMFormat::Relation::packed_MemberType_types)}; + protozero::packed_field_int32 field{pbf_relation, static_cast(OSMFormat::Relation::packed_MemberType_types)}; for (const auto& member : relation.members()) { - field.add_element(int32_t(osmium::item_type_to_nwr_index(member.type()))); + field.add_element(static_cast(osmium::item_type_to_nwr_index(member.type()))); } } } diff --git a/contrib/libosmium/include/osmium/io/detail/read_write.hpp b/contrib/libosmium/include/osmium/io/detail/read_write.hpp index 53cf30d42..bde056b6d 100644 --- a/contrib/libosmium/include/osmium/io/detail/read_write.hpp +++ b/contrib/libosmium/include/osmium/io/detail/read_write.hpp @@ -106,9 +106,10 @@ namespace osmium { return 0; // stdin } - int flags = O_RDONLY; #ifdef _WIN32 - flags |= O_BINARY; + const int flags = O_RDONLY | O_BINARY; +#else + const int flags = O_RDONLY; #endif const int fd = ::open(filename.c_str(), flags); if (fd < 0) { @@ -253,7 +254,7 @@ namespace osmium { * needed again soon. Keeps the buffer cache clear for other * things. */ -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) inline void remove_buffered_pages(int fd) noexcept { if (fd > 0) { ::posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); @@ -269,7 +270,7 @@ namespace osmium { * file that will not be needed again soon. Keeps the buffer cache * clear for other things. */ -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) inline void remove_buffered_pages(int fd, std::size_t size) noexcept { constexpr const std::size_t block_size = 4096; // Make sure to keep the last 10 blocks around, so were are diff --git a/contrib/libosmium/include/osmium/io/detail/string_util.hpp b/contrib/libosmium/include/osmium/io/detail/string_util.hpp index 706619881..ea5855613 100644 --- a/contrib/libosmium/include/osmium/io/detail/string_util.hpp +++ b/contrib/libosmium/include/osmium/io/detail/string_util.hpp @@ -113,7 +113,7 @@ namespace osmium { #endif string_snprintf(out, old_size, - std::size_t(len) + 1, + static_cast(len) + 1, format, args...); assert(len2 == len); diff --git a/contrib/libosmium/include/osmium/io/reader.hpp b/contrib/libosmium/include/osmium/io/reader.hpp index 691638069..643ffcd0c 100644 --- a/contrib/libosmium/include/osmium/io/reader.hpp +++ b/contrib/libosmium/include/osmium/io/reader.hpp @@ -248,7 +248,7 @@ namespace osmium { #endif } const int fd = osmium::io::detail::open_for_reading(filename); -#if __linux__ +#if defined(__linux__) || defined(__FreeBSD__) if (fd >= 0) { // Tell the kernel we are going to read this file sequentially ::posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL); diff --git a/contrib/libosmium/include/osmium/memory/item.hpp b/contrib/libosmium/include/osmium/memory/item.hpp index 3c6b2ecd5..a262371dd 100644 --- a/contrib/libosmium/include/osmium/memory/item.hpp +++ b/contrib/libosmium/include/osmium/memory/item.hpp @@ -181,7 +181,7 @@ namespace osmium { } diff_indicator_type diff() const noexcept { - return diff_indicator_type(m_diff); + return static_cast(m_diff); } char diff_as_char() const noexcept { @@ -190,7 +190,7 @@ namespace osmium { } void set_diff(const diff_indicator_type diff) noexcept { - m_diff = uint16_t(diff); + m_diff = static_cast(diff); } }; // class Item diff --git a/contrib/libosmium/include/osmium/osm/box.hpp b/contrib/libosmium/include/osmium/osm/box.hpp index f4da3fdca..f477a4f81 100644 --- a/contrib/libosmium/include/osmium/osm/box.hpp +++ b/contrib/libosmium/include/osmium/osm/box.hpp @@ -136,7 +136,7 @@ namespace osmium { * Box is defined, ie. contains defined locations. */ explicit constexpr operator bool() const noexcept { - return bool(m_bottom_left) && bool(m_top_right); + return static_cast(m_bottom_left) && static_cast(m_top_right); } /** diff --git a/contrib/libosmium/include/osmium/osm/crc.hpp b/contrib/libosmium/include/osmium/osm/crc.hpp index b6a806c1c..88441cae2 100644 --- a/contrib/libosmium/include/osmium/osm/crc.hpp +++ b/contrib/libosmium/include/osmium/osm/crc.hpp @@ -155,7 +155,7 @@ namespace osmium { } void update(const Timestamp& timestamp) noexcept { - update_int32(uint32_t(timestamp)); + update_int32(static_cast(timestamp)); } void update(const osmium::Location& location) noexcept { @@ -188,7 +188,7 @@ namespace osmium { void update(const osmium::RelationMember& member) noexcept { update_int64(static_cast(member.ref())); - update_int16(uint16_t(member.type())); + update_int16(static_cast(member.type())); update_string(member.role()); } diff --git a/contrib/libosmium/include/osmium/osm/item_type.hpp b/contrib/libosmium/include/osmium/osm/item_type.hpp index 5217d1639..c10eca7d6 100644 --- a/contrib/libosmium/include/osmium/osm/item_type.hpp +++ b/contrib/libosmium/include/osmium/osm/item_type.hpp @@ -70,7 +70,7 @@ namespace osmium { */ inline item_type nwr_index_to_item_type(unsigned int i) noexcept { assert(i <= 2); - return item_type(i + 1); + return static_cast(i + 1); } /** diff --git a/contrib/libosmium/include/osmium/osm/node_ref_list.hpp b/contrib/libosmium/include/osmium/osm/node_ref_list.hpp index 12b2b1d85..6d7c67b77 100644 --- a/contrib/libosmium/include/osmium/osm/node_ref_list.hpp +++ b/contrib/libosmium/include/osmium/osm/node_ref_list.hpp @@ -197,22 +197,22 @@ namespace osmium { /// Returns an iterator to the beginning. iterator begin() noexcept { - return iterator(data() + sizeof(NodeRefList)); + return reinterpret_cast(data() + sizeof(NodeRefList)); } /// Returns an iterator to the end. iterator end() noexcept { - return iterator(data() + byte_size()); + return reinterpret_cast(data() + byte_size()); } /// Returns an iterator to the beginning. const_iterator cbegin() const noexcept { - return const_iterator(data() + sizeof(NodeRefList)); + return reinterpret_cast(data() + sizeof(NodeRefList)); } /// Returns an iterator to the end. const_iterator cend() const noexcept { - return const_iterator(data() + byte_size()); + return reinterpret_cast(data() + byte_size()); } /// Returns an iterator to the beginning. diff --git a/contrib/libosmium/include/osmium/osm/object.hpp b/contrib/libosmium/include/osmium/osm/object.hpp index c4a07f492..a62c7603a 100644 --- a/contrib/libosmium/include/osmium/osm/object.hpp +++ b/contrib/libosmium/include/osmium/osm/object.hpp @@ -307,8 +307,9 @@ namespace osmium { */ OSMObject& set_timestamp(const char* timestamp) { assert(timestamp); - m_timestamp = detail::parse_timestamp(timestamp); - if (timestamp[20] != '\0') { + const char** str = ×tamp; + m_timestamp = detail::parse_timestamp(str); + if (**str != '\0') { throw std::invalid_argument{"can not parse timestamp: garbage after timestamp"}; } return *this; diff --git a/contrib/libosmium/include/osmium/osm/timestamp.hpp b/contrib/libosmium/include/osmium/osm/timestamp.hpp index 55dc777b5..e6cf1c458 100644 --- a/contrib/libosmium/include/osmium/osm/timestamp.hpp +++ b/contrib/libosmium/include/osmium/osm/timestamp.hpp @@ -79,7 +79,30 @@ namespace osmium { out += static_cast('0' + value); } - inline time_t parse_timestamp(const char* str) { + inline bool fractional_seconds(const char** s) noexcept { + const char* str = *s; + + if (*str != '.' && *str != ',') { + return false; + } + + ++str; + if (*str < '0' || *str > '9') { + return false; + } + + do { + ++str; + } while (*str >= '0' && *str <= '9'); + + *s = str; + return *str == 'Z'; + } + + inline std::time_t parse_timestamp(const char** s) { + const char* str = *s; + *s += 19; + static const std::array mon_lengths = {{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 @@ -104,7 +127,8 @@ namespace osmium { str[16] == ':' && str[17] >= '0' && str[17] <= '9' && str[18] >= '0' && str[18] <= '9' && - str[19] == 'Z') { + (str[19] == 'Z' || fractional_seconds(s))) { + ++(*s); std::tm tm; // NOLINT(cppcoreguidelines-pro-type-member-init,hicpp-member-init) tm.tm_year = (str[ 0] - '0') * 1000 + (str[ 1] - '0') * 100 + @@ -134,6 +158,11 @@ namespace osmium { throw std::invalid_argument{std::string{"can not parse timestamp: '"} + str + "'"}; } + inline std::time_t parse_timestamp(const char* s) { + const char** str = &s; + return parse_timestamp(str); + } + } // namespace detail /** @@ -149,7 +178,7 @@ namespace osmium { void to_iso_str(std::string& s) const { std::tm tm; // NOLINT(cppcoreguidelines-pro-type-member-init,hicpp-member-init) - time_t sse = seconds_since_epoch(); + const std::time_t sse = seconds_since_epoch(); #ifndef NDEBUG auto result = #endif @@ -193,7 +222,7 @@ namespace osmium { */ template ::value, int>::type = 0> constexpr Timestamp(T timestamp) noexcept : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions) - m_timestamp(uint32_t(timestamp)) { + m_timestamp(static_cast(timestamp)) { } /** @@ -230,18 +259,18 @@ namespace osmium { } /// Explicit conversion into time_t. - constexpr time_t seconds_since_epoch() const noexcept { - return time_t(m_timestamp); + constexpr std::time_t seconds_since_epoch() const noexcept { + return static_cast(m_timestamp); } /// Explicit conversion into uint32_t. explicit constexpr operator uint32_t() const noexcept { - return uint32_t(m_timestamp); + return m_timestamp; } /// Explicit conversion into uint64_t. explicit constexpr operator uint64_t() const noexcept { - return uint64_t(m_timestamp); + return static_cast(m_timestamp); } template @@ -307,7 +336,7 @@ namespace osmium { } inline bool operator==(const Timestamp& lhs, const Timestamp& rhs) noexcept { - return uint32_t(lhs) == uint32_t(rhs); + return static_cast(lhs) == static_cast(rhs); } inline bool operator!=(const Timestamp& lhs, const Timestamp& rhs) noexcept { @@ -315,7 +344,7 @@ namespace osmium { } inline bool operator<(const Timestamp& lhs, const Timestamp& rhs) noexcept { - return uint32_t(lhs) < uint32_t(rhs); + return static_cast(lhs) < static_cast(rhs); } inline bool operator>(const Timestamp& lhs, const Timestamp& rhs) noexcept { diff --git a/contrib/libosmium/include/osmium/thread/pool.hpp b/contrib/libosmium/include/osmium/thread/pool.hpp index fbc5deea9..889113289 100644 --- a/contrib/libosmium/include/osmium/thread/pool.hpp +++ b/contrib/libosmium/include/osmium/thread/pool.hpp @@ -66,7 +66,7 @@ namespace osmium { } if (num_threads < 0) { - num_threads += int(hardware_concurrency); + num_threads += static_cast(hardware_concurrency); } if (num_threads < 1) { diff --git a/contrib/libosmium/include/osmium/thread/util.hpp b/contrib/libosmium/include/osmium/thread/util.hpp index 694165964..b5a2ef10d 100644 --- a/contrib/libosmium/include/osmium/thread/util.hpp +++ b/contrib/libosmium/include/osmium/thread/util.hpp @@ -72,7 +72,7 @@ namespace osmium { } /** - * Set name of current thread for debugging. This only works on Linux. + * Set name of current thread for debugging. This currently only works on Linux and FreeBSD. */ #if defined(__linux__) inline void set_thread_name(const char* name) noexcept { diff --git a/contrib/libosmium/include/osmium/util/cast.hpp b/contrib/libosmium/include/osmium/util/cast.hpp deleted file mode 100644 index 9d2a37a6a..000000000 --- a/contrib/libosmium/include/osmium/util/cast.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef OSMIUM_UTIL_CAST_HPP -#define OSMIUM_UTIL_CAST_HPP - -/* - -This file is part of Osmium (https://osmcode.org/libosmium). - -Copyright 2013-2022 Jochen Topf and others (see README). - -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -*/ - -#include - -#ifndef assert -# include -#endif - -#include -#include -#include - -namespace osmium { - - // These functions are wrappers around static_cast<>() that call assert() - // to check that there is no integer overflow happening before doing the - // cast. There are several versions of this templated function here - // depending on the types of the input and output. In any case, both input - // and output have to be integral types. If the cast can't overflow, no - // check is done. - - template - struct are_real_integers : - std::integral_constant::value && - std::is_integral::value && - !std::is_same::value && - !std::is_same::value> { - }; - - template ::value && std::is_same::value, int>::type = 0> - OSMIUM_DEPRECATED inline T static_cast_with_assert(const F value) { - return value; - } - - template ::value && !std::is_same::value && (sizeof(T) > sizeof(F)), int>::type = 0> - OSMIUM_DEPRECATED inline T static_cast_with_assert(const F value) { - return static_cast(value); - } - - template ::value && !std::is_same::value && std::is_signed::value == std::is_signed::value && (sizeof(T) == sizeof(F)), int>::type = 0> - OSMIUM_DEPRECATED inline T static_cast_with_assert(const F value) { - return static_cast(value); - } - - template ::value && !std::is_same::value && (sizeof(T) < sizeof(F)) && std::is_signed::value && std::is_signed::value, int>::type = 0> - OSMIUM_DEPRECATED inline T static_cast_with_assert(const F value) { - assert(value >= std::numeric_limits::min() && value <= std::numeric_limits::max()); - return static_cast(value); - } - - template ::value && !std::is_same::value && (sizeof(T) <= sizeof(F)) && std::is_unsigned::value && std::is_signed::value, int>::type = 0> - OSMIUM_DEPRECATED inline T static_cast_with_assert(const F value) { - assert(value >= 0 && static_cast::type>(value) <= std::numeric_limits::max()); - return static_cast(value); - } - - template ::value && !std::is_same::value && (sizeof(T) < sizeof(F)) && std::is_unsigned::value && std::is_unsigned::value, int>::type = 0> - OSMIUM_DEPRECATED inline T static_cast_with_assert(const F value) { - assert(value <= std::numeric_limits::max()); - return static_cast(value); - } - - template ::value && !std::is_same::value && (sizeof(T) <= sizeof(F)) && std::is_signed::value && std::is_unsigned::value, int>::type = 0> - OSMIUM_DEPRECATED inline T static_cast_with_assert(const F value) { - assert(static_cast(value) <= static_cast(std::numeric_limits::max())); - return static_cast(value); - } - -} // namespace osmium - -#endif // OSMIUM_UTIL_CAST_HPP diff --git a/contrib/libosmium/include/osmium/util/timer.hpp b/contrib/libosmium/include/osmium/util/timer.hpp index adcdcbf98..58ea1deb3 100644 --- a/contrib/libosmium/include/osmium/util/timer.hpp +++ b/contrib/libosmium/include/osmium/util/timer.hpp @@ -79,10 +79,10 @@ namespace osmium { Timer() = default; - void start() const noexcept { // NOLINT(readability-convert-member-functions-to-static) + void start() noexcept { // NOLINT(readability-convert-member-functions-to-static) } - void stop() const noexcept { // NOLINT(readability-convert-member-functions-to-static) + void stop() noexcept { // NOLINT(readability-convert-member-functions-to-static) } int64_t elapsed_microseconds() const noexcept { // NOLINT(readability-convert-member-functions-to-static) diff --git a/contrib/libosmium/include/osmium/version.hpp b/contrib/libosmium/include/osmium/version.hpp index bd240ee3b..1ecfc3c7f 100644 --- a/contrib/libosmium/include/osmium/version.hpp +++ b/contrib/libosmium/include/osmium/version.hpp @@ -33,10 +33,15 @@ DEALINGS IN THE SOFTWARE. */ +// NOLINTNEXTLINE(modernize-macro-to-enum) #define LIBOSMIUM_VERSION_MAJOR 2 -#define LIBOSMIUM_VERSION_MINOR 19 + +// NOLINTNEXTLINE(modernize-macro-to-enum) +#define LIBOSMIUM_VERSION_MINOR 20 + +// NOLINTNEXTLINE(modernize-macro-to-enum) #define LIBOSMIUM_VERSION_PATCH 0 -#define LIBOSMIUM_VERSION_STRING "2.19.0" +#define LIBOSMIUM_VERSION_STRING "2.20.0" #endif // OSMIUM_VERSION_HPP