Skip to content

Commit d7c593b

Browse files
committed
update libosmium to 2.15.4
1 parent 8d9087f commit d7c593b

File tree

6 files changed

+48
-30
lines changed

6 files changed

+48
-30
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.3
2+
Revision: v2.15.4

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

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ namespace osmium {
713713

714714
};
715715

716-
void find_candidates(std::vector<candidate>& candidates, std::unordered_set<osmium::Location>& loc_done, const std::vector<location_to_ring_map>& xrings, candidate& cand) {
716+
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) {
717717
if (debug()) {
718718
std::cerr << " find_candidates sum=" << cand.sum << " start=" << cand.start_location << " stop=" << cand.stop_location << "\n";
719719
for (const auto& ring : cand.rings) {
@@ -751,13 +751,30 @@ namespace osmium {
751751
if (debug()) {
752752
std::cerr << " found candidate\n";
753753
}
754-
candidates.push_back(c);
754+
755+
if (candidates.empty()) {
756+
candidates.push_back(c);
757+
} else if (candidates.size() == 1) {
758+
// add new candidate to vector, keep sorted
759+
if (std::abs(c.sum) < std::abs(candidates.front().sum)) {
760+
candidates.insert(candidates.begin(), c);
761+
} else {
762+
candidates.push_back(c);
763+
}
764+
} else {
765+
// add new candidate if it has either smallest or largest area
766+
if (std::abs(c.sum) < std::abs(candidates.front().sum)) {
767+
candidates.front() = c;
768+
} else if (std::abs(c.sum) > std::abs(candidates.back().sum)) {
769+
candidates.back() = c;
770+
}
771+
}
755772
} else if (loc_done.count(c.stop_location) == 0) {
756773
if (debug()) {
757-
std::cerr << " recurse...\n";
774+
std::cerr << " recurse... (depth=" << depth << " candidates.size=" << candidates.size() << ")\n";
758775
}
759776
loc_done.insert(c.stop_location);
760-
find_candidates(candidates, loc_done, xrings, c);
777+
find_candidates(candidates, loc_done, xrings, c, depth + 1);
761778
loc_done.erase(c.stop_location);
762779
if (debug()) {
763780
std::cerr << " ...back\n";
@@ -800,7 +817,7 @@ namespace osmium {
800817
ring.reset();
801818
}
802819

803-
candidate cand{*ring_min, false};
820+
const candidate cand{*ring_min, false};
804821

805822
// Locations we have visited while finding candidates, used
806823
// to detect loops.
@@ -838,26 +855,20 @@ namespace osmium {
838855
}
839856

840857
// Find the candidate with the smallest/largest area
841-
const auto chosen_cand = ring_min_is_outer ?
842-
std::min_element(candidates.cbegin(), candidates.cend(), [](const candidate& lhs, const candidate& rhs) {
843-
return std::abs(lhs.sum) < std::abs(rhs.sum);
844-
}) :
845-
std::max_element(candidates.cbegin(), candidates.cend(), [](const candidate& lhs, const candidate& rhs) {
846-
return std::abs(lhs.sum) < std::abs(rhs.sum);
847-
});
858+
const auto chosen_cand = ring_min_is_outer ? candidates.front() : candidates.back();
848859

849860
if (debug()) {
850-
std::cerr << " Decided on: sum=" << chosen_cand->sum << "\n";
851-
for (const auto& ring : chosen_cand->rings) {
861+
std::cerr << " Decided on: sum=" << chosen_cand.sum << "\n";
862+
for (const auto& ring : chosen_cand.rings) {
852863
std::cerr << " " << ring.first.ring() << (ring.second ? " reverse" : "") << "\n";
853864
}
854865
}
855866

856867
// Join all (open) rings in the candidate to get one closed ring.
857-
assert(chosen_cand->rings.size() > 1);
858-
const auto& first_ring = chosen_cand->rings.front().first;
868+
assert(chosen_cand.rings.size() > 1);
869+
const auto& first_ring = chosen_cand.rings.front().first;
859870
const ProtoRing& remaining_ring = first_ring.ring();
860-
for (auto it = std::next(chosen_cand->rings.begin()); it != chosen_cand->rings.end(); ++it) {
871+
for (auto it = std::next(chosen_cand.rings.begin()); it != chosen_cand.rings.end(); ++it) {
861872
merge_two_rings(open_ring_its, first_ring, it->first);
862873
}
863874

@@ -1088,7 +1099,7 @@ namespace osmium {
10881099
create_rings_simple_case();
10891100
timer_simple_case.stop();
10901101
} else if (m_split_locations.size() > max_split_locations) {
1091-
if (debug()) {
1102+
if (m_config.debug_level > 0) {
10921103
std::cerr << " Ignoring polygon with "
10931104
<< m_split_locations.size()
10941105
<< " split locations (>"
@@ -1097,8 +1108,10 @@ namespace osmium {
10971108
}
10981109
return false;
10991110
} else {
1100-
if (debug()) {
1101-
std::cerr << " Found split locations -> using complex algorithm\n";
1111+
if (m_config.debug_level > 0) {
1112+
std::cerr << " Found "
1113+
<< m_split_locations.size()
1114+
<< " split locations -> using complex algorithm\n";
11021115
}
11031116
++m_stats.area_touching_rings_case;
11041117

contrib/libosmium/osmium/area/detail/node_ref_segment.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,10 @@ namespace osmium {
102102
NodeRefSegment() noexcept = default;
103103

104104
NodeRefSegment(const osmium::NodeRef& nr1, const osmium::NodeRef& nr2, role_type role, const osmium::Way* way) noexcept :
105-
m_first(nr1),
106-
m_second(nr2),
105+
m_first(nr1.location() < nr2.location() ? nr1 : nr2),
106+
m_second(nr1.location() < nr2.location() ? nr2 : nr1),
107107
m_way(way),
108108
m_role(role) {
109-
if (nr2.location() < nr1.location()) {
110-
using std::swap;
111-
swap(m_first, m_second);
112-
}
113109
}
114110

115111
/**
@@ -206,7 +202,7 @@ namespace osmium {
206202

207203
/**
208204
* The "determinant" of this segment. Used for calculating
209-
* the winding order or a ring.
205+
* the winding order of a ring.
210206
*/
211207
int64_t det() const noexcept {
212208
const vec a{start()};

contrib/libosmium/osmium/area/detail/proto_ring.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,14 @@ namespace osmium {
196196
}
197197

198198
void join_forward(ProtoRing& other) {
199+
m_segments.reserve(m_segments.size() + other.m_segments.size());
199200
for (NodeRefSegment* segment : other.m_segments) {
200201
add_segment_back(segment);
201202
}
202203
}
203204

204205
void join_backward(ProtoRing& other) {
206+
m_segments.reserve(m_segments.size() + other.m_segments.size());
205207
for (auto it = other.m_segments.rbegin(); it != other.m_segments.rend(); ++it) {
206208
(*it)->reverse();
207209
add_segment_back(*it);

contrib/libosmium/osmium/util/options.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ namespace osmium {
147147
return !(value == "false" || value == "no");
148148
}
149149

150+
/**
151+
* Is the set of options empty?
152+
*/
153+
bool empty() const noexcept {
154+
return m_options.empty();
155+
}
156+
150157
/**
151158
* The number of options set.
152159
*/

contrib/libosmium/osmium/version.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
3535

3636
#define LIBOSMIUM_VERSION_MAJOR 2
3737
#define LIBOSMIUM_VERSION_MINOR 15
38-
#define LIBOSMIUM_VERSION_PATCH 3
38+
#define LIBOSMIUM_VERSION_PATCH 4
3939

40-
#define LIBOSMIUM_VERSION_STRING "2.15.3"
40+
#define LIBOSMIUM_VERSION_STRING "2.15.4"
4141

4242
#endif // OSMIUM_VERSION_HPP

0 commit comments

Comments
 (0)