Skip to content

Commit 2dfd7d0

Browse files
committed
Update libosmium in contrib to version 2.15.6
1 parent fc9b385 commit 2dfd7d0

File tree

14 files changed

+102
-60
lines changed

14 files changed

+102
-60
lines changed

contrib/libosmium/README.contrib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Source: https://github.com/osmcode/libosmium
2-
Revision: v2.15.5
2+
Revision: v2.15.6

contrib/libosmium/include/osmium/area/detail/basic_assembler.hpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ namespace osmium {
105105

106106
static constexpr const std::size_t max_split_locations = 100ULL;
107107

108+
// Maximum recursion depth, stops complex multipolygons from
109+
// breaking everything.
110+
enum : unsigned {
111+
max_depth = 20U
112+
};
113+
108114
struct slocation {
109115

110116
enum {
@@ -713,7 +719,13 @@ namespace osmium {
713719

714720
};
715721

722+
struct exceeded_max_depth {};
723+
716724
void find_candidates(std::vector<candidate>& candidates, std::unordered_set<osmium::Location>& loc_done, const std::vector<location_to_ring_map>& xrings, const candidate& cand, unsigned depth = 0) {
725+
if (depth > max_depth) {
726+
throw exceeded_max_depth{};
727+
}
728+
717729
if (debug()) {
718730
std::cerr << " find_candidates sum=" << cand.sum << " start=" << cand.start_location << " stop=" << cand.stop_location << "\n";
719731
for (const auto& ring : cand.rings) {
@@ -826,7 +838,14 @@ namespace osmium {
826838
loc_done.insert(cand.stop_location);
827839

828840
std::vector<candidate> candidates;
829-
find_candidates(candidates, loc_done, xrings, cand);
841+
try {
842+
find_candidates(candidates, loc_done, xrings, cand);
843+
} catch (const exceeded_max_depth&) {
844+
if (m_config.debug_level > 0) {
845+
std::cerr << " Exceeded max depth (" << static_cast<unsigned>(max_depth) << ")\n";
846+
}
847+
return false;
848+
}
830849

831850
if (candidates.empty()) {
832851
if (debug()) {

contrib/libosmium/include/osmium/area/problem_reporter.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ namespace osmium {
9393
m_object_id = object_id;
9494
}
9595

96+
osmium::object_id_type object_id() const noexcept {
97+
return m_object_id;
98+
}
99+
96100
void set_nodes(size_t nodes) noexcept {
97101
m_nodes = nodes;
98102
}

contrib/libosmium/include/osmium/index/id_set.hpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,9 @@ namespace osmium {
387387
* Add the given Id to the set.
388388
*/
389389
void set(T id) final {
390-
m_data.push_back(id);
390+
if (m_data.empty() || m_data.back() != id) {
391+
m_data.push_back(id);
392+
}
391393
}
392394

393395
/**
@@ -430,7 +432,8 @@ namespace osmium {
430432

431433
/**
432434
* Sort the internal vector and remove any duplicates. Call this
433-
* before using size(), get_binary_search() or using an iterator.
435+
* before using size(), get_binary_search(), merge_sorted() or
436+
* using an iterator.
434437
*/
435438
void sort_unique() {
436439
std::sort(m_data.begin(), m_data.end());
@@ -453,6 +456,22 @@ namespace osmium {
453456
return m_data.capacity() * sizeof(T);
454457
}
455458

459+
/**
460+
* Merge the other set into this one. The result is sorted.
461+
*
462+
* @pre Both sets must be sorted and must not contain any
463+
* duplicates. Call sort_unique() if you are not sure.
464+
*/
465+
void merge_sorted(const IdSetSmall<T>& other) {
466+
std::vector<T> new_data;
467+
new_data.reserve(m_data.size() + other.m_data.size());
468+
std::set_union(m_data.cbegin(), m_data.cend(),
469+
other.m_data.cbegin(), other.m_data.cend(),
470+
std::back_inserter(new_data));
471+
using std::swap;
472+
swap(new_data, m_data);
473+
}
474+
456475
/// Iterator type. There is no non-const iterator.
457476
using const_iterator = typename std::vector<T>::const_iterator;
458477

contrib/libosmium/include/osmium/index/multimap/sparse_mem_multimap.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace osmium {
5353
* lot of memory, but might make sense for small maps.
5454
*/
5555
template <typename TId, typename TValue>
56-
class SparseMemMultimap : public osmium::index::multimap::Multimap<TId, TValue> {
56+
class SparseMemMultimap final : public osmium::index::multimap::Multimap<TId, TValue> {
5757

5858
// This is a rough estimate for the memory needed for each
5959
// element in the map (id + value + pointers to left, right,
@@ -79,13 +79,13 @@ namespace osmium {
7979

8080
SparseMemMultimap() = default;
8181

82-
~SparseMemMultimap() noexcept final = default;
82+
~SparseMemMultimap() noexcept = default;
8383

8484
void unsorted_set(const TId id, const TValue value) {
8585
m_elements.emplace(id, value);
8686
}
8787

88-
void set(const TId id, const TValue value) final {
88+
void set(const TId id, const TValue value) override {
8989
m_elements.emplace(id, value);
9090
}
9191

@@ -115,23 +115,23 @@ namespace osmium {
115115
return m_elements.end();
116116
}
117117

118-
size_t size() const final {
118+
size_t size() const override {
119119
return m_elements.size();
120120
}
121121

122-
size_t used_memory() const final {
122+
size_t used_memory() const override {
123123
return element_size * m_elements.size();
124124
}
125125

126-
void clear() final {
126+
void clear() override {
127127
m_elements.clear();
128128
}
129129

130130
void consolidate() {
131131
// intentionally left blank
132132
}
133133

134-
void dump_as_list(const int fd) final {
134+
void dump_as_list(const int fd) override {
135135
std::vector<element_type> v;
136136
v.reserve(m_elements.size());
137137
for (const auto& element : m_elements) {

contrib/libosmium/include/osmium/io/bzip2_compression.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ namespace osmium {
165165

166166
} // namespace detail
167167

168-
class Bzip2Compressor : public Compressor {
168+
class Bzip2Compressor final : public Compressor {
169169

170170
detail::file_wrapper m_file;
171171
BZFILE* m_bzfile = nullptr;
@@ -191,15 +191,15 @@ namespace osmium {
191191
Bzip2Compressor(Bzip2Compressor&&) = delete;
192192
Bzip2Compressor& operator=(Bzip2Compressor&&) = delete;
193193

194-
~Bzip2Compressor() noexcept final {
194+
~Bzip2Compressor() noexcept {
195195
try {
196196
close();
197197
} catch (...) {
198198
// Ignore any exceptions because destructor must not throw.
199199
}
200200
}
201201

202-
void write(const std::string& data) final {
202+
void write(const std::string& data) override {
203203
assert(data.size() < std::numeric_limits<int>::max());
204204
assert(m_bzfile);
205205
#ifdef _MSC_VER
@@ -212,7 +212,7 @@ namespace osmium {
212212
}
213213
}
214214

215-
void close() final {
215+
void close() override {
216216
if (m_bzfile) {
217217
#ifdef _MSC_VER
218218
osmium::detail::disable_invalid_parameter_handler diph;
@@ -232,7 +232,7 @@ namespace osmium {
232232

233233
}; // class Bzip2Compressor
234234

235-
class Bzip2Decompressor : public Decompressor {
235+
class Bzip2Decompressor final : public Decompressor {
236236

237237
detail::file_wrapper m_file;
238238
BZFILE* m_bzfile = nullptr;
@@ -258,15 +258,15 @@ namespace osmium {
258258
Bzip2Decompressor(Bzip2Decompressor&&) = delete;
259259
Bzip2Decompressor& operator=(Bzip2Decompressor&&) = delete;
260260

261-
~Bzip2Decompressor() noexcept final {
261+
~Bzip2Decompressor() noexcept {
262262
try {
263263
close();
264264
} catch (...) {
265265
// Ignore any exceptions because destructor must not throw.
266266
}
267267
}
268268

269-
std::string read() final {
269+
std::string read() override {
270270
#ifdef _MSC_VER
271271
osmium::detail::disable_invalid_parameter_handler diph;
272272
#endif
@@ -311,7 +311,7 @@ namespace osmium {
311311
return buffer;
312312
}
313313

314-
void close() final {
314+
void close() override {
315315
if (m_bzfile) {
316316
#ifdef _MSC_VER
317317
osmium::detail::disable_invalid_parameter_handler diph;
@@ -328,7 +328,7 @@ namespace osmium {
328328

329329
}; // class Bzip2Decompressor
330330

331-
class Bzip2BufferDecompressor : public Decompressor {
331+
class Bzip2BufferDecompressor final : public Decompressor {
332332

333333
const char* m_buffer;
334334
std::size_t m_buffer_size;
@@ -355,15 +355,15 @@ namespace osmium {
355355
Bzip2BufferDecompressor(Bzip2BufferDecompressor&&) = delete;
356356
Bzip2BufferDecompressor& operator=(Bzip2BufferDecompressor&&) = delete;
357357

358-
~Bzip2BufferDecompressor() noexcept final {
358+
~Bzip2BufferDecompressor() noexcept {
359359
try {
360360
close();
361361
} catch (...) {
362362
// Ignore any exceptions because destructor must not throw.
363363
}
364364
}
365365

366-
std::string read() final {
366+
std::string read() override {
367367
std::string output;
368368

369369
if (m_buffer) {
@@ -388,7 +388,7 @@ namespace osmium {
388388
return output;
389389
}
390390

391-
void close() final {
391+
void close() override {
392392
BZ2_bzDecompressEnd(&m_bzstream);
393393
}
394394

contrib/libosmium/include/osmium/io/compression.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ namespace osmium {
216216

217217
}; // class CompressionFactory
218218

219-
class NoCompressor : public Compressor {
219+
class NoCompressor final : public Compressor {
220220

221221
int m_fd;
222222

@@ -233,19 +233,19 @@ namespace osmium {
233233
NoCompressor(NoCompressor&&) = delete;
234234
NoCompressor& operator=(NoCompressor&&) = delete;
235235

236-
~NoCompressor() noexcept final {
236+
~NoCompressor() noexcept {
237237
try {
238238
close();
239239
} catch (...) {
240240
// Ignore any exceptions because destructor must not throw.
241241
}
242242
}
243243

244-
void write(const std::string& data) final {
244+
void write(const std::string& data) override {
245245
osmium::io::detail::reliable_write(m_fd, data.data(), data.size());
246246
}
247247

248-
void close() final {
248+
void close() override {
249249
if (m_fd >= 0) {
250250
const int fd = m_fd;
251251
m_fd = -1;
@@ -264,7 +264,7 @@ namespace osmium {
264264

265265
}; // class NoCompressor
266266

267-
class NoDecompressor : public Decompressor {
267+
class NoDecompressor final : public Decompressor {
268268

269269
int m_fd = -1;
270270
const char* m_buffer = nullptr;
@@ -288,15 +288,15 @@ namespace osmium {
288288
NoDecompressor(NoDecompressor&&) = delete;
289289
NoDecompressor& operator=(NoDecompressor&&) = delete;
290290

291-
~NoDecompressor() noexcept final {
291+
~NoDecompressor() noexcept {
292292
try {
293293
close();
294294
} catch (...) {
295295
// Ignore any exceptions because destructor must not throw.
296296
}
297297
}
298298

299-
std::string read() final {
299+
std::string read() override {
300300
std::string buffer;
301301

302302
if (m_buffer) {
@@ -317,7 +317,7 @@ namespace osmium {
317317
return buffer;
318318
}
319319

320-
void close() final {
320+
void close() override {
321321
if (m_fd >= 0) {
322322
const int fd = m_fd;
323323
m_fd = -1;

contrib/libosmium/include/osmium/io/detail/o5m_input_format.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ namespace osmium {
150150

151151
}; // class ReferenceTable
152152

153-
class O5mParser : public Parser {
153+
class O5mParser final : public Parser {
154154

155155
enum {
156156
initial_buffer_size = 1024UL * 1024UL
@@ -617,9 +617,9 @@ namespace osmium {
617617
O5mParser(O5mParser&&) = delete;
618618
O5mParser& operator=(O5mParser&&) = delete;
619619

620-
~O5mParser() noexcept final = default;
620+
~O5mParser() noexcept = default;
621621

622-
void run() final {
622+
void run() override {
623623
osmium::thread::set_thread_name("_osmium_o5m_in");
624624

625625
decode_header();

contrib/libosmium/include/osmium/io/detail/opl_input_format.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace osmium {
9898
}
9999
}
100100

101-
class OPLParser : public Parser {
101+
class OPLParser final : public Parser {
102102

103103
enum {
104104
initial_buffer_size = 1024UL * 1024UL
@@ -122,7 +122,7 @@ namespace osmium {
122122
OPLParser(OPLParser&&) = delete;
123123
OPLParser& operator=(OPLParser&&) = delete;
124124

125-
~OPLParser() noexcept final = default;
125+
~OPLParser() noexcept = default;
126126

127127
void parse_line(const char* data) {
128128
if (opl_parse_line(m_line_count, data, m_buffer, read_types())) {
@@ -134,7 +134,7 @@ namespace osmium {
134134
++m_line_count;
135135
}
136136

137-
void run() final {
137+
void run() override {
138138
osmium::thread::set_thread_name("_osmium_opl_in");
139139

140140
line_by_line(*this);

contrib/libosmium/include/osmium/io/detail/output_format.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ namespace osmium {
199199

200200
}; // class OutputFormatFactory
201201

202-
class BlackholeOutputFormat : public osmium::io::detail::OutputFormat {
202+
class BlackholeOutputFormat final : public osmium::io::detail::OutputFormat {
203203

204204
public:
205205

@@ -213,9 +213,9 @@ namespace osmium {
213213
BlackholeOutputFormat(BlackholeOutputFormat&&) = delete;
214214
BlackholeOutputFormat& operator=(BlackholeOutputFormat&&) = delete;
215215

216-
~BlackholeOutputFormat() noexcept final = default;
216+
~BlackholeOutputFormat() noexcept = default;
217217

218-
void write_buffer(osmium::memory::Buffer&& /*buffer*/) final {
218+
void write_buffer(osmium::memory::Buffer&& /*buffer*/) override {
219219
}
220220

221221
}; // class BlackholeOutputFormat

0 commit comments

Comments
 (0)