Merge commit 'b91c2f0299722e64a6945808d64c3397c35811d0' into third_party/update_dependencies
This commit is contained in:
+13
-11
@@ -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;
|
||||
|
||||
+17
-1
@@ -167,6 +167,20 @@ namespace osmium {
|
||||
return length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append data to buffer and append an additional \0.
|
||||
*
|
||||
* @param data Pointer to data.
|
||||
* @param length Length of data in bytes.
|
||||
* @returns The number of bytes appended (length + 1).
|
||||
*/
|
||||
osmium::memory::item_size_type append_with_zero(const char* data, const osmium::memory::item_size_type length) {
|
||||
unsigned char* target = reserve_space(length + 1);
|
||||
std::copy_n(reinterpret_cast<const unsigned char*>(data), length, target);
|
||||
target[length] = '\0';
|
||||
return length + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append \0-terminated string to buffer.
|
||||
*
|
||||
@@ -180,9 +194,11 @@ namespace osmium {
|
||||
/**
|
||||
* Append '\0' to the buffer.
|
||||
*
|
||||
* @deprecated Use append_with_zero() instead.
|
||||
*
|
||||
* @returns The number of bytes appended (always 1).
|
||||
*/
|
||||
osmium::memory::item_size_type append_zero() {
|
||||
OSMIUM_DEPRECATED osmium::memory::item_size_type append_zero() {
|
||||
*reserve_space(1) = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,8 @@ namespace osmium {
|
||||
if (std::strlen(value) > osmium::max_osm_string_length) {
|
||||
throw std::length_error("OSM tag value is too long");
|
||||
}
|
||||
add_size(append(key) + append(value));
|
||||
add_size(append(key));
|
||||
add_size(append(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,8 +118,8 @@ namespace osmium {
|
||||
if (value_length > osmium::max_osm_string_length) {
|
||||
throw std::length_error("OSM tag value is too long");
|
||||
}
|
||||
add_size(append(key, osmium::memory::item_size_type(key_length)) + append_zero() +
|
||||
append(value, osmium::memory::item_size_type(value_length)) + append_zero());
|
||||
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)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,8 +135,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) +
|
||||
append(value.data(), osmium::memory::item_size_type(value.size()) + 1));
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +145,8 @@ namespace osmium {
|
||||
* @param tag Tag.
|
||||
*/
|
||||
void add_tag(const osmium::Tag& tag) {
|
||||
add_size(append(tag.key()) + append(tag.value()));
|
||||
add_size(append(tag.key()));
|
||||
add_size(append(tag.value()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +228,7 @@ namespace osmium {
|
||||
throw std::length_error("OSM relation member role is too long");
|
||||
}
|
||||
member.set_role_size(osmium::string_size_type(length) + 1);
|
||||
add_size(append(role, osmium::memory::item_size_type(length)) + append_zero());
|
||||
add_size(append_with_zero(role, osmium::memory::item_size_type(length)));
|
||||
add_padding(true);
|
||||
}
|
||||
|
||||
@@ -310,7 +312,7 @@ namespace osmium {
|
||||
throw std::length_error("OSM user name is too long");
|
||||
}
|
||||
comment.set_user_size(osmium::string_size_type(length) + 1);
|
||||
add_size(append(user, osmium::memory::item_size_type(length)) + append_zero());
|
||||
add_size(append_with_zero(user, osmium::memory::item_size_type(length)));
|
||||
}
|
||||
|
||||
void add_text(osmium::ChangesetComment& comment, const char* text, const size_t length) {
|
||||
@@ -322,7 +324,7 @@ namespace osmium {
|
||||
throw std::length_error("OSM changeset comment is too long");
|
||||
}
|
||||
comment.set_text_size(osmium::string_size_type(length) + 1);
|
||||
add_size(append(text, osmium::memory::item_size_type(length)) + append_zero());
|
||||
add_size(append_with_zero(text, osmium::memory::item_size_type(length)));
|
||||
add_padding(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
+5
-3
@@ -92,6 +92,8 @@ namespace osmium {
|
||||
|
||||
osmium::io::File m_file;
|
||||
|
||||
detail::ParserFactory::create_parser_type m_creator;
|
||||
|
||||
enum class status {
|
||||
okay = 0, // normal reading
|
||||
error = 1, // some error occurred while reading
|
||||
@@ -128,13 +130,12 @@ namespace osmium {
|
||||
}
|
||||
|
||||
// This function will run in a separate thread.
|
||||
static void parser_thread(const osmium::io::File& file,
|
||||
static void parser_thread(const detail::ParserFactory::create_parser_type& creator,
|
||||
detail::future_string_queue_type& input_queue,
|
||||
detail::future_buffer_queue_type& osmdata_queue,
|
||||
std::promise<osmium::io::Header>&& header_promise,
|
||||
osmium::io::detail::reader_options options) {
|
||||
std::promise<osmium::io::Header> promise = std::move(header_promise);
|
||||
const auto creator = detail::ParserFactory::instance().get_creator_function(file);
|
||||
const auto parser = creator(input_queue, osmdata_queue, promise, options);
|
||||
parser->parse();
|
||||
}
|
||||
@@ -236,6 +237,7 @@ namespace osmium {
|
||||
template <typename... TArgs>
|
||||
explicit Reader(const osmium::io::File& file, TArgs&&... args) :
|
||||
m_file(file.check()),
|
||||
m_creator(detail::ParserFactory::instance().get_creator_function(m_file)),
|
||||
m_status(status::okay),
|
||||
m_childpid(0),
|
||||
m_input_queue(detail::get_input_queue_size(), "raw_input"),
|
||||
@@ -256,7 +258,7 @@ namespace osmium {
|
||||
|
||||
std::promise<osmium::io::Header> header_promise;
|
||||
m_header_future = header_promise.get_future();
|
||||
m_thread = osmium::thread::thread_handler{parser_thread, std::ref(m_file), std::ref(m_input_queue), std::ref(m_osmdata_queue), std::move(header_promise), m_options};
|
||||
m_thread = osmium::thread::thread_handler{parser_thread, std::ref(m_creator), std::ref(m_input_queue), std::ref(m_osmdata_queue), std::move(header_promise), m_options};
|
||||
}
|
||||
|
||||
template <typename... TArgs>
|
||||
|
||||
+12
-3
@@ -119,6 +119,15 @@ namespace osmium {
|
||||
auto_grow m_auto_grow{auto_grow::no};
|
||||
std::function<void(Buffer&)> m_full;
|
||||
|
||||
static size_t calculate_capacity(size_t capacity) noexcept {
|
||||
// The majority of all Nodes will fit into this size.
|
||||
constexpr static const size_t min_capacity = 64;
|
||||
if (capacity < min_capacity) {
|
||||
return min_capacity;
|
||||
}
|
||||
return capacity;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@@ -198,13 +207,13 @@ namespace osmium {
|
||||
* of the alignment.
|
||||
*/
|
||||
explicit Buffer(size_t capacity, auto_grow auto_grow = auto_grow::yes) :
|
||||
m_memory(new unsigned char[capacity]),
|
||||
m_memory(new unsigned char[calculate_capacity(capacity)]),
|
||||
m_data(m_memory.get()),
|
||||
m_capacity(capacity),
|
||||
m_capacity(calculate_capacity(capacity)),
|
||||
m_written(0),
|
||||
m_committed(0),
|
||||
m_auto_grow(auto_grow) {
|
||||
if (capacity % align_bytes != 0) {
|
||||
if (m_capacity % align_bytes != 0) {
|
||||
throw std::invalid_argument("buffer capacity needs to be multiple of alignment");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ namespace osmium {
|
||||
* Return the number of rules in this filter.
|
||||
*/
|
||||
size_t count() const {
|
||||
return m_rules.count();
|
||||
return m_rules.size();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#define LIBOSMIUM_VERSION_MAJOR 2
|
||||
#define LIBOSMIUM_VERSION_MINOR 11
|
||||
#define LIBOSMIUM_VERSION_PATCH 0
|
||||
#define LIBOSMIUM_VERSION_PATCH 3
|
||||
|
||||
#define LIBOSMIUM_VERSION_STRING "2.11.0"
|
||||
#define LIBOSMIUM_VERSION_STRING "2.11.3"
|
||||
|
||||
#endif // OSMIUM_VERSION_HPP
|
||||
|
||||
Reference in New Issue
Block a user