Merge commit 'a3a7a822e136d2357660d85124d8e7bb26ea6f7c' into subtrees-protozero-vtzero
This commit is contained in:
+5
-7
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,10 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/area/assembler_config.hpp>
|
||||
#include <osmium/area/detail/basic_assembler_with_tags.hpp>
|
||||
#include <osmium/area/detail/segment_list.hpp>
|
||||
@@ -50,6 +46,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/tag.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace area {
|
||||
@@ -111,8 +111,6 @@ namespace osmium {
|
||||
detail::BasicAssemblerWithTags(config) {
|
||||
}
|
||||
|
||||
~Assembler() noexcept = default;
|
||||
|
||||
/**
|
||||
* Assemble an area from the given way.
|
||||
* The resulting area is put into the out_buffer.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+14
-16
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,18 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/area/assembler_config.hpp>
|
||||
#include <osmium/area/detail/basic_assembler_with_tags.hpp>
|
||||
#include <osmium/area/detail/proto_ring.hpp>
|
||||
@@ -62,6 +50,18 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/way.hpp>
|
||||
#include <osmium/tags/filter.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace area {
|
||||
@@ -207,8 +207,6 @@ namespace osmium {
|
||||
detail::BasicAssemblerWithTags(config) {
|
||||
}
|
||||
|
||||
~AssemblerLegacy() noexcept = default;
|
||||
|
||||
/**
|
||||
* Assemble an area from the given way.
|
||||
* The resulting area is put into the out_buffer.
|
||||
@@ -335,7 +333,7 @@ namespace osmium {
|
||||
if (stats().wrong_role == 0) {
|
||||
detail::for_each_member(relation, members, [this, &ways_that_should_be_areas, &area_tags](const osmium::RelationMember& member, const osmium::Way& way) {
|
||||
if (!std::strcmp(member.role(), "inner")) {
|
||||
if (!way.nodes().empty() && way.is_closed() && way.tags().size() > 0) {
|
||||
if (!way.nodes().empty() && way.is_closed() && !way.tags().empty()) {
|
||||
const auto d = std::count_if(way.tags().cbegin(), way.tags().cend(), std::cref(filter()));
|
||||
if (d > 0) {
|
||||
osmium::tags::KeyFilter::iterator way_fi_begin(std::cref(filter()), way.tags().cbegin(), way.tags().cend());
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,6 +33,20 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/area/assembler_config.hpp>
|
||||
#include <osmium/area/detail/node_ref_segment.hpp>
|
||||
#include <osmium/area/detail/proto_ring.hpp>
|
||||
#include <osmium/area/detail/segment_list.hpp>
|
||||
#include <osmium/area/problem_reporter.hpp>
|
||||
#include <osmium/area/stats.hpp>
|
||||
#include <osmium/builder/osm_object_builder.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
#include <osmium/util/iterator.hpp>
|
||||
#include <osmium/util/timer.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
@@ -45,21 +59,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/builder/osm_object_builder.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
#include <osmium/util/iterator.hpp>
|
||||
#include <osmium/util/timer.hpp>
|
||||
|
||||
#include <osmium/area/assembler_config.hpp>
|
||||
#include <osmium/area/detail/node_ref_segment.hpp>
|
||||
#include <osmium/area/detail/proto_ring.hpp>
|
||||
#include <osmium/area/detail/segment_list.hpp>
|
||||
#include <osmium/area/problem_reporter.hpp>
|
||||
#include <osmium/area/stats.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace area {
|
||||
@@ -70,19 +69,17 @@ namespace osmium {
|
||||
|
||||
struct location_to_ring_map {
|
||||
osmium::Location location;
|
||||
open_ring_its_type::iterator ring_it;
|
||||
bool start;
|
||||
open_ring_its_type::iterator ring_it{};
|
||||
bool start{false};
|
||||
|
||||
location_to_ring_map(const osmium::Location& l, const open_ring_its_type::iterator& r, bool s) noexcept :
|
||||
location_to_ring_map(osmium::Location l, open_ring_its_type::iterator r, const bool s) noexcept :
|
||||
location(l),
|
||||
ring_it(r),
|
||||
start(s) {
|
||||
}
|
||||
|
||||
explicit location_to_ring_map(const osmium::Location& l) noexcept :
|
||||
location(l),
|
||||
ring_it(),
|
||||
start(false) {
|
||||
explicit location_to_ring_map(osmium::Location l) noexcept :
|
||||
location(l) {
|
||||
}
|
||||
|
||||
const ProtoRing& ring() const noexcept {
|
||||
@@ -108,7 +105,7 @@ namespace osmium {
|
||||
|
||||
struct slocation {
|
||||
|
||||
static constexpr const uint32_t invalid_item = 1 << 30;
|
||||
static constexpr const uint32_t invalid_item = 1u << 30u;
|
||||
|
||||
uint32_t item : 31;
|
||||
uint32_t reverse : 1;
|
||||
@@ -320,7 +317,7 @@ namespace osmium {
|
||||
const int64_t ly = end_location.y();
|
||||
const auto z = (bx - ax)*(ly - ay) - (by - ay)*(lx - ax);
|
||||
if (debug()) {
|
||||
std::cerr << " Segment XXXX z=" << z << "\n";
|
||||
std::cerr << " Segment z=" << z << '\n';
|
||||
}
|
||||
if (z > 0) {
|
||||
nesting += segment->is_reverse() ? -1 : 1;
|
||||
@@ -623,8 +620,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) {
|
||||
std::list<ProtoRing>::iterator r1 = *m1.ring_it;
|
||||
std::list<ProtoRing>::iterator r2 = *m2.ring_it;
|
||||
const auto r1 = *m1.ring_it;
|
||||
const auto r2 = *m2.ring_it;
|
||||
|
||||
if (r1->get_node_ref_stop().location() == r2->get_node_ref_start().location()) {
|
||||
r1->join_forward(*r2);
|
||||
@@ -689,13 +686,12 @@ namespace osmium {
|
||||
|
||||
struct candidate {
|
||||
int64_t sum;
|
||||
std::vector<std::pair<location_to_ring_map, bool>> rings;
|
||||
std::vector<std::pair<location_to_ring_map, bool>> rings{};
|
||||
osmium::Location start_location;
|
||||
osmium::Location stop_location;
|
||||
|
||||
explicit candidate(location_to_ring_map& ring, bool reverse) :
|
||||
sum(ring.ring().sum()),
|
||||
rings(),
|
||||
start_location(ring.ring().get_node_ref_start().location()),
|
||||
stop_location(ring.ring().get_node_ref_stop().location()) {
|
||||
rings.emplace_back(ring, reverse);
|
||||
@@ -813,8 +809,8 @@ namespace osmium {
|
||||
++m_stats.open_rings;
|
||||
if (m_config.problem_reporter) {
|
||||
for (auto& it : open_ring_its) {
|
||||
m_config.problem_reporter->report_ring_not_closed(it->get_node_ref_start());
|
||||
m_config.problem_reporter->report_ring_not_closed(it->get_node_ref_stop());
|
||||
m_config.problem_reporter->report_ring_not_closed(it->get_node_ref_start(), nullptr);
|
||||
m_config.problem_reporter->report_ring_not_closed(it->get_node_ref_stop(), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -939,20 +935,6 @@ namespace osmium {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if any ways were completely removed in the
|
||||
* erase_duplicate_segments step.
|
||||
*/
|
||||
bool ways_were_lost() {
|
||||
std::unordered_set<const osmium::Way*> ways_in_segments;
|
||||
|
||||
for (const auto& segment : m_segment_list) {
|
||||
ways_in_segments.insert(segment.way());
|
||||
}
|
||||
|
||||
return ways_in_segments.size() < m_num_members;
|
||||
}
|
||||
|
||||
#ifdef OSMIUM_WITH_TIMER
|
||||
static bool print_header() {
|
||||
std::cout << "nodes outer_rings inner_rings sort dupl intersection locations split simple_case complex_case roles_check\n";
|
||||
@@ -1022,15 +1004,6 @@ namespace osmium {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If one or more complete ways was removed because of
|
||||
// duplicate segments, this isn't a valid area.
|
||||
if (ways_were_lost()) {
|
||||
if (debug()) {
|
||||
std::cerr << " Complete ways removed because of duplicate segments\n";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_config.debug_level >= 3) {
|
||||
std::cerr << "Sorted de-duplicated segment list:\n";
|
||||
for (const auto& s : m_segment_list) {
|
||||
@@ -1170,8 +1143,6 @@ namespace osmium {
|
||||
#endif
|
||||
}
|
||||
|
||||
~BasicAssembler() noexcept = default;
|
||||
|
||||
const AssemblerConfig& config() const noexcept {
|
||||
return m_config;
|
||||
}
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <osmium/area/assembler_config.hpp>
|
||||
#include <osmium/area/detail/basic_assembler.hpp>
|
||||
#include <osmium/area/stats.hpp>
|
||||
#include <osmium/builder/osm_object_builder.hpp>
|
||||
#include <osmium/osm/tag.hpp>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace area {
|
||||
@@ -68,7 +68,7 @@ namespace osmium {
|
||||
static void copy_tags_without_type(osmium::builder::AreaBuilder& builder, const osmium::TagList& tags) {
|
||||
osmium::builder::TagListBuilder tl_builder{builder};
|
||||
for (const osmium::Tag& tag : tags) {
|
||||
if (std::strcmp(tag.key(), "type")) {
|
||||
if (std::strcmp(tag.key(), "type") != 0) {
|
||||
tl_builder.add_tag(tag.key(), tag.value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/area/detail/vector.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <iosfwd>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/area/detail/vector.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
class Way;
|
||||
@@ -74,20 +74,20 @@ namespace osmium {
|
||||
class NodeRefSegment {
|
||||
|
||||
// First node in order described above.
|
||||
osmium::NodeRef m_first;
|
||||
osmium::NodeRef m_first{};
|
||||
|
||||
// Second node in order described above.
|
||||
osmium::NodeRef m_second;
|
||||
osmium::NodeRef m_second{};
|
||||
|
||||
// Way this segment was from.
|
||||
const osmium::Way* m_way;
|
||||
const osmium::Way* m_way = nullptr;
|
||||
|
||||
// The ring this segment is part of. Initially nullptr, this
|
||||
// will be filled in once we know which ring the segment is in.
|
||||
ProtoRing* m_ring;
|
||||
ProtoRing* m_ring = nullptr;
|
||||
|
||||
// The role of this segment from the member role.
|
||||
role_type m_role;
|
||||
role_type m_role = role_type::unknown;
|
||||
|
||||
// Nodes have to be reversed to get the intended order.
|
||||
bool m_reverse = false;
|
||||
@@ -98,19 +98,12 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
NodeRefSegment() noexcept :
|
||||
m_first(),
|
||||
m_second(),
|
||||
m_way(nullptr),
|
||||
m_ring(nullptr),
|
||||
m_role(role_type::unknown) {
|
||||
}
|
||||
NodeRefSegment() noexcept = default;
|
||||
|
||||
NodeRefSegment(const osmium::NodeRef& nr1, const osmium::NodeRef& nr2, role_type role, const osmium::Way* way) noexcept :
|
||||
m_first(nr1),
|
||||
m_second(nr2),
|
||||
m_way(way),
|
||||
m_ring(nullptr),
|
||||
m_role(role) {
|
||||
if (nr2.location() < nr1.location()) {
|
||||
using std::swap;
|
||||
@@ -303,7 +296,7 @@ namespace osmium {
|
||||
* or a defined Location if the segments intersect.
|
||||
*/
|
||||
inline osmium::Location calculate_intersection(const NodeRefSegment& s1, const NodeRefSegment& s2) noexcept {
|
||||
// See http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
|
||||
// See https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
|
||||
// for some hints about how the algorithm works.
|
||||
const vec p0{s1.first()};
|
||||
const vec p1{s1.second()};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,6 +33,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/area/detail/node_ref_segment.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
@@ -40,10 +44,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/area/detail/node_ref_segment.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
class Way;
|
||||
@@ -64,18 +64,18 @@ namespace osmium {
|
||||
private:
|
||||
|
||||
// Segments in this ring.
|
||||
segments_type m_segments;
|
||||
segments_type m_segments{};
|
||||
|
||||
// If this is an outer ring, these point to it's inner rings
|
||||
// (if any).
|
||||
std::vector<ProtoRing*> m_inner;
|
||||
std::vector<ProtoRing*> m_inner{};
|
||||
|
||||
// The smallest segment. Will be kept current whenever a new
|
||||
// segment is added to the ring.
|
||||
NodeRefSegment* m_min_segment;
|
||||
|
||||
// If this is an inner ring, points to the outer ring.
|
||||
ProtoRing* m_outer_ring;
|
||||
ProtoRing* m_outer_ring = nullptr;
|
||||
|
||||
#ifdef OSMIUM_DEBUG_RING_NO
|
||||
static int64_t next_num() noexcept {
|
||||
@@ -91,10 +91,7 @@ namespace osmium {
|
||||
public:
|
||||
|
||||
explicit ProtoRing(NodeRefSegment* segment) noexcept :
|
||||
m_segments(),
|
||||
m_inner(),
|
||||
m_min_segment(segment),
|
||||
m_outer_ring(nullptr),
|
||||
#ifdef OSMIUM_DEBUG_RING_NO
|
||||
m_num(next_num()),
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,6 +33,15 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/area/detail/node_ref_segment.hpp>
|
||||
#include <osmium/area/problem_reporter.hpp>
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/relation.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
@@ -43,15 +52,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/area/detail/node_ref_segment.hpp>
|
||||
#include <osmium/area/problem_reporter.hpp>
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/relation.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace area {
|
||||
@@ -84,7 +84,7 @@ namespace osmium {
|
||||
|
||||
using slist_type = std::vector<NodeRefSegment>;
|
||||
|
||||
slist_type m_segments;
|
||||
slist_type m_segments{};
|
||||
|
||||
bool m_debug;
|
||||
|
||||
@@ -144,7 +144,6 @@ namespace osmium {
|
||||
public:
|
||||
|
||||
explicit SegmentList(bool debug) noexcept :
|
||||
m_segments(),
|
||||
m_debug(debug) {
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,12 +33,12 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace area {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,11 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/area/stats.hpp>
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
@@ -48,6 +43,11 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/way.hpp>
|
||||
#include <osmium/relations/collector.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace relations {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,13 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/area/stats.hpp>
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/relation.hpp>
|
||||
@@ -53,6 +46,13 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/tags/taglist.hpp>
|
||||
#include <osmium/tags/tags_filter.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
/**
|
||||
@@ -93,9 +93,9 @@ namespace osmium {
|
||||
* needed on closed ways or multipolygon relations
|
||||
* to build the area.
|
||||
*/
|
||||
explicit MultipolygonManager(const assembler_config_type& assembler_config, const osmium::TagsFilter& filter = osmium::TagsFilter{true}) :
|
||||
m_assembler_config(assembler_config),
|
||||
m_filter(filter) {
|
||||
explicit MultipolygonManager(assembler_config_type assembler_config, osmium::TagsFilter filter = osmium::TagsFilter{true}) :
|
||||
m_assembler_config(std::move(assembler_config)),
|
||||
m_filter(std::move(filter)) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,13 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/area/stats.hpp>
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/handler/check_order.hpp>
|
||||
@@ -55,6 +48,13 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/relations/relations_manager.hpp>
|
||||
#include <osmium/storage/item_stash.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,12 +33,12 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
class NodeRef;
|
||||
@@ -62,18 +62,24 @@ namespace osmium {
|
||||
protected:
|
||||
|
||||
// Type of object we are currently working on
|
||||
osmium::item_type m_object_type;
|
||||
osmium::item_type m_object_type = osmium::item_type::undefined;
|
||||
|
||||
// ID of the relation/way we are currently working on
|
||||
osmium::object_id_type m_object_id;
|
||||
osmium::object_id_type m_object_id = 0;
|
||||
|
||||
// Number of nodes in the area
|
||||
size_t m_nodes;
|
||||
size_t m_nodes = 0;
|
||||
|
||||
public:
|
||||
|
||||
ProblemReporter() = default;
|
||||
|
||||
ProblemReporter(const ProblemReporter&) = default;
|
||||
ProblemReporter& operator=(const ProblemReporter&) = default;
|
||||
|
||||
ProblemReporter(ProblemReporter&&) noexcept = default;
|
||||
ProblemReporter& operator=(ProblemReporter&&) noexcept = default;
|
||||
|
||||
virtual ~ProblemReporter() = default;
|
||||
|
||||
/**
|
||||
@@ -161,7 +167,7 @@ namespace osmium {
|
||||
* @param nr NodeRef of one end of the ring.
|
||||
* @param way Optional pointer to way the end node is in.
|
||||
*/
|
||||
virtual void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way = nullptr) {
|
||||
virtual void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,13 +33,13 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <osmium/area/problem_reporter_stream.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
class NodeRef;
|
||||
@@ -57,8 +57,6 @@ namespace osmium {
|
||||
ProblemReporterStream(m_sstream) {
|
||||
}
|
||||
|
||||
~ProblemReporterException() override = default;
|
||||
|
||||
void report_duplicate_node(osmium::object_id_type node_id1, osmium::object_id_type node_id2, osmium::Location location) override {
|
||||
m_sstream.str("");
|
||||
ProblemReporterStream::report_duplicate_node(node_id1, node_id2, location);
|
||||
@@ -90,7 +88,7 @@ namespace osmium {
|
||||
throw std::runtime_error{m_sstream.str()};
|
||||
}
|
||||
|
||||
void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way = nullptr) override {
|
||||
void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way) override {
|
||||
m_sstream.str("");
|
||||
ProblemReporterStream::report_ring_not_closed(nr, way);
|
||||
throw std::runtime_error{m_sstream.str()};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -42,10 +42,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
* @attention If you include this file, you'll need to link with `libgdal`.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <gdalcpp.hpp>
|
||||
|
||||
#include <osmium/area/problem_reporter.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
#include <osmium/geom/ogr.hpp>
|
||||
@@ -56,6 +52,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <gdalcpp.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace area {
|
||||
@@ -137,8 +137,6 @@ namespace osmium {
|
||||
;
|
||||
}
|
||||
|
||||
~ProblemReporterOGR() override = default;
|
||||
|
||||
void report_duplicate_node(osmium::object_id_type node_id1, osmium::object_id_type node_id2, osmium::Location location) override {
|
||||
write_point("duplicate_node", node_id1, node_id2, location);
|
||||
}
|
||||
@@ -162,7 +160,7 @@ namespace osmium {
|
||||
write_line("overlapping_segment", nr1.ref(), nr2.ref(), nr1.location(), nr2.location());
|
||||
}
|
||||
|
||||
void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way = nullptr) override {
|
||||
void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way) override {
|
||||
write_point("ring_not_closed", nr.ref(), way ? way->id() : 0, nr.location());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,8 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include <osmium/area/problem_reporter.hpp>
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
@@ -42,6 +40,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace area {
|
||||
@@ -56,8 +56,6 @@ namespace osmium {
|
||||
m_out(&out) {
|
||||
}
|
||||
|
||||
~ProblemReporterStream() override = default;
|
||||
|
||||
void header(const char* msg) {
|
||||
*m_out << "DATA PROBLEM: " << msg << " on " << item_type_to_char(m_object_type) << m_object_id << " (with " << m_nodes << " nodes): ";
|
||||
}
|
||||
@@ -91,7 +89,7 @@ namespace osmium {
|
||||
<< " node_id2=" << nr2.ref() << " location2=" << nr2.location() << "\n";
|
||||
}
|
||||
|
||||
void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way = nullptr) override {
|
||||
void report_ring_not_closed(const osmium::NodeRef& nr, const osmium::Way* way) override {
|
||||
header("ring not closed");
|
||||
*m_out << "node_id=" << nr.ref() << " location=" << nr.location();
|
||||
if (way) {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+74
-44
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,16 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/builder/builder.hpp>
|
||||
#include <osmium/builder/osm_object_builder.hpp>
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
@@ -56,6 +46,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/timestamp.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace builder {
|
||||
@@ -94,13 +94,13 @@ namespace osmium {
|
||||
};
|
||||
#else
|
||||
// True if Predicate matches for none of the types Ts
|
||||
template <template<typename> class Predicate, typename... Ts>
|
||||
template <template <typename> class Predicate, typename... Ts>
|
||||
struct static_none_of : std::is_same<std::tuple<std::false_type, typename Predicate<Ts>::type...>,
|
||||
std::tuple<typename Predicate<Ts>::type..., std::false_type>>
|
||||
{};
|
||||
|
||||
// True if Predicate matches for all of the types Ts
|
||||
template <template<typename> class Predicate, typename... Ts>
|
||||
template <template <typename> class Predicate, typename... Ts>
|
||||
struct static_all_of : std::is_same<std::tuple<std::true_type, typename Predicate<Ts>::type...>,
|
||||
std::tuple<typename Predicate<Ts>::type..., std::true_type>>
|
||||
{};
|
||||
@@ -364,17 +364,21 @@ namespace osmium {
|
||||
|
||||
template <typename TTagIterator>
|
||||
inline constexpr detail::tags_from_iterator_pair<TTagIterator> _tags(TTagIterator first, TTagIterator last) {
|
||||
return detail::tags_from_iterator_pair<TTagIterator>(first, last);
|
||||
return {first, last};
|
||||
}
|
||||
|
||||
template <typename TContainer>
|
||||
inline detail::tags_from_iterator_pair<typename TContainer::const_iterator> _tags(const TContainer& container) {
|
||||
return detail::tags_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
using tag_ilist = std::initializer_list<std::pair<const char*, const char*>>;
|
||||
inline detail::tags_from_iterator_pair<tag_ilist::const_iterator> _tags(const tag_ilist& container) {
|
||||
return detail::tags_from_iterator_pair<tag_ilist::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
|
||||
@@ -388,22 +392,28 @@ namespace osmium {
|
||||
|
||||
template <typename TIdIterator>
|
||||
inline constexpr detail::nodes_from_iterator_pair<TIdIterator> _nodes(TIdIterator first, TIdIterator last) {
|
||||
return detail::nodes_from_iterator_pair<TIdIterator>(first, last);
|
||||
return {first, last};
|
||||
}
|
||||
|
||||
template <typename TContainer>
|
||||
inline detail::nodes_from_iterator_pair<typename TContainer::const_iterator> _nodes(const TContainer& container) {
|
||||
return detail::nodes_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
using object_id_ilist = std::initializer_list<osmium::object_id_type>;
|
||||
inline detail::nodes_from_iterator_pair<object_id_ilist::const_iterator> _nodes(const object_id_ilist& container) {
|
||||
return detail::nodes_from_iterator_pair<object_id_ilist::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
using node_ref_ilist = std::initializer_list<osmium::NodeRef>;
|
||||
inline detail::nodes_from_iterator_pair<node_ref_ilist::const_iterator> _nodes(const node_ref_ilist& container) {
|
||||
return detail::nodes_from_iterator_pair<node_ref_ilist::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
|
||||
@@ -422,17 +432,21 @@ namespace osmium {
|
||||
|
||||
template <typename TMemberIterator>
|
||||
inline constexpr detail::members_from_iterator_pair<TMemberIterator> _members(TMemberIterator first, TMemberIterator last) {
|
||||
return detail::members_from_iterator_pair<TMemberIterator>(first, last);
|
||||
return {first, last};
|
||||
}
|
||||
|
||||
template <typename TContainer>
|
||||
inline detail::members_from_iterator_pair<typename TContainer::const_iterator> _members(const TContainer& container) {
|
||||
return detail::members_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
using member_ilist = std::initializer_list<member_type>;
|
||||
inline detail::members_from_iterator_pair<member_ilist::const_iterator> _members(const member_ilist& container) {
|
||||
return detail::members_from_iterator_pair<member_ilist::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
|
||||
@@ -450,58 +464,74 @@ namespace osmium {
|
||||
|
||||
template <typename TCommentIterator>
|
||||
inline constexpr detail::comments_from_iterator_pair<TCommentIterator> _comments(TCommentIterator first, TCommentIterator last) {
|
||||
return detail::comments_from_iterator_pair<TCommentIterator>(first, last);
|
||||
return {first, last};
|
||||
}
|
||||
|
||||
template <typename TContainer>
|
||||
inline detail::comments_from_iterator_pair<typename TContainer::const_iterator> _comments(const TContainer& container) {
|
||||
return detail::comments_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
using comment_ilist = std::initializer_list<comment_type>;
|
||||
inline detail::comments_from_iterator_pair<comment_ilist::const_iterator> _comments(const comment_ilist& container) {
|
||||
return detail::comments_from_iterator_pair<comment_ilist::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
|
||||
template <typename TIdIterator>
|
||||
inline constexpr detail::outer_ring_from_iterator_pair<TIdIterator> _outer_ring(TIdIterator first, TIdIterator last) {
|
||||
return detail::outer_ring_from_iterator_pair<TIdIterator>(first, last);
|
||||
return {first, last};
|
||||
}
|
||||
|
||||
template <typename TContainer>
|
||||
inline detail::outer_ring_from_iterator_pair<typename TContainer::const_iterator> _outer_ring(const TContainer& container) {
|
||||
return detail::outer_ring_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
using object_id_ilist = std::initializer_list<osmium::object_id_type>;
|
||||
inline detail::outer_ring_from_iterator_pair<object_id_ilist::const_iterator> _outer_ring(const object_id_ilist& container) {
|
||||
return detail::outer_ring_from_iterator_pair<object_id_ilist::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
using node_ref_ilist = std::initializer_list<osmium::NodeRef>;
|
||||
inline detail::outer_ring_from_iterator_pair<node_ref_ilist::const_iterator> _outer_ring(const node_ref_ilist& container) {
|
||||
return detail::outer_ring_from_iterator_pair<node_ref_ilist::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
template <typename TIdIterator>
|
||||
inline constexpr detail::inner_ring_from_iterator_pair<TIdIterator> _inner_ring(TIdIterator first, TIdIterator last) {
|
||||
return detail::inner_ring_from_iterator_pair<TIdIterator>(first, last);
|
||||
return {first, last};
|
||||
}
|
||||
|
||||
template <typename TContainer>
|
||||
inline detail::inner_ring_from_iterator_pair<typename TContainer::const_iterator> _inner_ring(const TContainer& container) {
|
||||
return detail::inner_ring_from_iterator_pair<typename TContainer::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
using object_id_ilist = std::initializer_list<osmium::object_id_type>;
|
||||
inline detail::inner_ring_from_iterator_pair<object_id_ilist::const_iterator> _inner_ring(const object_id_ilist& container) {
|
||||
return detail::inner_ring_from_iterator_pair<object_id_ilist::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
using node_ref_ilist = std::initializer_list<osmium::NodeRef>;
|
||||
inline detail::inner_ring_from_iterator_pair<node_ref_ilist::const_iterator> _inner_ring(const node_ref_ilist& container) {
|
||||
return detail::inner_ring_from_iterator_pair<node_ref_ilist::const_iterator>(std::begin(container), std::end(container));
|
||||
using std::begin;
|
||||
using std::end;
|
||||
return {begin(container), end(container)};
|
||||
}
|
||||
|
||||
|
||||
@@ -516,7 +546,7 @@ namespace osmium {
|
||||
struct changeset_handler : public entity_handler {
|
||||
|
||||
template <typename TDummy>
|
||||
static void set_value(osmium::Changeset&, const TDummy&) noexcept {
|
||||
static void set_value(osmium::Changeset& /*changeset*/, const TDummy& /*dummy*/) noexcept {
|
||||
}
|
||||
|
||||
static void set_value(osmium::Changeset& changeset, attr::_cid id) noexcept {
|
||||
@@ -548,7 +578,7 @@ namespace osmium {
|
||||
struct object_handler : public entity_handler {
|
||||
|
||||
template <typename TDummy>
|
||||
static void set_value(osmium::OSMObject&, const TDummy&) noexcept {
|
||||
static void set_value(osmium::OSMObject& /*object*/, const TDummy& /*dummy*/) noexcept {
|
||||
}
|
||||
|
||||
static void set_value(osmium::OSMObject& object, attr::_id id) noexcept {
|
||||
@@ -601,7 +631,7 @@ namespace osmium {
|
||||
// ==============================================================
|
||||
|
||||
template <typename... TArgs>
|
||||
inline constexpr const char* get_user(const attr::_user& user, const TArgs&...) noexcept {
|
||||
inline constexpr const char* get_user(const attr::_user& user, const TArgs&... /*args*/) noexcept {
|
||||
return user.value;
|
||||
}
|
||||
|
||||
@@ -611,7 +641,7 @@ namespace osmium {
|
||||
|
||||
template <typename TFirst, typename... TRest>
|
||||
inline constexpr typename std::enable_if<!std::is_same<attr::_user, TFirst>::value, const char*>::type
|
||||
get_user(const TFirst&, const TRest&... args) noexcept {
|
||||
get_user(const TFirst& /*first*/, const TRest&... args) noexcept {
|
||||
return get_user(args...);
|
||||
}
|
||||
|
||||
@@ -625,7 +655,7 @@ namespace osmium {
|
||||
struct tags_handler {
|
||||
|
||||
template <typename TDummy>
|
||||
static void set_value(TagListBuilder&, const TDummy&) noexcept {
|
||||
static void set_value(TagListBuilder& /*tlb*/, const TDummy& /*dummy*/) noexcept {
|
||||
}
|
||||
|
||||
static void set_value(TagListBuilder& builder, const attr::_tag& tag) {
|
||||
@@ -644,7 +674,7 @@ namespace osmium {
|
||||
struct nodes_handler {
|
||||
|
||||
template <typename TDummy>
|
||||
static void set_value(WayNodeListBuilder&, const TDummy&) noexcept {
|
||||
static void set_value(WayNodeListBuilder& /*wnlb*/, const TDummy& /*dummy*/) noexcept {
|
||||
}
|
||||
|
||||
static void set_value(WayNodeListBuilder& builder, const attr::_node& node_ref) {
|
||||
@@ -663,7 +693,7 @@ namespace osmium {
|
||||
struct members_handler {
|
||||
|
||||
template <typename TDummy>
|
||||
static void set_value(RelationMemberListBuilder&, const TDummy&) noexcept {
|
||||
static void set_value(RelationMemberListBuilder& /*rmlb*/, const TDummy& /*dummy*/) noexcept {
|
||||
}
|
||||
|
||||
static void set_value(RelationMemberListBuilder& builder, const attr::_member& member) {
|
||||
@@ -682,7 +712,7 @@ namespace osmium {
|
||||
struct discussion_handler {
|
||||
|
||||
template <typename TDummy>
|
||||
static void set_value(ChangesetDiscussionBuilder&, const TDummy&) noexcept {
|
||||
static void set_value(ChangesetDiscussionBuilder& /*cdb*/, const TDummy& /*dummy*/) noexcept {
|
||||
}
|
||||
|
||||
static void set_value(ChangesetDiscussionBuilder& builder, const attr::_comment& comment) {
|
||||
@@ -703,7 +733,7 @@ namespace osmium {
|
||||
struct ring_handler {
|
||||
|
||||
template <typename TDummy>
|
||||
static void set_value(AreaBuilder&, const TDummy&) noexcept {
|
||||
static void set_value(AreaBuilder& /*ab*/, const TDummy& /*dummy*/) noexcept {
|
||||
}
|
||||
|
||||
template <typename TIterator>
|
||||
@@ -728,7 +758,7 @@ namespace osmium {
|
||||
|
||||
template <typename TBuilder, typename THandler, typename... TArgs>
|
||||
inline typename std::enable_if<!is_handled_by<THandler, TArgs...>::value>::type
|
||||
add_list(osmium::builder::Builder&, const TArgs&...) noexcept {
|
||||
add_list(osmium::builder::Builder& /*parent*/, const TArgs&... /*args*/) noexcept {
|
||||
}
|
||||
|
||||
template <typename TBuilder, typename THandler, typename... TArgs>
|
||||
|
||||
+11
-11
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
#include <osmium/memory/item.hpp>
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
#include <osmium/memory/item.hpp>
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
/**
|
||||
@@ -60,12 +60,6 @@ namespace osmium {
|
||||
Builder* m_parent;
|
||||
std::size_t m_item_offset;
|
||||
|
||||
Builder(const Builder&) = delete;
|
||||
Builder(Builder&&) = delete;
|
||||
|
||||
Builder& operator=(const Builder&) = delete;
|
||||
Builder& operator=(Builder&&) = delete;
|
||||
|
||||
protected:
|
||||
|
||||
explicit Builder(osmium::memory::Buffer& buffer, Builder* parent, osmium::memory::item_size_type size) :
|
||||
@@ -203,6 +197,12 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
Builder(const Builder&) = delete;
|
||||
Builder(Builder&&) = delete;
|
||||
|
||||
Builder& operator=(const Builder&) = delete;
|
||||
Builder& operator=(Builder&&) = delete;
|
||||
|
||||
/// Return the buffer this builder is using.
|
||||
osmium::memory::Buffer& buffer() noexcept {
|
||||
return m_buffer;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <initializer_list>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/builder/osm_object_builder.hpp>
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
class NodeRef;
|
||||
@@ -103,7 +103,7 @@ namespace osmium {
|
||||
* @deprecated
|
||||
* Use osmium::builder::add_tag_list() instead.
|
||||
*/
|
||||
OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list_from_func(osmium::memory::Buffer& buffer, std::function<void(osmium::builder::TagListBuilder&)> func) {
|
||||
OSMIUM_DEPRECATED inline const osmium::TagList& build_tag_list_from_func(osmium::memory::Buffer& buffer, const std::function<void(osmium::builder::TagListBuilder&)>& func) {
|
||||
const size_t pos = buffer.committed();
|
||||
{
|
||||
osmium::builder::TagListBuilder tl_builder(buffer);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,18 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <initializer_list>
|
||||
#include <limits>
|
||||
#include <new>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/builder/builder.hpp>
|
||||
#include <osmium/memory/item.hpp>
|
||||
#include <osmium/osm/area.hpp>
|
||||
@@ -60,9 +48,20 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/timestamp.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
#include <osmium/util/cast.hpp>
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <initializer_list>
|
||||
#include <limits>
|
||||
#include <new>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace memory {
|
||||
@@ -85,6 +84,12 @@ namespace osmium {
|
||||
new (&item()) TagList{};
|
||||
}
|
||||
|
||||
TagListBuilder(const TagListBuilder&) = delete;
|
||||
TagListBuilder& operator=(const TagListBuilder&) = delete;
|
||||
|
||||
TagListBuilder(TagListBuilder&&) = delete;
|
||||
TagListBuilder& operator=(TagListBuilder&&) = delete;
|
||||
|
||||
~TagListBuilder() {
|
||||
add_padding();
|
||||
}
|
||||
@@ -196,6 +201,12 @@ namespace osmium {
|
||||
new (&item()) T{};
|
||||
}
|
||||
|
||||
NodeRefListBuilder(const NodeRefListBuilder&) = delete;
|
||||
NodeRefListBuilder& operator=(const NodeRefListBuilder&) = delete;
|
||||
|
||||
NodeRefListBuilder(NodeRefListBuilder&&) = delete;
|
||||
NodeRefListBuilder& operator=(NodeRefListBuilder&&) = delete;
|
||||
|
||||
~NodeRefListBuilder() {
|
||||
add_padding();
|
||||
}
|
||||
@@ -247,6 +258,12 @@ namespace osmium {
|
||||
new (&item()) RelationMemberList{};
|
||||
}
|
||||
|
||||
RelationMemberListBuilder(const RelationMemberListBuilder&) = delete;
|
||||
RelationMemberListBuilder& operator=(const RelationMemberListBuilder&) = delete;
|
||||
|
||||
RelationMemberListBuilder(RelationMemberListBuilder&&) = delete;
|
||||
RelationMemberListBuilder& operator=(RelationMemberListBuilder&&) = delete;
|
||||
|
||||
~RelationMemberListBuilder() {
|
||||
add_padding();
|
||||
}
|
||||
@@ -265,7 +282,7 @@ namespace osmium {
|
||||
* osmium::max_osm_string_length
|
||||
*/
|
||||
void add_member(osmium::item_type type, object_id_type ref, const char* role, const std::size_t role_length, const osmium::OSMObject* full_member = nullptr) {
|
||||
osmium::RelationMember* member = reserve_space_for<osmium::RelationMember>();
|
||||
auto* member = reserve_space_for<osmium::RelationMember>();
|
||||
new (member) osmium::RelationMember{ref, type, full_member != nullptr};
|
||||
add_size(sizeof(RelationMember));
|
||||
add_role(*member, role, role_length);
|
||||
@@ -339,6 +356,12 @@ namespace osmium {
|
||||
new (&item()) ChangesetDiscussion{};
|
||||
}
|
||||
|
||||
ChangesetDiscussionBuilder(const ChangesetDiscussionBuilder&) = delete;
|
||||
ChangesetDiscussionBuilder& operator=(const ChangesetDiscussionBuilder&) = delete;
|
||||
|
||||
ChangesetDiscussionBuilder(ChangesetDiscussionBuilder&&) = delete;
|
||||
ChangesetDiscussionBuilder& operator=(ChangesetDiscussionBuilder&&) = delete;
|
||||
|
||||
~ChangesetDiscussionBuilder() {
|
||||
assert(!m_comment && "You have to always call both add_comment() and then add_comment_text() in that order for each comment!");
|
||||
add_padding();
|
||||
@@ -440,18 +463,25 @@ namespace osmium {
|
||||
* Set user name.
|
||||
*
|
||||
* @param user Pointer to \0-terminated user name.
|
||||
*
|
||||
* @pre @code strlen(user) < 2^16 - 1 @endcode
|
||||
*/
|
||||
TDerived& set_user(const char* user) {
|
||||
return set_user(user, static_cast_with_assert<string_size_type>(std::strlen(user)));
|
||||
const auto len = std::strlen(user);
|
||||
assert(len < std::numeric_limits<string_size_type>::max());
|
||||
return set_user(user, static_cast<string_size_type>(len));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set user name.
|
||||
*
|
||||
* @param user User name.
|
||||
*
|
||||
* @pre @code user.size() < 2^16 - 1 @endcode
|
||||
*/
|
||||
TDerived& set_user(const std::string& user) {
|
||||
return set_user(user.data(), static_cast_with_assert<string_size_type>(user.size()));
|
||||
assert(user.size() < std::numeric_limits<string_size_type>::max());
|
||||
return set_user(user.data(), static_cast<string_size_type>(user.size()));
|
||||
}
|
||||
|
||||
/// @deprecated Use set_user(...) instead.
|
||||
@@ -649,18 +679,25 @@ namespace osmium {
|
||||
* Set user name.
|
||||
*
|
||||
* @param user Pointer to \0-terminated user name.
|
||||
*
|
||||
* @pre @code strlen(user) < 2^16 - 1 @endcode
|
||||
*/
|
||||
ChangesetBuilder& set_user(const char* user) {
|
||||
return set_user(user, static_cast_with_assert<string_size_type>(std::strlen(user)));
|
||||
const auto len = std::strlen(user);
|
||||
assert(len <= std::numeric_limits<string_size_type>::max());
|
||||
return set_user(user, static_cast<string_size_type>(len));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set user name.
|
||||
*
|
||||
* @param user User name.
|
||||
*
|
||||
* @pre @code user.size() < 2^16 - 1 @endcode
|
||||
*/
|
||||
ChangesetBuilder& set_user(const std::string& user) {
|
||||
return set_user(user.data(), static_cast_with_assert<string_size_type>(user.size()));
|
||||
assert(user.size() < std::numeric_limits<string_size_type>::max());
|
||||
return set_user(user.data(), static_cast<string_size_type>(user.size()));
|
||||
}
|
||||
|
||||
/// @deprecated Use set_user(...) instead.
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/osm/diff_object.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/osm/diff_object.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
class OSMObject;
|
||||
@@ -69,11 +69,11 @@ namespace osmium {
|
||||
const bool use_curr_for_prev = m_prev->type() != m_curr->type() || m_prev->id() != m_curr->id();
|
||||
const bool use_curr_for_next = m_next == m_end || m_next->type() != m_curr->type() || m_next->id() != m_curr->id();
|
||||
|
||||
m_diff = std::move(osmium::DiffObject{
|
||||
m_diff = osmium::DiffObject{
|
||||
*(use_curr_for_prev ? m_curr : m_prev),
|
||||
*m_curr,
|
||||
*(use_curr_for_next ? m_curr : m_next)
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+19
-11
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,11 +33,11 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
class Node;
|
||||
@@ -54,21 +54,29 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
HandlerWrapperBase() = default;
|
||||
|
||||
HandlerWrapperBase(const HandlerWrapperBase&) = default;
|
||||
HandlerWrapperBase& operator=(const HandlerWrapperBase&) = default;
|
||||
|
||||
HandlerWrapperBase(HandlerWrapperBase&&) noexcept = default;
|
||||
HandlerWrapperBase& operator=(HandlerWrapperBase&&) noexcept = default;
|
||||
|
||||
virtual ~HandlerWrapperBase() = default;
|
||||
|
||||
virtual void node(const osmium::Node&) {
|
||||
virtual void node(const osmium::Node& /*node*/) {
|
||||
}
|
||||
|
||||
virtual void way(const osmium::Way&) {
|
||||
virtual void way(const osmium::Way& /*way*/) {
|
||||
}
|
||||
|
||||
virtual void relation(const osmium::Relation&) {
|
||||
virtual void relation(const osmium::Relation& /*relation*/) {
|
||||
}
|
||||
|
||||
virtual void area(const osmium::Area&) {
|
||||
virtual void area(const osmium::Area& /*area*/) {
|
||||
}
|
||||
|
||||
virtual void changeset(const osmium::Changeset&) {
|
||||
virtual void changeset(const osmium::Changeset& /*changeset*/) {
|
||||
}
|
||||
|
||||
virtual void flush() {
|
||||
@@ -78,7 +86,7 @@ namespace osmium {
|
||||
|
||||
|
||||
// The following uses trick from
|
||||
// http://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence
|
||||
// https://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence
|
||||
// to either call handler style functions or visitor style operator().
|
||||
|
||||
#define OSMIUM_DYNAMIC_HANDLER_DISPATCH(_name_, _type_) \
|
||||
@@ -98,12 +106,12 @@ auto _name_##_dispatch(THandler& handler, const osmium::_type_& object, long) ->
|
||||
OSMIUM_DYNAMIC_HANDLER_DISPATCH(area, Area)
|
||||
|
||||
template <typename THandler>
|
||||
auto flush_dispatch(THandler& handler, int) -> decltype(handler.flush(), void()) {
|
||||
auto flush_dispatch(THandler& handler, int /*dispatch*/) -> decltype(handler.flush(), void()) {
|
||||
handler.flush();
|
||||
}
|
||||
|
||||
template <typename THandler>
|
||||
void flush_dispatch(THandler&, long) {
|
||||
void flush_dispatch(THandler& /*handler*/, long /*dispatch*/) { // NOLINT(google-runtime-int)
|
||||
}
|
||||
|
||||
template <typename THandler>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,10 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/area/assembler.hpp>
|
||||
#include <osmium/area/multipolygon_collector.hpp>
|
||||
#include <osmium/handler/node_locations_for_ways.hpp> // IWYU pragma: keep
|
||||
@@ -47,6 +43,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/entity_bits.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+11
-8
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/util/double.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <iosfwd>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/util/double.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
@@ -70,8 +70,11 @@ namespace osmium {
|
||||
/**
|
||||
* Create Coordinates from a Location. Will throw
|
||||
* osmium::invalid_location if the location is not valid.
|
||||
*
|
||||
* This constructor is not explicit on purpose allowing use of
|
||||
* a Location everywhere a Coordinates object is needed.
|
||||
*/
|
||||
Coordinates(const osmium::Location& location) :
|
||||
Coordinates(const osmium::Location& location) : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
|
||||
x(location.lon()),
|
||||
y(location.lat()) {
|
||||
}
|
||||
@@ -95,9 +98,9 @@ namespace osmium {
|
||||
*/
|
||||
void append_to_string(std::string& s, const char infix, int precision) const {
|
||||
if (valid()) {
|
||||
osmium::util::double2string(s, x, precision);
|
||||
osmium::double2string(s, x, precision);
|
||||
s += infix;
|
||||
osmium::util::double2string(s, y, precision);
|
||||
osmium::double2string(s, y, precision);
|
||||
} else {
|
||||
s.append("invalid");
|
||||
}
|
||||
@@ -143,7 +146,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
inline bool operator!=(const Coordinates& lhs, const Coordinates& rhs) noexcept {
|
||||
return ! operator==(lhs, rhs);
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
template <typename TChar, typename TTraits>
|
||||
|
||||
+8
-10
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,11 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/memory/collection.hpp>
|
||||
#include <osmium/memory/item.hpp>
|
||||
@@ -50,6 +45,11 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
/**
|
||||
@@ -267,7 +267,6 @@ namespace osmium {
|
||||
size_t num_points = 0;
|
||||
|
||||
if (un == use_nodes::unique) {
|
||||
osmium::Location last_location;
|
||||
switch (dir) {
|
||||
case direction::forward:
|
||||
num_points = fill_linestring_unique(wnl.cbegin(), wnl.cend());
|
||||
@@ -294,7 +293,7 @@ namespace osmium {
|
||||
return linestring_finish(num_points);
|
||||
}
|
||||
|
||||
linestring_type create_linestring(const osmium::Way& way, use_nodes un=use_nodes::unique, direction dir = direction::forward) {
|
||||
linestring_type create_linestring(const osmium::Way& way, use_nodes un = use_nodes::unique, direction dir = direction::forward) {
|
||||
try {
|
||||
return create_linestring(way.nodes(), un, dir);
|
||||
} catch (osmium::geometry_error& e) {
|
||||
@@ -341,7 +340,6 @@ namespace osmium {
|
||||
size_t num_points = 0;
|
||||
|
||||
if (un == use_nodes::unique) {
|
||||
osmium::Location last_location;
|
||||
switch (dir) {
|
||||
case direction::forward:
|
||||
num_points = fill_polygon_unique(wnl.cbegin(), wnl.cend());
|
||||
@@ -368,7 +366,7 @@ namespace osmium {
|
||||
return polygon_finish(num_points);
|
||||
}
|
||||
|
||||
polygon_type create_polygon(const osmium::Way& way, use_nodes un=use_nodes::unique, direction dir = direction::forward) {
|
||||
polygon_type create_polygon(const osmium::Way& way, use_nodes un = use_nodes::unique, direction dir = direction::forward) {
|
||||
try {
|
||||
return create_polygon(way.nodes(), un, dir);
|
||||
} catch (osmium::geometry_error& e) {
|
||||
|
||||
+29
-7
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
@@ -60,7 +60,7 @@ namespace osmium {
|
||||
using multipolygon_type = std::string;
|
||||
using ring_type = std::string;
|
||||
|
||||
GeoJSONFactoryImpl(int /* srid */, int precision = 7) :
|
||||
explicit GeoJSONFactoryImpl(int /*srid*/, int precision = 7) :
|
||||
m_precision(precision) {
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace osmium {
|
||||
|
||||
// { "type": "Point", "coordinates": [100.0, 0.0] }
|
||||
point_type make_point(const osmium::geom::Coordinates& xy) const {
|
||||
std::string str {"{\"type\":\"Point\",\"coordinates\":"};
|
||||
std::string str{"{\"type\":\"Point\",\"coordinates\":"};
|
||||
xy.append_to_string(str, '[', ',', ']', m_precision);
|
||||
str += "}";
|
||||
return str;
|
||||
@@ -86,7 +86,7 @@ namespace osmium {
|
||||
m_str += ',';
|
||||
}
|
||||
|
||||
linestring_type linestring_finish(size_t /* num_points */) {
|
||||
linestring_type linestring_finish(size_t /*num_points*/) {
|
||||
assert(!m_str.empty());
|
||||
std::string str;
|
||||
|
||||
@@ -98,6 +98,28 @@ namespace osmium {
|
||||
return str;
|
||||
}
|
||||
|
||||
/* Polygon */
|
||||
void polygon_start() {
|
||||
m_str = "{\"type\":\"Polygon\",\"coordinates\":[[";
|
||||
}
|
||||
|
||||
void polygon_add_location(const osmium::geom::Coordinates& xy) {
|
||||
xy.append_to_string(m_str, '[', ',', ']', m_precision);
|
||||
m_str += ',';
|
||||
}
|
||||
|
||||
polygon_type polygon_finish(size_t /*num_points*/) {
|
||||
assert(!m_str.empty());
|
||||
std::string str;
|
||||
|
||||
using std::swap;
|
||||
swap(str, m_str);
|
||||
|
||||
str.back() = ']';
|
||||
str += "]}";
|
||||
return str;
|
||||
}
|
||||
|
||||
/* MultiPolygon */
|
||||
|
||||
void multipolygon_start() {
|
||||
|
||||
+12
-12
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -52,14 +52,9 @@ DEALINGS IN THE SOFTWARE.
|
||||
* @attention If you include this file, you'll need to link with `libgeos`.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
|
||||
#include <geos/geom/Coordinate.h>
|
||||
#include <geos/geom/CoordinateSequence.h>
|
||||
@@ -72,9 +67,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <geos/geom/PrecisionModel.h>
|
||||
#include <geos/util/GEOSException.h>
|
||||
|
||||
#include <osmium/geom/factory.hpp>
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
// MSVC doesn't support throw_with_nested yet
|
||||
#ifdef _MSC_VER
|
||||
|
||||
+6
-6
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/util.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
@@ -48,7 +48,7 @@ namespace osmium {
|
||||
/**
|
||||
* @brief Functions to calculate arc distance on Earth using the haversine formula.
|
||||
*
|
||||
* See http://en.wikipedia.org/wiki/Haversine_formula
|
||||
* See https://en.wikipedia.org/wiki/Haversine_formula
|
||||
*
|
||||
* Implementation derived from
|
||||
* http://blog.julien.cayzac.name/2008/10/arc-and-distance-between-two-points-on.html
|
||||
@@ -69,7 +69,7 @@ namespace osmium {
|
||||
double lath = sin(deg_to_rad(c1.y - c2.y) * 0.5);
|
||||
lath *= lath;
|
||||
const double tmp = cos(deg_to_rad(c1.y)) * cos(deg_to_rad(c2.y));
|
||||
return 2.0 * EARTH_RADIUS_IN_METERS * asin(sqrt(lath + tmp*lonh));
|
||||
return 2.0 * EARTH_RADIUS_IN_METERS * asin(sqrt(lath + tmp * lonh));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,13 +33,13 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/util.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
@@ -54,7 +54,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
inline double lat_to_y_with_tan(double lat) { // not constexpr because math functions aren't
|
||||
return earth_radius_for_epsg3857 * std::log(std::tan(osmium::geom::PI/4 + deg_to_rad(lat)/2));
|
||||
return earth_radius_for_epsg3857 * std::log(std::tan(osmium::geom::PI / 4 + deg_to_rad(lat) / 2));
|
||||
}
|
||||
|
||||
#ifdef OSMIUM_USE_SLOW_MERCATOR_PROJECTION
|
||||
@@ -101,7 +101,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
inline double y_to_lat(double y) { // not constexpr because math functions aren't
|
||||
return rad_to_deg(2 * std::atan(std::exp(y / earth_radius_for_epsg3857)) - osmium::geom::PI/2);
|
||||
return rad_to_deg(2 * std::atan(std::exp(y / earth_radius_for_epsg3857)) - osmium::geom::PI / 2);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
@@ -138,7 +138,11 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
MercatorProjection() {
|
||||
// This is not "= default" on purpose because some compilers don't
|
||||
// like it and complain that "default initialization of an object
|
||||
// of const type 'const osmium::geom::MercatorProjection' requires
|
||||
// a user-provided default constructor".
|
||||
MercatorProjection() { // NOLINT(hicpp-use-equals-default, modernize-use-equals-default)
|
||||
}
|
||||
|
||||
Coordinates operator()(osmium::Location location) const {
|
||||
|
||||
+6
-6
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -42,16 +42,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
* @attention If you include this file, you'll need to link with `libgdal`.
|
||||
*/
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
|
||||
#include <ogr_geometry.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <ogr_geometry.h>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -42,16 +42,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
* @attention If you include this file, you'll need to link with `libproj`.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <proj_api.h>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/mercator_projection.hpp>
|
||||
#include <osmium/geom/util.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
|
||||
#include <proj_api.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
@@ -161,7 +161,9 @@ namespace osmium {
|
||||
Coordinates operator()(osmium::Location location) const {
|
||||
if (m_epsg == 4326) {
|
||||
return Coordinates{location.lon(), location.lat()};
|
||||
} else if (m_epsg == 3857) {
|
||||
}
|
||||
|
||||
if (m_epsg == 3857) {
|
||||
return Coordinates{detail::lon_to_x(location.lon()),
|
||||
detail::lat_to_y(location.lat())};
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,11 +33,11 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+5
-5
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,13 +33,13 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/mercator_projection.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
@@ -177,7 +177,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
inline bool operator!=(const Tile& lhs, const Tile& rhs) noexcept {
|
||||
return ! (lhs == rhs);
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+20
-17
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
#include <osmium/util/cast.hpp>
|
||||
#include <osmium/util/endian.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
@@ -70,8 +70,8 @@ namespace osmium {
|
||||
out.reserve(str.size() * 2);
|
||||
|
||||
for (char c : str) {
|
||||
out += lookup_hex[(c >> 4) & 0xf];
|
||||
out += lookup_hex[c & 0xf];
|
||||
out += lookup_hex[(static_cast<unsigned int>(c) >> 4u) & 0xfu];
|
||||
out += lookup_hex[ static_cast<unsigned int>(c) & 0xfu];
|
||||
}
|
||||
|
||||
return out;
|
||||
@@ -83,7 +83,7 @@ namespace osmium {
|
||||
* Type of WKB geometry.
|
||||
* These definitions are from
|
||||
* 99-049_OpenGIS_Simple_Features_Specification_For_SQL_Rev_1.1.pdf (for WKB)
|
||||
* and http://trac.osgeo.org/postgis/browser/trunk/doc/ZMSgeoms.txt (for EWKB).
|
||||
* and https://trac.osgeo.org/postgis/browser/trunk/doc/ZMSgeoms.txt (for EWKB).
|
||||
* They are used to encode geometries into the WKB format.
|
||||
*/
|
||||
enum wkbGeometryType : uint32_t {
|
||||
@@ -140,8 +140,11 @@ namespace osmium {
|
||||
}
|
||||
|
||||
void set_size(const std::size_t offset, const std::size_t size) {
|
||||
uint32_t s = static_cast_with_assert<uint32_t>(size);
|
||||
std::copy_n(reinterpret_cast<char*>(&s), sizeof(uint32_t), &m_data[offset]);
|
||||
if (size > std::numeric_limits<uint32_t>::max()) {
|
||||
throw geometry_error{"Too many points in geometry"};
|
||||
}
|
||||
const auto s = static_cast<uint32_t>(size);
|
||||
std::copy_n(reinterpret_cast<const char*>(&s), sizeof(uint32_t), &m_data[offset]);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -168,9 +171,9 @@ namespace osmium {
|
||||
|
||||
if (m_out_type == out_type::hex) {
|
||||
return convert_to_hex(data);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* LineString */
|
||||
@@ -194,9 +197,9 @@ namespace osmium {
|
||||
|
||||
if (m_out_type == out_type::hex) {
|
||||
return convert_to_hex(data);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* MultiPolygon */
|
||||
@@ -254,9 +257,9 @@ namespace osmium {
|
||||
|
||||
if (m_out_type == out_type::hex) {
|
||||
return convert_to_hex(data);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}; // class WKBFactoryImpl
|
||||
|
||||
+29
-7
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/geom/coordinates.hpp>
|
||||
#include <osmium/geom/factory.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace geom {
|
||||
@@ -67,8 +67,7 @@ namespace osmium {
|
||||
using multipolygon_type = std::string;
|
||||
using ring_type = std::string;
|
||||
|
||||
WKTFactoryImpl(int srid, int precision = 7, wkt_type wtype = wkt_type::wkt) :
|
||||
m_srid_prefix(),
|
||||
explicit WKTFactoryImpl(int srid, int precision = 7, wkt_type wtype = wkt_type::wkt) :
|
||||
m_precision(precision),
|
||||
m_wkt_type(wtype) {
|
||||
if (m_wkt_type == wkt_type::ewkt) {
|
||||
@@ -81,7 +80,7 @@ namespace osmium {
|
||||
/* Point */
|
||||
|
||||
point_type make_point(const osmium::geom::Coordinates& xy) const {
|
||||
std::string str {m_srid_prefix};
|
||||
std::string str{m_srid_prefix};
|
||||
str += "POINT";
|
||||
xy.append_to_string(str, '(', ' ', ')', m_precision);
|
||||
return str;
|
||||
@@ -110,6 +109,29 @@ namespace osmium {
|
||||
return str;
|
||||
}
|
||||
|
||||
/* Polygon */
|
||||
void polygon_start() {
|
||||
m_str = m_srid_prefix;
|
||||
m_str += "POLYGON((";
|
||||
}
|
||||
|
||||
void polygon_add_location(const osmium::geom::Coordinates& xy) {
|
||||
xy.append_to_string(m_str, ' ', m_precision);
|
||||
m_str += ',';
|
||||
}
|
||||
|
||||
polygon_type polygon_finish(size_t /* num_points */) {
|
||||
assert(!m_str.empty());
|
||||
std::string str;
|
||||
|
||||
using std::swap;
|
||||
swap(str, m_str);
|
||||
|
||||
str.back() = ')';
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
|
||||
/* MultiPolygon */
|
||||
|
||||
void multipolygon_start() {
|
||||
|
||||
+13
-13
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -72,40 +72,40 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
void osm_object(const osmium::OSMObject&) const noexcept {
|
||||
void osm_object(const osmium::OSMObject& /*osm_object*/) const noexcept {
|
||||
}
|
||||
|
||||
void node(const osmium::Node&) const noexcept {
|
||||
void node(const osmium::Node& /*node*/) const noexcept {
|
||||
}
|
||||
|
||||
void way(const osmium::Way&) const noexcept {
|
||||
void way(const osmium::Way& /*way*/) const noexcept {
|
||||
}
|
||||
|
||||
void relation(const osmium::Relation&) const noexcept {
|
||||
void relation(const osmium::Relation& /*relation*/) const noexcept {
|
||||
}
|
||||
|
||||
void area(const osmium::Area&) const noexcept {
|
||||
void area(const osmium::Area& /*area*/) const noexcept {
|
||||
}
|
||||
|
||||
void changeset(const osmium::Changeset&) const noexcept {
|
||||
void changeset(const osmium::Changeset& /*changeset*/) const noexcept {
|
||||
}
|
||||
|
||||
void tag_list(const osmium::TagList&) const noexcept {
|
||||
void tag_list(const osmium::TagList& /*tag_list*/) const noexcept {
|
||||
}
|
||||
|
||||
void way_node_list(const osmium::WayNodeList&) const noexcept {
|
||||
void way_node_list(const osmium::WayNodeList& /*way_node_list*/) const noexcept {
|
||||
}
|
||||
|
||||
void relation_member_list(const osmium::RelationMemberList&) const noexcept {
|
||||
void relation_member_list(const osmium::RelationMemberList& /*relation_member_list*/) const noexcept {
|
||||
}
|
||||
|
||||
void outer_ring(const osmium::OuterRing&) const noexcept {
|
||||
void outer_ring(const osmium::OuterRing& /*outer_ring*/) const noexcept {
|
||||
}
|
||||
|
||||
void inner_ring(const osmium::InnerRing&) const noexcept {
|
||||
void inner_ring(const osmium::InnerRing& /*inner_ring*/) const noexcept {
|
||||
}
|
||||
|
||||
void changeset_discussion(const osmium::ChangesetDiscussion&) const noexcept {
|
||||
void changeset_discussion(const osmium::ChangesetDiscussion& /*changeset_discussion*/) const noexcept {
|
||||
}
|
||||
|
||||
void flush() const noexcept {
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,10 +33,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#define OSMIUM_CHAIN_HANDLER_CALL(_func_, _type_) \
|
||||
template <int N, int SIZE, typename THandlers> \
|
||||
struct call_ ## _func_ { \
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,10 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/osm/node.hpp>
|
||||
#include <osmium/osm/object_comparisons.hpp>
|
||||
@@ -44,6 +40,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,8 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/index/map.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
@@ -46,6 +44,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/way.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace handler {
|
||||
@@ -78,11 +78,6 @@ namespace osmium {
|
||||
m_relation_index(relation_index) {
|
||||
}
|
||||
|
||||
DiskStore(const DiskStore&) = delete;
|
||||
DiskStore& operator=(const DiskStore&) = delete;
|
||||
|
||||
~DiskStore() noexcept = default;
|
||||
|
||||
void node(const osmium::Node& node) {
|
||||
m_node_index.set(node.positive_id(), m_offset);
|
||||
m_offset += node.byte_size();
|
||||
|
||||
+7
-7
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,10 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/memory/collection.hpp>
|
||||
#include <osmium/memory/item.hpp>
|
||||
@@ -54,6 +50,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/way.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace handler {
|
||||
@@ -136,10 +136,10 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
explicit Dump(std::ostream& out, bool with_size = true, const std::string& prefix = "") :
|
||||
explicit Dump(std::ostream& out, bool with_size = true, std::string prefix = "") :
|
||||
m_out(&out),
|
||||
m_with_size(with_size),
|
||||
m_prefix(prefix) {
|
||||
m_prefix(std::move(prefix)) {
|
||||
}
|
||||
|
||||
void tag_list(const osmium::TagList& tags) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,19 +33,18 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/map/dummy.hpp>
|
||||
#include <osmium/index/node_locations_map.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/node.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <osmium/index/node_locations_map.hpp>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@@ -99,7 +98,7 @@ namespace osmium {
|
||||
public:
|
||||
|
||||
explicit NodeLocationsForWays(TStoragePosIDs& storage_pos,
|
||||
TStorageNegIDs& storage_neg = get_dummy()) :
|
||||
TStorageNegIDs& storage_neg = get_dummy()) noexcept :
|
||||
m_storage_pos(storage_pos),
|
||||
m_storage_neg(storage_neg) {
|
||||
}
|
||||
@@ -107,8 +106,8 @@ namespace osmium {
|
||||
NodeLocationsForWays(const NodeLocationsForWays&) = delete;
|
||||
NodeLocationsForWays& operator=(const NodeLocationsForWays&) = delete;
|
||||
|
||||
NodeLocationsForWays(NodeLocationsForWays&&) = default;
|
||||
NodeLocationsForWays& operator=(NodeLocationsForWays&&) = default;
|
||||
NodeLocationsForWays(NodeLocationsForWays&&) noexcept = default;
|
||||
NodeLocationsForWays& operator=(NodeLocationsForWays&&) noexcept = default;
|
||||
|
||||
~NodeLocationsForWays() noexcept = default;
|
||||
|
||||
@@ -138,10 +137,9 @@ namespace osmium {
|
||||
*/
|
||||
osmium::Location get_node_location(const osmium::object_id_type id) const {
|
||||
if (id >= 0) {
|
||||
return m_storage_pos.get_noexcept(static_cast<osmium::unsigned_object_id_type>( id));
|
||||
} else {
|
||||
return m_storage_neg.get_noexcept(static_cast<osmium::unsigned_object_id_type>(-id));
|
||||
return m_storage_pos.get_noexcept(static_cast<osmium::unsigned_object_id_type>(id));
|
||||
}
|
||||
return m_storage_neg.get_noexcept(static_cast<osmium::unsigned_object_id_type>(-id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/index/multimap.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/relation.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
@@ -70,11 +70,6 @@ namespace osmium {
|
||||
m_index_r2r(r2r) {
|
||||
}
|
||||
|
||||
ObjectRelations(const ObjectRelations&) = delete;
|
||||
ObjectRelations& operator=(const ObjectRelations&) = delete;
|
||||
|
||||
~ObjectRelations() noexcept = default;
|
||||
|
||||
void way(const osmium::Way& way) {
|
||||
for (const auto& node_ref : way.nodes()) {
|
||||
m_index_n2w.set(node_ref.positive_ref(), way.positive_id());
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace osmium {
|
||||
}
|
||||
assert(config.size() > 1);
|
||||
const std::string& filename = config[1];
|
||||
const int fd = ::open(filename.c_str(), O_CREAT | O_RDWR, 0644);
|
||||
const int fd = ::open(filename.c_str(), O_CREAT | O_RDWR, 0644); // NOLINT(hicpp-signed-bitwise)
|
||||
if (fd == -1) {
|
||||
throw std::runtime_error{std::string{"can't open file '"} + filename + "': " + std::strerror(errno)};
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -54,8 +54,6 @@ namespace osmium {
|
||||
mmap_vector_base<T>() {
|
||||
}
|
||||
|
||||
~mmap_vector_anon() noexcept = default;
|
||||
|
||||
}; // class mmap_vector_anon
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,15 +33,15 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/util/memory_mapping.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <new> // IWYU pragma: keep
|
||||
#include <stdexcept>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/util/memory_mapping.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace detail {
|
||||
@@ -58,27 +58,24 @@ namespace osmium {
|
||||
|
||||
protected:
|
||||
|
||||
size_t m_size;
|
||||
osmium::util::TypedMemoryMapping<T> m_mapping;
|
||||
size_t m_size = 0;
|
||||
osmium::TypedMemoryMapping<T> m_mapping;
|
||||
|
||||
public:
|
||||
|
||||
mmap_vector_base(int fd, size_t capacity, size_t size = 0) :
|
||||
m_size(size),
|
||||
m_mapping(capacity, osmium::util::MemoryMapping::mapping_mode::write_shared, fd) {
|
||||
m_mapping(capacity, osmium::MemoryMapping::mapping_mode::write_shared, fd) {
|
||||
assert(size <= capacity);
|
||||
std::fill(data() + size, data() + capacity, osmium::index::empty_value<T>());
|
||||
shrink_to_fit();
|
||||
}
|
||||
|
||||
explicit mmap_vector_base(size_t capacity = mmap_vector_size_increment) :
|
||||
m_size(0),
|
||||
m_mapping(capacity) {
|
||||
std::fill_n(data(), capacity, osmium::index::empty_value<T>());
|
||||
}
|
||||
|
||||
~mmap_vector_base() noexcept = default;
|
||||
|
||||
using value_type = T;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,15 +33,15 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/detail/mmap_vector_base.hpp>
|
||||
#include <osmium/index/detail/tmpfile.hpp>
|
||||
#include <osmium/util/file.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <osmium/index/detail/mmap_vector_base.hpp>
|
||||
#include <osmium/index/detail/tmpfile.hpp>
|
||||
#include <osmium/util/file.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace detail {
|
||||
@@ -54,7 +54,7 @@ namespace osmium {
|
||||
class mmap_vector_file : public mmap_vector_base<T> {
|
||||
|
||||
static std::size_t filesize(int fd) {
|
||||
const auto size = osmium::util::file_size(fd);
|
||||
const auto size = osmium::file_size(fd);
|
||||
|
||||
if (size % sizeof(T) != 0) {
|
||||
throw std::runtime_error{"Index file has wrong size (must be multiple of " + std::to_string(sizeof(T)) + ")."};
|
||||
@@ -78,8 +78,6 @@ namespace osmium {
|
||||
filesize(fd)) {
|
||||
}
|
||||
|
||||
~mmap_vector_file() noexcept = default;
|
||||
|
||||
}; // class mmap_vector_file
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/map.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
@@ -67,8 +67,6 @@ namespace osmium {
|
||||
m_vector(fd) {
|
||||
}
|
||||
|
||||
~VectorBasedDenseMap() noexcept final = default;
|
||||
|
||||
void reserve(const std::size_t size) final {
|
||||
m_vector.reserve(size);
|
||||
}
|
||||
@@ -146,7 +144,7 @@ namespace osmium {
|
||||
}; // class VectorBasedDenseMap
|
||||
|
||||
|
||||
template <typename TId, typename TValue, template<typename...> class TVector>
|
||||
template <typename TId, typename TValue, template <typename...> class TVector>
|
||||
class VectorBasedSparseMap : public Map<TId, TValue> {
|
||||
|
||||
public:
|
||||
@@ -180,8 +178,6 @@ namespace osmium {
|
||||
m_vector(fd) {
|
||||
}
|
||||
|
||||
~VectorBasedSparseMap() final = default;
|
||||
|
||||
void set(const TId id, const TValue value) final {
|
||||
m_vector.push_back(element_type(id, value));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,21 +33,21 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/multimap.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
|
||||
namespace multimap {
|
||||
|
||||
template <typename TId, typename TValue, template<typename...> class TVector>
|
||||
template <typename TId, typename TValue, template <typename...> class TVector>
|
||||
class VectorBasedSparseMultimap : public Multimap<TId, TValue> {
|
||||
|
||||
public:
|
||||
@@ -75,8 +75,6 @@ namespace osmium {
|
||||
m_vector(fd) {
|
||||
}
|
||||
|
||||
~VectorBasedSparseMultimap() noexcept final = default;
|
||||
|
||||
void set(const TId id, const TValue value) final {
|
||||
m_vector.push_back(element_type(id, value));
|
||||
}
|
||||
|
||||
+20
-12
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,6 +33,9 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
@@ -42,9 +45,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
@@ -58,6 +58,14 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
IdSet() = default;
|
||||
|
||||
IdSet(const IdSet&) = default;
|
||||
IdSet& operator=(const IdSet&) = default;
|
||||
|
||||
IdSet(IdSet&&) noexcept = default;
|
||||
IdSet& operator=(IdSet&&) noexcept = default;
|
||||
|
||||
virtual ~IdSet() = default;
|
||||
|
||||
/**
|
||||
@@ -113,7 +121,7 @@ namespace osmium {
|
||||
const auto slot = m_set->m_data[cid][IdSetDense<T>::offset(m_value)];
|
||||
if (slot == 0) {
|
||||
m_value += 8;
|
||||
m_value &= ~0x7;
|
||||
m_value &= ~0x7ull;
|
||||
} else {
|
||||
++m_value;
|
||||
}
|
||||
@@ -154,7 +162,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
bool operator!=(const IdSetDenseIterator<T>& rhs) const noexcept {
|
||||
return ! (*this == rhs);
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
T operator*() const noexcept {
|
||||
@@ -183,22 +191,22 @@ namespace osmium {
|
||||
// which would mean less (but larger) memory allocations. For
|
||||
// relations Ids it could be smaller, because they would all fit
|
||||
// into a smaller allocation.
|
||||
constexpr static const std::size_t chunk_bits = 22;
|
||||
constexpr static const std::size_t chunk_size = 1 << chunk_bits;
|
||||
constexpr static const std::size_t chunk_bits = 22u;
|
||||
constexpr static const std::size_t chunk_size = 1u << chunk_bits;
|
||||
|
||||
std::vector<std::unique_ptr<unsigned char[]>> m_data;
|
||||
T m_size = 0;
|
||||
|
||||
static std::size_t chunk_id(T id) noexcept {
|
||||
return id >> (chunk_bits + 3);
|
||||
return id >> (chunk_bits + 3u);
|
||||
}
|
||||
|
||||
static std::size_t offset(T id) noexcept {
|
||||
return (id >> 3) & ((1 << chunk_bits) - 1);
|
||||
return (id >> 3u) & ((1u << chunk_bits) - 1u);
|
||||
}
|
||||
|
||||
static unsigned char bitmask(T id) noexcept {
|
||||
return 1 << (id & 0x7);
|
||||
return 1u << (id & 0x7u);
|
||||
}
|
||||
|
||||
T last() const noexcept {
|
||||
@@ -422,7 +430,7 @@ namespace osmium {
|
||||
}; // class IdSetSmall
|
||||
|
||||
/// @deprecated Use nwr_array helper class instead.
|
||||
template <template<typename> class IdSetType>
|
||||
template <template <typename> class IdSetType>
|
||||
class NWRIdSet {
|
||||
|
||||
using id_set_type = IdSetType<osmium::unsigned_object_id_type>;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+22
-19
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,6 +33,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/util/string.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
@@ -43,8 +45,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/util/string.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
struct map_factory_error : public std::runtime_error {
|
||||
@@ -98,13 +98,10 @@ namespace osmium {
|
||||
static_assert(std::is_integral<TId>::value && std::is_unsigned<TId>::value,
|
||||
"TId template parameter for class Map must be unsigned integral type");
|
||||
|
||||
Map(const Map&) = delete;
|
||||
Map& operator=(const Map&) = delete;
|
||||
|
||||
protected:
|
||||
|
||||
Map(Map&&) = default;
|
||||
Map& operator=(Map&&) = default;
|
||||
Map(Map&&) noexcept = default;
|
||||
Map& operator=(Map&&) noexcept = default;
|
||||
|
||||
public:
|
||||
|
||||
@@ -114,11 +111,14 @@ namespace osmium {
|
||||
/// The "value" type, usually a Location or size_t.
|
||||
using value_type = TValue;
|
||||
|
||||
Map() = default;
|
||||
Map() noexcept = default;
|
||||
|
||||
Map(const Map&) = delete;
|
||||
Map& operator=(const Map&) = delete;
|
||||
|
||||
virtual ~Map() noexcept = default;
|
||||
|
||||
virtual void reserve(const size_t) {
|
||||
virtual void reserve(const size_t /*size*/) {
|
||||
// default implementation is empty
|
||||
}
|
||||
|
||||
@@ -210,14 +210,16 @@ namespace osmium {
|
||||
|
||||
MapFactory() = default;
|
||||
|
||||
~MapFactory() = default;
|
||||
|
||||
public:
|
||||
|
||||
MapFactory(const MapFactory&) = delete;
|
||||
MapFactory& operator=(const MapFactory&) = delete;
|
||||
|
||||
MapFactory(MapFactory&&) = delete;
|
||||
MapFactory& operator=(MapFactory&&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
static MapFactory<id_type, value_type>& instance() {
|
||||
static MapFactory<id_type, value_type> factory;
|
||||
return factory;
|
||||
@@ -262,16 +264,16 @@ namespace osmium {
|
||||
|
||||
namespace map {
|
||||
|
||||
template <typename TId, typename TValue, template<typename, typename> class TMap>
|
||||
template <typename TId, typename TValue, template <typename, typename> class TMap>
|
||||
struct create_map {
|
||||
TMap<TId, TValue>* operator()(const std::vector<std::string>&) {
|
||||
TMap<TId, TValue>* operator()(const std::vector<std::string>& /*config_string*/) {
|
||||
return new TMap<TId, TValue>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace map
|
||||
|
||||
template <typename TId, typename TValue, template<typename, typename> class TMap>
|
||||
template <typename TId, typename TValue, template <typename, typename> class TMap>
|
||||
inline bool register_map(const std::string& name) {
|
||||
return osmium::index::MapFactory<TId, TValue>::instance().register_map(name, [](const std::vector<std::string>& config) {
|
||||
return map::create_map<TId, TValue, TMap>()(config);
|
||||
@@ -283,10 +285,11 @@ namespace osmium {
|
||||
|
||||
#define REGISTER_MAP(id, value, klass, name) \
|
||||
namespace osmium { namespace index { namespace detail { \
|
||||
const bool OSMIUM_CONCATENATE_(registered_, name) = osmium::index::register_map<id, value, klass>(#name); \
|
||||
inline bool OSMIUM_CONCATENATE_(get_registered_, name)() noexcept { \
|
||||
return OSMIUM_CONCATENATE_(registered_, name); \
|
||||
} \
|
||||
namespace OSMIUM_CONCATENATE_(register_map_, __COUNTER__) { \
|
||||
const bool registered = osmium::index::register_map<id, value, klass>(#name); \
|
||||
inline bool get_registered() noexcept { \
|
||||
return registered; \
|
||||
} } \
|
||||
} } }
|
||||
|
||||
} // namespace index
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,12 +33,12 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/detail/create_map_with_fd.hpp>
|
||||
#include <osmium/index/detail/mmap_vector_file.hpp>
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
#include <osmium/index/detail/create_map_with_fd.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_DENSE_FILE_ARRAY
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,10 +33,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_DENSE_MEM_ARRAY
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,11 +33,11 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/map.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
@@ -56,9 +56,7 @@ namespace osmium {
|
||||
|
||||
Dummy() = default;
|
||||
|
||||
~Dummy() noexcept final = default;
|
||||
|
||||
void set(const TId, const TValue) final {
|
||||
void set(const TId /*id*/, const TValue /*value*/) final {
|
||||
// intentionally left blank
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,15 +33,15 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/map.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/map.hpp>
|
||||
#include <osmium/index/index.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_FLEX_MEM
|
||||
|
||||
namespace osmium {
|
||||
@@ -67,7 +67,7 @@ namespace osmium {
|
||||
};
|
||||
|
||||
enum constant_block_size : uint64_t {
|
||||
block_size = 1ll << bits
|
||||
block_size = 1ull << bits
|
||||
};
|
||||
|
||||
// Minimum number of entries in the sparse index before we
|
||||
@@ -92,7 +92,7 @@ namespace osmium {
|
||||
|
||||
entry(uint64_t i, TValue v) :
|
||||
id(i),
|
||||
value(v) {
|
||||
value(std::move(v)) {
|
||||
}
|
||||
|
||||
bool operator<(const entry other) const noexcept {
|
||||
@@ -179,8 +179,6 @@ namespace osmium {
|
||||
m_dense(use_dense) {
|
||||
}
|
||||
|
||||
~FlexMem() noexcept final = default;
|
||||
|
||||
bool is_dense() const noexcept {
|
||||
return m_dense;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,12 +33,12 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/detail/create_map_with_fd.hpp>
|
||||
#include <osmium/index/detail/mmap_vector_file.hpp>
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
#include <osmium/index/detail/create_map_with_fd.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_SPARSE_FILE_ARRAY
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,10 +33,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/detail/vector_map.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_ARRAY
|
||||
|
||||
namespace osmium {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,16 +33,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/map.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
#include <algorithm> // IWYU pragma: keep (for std::copy)
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/map.hpp>
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_MAP
|
||||
|
||||
namespace osmium {
|
||||
@@ -70,8 +70,6 @@ namespace osmium {
|
||||
|
||||
SparseMemMap() = default;
|
||||
|
||||
~SparseMemMap() noexcept final = default;
|
||||
|
||||
void set(const TId id, const TValue value) final {
|
||||
m_elements[id] = value;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -35,16 +35,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifdef OSMIUM_WITH_SPARSEHASH
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <google/sparsetable>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/map.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
#include <google/sparsetable>
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#define OSMIUM_HAS_INDEX_MAP_SPARSE_MEM_TABLE
|
||||
|
||||
namespace osmium {
|
||||
@@ -88,8 +88,6 @@ namespace osmium {
|
||||
m_elements(grow_size) {
|
||||
}
|
||||
|
||||
~SparseMemTable() noexcept final = default;
|
||||
|
||||
void set(const TId id, const TValue value) final {
|
||||
if (id >= m_elements.size()) {
|
||||
m_elements.resize(id + m_grow_size);
|
||||
@@ -121,7 +119,7 @@ namespace osmium {
|
||||
|
||||
size_t used_memory() const final {
|
||||
// unused elements use 1 bit, used elements sizeof(TValue) bytes
|
||||
// http://google-sparsehash.googlecode.com/svn/trunk/doc/sparsetable.html
|
||||
// https://github.com/sparsehash/sparsehash/blob/master/doc/sparsetable.html
|
||||
return (m_elements.size() / 8) + (m_elements.num_nonempty() * sizeof(TValue));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+6
-6
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -54,13 +54,10 @@ namespace osmium {
|
||||
|
||||
using element_type = typename std::pair<TId, TValue>;
|
||||
|
||||
Multimap(const Multimap&) = delete;
|
||||
Multimap& operator=(const Multimap&) = delete;
|
||||
|
||||
protected:
|
||||
|
||||
Multimap(Multimap&&) = default;
|
||||
Multimap& operator=(Multimap&&) = default;
|
||||
Multimap(Multimap&&) noexcept = default;
|
||||
Multimap& operator=(Multimap&&) noexcept = default;
|
||||
|
||||
public:
|
||||
|
||||
@@ -72,6 +69,9 @@ namespace osmium {
|
||||
|
||||
Multimap() = default;
|
||||
|
||||
Multimap(const Multimap&) = delete;
|
||||
Multimap& operator=(const Multimap&) = delete;
|
||||
|
||||
virtual ~Multimap() noexcept = default;
|
||||
|
||||
/// Set the field with id to value.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,14 +33,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/index/index.hpp>
|
||||
#include <osmium/index/multimap.hpp>
|
||||
#include <osmium/index/multimap/sparse_mem_array.hpp>
|
||||
#include <osmium/index/multimap/sparse_mem_multimap.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,10 +33,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/detail/vector_multimap.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,15 +33,15 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/index/multimap.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/index/multimap.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -34,6 +34,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <osmium/index/map.hpp> // IWYU pragma: keep
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
#define OSMIUM_WANT_NODE_LOCATION_MAPS
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,6 +33,10 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/relation.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
@@ -42,10 +46,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/relation.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
@@ -187,8 +187,10 @@ namespace osmium {
|
||||
RelationsMapIndex(const RelationsMapIndex&) = delete;
|
||||
RelationsMapIndex& operator=(const RelationsMapIndex&) = delete;
|
||||
|
||||
RelationsMapIndex(RelationsMapIndex&&) = default;
|
||||
RelationsMapIndex& operator=(RelationsMapIndex&&) = default;
|
||||
RelationsMapIndex(RelationsMapIndex&& /*other*/) noexcept(std::is_nothrow_move_constructible<map_type>::value);
|
||||
RelationsMapIndex& operator=(RelationsMapIndex&& /*other*/) noexcept(std::is_nothrow_move_assignable<map_type>::value);
|
||||
|
||||
~RelationsMapIndex() noexcept = default;
|
||||
|
||||
/**
|
||||
* Find the given relation id in the index and call the given
|
||||
@@ -256,6 +258,11 @@ namespace osmium {
|
||||
|
||||
}; // class RelationsMapIndex
|
||||
|
||||
// defined outside the class on purpose
|
||||
// see https://akrzemi1.wordpress.com/2015/09/11/declaring-the-move-constructor/
|
||||
inline RelationsMapIndex::RelationsMapIndex(RelationsMapIndex&&) noexcept(std::is_nothrow_move_constructible<map_type>::value) = default;
|
||||
inline RelationsMapIndex& RelationsMapIndex::operator=(RelationsMapIndex&&) noexcept(std::is_nothrow_move_assignable<map_type>::value) = default;
|
||||
|
||||
class RelationsMapIndexes {
|
||||
|
||||
friend class RelationsMapStash;
|
||||
@@ -321,8 +328,10 @@ namespace osmium {
|
||||
RelationsMapStash(const RelationsMapStash&) = delete;
|
||||
RelationsMapStash& operator=(const RelationsMapStash&) = delete;
|
||||
|
||||
RelationsMapStash(RelationsMapStash&&) = default;
|
||||
RelationsMapStash& operator=(RelationsMapStash&&) = default;
|
||||
RelationsMapStash(RelationsMapStash&& /*other*/) noexcept(std::is_nothrow_move_constructible<map_type>::value);
|
||||
RelationsMapStash& operator=(RelationsMapStash&& /*other*/) noexcept(std::is_nothrow_move_assignable<map_type>::value);
|
||||
|
||||
~RelationsMapStash() noexcept = default;
|
||||
|
||||
/**
|
||||
* Add mapping from member to parent relation in the stash.
|
||||
@@ -431,6 +440,11 @@ namespace osmium {
|
||||
|
||||
}; // class RelationsMapStash
|
||||
|
||||
// defined outside the class on purpose
|
||||
// see https://akrzemi1.wordpress.com/2015/09/11/declaring-the-move-constructor/
|
||||
inline RelationsMapStash::RelationsMapStash(RelationsMapStash&&) noexcept(std::is_nothrow_move_constructible<map_type>::value) = default;
|
||||
inline RelationsMapStash& RelationsMapStash::operator=(RelationsMapStash&&) noexcept(std::is_nothrow_move_assignable<map_type>::value) = default;
|
||||
|
||||
} // namespace index
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+43
-22
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -42,25 +42,26 @@ DEALINGS IN THE SOFTWARE.
|
||||
* @attention If you include this file, you'll need to link with `libbz2`.
|
||||
*/
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
#include <bzlib.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <osmium/io/compression.hpp>
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
#include <osmium/io/error.hpp>
|
||||
#include <osmium/io/file_compression.hpp>
|
||||
#include <osmium/io/writer_options.hpp>
|
||||
#include <osmium/util/cast.hpp>
|
||||
#include <osmium/util/compatibility.hpp>
|
||||
|
||||
#include <bzlib.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace osmium {
|
||||
|
||||
/**
|
||||
@@ -117,6 +118,12 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
|
||||
Bzip2Compressor(const Bzip2Compressor&) = delete;
|
||||
Bzip2Compressor& operator=(const Bzip2Compressor&) = delete;
|
||||
|
||||
Bzip2Compressor(Bzip2Compressor&&) = delete;
|
||||
Bzip2Compressor& operator=(Bzip2Compressor&&) = delete;
|
||||
|
||||
~Bzip2Compressor() noexcept final {
|
||||
try {
|
||||
close();
|
||||
@@ -127,7 +134,8 @@ namespace osmium {
|
||||
|
||||
void write(const std::string& data) final {
|
||||
int error;
|
||||
::BZ2_bzWrite(&error, m_bzfile, const_cast<char*>(data.data()), static_cast_with_assert<int>(data.size()));
|
||||
assert(data.size() < std::numeric_limits<int>::max());
|
||||
::BZ2_bzWrite(&error, m_bzfile, const_cast<char*>(data.data()), static_cast<int>(data.size()));
|
||||
if (error != BZ_OK && error != BZ_STREAM_END) {
|
||||
detail::throw_bzip2_error(m_bzfile, "write failed", error);
|
||||
}
|
||||
@@ -157,22 +165,26 @@ namespace osmium {
|
||||
class Bzip2Decompressor : public Decompressor {
|
||||
|
||||
FILE* m_file;
|
||||
int m_bzerror;
|
||||
int m_bzerror = BZ_OK;
|
||||
BZFILE* m_bzfile;
|
||||
bool m_stream_end {false};
|
||||
bool m_stream_end = false;
|
||||
|
||||
public:
|
||||
|
||||
explicit Bzip2Decompressor(int fd) :
|
||||
Decompressor(),
|
||||
m_file(fdopen(::dup(fd), "rb")),
|
||||
m_bzerror(BZ_OK),
|
||||
m_bzfile(::BZ2_bzReadOpen(&m_bzerror, m_file, 0, 0, nullptr, 0)) {
|
||||
if (!m_bzfile) {
|
||||
detail::throw_bzip2_error(m_bzfile, "read open failed", m_bzerror);
|
||||
}
|
||||
}
|
||||
|
||||
Bzip2Decompressor(const Bzip2Decompressor&) = delete;
|
||||
Bzip2Decompressor& operator=(const Bzip2Decompressor&) = delete;
|
||||
|
||||
Bzip2Decompressor(Bzip2Decompressor&&) = delete;
|
||||
Bzip2Decompressor& operator=(Bzip2Decompressor&&) = delete;
|
||||
|
||||
~Bzip2Decompressor() noexcept final {
|
||||
try {
|
||||
close();
|
||||
@@ -187,7 +199,8 @@ namespace osmium {
|
||||
if (!m_stream_end) {
|
||||
buffer.resize(osmium::io::Decompressor::input_buffer_size);
|
||||
int error;
|
||||
const int nread = ::BZ2_bzRead(&error, m_bzfile, const_cast<char*>(buffer.data()), static_cast_with_assert<int>(buffer.size()));
|
||||
assert(buffer.size() < std::numeric_limits<int>::max());
|
||||
const int nread = ::BZ2_bzRead(&error, m_bzfile, const_cast<char*>(buffer.data()), static_cast<int>(buffer.size()));
|
||||
if (error != BZ_OK && error != BZ_STREAM_END) {
|
||||
detail::throw_bzip2_error(m_bzfile, "read failed", error);
|
||||
}
|
||||
@@ -204,7 +217,8 @@ namespace osmium {
|
||||
if (error != BZ_OK) {
|
||||
detail::throw_bzip2_error(m_bzfile, "read close failed", error);
|
||||
}
|
||||
m_bzfile = ::BZ2_bzReadOpen(&error, m_file, 0, 0, const_cast<void*>(static_cast<const void*>(unused_data.data())), static_cast_with_assert<int>(unused_data.size()));
|
||||
assert(unused_data.size() < std::numeric_limits<int>::max());
|
||||
m_bzfile = ::BZ2_bzReadOpen(&error, m_file, 0, 0, const_cast<void*>(static_cast<const void*>(unused_data.data())), static_cast<int>(unused_data.size()));
|
||||
if (error != BZ_OK) {
|
||||
detail::throw_bzip2_error(m_bzfile, "read open failed", error);
|
||||
}
|
||||
@@ -251,7 +265,8 @@ namespace osmium {
|
||||
m_buffer_size(size),
|
||||
m_bzstream() {
|
||||
m_bzstream.next_in = const_cast<char*>(buffer);
|
||||
m_bzstream.avail_in = static_cast_with_assert<unsigned int>(size);
|
||||
assert(size < std::numeric_limits<unsigned int>::max());
|
||||
m_bzstream.avail_in = static_cast<unsigned int>(size);
|
||||
const int result = BZ2_bzDecompressInit(&m_bzstream, 0, 0);
|
||||
if (result != BZ_OK) {
|
||||
std::string message{"bzip2 error: decompression init failed: "};
|
||||
@@ -259,6 +274,12 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
|
||||
Bzip2BufferDecompressor(const Bzip2BufferDecompressor&) = delete;
|
||||
Bzip2BufferDecompressor& operator=(const Bzip2BufferDecompressor&) = delete;
|
||||
|
||||
Bzip2BufferDecompressor(Bzip2BufferDecompressor&&) = delete;
|
||||
Bzip2BufferDecompressor& operator=(Bzip2BufferDecompressor&&) = delete;
|
||||
|
||||
~Bzip2BufferDecompressor() noexcept final {
|
||||
try {
|
||||
close();
|
||||
@@ -287,7 +308,7 @@ namespace osmium {
|
||||
throw bzip2_error{message, result};
|
||||
}
|
||||
|
||||
output.resize(static_cast<unsigned long>(m_bzstream.next_out - output.data()));
|
||||
output.resize(static_cast<std::size_t>(m_bzstream.next_out - output.data()));
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
+39
-27
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,6 +33,12 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
#include <osmium/io/error.hpp>
|
||||
#include <osmium/io/file_compression.hpp>
|
||||
#include <osmium/io/writer_options.hpp>
|
||||
#include <osmium/util/file.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
@@ -50,12 +56,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#include <osmium/io/detail/read_write.hpp>
|
||||
#include <osmium/io/error.hpp>
|
||||
#include <osmium/io/file_compression.hpp>
|
||||
#include <osmium/io/writer_options.hpp>
|
||||
#include <osmium/util/file.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@@ -76,6 +76,12 @@ namespace osmium {
|
||||
m_fsync(sync) {
|
||||
}
|
||||
|
||||
Compressor(const Compressor&) = default;
|
||||
Compressor& operator=(const Compressor&) = default;
|
||||
|
||||
Compressor(Compressor&&) noexcept = default;
|
||||
Compressor& operator=(Compressor&&) noexcept = default;
|
||||
|
||||
virtual ~Compressor() noexcept = default;
|
||||
|
||||
virtual void write(const std::string& data) = 0;
|
||||
@@ -152,12 +158,6 @@ namespace osmium {
|
||||
|
||||
CompressionFactory() = default;
|
||||
|
||||
CompressionFactory(const CompressionFactory&) = delete;
|
||||
CompressionFactory& operator=(const CompressionFactory&) = delete;
|
||||
|
||||
CompressionFactory(CompressionFactory&&) = delete;
|
||||
CompressionFactory& operator=(CompressionFactory&&) = delete;
|
||||
|
||||
const callbacks_type& find_callbacks(osmium::io::file_compression compression) const {
|
||||
const auto it = m_callbacks.find(compression);
|
||||
|
||||
@@ -173,6 +173,14 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
CompressionFactory(const CompressionFactory&) = delete;
|
||||
CompressionFactory& operator=(const CompressionFactory&) = delete;
|
||||
|
||||
CompressionFactory(CompressionFactory&&) = delete;
|
||||
CompressionFactory& operator=(CompressionFactory&&) = delete;
|
||||
|
||||
~CompressionFactory() noexcept = default;
|
||||
|
||||
static CompressionFactory& instance() {
|
||||
static CompressionFactory factory;
|
||||
return factory;
|
||||
@@ -201,7 +209,7 @@ namespace osmium {
|
||||
std::unique_ptr<osmium::io::Decompressor> create_decompressor(osmium::io::file_compression compression, int fd) const {
|
||||
const auto callbacks = find_callbacks(compression);
|
||||
auto p = std::unique_ptr<osmium::io::Decompressor>(std::get<1>(callbacks)(fd));
|
||||
p->set_file_size(osmium::util::file_size(fd));
|
||||
p->set_file_size(osmium::file_size(fd));
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -223,6 +231,12 @@ namespace osmium {
|
||||
m_fd(fd) {
|
||||
}
|
||||
|
||||
NoCompressor(const NoCompressor&) = delete;
|
||||
NoCompressor& operator=(const NoCompressor&) = delete;
|
||||
|
||||
NoCompressor(NoCompressor&&) = delete;
|
||||
NoCompressor& operator=(NoCompressor&&) = delete;
|
||||
|
||||
~NoCompressor() noexcept final {
|
||||
try {
|
||||
close();
|
||||
@@ -250,27 +264,28 @@ namespace osmium {
|
||||
|
||||
class NoDecompressor : public Decompressor {
|
||||
|
||||
int m_fd;
|
||||
const char *m_buffer;
|
||||
std::size_t m_buffer_size;
|
||||
int m_fd = -1;
|
||||
const char* m_buffer = nullptr;
|
||||
std::size_t m_buffer_size = 0;
|
||||
std::size_t m_offset = 0;
|
||||
|
||||
public:
|
||||
|
||||
explicit NoDecompressor(int fd) :
|
||||
Decompressor(),
|
||||
m_fd(fd),
|
||||
m_buffer(nullptr),
|
||||
m_buffer_size(0) {
|
||||
m_fd(fd) {
|
||||
}
|
||||
|
||||
NoDecompressor(const char* buffer, std::size_t size) :
|
||||
Decompressor(),
|
||||
m_fd(-1),
|
||||
m_buffer(buffer),
|
||||
m_buffer_size(size) {
|
||||
}
|
||||
|
||||
NoDecompressor(const NoDecompressor&) = delete;
|
||||
NoDecompressor& operator=(const NoDecompressor&) = delete;
|
||||
|
||||
NoDecompressor(NoDecompressor&&) = delete;
|
||||
NoDecompressor& operator=(NoDecompressor&&) = delete;
|
||||
|
||||
~NoDecompressor() noexcept final {
|
||||
try {
|
||||
close();
|
||||
@@ -290,10 +305,7 @@ namespace osmium {
|
||||
}
|
||||
} else {
|
||||
buffer.resize(osmium::io::Decompressor::input_buffer_size);
|
||||
const auto nread = ::read(m_fd, const_cast<char*>(buffer.data()), osmium::io::Decompressor::input_buffer_size);
|
||||
if (nread < 0) {
|
||||
throw std::system_error{errno, std::system_category(), "Read failed"};
|
||||
}
|
||||
const auto nread = detail::reliable_read(m_fd, const_cast<char*>(buffer.data()), osmium::io::Decompressor::input_buffer_size);
|
||||
buffer.resize(std::string::size_type(nread));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,7 +33,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/io/writer.hpp> // IWYU pragma: export
|
||||
#include <osmium/io/detail/debug_output_format.hpp> // IWYU pragma: export
|
||||
#include <osmium/io/writer.hpp> // IWYU pragma: export
|
||||
|
||||
#endif // OSMIUM_IO_DEBUG_OUTPUT_HPP
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,16 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/crc.hpp>
|
||||
|
||||
#include <osmium/io/detail/output_format.hpp>
|
||||
#include <osmium/io/detail/queue_util.hpp>
|
||||
#include <osmium/io/detail/string_util.hpp>
|
||||
@@ -56,6 +46,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/crc.hpp>
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/metadata_options.hpp>
|
||||
#include <osmium/osm/node.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/object.hpp>
|
||||
@@ -68,6 +59,16 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/util/minmax.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
#include <boost/crc.hpp>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@@ -92,18 +93,19 @@ namespace osmium {
|
||||
|
||||
struct debug_output_options {
|
||||
|
||||
/// Should metadata of objects be added?
|
||||
bool add_metadata;
|
||||
/// Which metadata of objects should be added?
|
||||
osmium::metadata_options add_metadata;
|
||||
|
||||
/// Output with ANSI colors?
|
||||
bool use_color;
|
||||
bool use_color = false;
|
||||
|
||||
/// Add CRC32 checksum to each object?
|
||||
bool add_crc32;
|
||||
bool add_crc32 = false;
|
||||
|
||||
/// Write in form of a diff file?
|
||||
bool format_as_diff;
|
||||
};
|
||||
bool format_as_diff = false;
|
||||
|
||||
}; // struct debug_output_options
|
||||
|
||||
/**
|
||||
* Writes out one buffer with OSM data in Debug format.
|
||||
@@ -144,7 +146,8 @@ namespace osmium {
|
||||
*m_out += '-';
|
||||
*m_out += color_reset;
|
||||
return;
|
||||
} else if (m_diff_char == '+') {
|
||||
}
|
||||
if (m_diff_char == '+') {
|
||||
*m_out += color_backg_green;
|
||||
*m_out += color_white;
|
||||
*m_out += color_bold;
|
||||
@@ -218,26 +221,36 @@ namespace osmium {
|
||||
|
||||
void write_meta(const osmium::OSMObject& object) {
|
||||
output_int(object.id());
|
||||
*m_out += '\n';
|
||||
if (m_options.add_metadata) {
|
||||
if (object.visible()) {
|
||||
*m_out += " visible\n";
|
||||
} else {
|
||||
write_error(" deleted\n");
|
||||
}
|
||||
if (m_options.add_metadata.version()) {
|
||||
write_fieldname("version");
|
||||
*m_out += " ";
|
||||
output_int(object.version());
|
||||
if (object.visible()) {
|
||||
*m_out += " visible\n";
|
||||
} else {
|
||||
write_error(" deleted\n");
|
||||
}
|
||||
*m_out += '\n';
|
||||
}
|
||||
if (m_options.add_metadata.changeset()) {
|
||||
write_fieldname("changeset");
|
||||
output_int(object.changeset());
|
||||
*m_out += '\n';
|
||||
}
|
||||
if (m_options.add_metadata.timestamp()) {
|
||||
write_fieldname("timestamp");
|
||||
write_timestamp(object.timestamp());
|
||||
}
|
||||
if (m_options.add_metadata.user() || m_options.add_metadata.uid()) {
|
||||
write_fieldname("user");
|
||||
*m_out += " ";
|
||||
output_int(object.uid());
|
||||
*m_out += ' ';
|
||||
write_string(object.user());
|
||||
if (m_options.add_metadata.uid()) {
|
||||
output_int(object.uid());
|
||||
*m_out += ' ';
|
||||
}
|
||||
if (m_options.add_metadata.user()) {
|
||||
write_string(object.user());
|
||||
}
|
||||
*m_out += '\n';
|
||||
}
|
||||
}
|
||||
@@ -261,8 +274,9 @@ namespace osmium {
|
||||
*m_out += " ";
|
||||
write_string(tag.key());
|
||||
auto spacing = max() - std::strlen(tag.key());
|
||||
while (spacing--) {
|
||||
while (spacing > 0) {
|
||||
*m_out += " ";
|
||||
--spacing;
|
||||
}
|
||||
*m_out += " = ";
|
||||
write_string(tag.value());
|
||||
@@ -322,14 +336,6 @@ namespace osmium {
|
||||
m_utf8_suffix(options.use_color ? color_blue : "") {
|
||||
}
|
||||
|
||||
DebugOutputBlock(const DebugOutputBlock&) = default;
|
||||
DebugOutputBlock& operator=(const DebugOutputBlock&) = default;
|
||||
|
||||
DebugOutputBlock(DebugOutputBlock&&) = default;
|
||||
DebugOutputBlock& operator=(DebugOutputBlock&&) = default;
|
||||
|
||||
~DebugOutputBlock() noexcept = default;
|
||||
|
||||
std::string operator()() {
|
||||
osmium::apply(m_input_buffer->cbegin(), m_input_buffer->cend(), *this);
|
||||
|
||||
@@ -522,19 +528,13 @@ namespace osmium {
|
||||
public:
|
||||
|
||||
DebugOutputFormat(osmium::thread::Pool& pool, const osmium::io::File& file, future_string_queue_type& output_queue) :
|
||||
OutputFormat(pool, output_queue),
|
||||
m_options() {
|
||||
m_options.add_metadata = file.is_not_false("add_metadata");
|
||||
OutputFormat(pool, output_queue) {
|
||||
m_options.add_metadata = osmium::metadata_options{file.get("add_metadata")};
|
||||
m_options.use_color = file.is_true("color");
|
||||
m_options.add_crc32 = file.is_true("add_crc32");
|
||||
m_options.format_as_diff = file.is_true("diff");
|
||||
}
|
||||
|
||||
DebugOutputFormat(const DebugOutputFormat&) = delete;
|
||||
DebugOutputFormat& operator=(const DebugOutputFormat&) = delete;
|
||||
|
||||
~DebugOutputFormat() noexcept final = default;
|
||||
|
||||
void write_header(const osmium::io::Header& header) final {
|
||||
if (m_options.format_as_diff) {
|
||||
return;
|
||||
|
||||
+30
-26
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,14 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/io/detail/queue_util.hpp>
|
||||
#include <osmium/io/error.hpp>
|
||||
#include <osmium/io/file.hpp>
|
||||
@@ -50,6 +42,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/entity_bits.hpp>
|
||||
#include <osmium/thread/pool.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@@ -177,37 +177,41 @@ namespace osmium {
|
||||
|
||||
private:
|
||||
|
||||
using map_type = std::map<osmium::io::file_format, create_parser_type>;
|
||||
std::array<create_parser_type, static_cast<std::size_t>(file_format::last) + 1> m_callbacks;
|
||||
|
||||
map_type m_callbacks;
|
||||
ParserFactory() noexcept = default;
|
||||
|
||||
ParserFactory() :
|
||||
m_callbacks() {
|
||||
create_parser_type& callbacks(const osmium::io::file_format format) noexcept {
|
||||
return m_callbacks[static_cast<std::size_t>(format)];
|
||||
}
|
||||
|
||||
const create_parser_type& callbacks(const osmium::io::file_format format) const noexcept {
|
||||
return m_callbacks[static_cast<std::size_t>(format)];
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static ParserFactory& instance() {
|
||||
static ParserFactory& instance() noexcept {
|
||||
static ParserFactory factory;
|
||||
return factory;
|
||||
}
|
||||
|
||||
bool register_parser(osmium::io::file_format format, create_parser_type&& create_function) {
|
||||
const auto result = m_callbacks.emplace(format, std::forward<create_parser_type>(create_function));
|
||||
return result.second;
|
||||
bool register_parser(const osmium::io::file_format format, create_parser_type&& create_function) {
|
||||
callbacks(format) = std::forward<create_parser_type>(create_function);
|
||||
return true;
|
||||
}
|
||||
|
||||
create_parser_type get_creator_function(const osmium::io::File& file) const {
|
||||
const auto it = m_callbacks.find(file.format());
|
||||
if (it == m_callbacks.end()) {
|
||||
throw unsupported_file_format_error{
|
||||
std::string{"Can not open file '"} +
|
||||
file.filename() +
|
||||
"' with type '" +
|
||||
as_string(file.format()) +
|
||||
"'. No support for reading this format in this program."};
|
||||
const auto func = callbacks(file.format());
|
||||
if (func) {
|
||||
return func;
|
||||
}
|
||||
return it->second;
|
||||
throw unsupported_file_format_error{
|
||||
std::string{"Can not open file '"} +
|
||||
file.filename() +
|
||||
"' with type '" +
|
||||
as_string(file.format()) +
|
||||
"'. No support for reading this format in this program."};
|
||||
}
|
||||
|
||||
}; // class ParserFactory
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,18 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <protozero/exception.hpp>
|
||||
#include <protozero/varint.hpp>
|
||||
|
||||
#include <osmium/builder/osm_object_builder.hpp>
|
||||
#include <osmium/io/detail/input_format.hpp>
|
||||
#include <osmium/io/detail/queue_util.hpp>
|
||||
@@ -63,9 +51,21 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
#include <osmium/thread/util.hpp>
|
||||
#include <osmium/util/cast.hpp>
|
||||
#include <osmium/util/delta.hpp>
|
||||
|
||||
#include <protozero/exception.hpp>
|
||||
#include <protozero/varint.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <future>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace builder {
|
||||
@@ -90,7 +90,7 @@ namespace osmium {
|
||||
namespace detail {
|
||||
|
||||
// Implementation of the o5m/o5c file formats according to the
|
||||
// description at http://wiki.openstreetmap.org/wiki/O5m .
|
||||
// description at https://wiki.openstreetmap.org/wiki/O5m .
|
||||
|
||||
class ReferenceTable {
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace osmium {
|
||||
if (m_table.empty() || index == 0 || index > number_of_entries) {
|
||||
throw o5m_error{"reference to non-existing string in table"};
|
||||
}
|
||||
auto entry = (current_entry + number_of_entries - index) % number_of_entries;
|
||||
const auto entry = (current_entry + number_of_entries - index) % number_of_entries;
|
||||
return &m_table[entry * entry_size];
|
||||
}
|
||||
|
||||
@@ -145,13 +145,13 @@ namespace osmium {
|
||||
|
||||
class O5mParser : public Parser {
|
||||
|
||||
static constexpr int buffer_size = 2 * 1000 * 1000;
|
||||
static constexpr std::size_t buffer_size = 2 * 1000 * 1000;
|
||||
|
||||
osmium::io::Header m_header;
|
||||
osmium::io::Header m_header{};
|
||||
|
||||
osmium::memory::Buffer m_buffer;
|
||||
|
||||
std::string m_input;
|
||||
std::string m_input{};
|
||||
|
||||
const char* m_data;
|
||||
const char* m_end;
|
||||
@@ -163,7 +163,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
bool ensure_bytes_available(std::size_t need_bytes) {
|
||||
if ((m_end - m_data) >= long(need_bytes)) {
|
||||
if ((m_end - m_data) >= static_cast<int64_t>(need_bytes)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace osmium {
|
||||
void check_header_magic() {
|
||||
static const unsigned char header_magic[] = { 0xff, 0xe0, 0x04, 'o', '5' };
|
||||
|
||||
if (std::strncmp(reinterpret_cast<const char*>(header_magic), m_data, sizeof(header_magic))) {
|
||||
if (std::strncmp(reinterpret_cast<const char*>(header_magic), m_data, sizeof(header_magic)) != 0) {
|
||||
throw o5m_error{"wrong header magic"};
|
||||
}
|
||||
|
||||
@@ -231,15 +231,15 @@ namespace osmium {
|
||||
set_header_value(m_header);
|
||||
}
|
||||
|
||||
osmium::util::DeltaDecode<osmium::object_id_type> m_delta_id;
|
||||
osmium::DeltaDecode<osmium::object_id_type> m_delta_id;
|
||||
|
||||
osmium::util::DeltaDecode<int64_t> m_delta_timestamp;
|
||||
osmium::util::DeltaDecode<osmium::changeset_id_type> m_delta_changeset;
|
||||
osmium::util::DeltaDecode<int64_t> m_delta_lon;
|
||||
osmium::util::DeltaDecode<int64_t> m_delta_lat;
|
||||
osmium::DeltaDecode<int64_t> m_delta_timestamp;
|
||||
osmium::DeltaDecode<osmium::changeset_id_type> m_delta_changeset;
|
||||
osmium::DeltaDecode<int64_t> m_delta_lon;
|
||||
osmium::DeltaDecode<int64_t> m_delta_lat;
|
||||
|
||||
osmium::util::DeltaDecode<osmium::object_id_type> m_delta_way_node_id;
|
||||
osmium::util::DeltaDecode<osmium::object_id_type> m_delta_member_ids[3];
|
||||
osmium::DeltaDecode<osmium::object_id_type> m_delta_way_node_id;
|
||||
osmium::DeltaDecode<osmium::object_id_type> m_delta_member_ids[3];
|
||||
|
||||
void reset() {
|
||||
m_reference_table.clear();
|
||||
@@ -263,18 +263,21 @@ namespace osmium {
|
||||
throw o5m_error{"string format error"};
|
||||
}
|
||||
return *dataptr;
|
||||
} else { // get from reference table
|
||||
auto index = protozero::decode_varint(dataptr, end);
|
||||
return m_reference_table.get(index);
|
||||
}
|
||||
// get from reference table
|
||||
const auto index = protozero::decode_varint(dataptr, end);
|
||||
return m_reference_table.get(index);
|
||||
}
|
||||
|
||||
std::pair<osmium::user_id_type, const char*> decode_user(const char** dataptr, const char* const end) {
|
||||
bool update_pointer = (**dataptr == 0x00);
|
||||
const bool update_pointer = (**dataptr == 0x00);
|
||||
const char* data = decode_string(dataptr, end);
|
||||
const char* start = data;
|
||||
|
||||
auto uid = protozero::decode_varint(&data, end);
|
||||
const auto uid = protozero::decode_varint(&data, end);
|
||||
if (uid > std::numeric_limits<user_id_type>::max()) {
|
||||
throw o5m_error{"uid out of range"};
|
||||
}
|
||||
|
||||
if (data == end) {
|
||||
throw o5m_error{"missing user name"};
|
||||
@@ -285,7 +288,7 @@ namespace osmium {
|
||||
if (uid == 0 && update_pointer) {
|
||||
m_reference_table.add("\0\0", 2);
|
||||
*dataptr = data;
|
||||
return std::make_pair(0, "");
|
||||
return {0, ""};
|
||||
}
|
||||
|
||||
while (*data++) {
|
||||
@@ -299,14 +302,14 @@ namespace osmium {
|
||||
*dataptr = data;
|
||||
}
|
||||
|
||||
return std::make_pair(static_cast_with_assert<osmium::user_id_type>(uid), user);
|
||||
return {static_cast<osmium::user_id_type>(uid), user};
|
||||
}
|
||||
|
||||
void decode_tags(osmium::builder::Builder& parent, const char** dataptr, const char* const end) {
|
||||
osmium::builder::TagListBuilder builder{parent};
|
||||
|
||||
while (*dataptr != end) {
|
||||
bool update_pointer = (**dataptr == 0x00);
|
||||
const bool update_pointer = (**dataptr == 0x00);
|
||||
const char* data = decode_string(dataptr, end);
|
||||
const char* start = data;
|
||||
|
||||
@@ -316,6 +319,10 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
|
||||
if (data == end) {
|
||||
throw o5m_error{"no null byte in tag value"};
|
||||
}
|
||||
|
||||
const char* value = data;
|
||||
while (*data++) {
|
||||
if (data == end) {
|
||||
@@ -338,8 +345,13 @@ namespace osmium {
|
||||
if (**dataptr == 0x00) { // no info section
|
||||
++*dataptr;
|
||||
} else { // has info section
|
||||
object.set_version(static_cast_with_assert<object_version_type>(protozero::decode_varint(dataptr, end)));
|
||||
auto timestamp = m_delta_timestamp.update(zvarint(dataptr, end));
|
||||
const auto version = protozero::decode_varint(dataptr, end);
|
||||
if (version > std::numeric_limits<object_version_type>::max()) {
|
||||
throw o5m_error{"object version too large"};
|
||||
}
|
||||
object.set_version(static_cast<object_version_type>(version));
|
||||
|
||||
const auto timestamp = m_delta_timestamp.update(zvarint(dataptr, end));
|
||||
if (timestamp != 0) { // has timestamp
|
||||
object.set_timestamp(timestamp);
|
||||
object.set_changeset(m_delta_changeset.update(zvarint(dataptr, end)));
|
||||
@@ -368,8 +380,8 @@ namespace osmium {
|
||||
builder.set_visible(false);
|
||||
builder.set_location(osmium::Location{});
|
||||
} else {
|
||||
auto lon = m_delta_lon.update(zvarint(&data, end));
|
||||
auto lat = m_delta_lat.update(zvarint(&data, end));
|
||||
const auto lon = m_delta_lon.update(zvarint(&data, end));
|
||||
const auto lat = m_delta_lat.update(zvarint(&data, end));
|
||||
builder.set_location(osmium::Location{lon, lat});
|
||||
|
||||
if (data != end) {
|
||||
@@ -389,7 +401,7 @@ namespace osmium {
|
||||
// no reference section, object is deleted
|
||||
builder.set_visible(false);
|
||||
} else {
|
||||
auto reference_section_length = protozero::decode_varint(&data, end);
|
||||
const auto reference_section_length = protozero::decode_varint(&data, end);
|
||||
if (reference_section_length > 0) {
|
||||
const char* const end_refs = data + reference_section_length;
|
||||
if (end_refs > end) {
|
||||
@@ -417,7 +429,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
std::pair<osmium::item_type, const char*> decode_role(const char** dataptr, const char* const end) {
|
||||
bool update_pointer = (**dataptr == 0x00);
|
||||
const bool update_pointer = (**dataptr == 0x00);
|
||||
const char* data = decode_string(dataptr, end);
|
||||
const char* start = data;
|
||||
|
||||
@@ -438,7 +450,7 @@ namespace osmium {
|
||||
*dataptr = data;
|
||||
}
|
||||
|
||||
return std::make_pair(member_type, role);
|
||||
return {member_type, role};
|
||||
}
|
||||
|
||||
void decode_relation(const char* data, const char* const end) {
|
||||
@@ -452,7 +464,7 @@ namespace osmium {
|
||||
// no reference section, object is deleted
|
||||
builder.set_visible(false);
|
||||
} else {
|
||||
auto reference_section_length = protozero::decode_varint(&data, end);
|
||||
const auto reference_section_length = protozero::decode_varint(&data, end);
|
||||
if (reference_section_length > 0) {
|
||||
const char* const end_refs = data + reference_section_length;
|
||||
if (end_refs > end) {
|
||||
@@ -480,23 +492,23 @@ namespace osmium {
|
||||
}
|
||||
|
||||
void decode_bbox(const char* data, const char* const end) {
|
||||
auto sw_lon = zvarint(&data, end);
|
||||
auto sw_lat = zvarint(&data, end);
|
||||
auto ne_lon = zvarint(&data, end);
|
||||
auto ne_lat = zvarint(&data, end);
|
||||
const auto sw_lon = zvarint(&data, end);
|
||||
const auto sw_lat = zvarint(&data, end);
|
||||
const auto ne_lon = zvarint(&data, end);
|
||||
const auto ne_lat = zvarint(&data, end);
|
||||
|
||||
m_header.add_box(osmium::Box{osmium::Location{sw_lon, sw_lat},
|
||||
osmium::Location{ne_lon, ne_lat}});
|
||||
}
|
||||
|
||||
void decode_timestamp(const char* data, const char* const end) {
|
||||
auto timestamp = osmium::Timestamp(zvarint(&data, end)).to_iso();
|
||||
const auto timestamp = osmium::Timestamp(zvarint(&data, end)).to_iso();
|
||||
m_header.set("o5m_timestamp", timestamp);
|
||||
m_header.set("timestamp", timestamp);
|
||||
}
|
||||
|
||||
void flush() {
|
||||
osmium::memory::Buffer buffer(buffer_size);
|
||||
osmium::memory::Buffer buffer{buffer_size};
|
||||
using std::swap;
|
||||
swap(m_buffer, buffer);
|
||||
send_to_output_queue(std::move(buffer));
|
||||
@@ -516,7 +528,7 @@ namespace osmium {
|
||||
|
||||
void decode_data() {
|
||||
while (ensure_bytes_available(1)) {
|
||||
dataset_type ds_type = dataset_type(*m_data++);
|
||||
const auto ds_type = static_cast<dataset_type>(*m_data++);
|
||||
if (ds_type > dataset_type::jump) {
|
||||
if (ds_type == dataset_type::reset) {
|
||||
reset();
|
||||
@@ -591,13 +603,17 @@ namespace osmium {
|
||||
|
||||
explicit O5mParser(parser_arguments& args) :
|
||||
Parser(args),
|
||||
m_header(),
|
||||
m_buffer(buffer_size),
|
||||
m_input(),
|
||||
m_data(m_input.data()),
|
||||
m_end(m_data) {
|
||||
}
|
||||
|
||||
O5mParser(const O5mParser&) = delete;
|
||||
O5mParser& operator=(const O5mParser&) = delete;
|
||||
|
||||
O5mParser(O5mParser&&) = delete;
|
||||
O5mParser& operator=(O5mParser&&) = delete;
|
||||
|
||||
~O5mParser() noexcept final = default;
|
||||
|
||||
void run() final {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,11 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/io/detail/input_format.hpp>
|
||||
#include <osmium/io/detail/opl_parser_functions.hpp>
|
||||
#include <osmium/io/file_format.hpp>
|
||||
@@ -45,6 +40,11 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
#include <osmium/thread/util.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@@ -120,6 +120,12 @@ namespace osmium {
|
||||
set_header_value(osmium::io::Header{});
|
||||
}
|
||||
|
||||
OPLParser(const OPLParser&) = delete;
|
||||
OPLParser& operator=(const OPLParser&) = delete;
|
||||
|
||||
OPLParser(OPLParser&&) = delete;
|
||||
OPLParser& operator=(OPLParser&&) = delete;
|
||||
|
||||
~OPLParser() noexcept final = default;
|
||||
|
||||
void parse_line(const char* data) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,12 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/io/detail/output_format.hpp>
|
||||
#include <osmium/io/detail/queue_util.hpp>
|
||||
#include <osmium/io/detail/string_util.hpp>
|
||||
@@ -51,6 +45,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/changeset.hpp>
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/metadata_options.hpp>
|
||||
#include <osmium/osm/node.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/object.hpp>
|
||||
@@ -61,6 +56,12 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/thread/pool.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@@ -69,16 +70,16 @@ namespace osmium {
|
||||
|
||||
struct opl_output_options {
|
||||
|
||||
/// Should metadata of objects be added?
|
||||
bool add_metadata;
|
||||
/// Which metadata of objects should be added?
|
||||
osmium::metadata_options add_metadata;
|
||||
|
||||
/// Should node locations be added to ways?
|
||||
bool locations_on_ways;
|
||||
bool locations_on_ways = false;
|
||||
|
||||
/// Write in form of a diff file?
|
||||
bool format_as_diff;
|
||||
bool format_as_diff = false;
|
||||
|
||||
};
|
||||
}; // struct opl_output_options
|
||||
|
||||
/**
|
||||
* Writes out one buffer with OSM data in OPL format.
|
||||
@@ -123,19 +124,29 @@ namespace osmium {
|
||||
|
||||
void write_meta(const osmium::OSMObject& object) {
|
||||
output_int(object.id());
|
||||
if (m_options.add_metadata) {
|
||||
*m_out += ' ';
|
||||
write_field_int('v', object.version());
|
||||
if (m_options.add_metadata.any()) {
|
||||
if (m_options.add_metadata.version()) {
|
||||
*m_out += ' ';
|
||||
write_field_int('v', object.version());
|
||||
}
|
||||
*m_out += " d";
|
||||
*m_out += (object.visible() ? 'V' : 'D');
|
||||
*m_out += ' ';
|
||||
write_field_int('c', object.changeset());
|
||||
*m_out += ' ';
|
||||
write_field_timestamp('t', object.timestamp());
|
||||
*m_out += ' ';
|
||||
write_field_int('i', object.uid());
|
||||
*m_out += " u";
|
||||
append_encoded_string(object.user());
|
||||
if (m_options.add_metadata.changeset()) {
|
||||
*m_out += ' ';
|
||||
write_field_int('c', object.changeset());
|
||||
}
|
||||
if (m_options.add_metadata.timestamp()) {
|
||||
*m_out += ' ';
|
||||
write_field_timestamp('t', object.timestamp());
|
||||
}
|
||||
if (m_options.add_metadata.uid()) {
|
||||
*m_out += ' ';
|
||||
write_field_int('i', object.uid());
|
||||
}
|
||||
if (m_options.add_metadata.user()) {
|
||||
*m_out += " u";
|
||||
append_encoded_string(object.user());
|
||||
}
|
||||
}
|
||||
write_tags(object.tags());
|
||||
}
|
||||
@@ -167,14 +178,6 @@ namespace osmium {
|
||||
m_options(options) {
|
||||
}
|
||||
|
||||
OPLOutputBlock(const OPLOutputBlock&) = default;
|
||||
OPLOutputBlock& operator=(const OPLOutputBlock&) = default;
|
||||
|
||||
OPLOutputBlock(OPLOutputBlock&&) = default;
|
||||
OPLOutputBlock& operator=(OPLOutputBlock&&) = default;
|
||||
|
||||
~OPLOutputBlock() noexcept = default;
|
||||
|
||||
std::string operator()() {
|
||||
osmium::apply(m_input_buffer->cbegin(), m_input_buffer->cend(), *this);
|
||||
|
||||
@@ -285,18 +288,12 @@ namespace osmium {
|
||||
public:
|
||||
|
||||
OPLOutputFormat(osmium::thread::Pool& pool, const osmium::io::File& file, future_string_queue_type& output_queue) :
|
||||
OutputFormat(pool, output_queue),
|
||||
m_options() {
|
||||
m_options.add_metadata = file.is_not_false("add_metadata");
|
||||
OutputFormat(pool, output_queue) {
|
||||
m_options.add_metadata = osmium::metadata_options{file.get("add_metadata")};
|
||||
m_options.locations_on_ways = file.is_true("locations_on_ways");
|
||||
m_options.format_as_diff = file.is_true("diff");
|
||||
}
|
||||
|
||||
OPLOutputFormat(const OPLOutputFormat&) = delete;
|
||||
OPLOutputFormat& operator=(const OPLOutputFormat&) = delete;
|
||||
|
||||
~OPLOutputFormat() noexcept final = default;
|
||||
|
||||
void write_buffer(osmium::memory::Buffer&& buffer) final {
|
||||
m_output_queue.push(m_pool.submit(OPLOutputBlock{std::move(buffer), m_options}));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,15 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <utf8.h>
|
||||
|
||||
#include <osmium/builder/osm_object_builder.hpp>
|
||||
#include <osmium/io/error.hpp>
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
@@ -56,6 +47,15 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
|
||||
#include <utf8.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace builder {
|
||||
@@ -187,7 +187,8 @@ namespace osmium {
|
||||
while (true) {
|
||||
if (*s == '\0' || *s == ' ' || *s == '\t' || *s == ',' || *s == '=') {
|
||||
break;
|
||||
} else if (*s == '%') {
|
||||
}
|
||||
if (*s == '%') {
|
||||
++s;
|
||||
opl_parse_escaped(&s, result);
|
||||
} else {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,13 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/io/detail/queue_util.hpp>
|
||||
#include <osmium/io/error.hpp>
|
||||
@@ -48,6 +41,13 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
#include <osmium/thread/pool.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@@ -121,23 +121,23 @@ namespace osmium {
|
||||
|
||||
public:
|
||||
|
||||
OutputFormat(osmium::thread::Pool& pool, future_string_queue_type& output_queue) :
|
||||
OutputFormat(osmium::thread::Pool& pool, future_string_queue_type& output_queue) noexcept :
|
||||
m_pool(pool),
|
||||
m_output_queue(output_queue) {
|
||||
}
|
||||
|
||||
OutputFormat(const OutputFormat&) = delete;
|
||||
OutputFormat(OutputFormat&&) = delete;
|
||||
|
||||
OutputFormat& operator=(const OutputFormat&) = delete;
|
||||
|
||||
OutputFormat(OutputFormat&&) = delete;
|
||||
OutputFormat& operator=(OutputFormat&&) = delete;
|
||||
|
||||
virtual ~OutputFormat() noexcept = default;
|
||||
|
||||
virtual void write_header(const osmium::io::Header&) {
|
||||
virtual void write_header(const osmium::io::Header& /*header*/) {
|
||||
}
|
||||
|
||||
virtual void write_buffer(osmium::memory::Buffer&&) = 0;
|
||||
virtual void write_buffer(osmium::memory::Buffer&& /*buffer*/) = 0;
|
||||
|
||||
virtual void write_end() {
|
||||
}
|
||||
@@ -159,32 +159,34 @@ namespace osmium {
|
||||
|
||||
private:
|
||||
|
||||
using map_type = std::map<osmium::io::file_format, create_output_type>;
|
||||
std::array<create_output_type, static_cast<std::size_t>(file_format::last) + 1> m_callbacks;
|
||||
|
||||
map_type m_callbacks;
|
||||
OutputFormatFactory() noexcept = default;
|
||||
|
||||
OutputFormatFactory() :
|
||||
m_callbacks() {
|
||||
create_output_type& callbacks(const osmium::io::file_format format) noexcept {
|
||||
return m_callbacks[static_cast<std::size_t>(format)];
|
||||
}
|
||||
|
||||
const create_output_type& callbacks(const osmium::io::file_format format) const noexcept {
|
||||
return m_callbacks[static_cast<std::size_t>(format)];
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static OutputFormatFactory& instance() {
|
||||
static OutputFormatFactory& instance() noexcept {
|
||||
static OutputFormatFactory factory;
|
||||
return factory;
|
||||
}
|
||||
|
||||
bool register_output_format(osmium::io::file_format format, create_output_type create_function) {
|
||||
if (! m_callbacks.insert(map_type::value_type(format, create_function)).second) {
|
||||
return false;
|
||||
}
|
||||
bool register_output_format(const osmium::io::file_format format, create_output_type&& create_function) {
|
||||
callbacks(format) = std::forward<create_output_type>(create_function);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<osmium::io::detail::OutputFormat> create_output(osmium::thread::Pool& pool, const osmium::io::File& file, future_string_queue_type& output_queue) {
|
||||
const auto it = m_callbacks.find(file.format());
|
||||
if (it != m_callbacks.end()) {
|
||||
return std::unique_ptr<osmium::io::detail::OutputFormat>((it->second)(pool, file, output_queue));
|
||||
std::unique_ptr<osmium::io::detail::OutputFormat> create_output(osmium::thread::Pool& pool, const osmium::io::File& file, future_string_queue_type& output_queue) const {
|
||||
const auto func = callbacks(file.format());
|
||||
if (func) {
|
||||
return std::unique_ptr<osmium::io::detail::OutputFormat>((func)(pool, file, output_queue));
|
||||
}
|
||||
|
||||
throw unsupported_file_format_error{
|
||||
@@ -208,6 +210,9 @@ namespace osmium {
|
||||
BlackholeOutputFormat(const BlackholeOutputFormat&) = delete;
|
||||
BlackholeOutputFormat& operator=(const BlackholeOutputFormat&) = delete;
|
||||
|
||||
BlackholeOutputFormat(BlackholeOutputFormat&&) = delete;
|
||||
BlackholeOutputFormat& operator=(BlackholeOutputFormat&&) = delete;
|
||||
|
||||
~BlackholeOutputFormat() noexcept final = default;
|
||||
|
||||
void write_buffer(osmium::memory::Buffer&& /*buffer*/) final {
|
||||
|
||||
+7
-7
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,18 +33,18 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <osmium/io/error.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
|
||||
// needed for htonl and ntohl
|
||||
// needed for htonl and ntohl or their equivalent in protozero
|
||||
#ifndef _WIN32
|
||||
# include <netinet/in.h>
|
||||
#else
|
||||
# include <winsock2.h>
|
||||
# include <protozero/byteswap.hpp>
|
||||
#endif
|
||||
|
||||
#include <osmium/io/error.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
|
||||
+170
-163
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,19 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <protozero/iterators.hpp>
|
||||
#include <protozero/pbf_message.hpp>
|
||||
#include <protozero/types.hpp>
|
||||
|
||||
#include <osmium/builder/osm_object_builder.hpp>
|
||||
#include <osmium/io/detail/pbf.hpp> // IWYU pragma: export
|
||||
#include <osmium/io/detail/protobuf_tags.hpp>
|
||||
@@ -63,9 +50,21 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/timestamp.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
#include <osmium/osm/way.hpp>
|
||||
#include <osmium/util/cast.hpp>
|
||||
#include <osmium/util/delta.hpp>
|
||||
|
||||
#include <protozero/iterators.hpp>
|
||||
#include <protozero/pbf_message.hpp>
|
||||
#include <protozero/types.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace builder {
|
||||
@@ -103,7 +102,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
protozero::pbf_message<OSMFormat::StringTable> pbf_string_table{data};
|
||||
while (pbf_string_table.next(OSMFormat::StringTable::repeated_bytes_s)) {
|
||||
while (pbf_string_table.next(OSMFormat::StringTable::repeated_bytes_s, protozero::pbf_wire_type::length_delimited)) {
|
||||
const auto str_view = pbf_string_table.get_view();
|
||||
if (str_view.size() > osmium::max_osm_string_length) {
|
||||
throw osmium::pbf_error{"overlong string in string table"};
|
||||
@@ -115,20 +114,20 @@ namespace osmium {
|
||||
void decode_primitive_block_metadata() {
|
||||
protozero::pbf_message<OSMFormat::PrimitiveBlock> pbf_primitive_block{m_data};
|
||||
while (pbf_primitive_block.next()) {
|
||||
switch (pbf_primitive_block.tag()) {
|
||||
case OSMFormat::PrimitiveBlock::required_StringTable_stringtable:
|
||||
switch (pbf_primitive_block.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::PrimitiveBlock::required_StringTable_stringtable, protozero::pbf_wire_type::length_delimited):
|
||||
decode_stringtable(pbf_primitive_block.get_view());
|
||||
break;
|
||||
case OSMFormat::PrimitiveBlock::optional_int32_granularity:
|
||||
case protozero::tag_and_type(OSMFormat::PrimitiveBlock::optional_int32_granularity, protozero::pbf_wire_type::varint):
|
||||
m_granularity = pbf_primitive_block.get_int32();
|
||||
break;
|
||||
case OSMFormat::PrimitiveBlock::optional_int32_date_granularity:
|
||||
case protozero::tag_and_type(OSMFormat::PrimitiveBlock::optional_int32_date_granularity, protozero::pbf_wire_type::varint):
|
||||
m_date_factor = pbf_primitive_block.get_int32();
|
||||
break;
|
||||
case OSMFormat::PrimitiveBlock::optional_int64_lat_offset:
|
||||
case protozero::tag_and_type(OSMFormat::PrimitiveBlock::optional_int64_lat_offset, protozero::pbf_wire_type::varint):
|
||||
m_lat_offset = pbf_primitive_block.get_int64();
|
||||
break;
|
||||
case OSMFormat::PrimitiveBlock::optional_int64_lon_offset:
|
||||
case protozero::tag_and_type(OSMFormat::PrimitiveBlock::optional_int64_lon_offset, protozero::pbf_wire_type::varint):
|
||||
m_lon_offset = pbf_primitive_block.get_int64();
|
||||
break;
|
||||
default:
|
||||
@@ -139,11 +138,11 @@ namespace osmium {
|
||||
|
||||
void decode_primitive_block_data() {
|
||||
protozero::pbf_message<OSMFormat::PrimitiveBlock> pbf_primitive_block{m_data};
|
||||
while (pbf_primitive_block.next(OSMFormat::PrimitiveBlock::repeated_PrimitiveGroup_primitivegroup)) {
|
||||
while (pbf_primitive_block.next(OSMFormat::PrimitiveBlock::repeated_PrimitiveGroup_primitivegroup, protozero::pbf_wire_type::length_delimited)) {
|
||||
protozero::pbf_message<OSMFormat::PrimitiveGroup> pbf_primitive_group = pbf_primitive_block.get_message();
|
||||
while (pbf_primitive_group.next()) {
|
||||
switch (pbf_primitive_group.tag()) {
|
||||
case OSMFormat::PrimitiveGroup::repeated_Node_nodes:
|
||||
switch (pbf_primitive_group.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::PrimitiveGroup::repeated_Node_nodes, protozero::pbf_wire_type::length_delimited):
|
||||
if (m_read_types & osmium::osm_entity_bits::node) {
|
||||
decode_node(pbf_primitive_group.get_view());
|
||||
m_buffer.commit();
|
||||
@@ -151,7 +150,7 @@ namespace osmium {
|
||||
pbf_primitive_group.skip();
|
||||
}
|
||||
break;
|
||||
case OSMFormat::PrimitiveGroup::optional_DenseNodes_dense:
|
||||
case protozero::tag_and_type(OSMFormat::PrimitiveGroup::optional_DenseNodes_dense, protozero::pbf_wire_type::length_delimited):
|
||||
if (m_read_types & osmium::osm_entity_bits::node) {
|
||||
if (m_read_metadata == osmium::io::read_meta::yes) {
|
||||
decode_dense_nodes(pbf_primitive_group.get_view());
|
||||
@@ -163,7 +162,7 @@ namespace osmium {
|
||||
pbf_primitive_group.skip();
|
||||
}
|
||||
break;
|
||||
case OSMFormat::PrimitiveGroup::repeated_Way_ways:
|
||||
case protozero::tag_and_type(OSMFormat::PrimitiveGroup::repeated_Way_ways, protozero::pbf_wire_type::length_delimited):
|
||||
if (m_read_types & osmium::osm_entity_bits::way) {
|
||||
decode_way(pbf_primitive_group.get_view());
|
||||
m_buffer.commit();
|
||||
@@ -171,7 +170,7 @@ namespace osmium {
|
||||
pbf_primitive_group.skip();
|
||||
}
|
||||
break;
|
||||
case OSMFormat::PrimitiveGroup::repeated_Relation_relations:
|
||||
case protozero::tag_and_type(OSMFormat::PrimitiveGroup::repeated_Relation_relations, protozero::pbf_wire_type::length_delimited):
|
||||
if (m_read_types & osmium::osm_entity_bits::relation) {
|
||||
decode_relation(pbf_primitive_group.get_view());
|
||||
m_buffer.commit();
|
||||
@@ -191,35 +190,45 @@ namespace osmium {
|
||||
|
||||
protozero::pbf_message<OSMFormat::Info> pbf_info{data};
|
||||
while (pbf_info.next()) {
|
||||
switch (pbf_info.tag()) {
|
||||
case OSMFormat::Info::optional_int32_version:
|
||||
switch (pbf_info.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::Info::optional_int32_version, protozero::pbf_wire_type::varint):
|
||||
{
|
||||
const auto version = pbf_info.get_int32();
|
||||
if (version < 0) {
|
||||
if (version < -1) {
|
||||
throw osmium::pbf_error{"object version must not be negative"};
|
||||
}
|
||||
object.set_version(static_cast_with_assert<object_version_type>(version));
|
||||
|
||||
if (version == -1) {
|
||||
object.set_version(0U);
|
||||
} else {
|
||||
object.set_version(static_cast<object_version_type>(version));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OSMFormat::Info::optional_int64_timestamp:
|
||||
case protozero::tag_and_type(OSMFormat::Info::optional_int64_timestamp, protozero::pbf_wire_type::varint):
|
||||
object.set_timestamp(pbf_info.get_int64() * m_date_factor / 1000);
|
||||
break;
|
||||
case OSMFormat::Info::optional_int64_changeset:
|
||||
case protozero::tag_and_type(OSMFormat::Info::optional_int64_changeset, protozero::pbf_wire_type::varint):
|
||||
{
|
||||
const auto changeset_id = pbf_info.get_int64();
|
||||
if (changeset_id < 0) {
|
||||
throw osmium::pbf_error{"object changeset_id must not be negative"};
|
||||
if (changeset_id < -1 || changeset_id >= std::numeric_limits<changeset_id_type>::max()) {
|
||||
throw osmium::pbf_error{"object changeset_id must be between 0 and 2^32-1"};
|
||||
}
|
||||
|
||||
if (changeset_id == -1) {
|
||||
object.set_changeset(0U);
|
||||
} else {
|
||||
object.set_changeset(static_cast<changeset_id_type>(changeset_id));
|
||||
}
|
||||
object.set_changeset(static_cast_with_assert<changeset_id_type>(changeset_id));
|
||||
}
|
||||
break;
|
||||
case OSMFormat::Info::optional_int32_uid:
|
||||
case protozero::tag_and_type(OSMFormat::Info::optional_int32_uid, protozero::pbf_wire_type::varint):
|
||||
object.set_uid_from_signed(pbf_info.get_int32());
|
||||
break;
|
||||
case OSMFormat::Info::optional_uint32_user_sid:
|
||||
case protozero::tag_and_type(OSMFormat::Info::optional_uint32_user_sid, protozero::pbf_wire_type::varint):
|
||||
user = m_stringtable.at(pbf_info.get_uint32());
|
||||
break;
|
||||
case OSMFormat::Info::optional_bool_visible:
|
||||
case protozero::tag_and_type(OSMFormat::Info::optional_bool_visible, protozero::pbf_wire_type::varint):
|
||||
object.set_visible(pbf_info.get_bool());
|
||||
break;
|
||||
default:
|
||||
@@ -249,7 +258,7 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
|
||||
int32_t convert_pbf_coordinate(int64_t c) const {
|
||||
int32_t convert_pbf_coordinate(int64_t c) const noexcept {
|
||||
return int32_t((c * m_granularity + m_lon_offset) / resolution_convert);
|
||||
}
|
||||
|
||||
@@ -266,27 +275,27 @@ namespace osmium {
|
||||
|
||||
protozero::pbf_message<OSMFormat::Node> pbf_node{data};
|
||||
while (pbf_node.next()) {
|
||||
switch (pbf_node.tag()) {
|
||||
case OSMFormat::Node::required_sint64_id:
|
||||
switch (pbf_node.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::Node::required_sint64_id, protozero::pbf_wire_type::varint):
|
||||
node.set_id(pbf_node.get_sint64());
|
||||
break;
|
||||
case OSMFormat::Node::packed_uint32_keys:
|
||||
case protozero::tag_and_type(OSMFormat::Node::packed_uint32_keys, protozero::pbf_wire_type::length_delimited):
|
||||
keys = pbf_node.get_packed_uint32();
|
||||
break;
|
||||
case OSMFormat::Node::packed_uint32_vals:
|
||||
case protozero::tag_and_type(OSMFormat::Node::packed_uint32_vals, protozero::pbf_wire_type::length_delimited):
|
||||
vals = pbf_node.get_packed_uint32();
|
||||
break;
|
||||
case OSMFormat::Node::optional_Info_info:
|
||||
case protozero::tag_and_type(OSMFormat::Node::optional_Info_info, protozero::pbf_wire_type::length_delimited):
|
||||
if (m_read_metadata == osmium::io::read_meta::yes) {
|
||||
user = decode_info(pbf_node.get_view(), builder.object());
|
||||
} else {
|
||||
pbf_node.skip();
|
||||
}
|
||||
break;
|
||||
case OSMFormat::Node::required_sint64_lat:
|
||||
case protozero::tag_and_type(OSMFormat::Node::required_sint64_lat, protozero::pbf_wire_type::varint):
|
||||
lat = pbf_node.get_sint64();
|
||||
break;
|
||||
case OSMFormat::Node::required_sint64_lon:
|
||||
case protozero::tag_and_type(OSMFormat::Node::required_sint64_lon, protozero::pbf_wire_type::varint):
|
||||
lon = pbf_node.get_sint64();
|
||||
break;
|
||||
default:
|
||||
@@ -323,30 +332,30 @@ namespace osmium {
|
||||
|
||||
protozero::pbf_message<OSMFormat::Way> pbf_way{data};
|
||||
while (pbf_way.next()) {
|
||||
switch (pbf_way.tag()) {
|
||||
case OSMFormat::Way::required_int64_id:
|
||||
switch (pbf_way.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::Way::required_int64_id, protozero::pbf_wire_type::varint):
|
||||
builder.object().set_id(pbf_way.get_int64());
|
||||
break;
|
||||
case OSMFormat::Way::packed_uint32_keys:
|
||||
case protozero::tag_and_type(OSMFormat::Way::packed_uint32_keys, protozero::pbf_wire_type::length_delimited):
|
||||
keys = pbf_way.get_packed_uint32();
|
||||
break;
|
||||
case OSMFormat::Way::packed_uint32_vals:
|
||||
case protozero::tag_and_type(OSMFormat::Way::packed_uint32_vals, protozero::pbf_wire_type::length_delimited):
|
||||
vals = pbf_way.get_packed_uint32();
|
||||
break;
|
||||
case OSMFormat::Way::optional_Info_info:
|
||||
case protozero::tag_and_type(OSMFormat::Way::optional_Info_info, protozero::pbf_wire_type::length_delimited):
|
||||
if (m_read_metadata == osmium::io::read_meta::yes) {
|
||||
user = decode_info(pbf_way.get_view(), builder.object());
|
||||
} else {
|
||||
pbf_way.skip();
|
||||
}
|
||||
break;
|
||||
case OSMFormat::Way::packed_sint64_refs:
|
||||
case protozero::tag_and_type(OSMFormat::Way::packed_sint64_refs, protozero::pbf_wire_type::length_delimited):
|
||||
refs = pbf_way.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::Way::packed_sint64_lat:
|
||||
case protozero::tag_and_type(OSMFormat::Way::packed_sint64_lat, protozero::pbf_wire_type::length_delimited):
|
||||
lats = pbf_way.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::Way::packed_sint64_lon:
|
||||
case protozero::tag_and_type(OSMFormat::Way::packed_sint64_lon, protozero::pbf_wire_type::length_delimited):
|
||||
lons = pbf_way.get_packed_sint64();
|
||||
break;
|
||||
default:
|
||||
@@ -358,14 +367,14 @@ namespace osmium {
|
||||
|
||||
if (!refs.empty()) {
|
||||
osmium::builder::WayNodeListBuilder wnl_builder{builder};
|
||||
osmium::util::DeltaDecode<int64_t> ref;
|
||||
osmium::DeltaDecode<int64_t> ref;
|
||||
if (lats.empty()) {
|
||||
for (const auto& ref_value : refs) {
|
||||
wnl_builder.add_node_ref(ref.update(ref_value));
|
||||
}
|
||||
} else {
|
||||
osmium::util::DeltaDecode<int64_t> lon;
|
||||
osmium::util::DeltaDecode<int64_t> lat;
|
||||
osmium::DeltaDecode<int64_t> lon;
|
||||
osmium::DeltaDecode<int64_t> lat;
|
||||
while (!refs.empty() && !lons.empty() && !lats.empty()) {
|
||||
wnl_builder.add_node_ref(
|
||||
ref.update(refs.front()),
|
||||
@@ -395,30 +404,30 @@ namespace osmium {
|
||||
|
||||
protozero::pbf_message<OSMFormat::Relation> pbf_relation{data};
|
||||
while (pbf_relation.next()) {
|
||||
switch (pbf_relation.tag()) {
|
||||
case OSMFormat::Relation::required_int64_id:
|
||||
switch (pbf_relation.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::Relation::required_int64_id, protozero::pbf_wire_type::varint):
|
||||
builder.object().set_id(pbf_relation.get_int64());
|
||||
break;
|
||||
case OSMFormat::Relation::packed_uint32_keys:
|
||||
case protozero::tag_and_type(OSMFormat::Relation::packed_uint32_keys, protozero::pbf_wire_type::length_delimited):
|
||||
keys = pbf_relation.get_packed_uint32();
|
||||
break;
|
||||
case OSMFormat::Relation::packed_uint32_vals:
|
||||
case protozero::tag_and_type(OSMFormat::Relation::packed_uint32_vals, protozero::pbf_wire_type::length_delimited):
|
||||
vals = pbf_relation.get_packed_uint32();
|
||||
break;
|
||||
case OSMFormat::Relation::optional_Info_info:
|
||||
case protozero::tag_and_type(OSMFormat::Relation::optional_Info_info, protozero::pbf_wire_type::length_delimited):
|
||||
if (m_read_metadata == osmium::io::read_meta::yes) {
|
||||
user = decode_info(pbf_relation.get_view(), builder.object());
|
||||
} else {
|
||||
pbf_relation.skip();
|
||||
}
|
||||
break;
|
||||
case OSMFormat::Relation::packed_int32_roles_sid:
|
||||
case protozero::tag_and_type(OSMFormat::Relation::packed_int32_roles_sid, protozero::pbf_wire_type::length_delimited):
|
||||
roles = pbf_relation.get_packed_int32();
|
||||
break;
|
||||
case OSMFormat::Relation::packed_sint64_memids:
|
||||
case protozero::tag_and_type(OSMFormat::Relation::packed_sint64_memids, protozero::pbf_wire_type::length_delimited):
|
||||
refs = pbf_relation.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::Relation::packed_MemberType_types:
|
||||
case protozero::tag_and_type(OSMFormat::Relation::packed_MemberType_types, protozero::pbf_wire_type::length_delimited):
|
||||
types = pbf_relation.get_packed_enum();
|
||||
break;
|
||||
default:
|
||||
@@ -430,7 +439,7 @@ namespace osmium {
|
||||
|
||||
if (!refs.empty()) {
|
||||
osmium::builder::RelationMemberListBuilder rml_builder{builder};
|
||||
osmium::util::DeltaDecode<int64_t> ref;
|
||||
osmium::DeltaDecode<int64_t> ref;
|
||||
while (!roles.empty() && !refs.empty() && !types.empty()) {
|
||||
const auto& r = m_stringtable.at(roles.front());
|
||||
const int type = types.front();
|
||||
@@ -477,17 +486,17 @@ namespace osmium {
|
||||
|
||||
protozero::pbf_message<OSMFormat::DenseNodes> pbf_dense_nodes{data};
|
||||
while (pbf_dense_nodes.next()) {
|
||||
switch (pbf_dense_nodes.tag()) {
|
||||
case OSMFormat::DenseNodes::packed_sint64_id:
|
||||
switch (pbf_dense_nodes.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::DenseNodes::packed_sint64_id, protozero::pbf_wire_type::length_delimited):
|
||||
ids = pbf_dense_nodes.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::DenseNodes::packed_sint64_lat:
|
||||
case protozero::tag_and_type(OSMFormat::DenseNodes::packed_sint64_lat, protozero::pbf_wire_type::length_delimited):
|
||||
lats = pbf_dense_nodes.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::DenseNodes::packed_sint64_lon:
|
||||
case protozero::tag_and_type(OSMFormat::DenseNodes::packed_sint64_lon, protozero::pbf_wire_type::length_delimited):
|
||||
lons = pbf_dense_nodes.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::DenseNodes::packed_int32_keys_vals:
|
||||
case protozero::tag_and_type(OSMFormat::DenseNodes::packed_int32_keys_vals, protozero::pbf_wire_type::length_delimited):
|
||||
tags = pbf_dense_nodes.get_packed_int32();
|
||||
break;
|
||||
default:
|
||||
@@ -495,9 +504,9 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
|
||||
osmium::util::DeltaDecode<int64_t> dense_id;
|
||||
osmium::util::DeltaDecode<int64_t> dense_latitude;
|
||||
osmium::util::DeltaDecode<int64_t> dense_longitude;
|
||||
osmium::DeltaDecode<int64_t> dense_id;
|
||||
osmium::DeltaDecode<int64_t> dense_latitude;
|
||||
osmium::DeltaDecode<int64_t> dense_longitude;
|
||||
|
||||
auto tag_it = tags.begin();
|
||||
|
||||
@@ -531,8 +540,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
void decode_dense_nodes(const data_view& data) {
|
||||
bool has_info = false;
|
||||
bool has_visibles = false;
|
||||
bool has_info = false;
|
||||
|
||||
protozero::iterator_range<protozero::pbf_reader::const_sint64_iterator> ids;
|
||||
protozero::iterator_range<protozero::pbf_reader::const_sint64_iterator> lats;
|
||||
@@ -549,33 +557,32 @@ namespace osmium {
|
||||
|
||||
protozero::pbf_message<OSMFormat::DenseNodes> pbf_dense_nodes{data};
|
||||
while (pbf_dense_nodes.next()) {
|
||||
switch (pbf_dense_nodes.tag()) {
|
||||
case OSMFormat::DenseNodes::packed_sint64_id:
|
||||
switch (pbf_dense_nodes.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::DenseNodes::packed_sint64_id, protozero::pbf_wire_type::length_delimited):
|
||||
ids = pbf_dense_nodes.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::DenseNodes::optional_DenseInfo_denseinfo:
|
||||
case protozero::tag_and_type(OSMFormat::DenseNodes::optional_DenseInfo_denseinfo, protozero::pbf_wire_type::length_delimited):
|
||||
{
|
||||
has_info = true;
|
||||
protozero::pbf_message<OSMFormat::DenseInfo> pbf_dense_info{pbf_dense_nodes.get_message()};
|
||||
while (pbf_dense_info.next()) {
|
||||
switch (pbf_dense_info.tag()) {
|
||||
case OSMFormat::DenseInfo::packed_int32_version:
|
||||
switch (pbf_dense_info.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::DenseInfo::packed_int32_version, protozero::pbf_wire_type::length_delimited):
|
||||
versions = pbf_dense_info.get_packed_int32();
|
||||
break;
|
||||
case OSMFormat::DenseInfo::packed_sint64_timestamp:
|
||||
case protozero::tag_and_type(OSMFormat::DenseInfo::packed_sint64_timestamp, protozero::pbf_wire_type::length_delimited):
|
||||
timestamps = pbf_dense_info.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::DenseInfo::packed_sint64_changeset:
|
||||
case protozero::tag_and_type(OSMFormat::DenseInfo::packed_sint64_changeset, protozero::pbf_wire_type::length_delimited):
|
||||
changesets = pbf_dense_info.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::DenseInfo::packed_sint32_uid:
|
||||
case protozero::tag_and_type(OSMFormat::DenseInfo::packed_sint32_uid, protozero::pbf_wire_type::length_delimited):
|
||||
uids = pbf_dense_info.get_packed_sint32();
|
||||
break;
|
||||
case OSMFormat::DenseInfo::packed_sint32_user_sid:
|
||||
case protozero::tag_and_type(OSMFormat::DenseInfo::packed_sint32_user_sid, protozero::pbf_wire_type::length_delimited):
|
||||
user_sids = pbf_dense_info.get_packed_sint32();
|
||||
break;
|
||||
case OSMFormat::DenseInfo::packed_bool_visible:
|
||||
has_visibles = true;
|
||||
case protozero::tag_and_type(OSMFormat::DenseInfo::packed_bool_visible, protozero::pbf_wire_type::length_delimited):
|
||||
visibles = pbf_dense_info.get_packed_bool();
|
||||
break;
|
||||
default:
|
||||
@@ -584,13 +591,13 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OSMFormat::DenseNodes::packed_sint64_lat:
|
||||
case protozero::tag_and_type(OSMFormat::DenseNodes::packed_sint64_lat, protozero::pbf_wire_type::length_delimited):
|
||||
lats = pbf_dense_nodes.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::DenseNodes::packed_sint64_lon:
|
||||
case protozero::tag_and_type(OSMFormat::DenseNodes::packed_sint64_lon, protozero::pbf_wire_type::length_delimited):
|
||||
lons = pbf_dense_nodes.get_packed_sint64();
|
||||
break;
|
||||
case OSMFormat::DenseNodes::packed_int32_keys_vals:
|
||||
case protozero::tag_and_type(OSMFormat::DenseNodes::packed_int32_keys_vals, protozero::pbf_wire_type::length_delimited):
|
||||
tags = pbf_dense_nodes.get_packed_int32();
|
||||
break;
|
||||
default:
|
||||
@@ -598,13 +605,13 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
|
||||
osmium::util::DeltaDecode<int64_t> dense_id;
|
||||
osmium::util::DeltaDecode<int64_t> dense_latitude;
|
||||
osmium::util::DeltaDecode<int64_t> dense_longitude;
|
||||
osmium::util::DeltaDecode<int64_t> dense_uid;
|
||||
osmium::util::DeltaDecode<int64_t> dense_user_sid;
|
||||
osmium::util::DeltaDecode<int64_t> dense_changeset;
|
||||
osmium::util::DeltaDecode<int64_t> dense_timestamp;
|
||||
osmium::DeltaDecode<int64_t> dense_id;
|
||||
osmium::DeltaDecode<int64_t> dense_latitude;
|
||||
osmium::DeltaDecode<int64_t> dense_longitude;
|
||||
osmium::DeltaDecode<int64_t> dense_uid;
|
||||
osmium::DeltaDecode<int64_t> dense_user_sid;
|
||||
osmium::DeltaDecode<int64_t> dense_changeset;
|
||||
osmium::DeltaDecode<int64_t> dense_timestamp;
|
||||
|
||||
auto tag_it = tags.begin();
|
||||
|
||||
@@ -624,47 +631,55 @@ namespace osmium {
|
||||
ids.drop_front();
|
||||
|
||||
if (has_info) {
|
||||
if (versions.empty() ||
|
||||
changesets.empty() ||
|
||||
timestamps.empty() ||
|
||||
uids.empty() ||
|
||||
user_sids.empty()) {
|
||||
// this is against the spec, must have same number of elements
|
||||
throw osmium::pbf_error{"PBF format error"};
|
||||
}
|
||||
|
||||
const auto version = versions.front();
|
||||
versions.drop_front();
|
||||
if (version < 0) {
|
||||
throw osmium::pbf_error{"object version must not be negative"};
|
||||
}
|
||||
node.set_version(static_cast<osmium::object_version_type>(version));
|
||||
|
||||
const auto changeset_id = dense_changeset.update(changesets.front());
|
||||
changesets.drop_front();
|
||||
if (changeset_id < 0) {
|
||||
throw osmium::pbf_error{"object changeset_id must not be negative"};
|
||||
}
|
||||
node.set_changeset(static_cast<osmium::changeset_id_type>(changeset_id));
|
||||
|
||||
node.set_timestamp(dense_timestamp.update(timestamps.front()) * m_date_factor / 1000);
|
||||
timestamps.drop_front();
|
||||
node.set_uid_from_signed(static_cast<osmium::signed_user_id_type>(dense_uid.update(uids.front())));
|
||||
uids.drop_front();
|
||||
|
||||
if (has_visibles) {
|
||||
if (visibles.empty()) {
|
||||
// this is against the spec, must have same number of elements
|
||||
throw osmium::pbf_error{"PBF format error"};
|
||||
if (!versions.empty()) {
|
||||
const auto version = versions.front();
|
||||
versions.drop_front();
|
||||
if (version < -1) {
|
||||
throw osmium::pbf_error{"object version must not be negative"};
|
||||
}
|
||||
|
||||
if (version == -1) {
|
||||
node.set_version(0U);
|
||||
} else {
|
||||
node.set_version(static_cast<osmium::object_version_type>(version));
|
||||
}
|
||||
}
|
||||
|
||||
if (!changesets.empty()) {
|
||||
const auto changeset_id = dense_changeset.update(changesets.front());
|
||||
changesets.drop_front();
|
||||
if (changeset_id < -1 || changeset_id >= std::numeric_limits<changeset_id_type>::max()) {
|
||||
throw osmium::pbf_error{"object changeset_id must be between 0 and 2^32-1"};
|
||||
}
|
||||
|
||||
if (changeset_id == -1) {
|
||||
node.set_changeset(0U);
|
||||
} else {
|
||||
node.set_changeset(static_cast<osmium::changeset_id_type>(changeset_id));
|
||||
}
|
||||
}
|
||||
|
||||
if (!timestamps.empty()) {
|
||||
node.set_timestamp(dense_timestamp.update(timestamps.front()) * m_date_factor / 1000);
|
||||
timestamps.drop_front();
|
||||
}
|
||||
|
||||
if (!uids.empty()) {
|
||||
node.set_uid_from_signed(static_cast<osmium::signed_user_id_type>(dense_uid.update(uids.front())));
|
||||
uids.drop_front();
|
||||
}
|
||||
|
||||
if (!visibles.empty()) {
|
||||
visible = (visibles.front() != 0);
|
||||
visibles.drop_front();
|
||||
}
|
||||
node.set_visible(visible);
|
||||
|
||||
const auto& u = m_stringtable.at(dense_user_sid.update(user_sids.front()));
|
||||
user_sids.drop_front();
|
||||
builder.set_user(u.first, u.second);
|
||||
if (!user_sids.empty()) {
|
||||
const auto& u = m_stringtable.at(dense_user_sid.update(user_sids.front()));
|
||||
user_sids.drop_front();
|
||||
builder.set_user(u.first, u.second);
|
||||
}
|
||||
}
|
||||
|
||||
// even if the node isn't visible, there's still a record
|
||||
@@ -722,8 +737,8 @@ namespace osmium {
|
||||
|
||||
protozero::pbf_message<FileFormat::Blob> pbf_blob{blob_data};
|
||||
while (pbf_blob.next()) {
|
||||
switch (pbf_blob.tag()) {
|
||||
case FileFormat::Blob::optional_bytes_raw:
|
||||
switch (pbf_blob.tag_and_type()) {
|
||||
case protozero::tag_and_type(FileFormat::Blob::optional_bytes_raw, protozero::pbf_wire_type::length_delimited):
|
||||
{
|
||||
const auto data_len = pbf_blob.get_view();
|
||||
if (data_len.size() > max_uncompressed_blob_size) {
|
||||
@@ -731,27 +746,27 @@ namespace osmium {
|
||||
}
|
||||
return data_len;
|
||||
}
|
||||
case FileFormat::Blob::optional_int32_raw_size:
|
||||
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) {
|
||||
throw osmium::pbf_error{"illegal blob size"};
|
||||
}
|
||||
break;
|
||||
case FileFormat::Blob::optional_bytes_zlib_data:
|
||||
case protozero::tag_and_type(FileFormat::Blob::optional_bytes_zlib_data, protozero::pbf_wire_type::length_delimited):
|
||||
zlib_data = pbf_blob.get_view();
|
||||
break;
|
||||
case FileFormat::Blob::optional_bytes_lzma_data:
|
||||
case protozero::tag_and_type(FileFormat::Blob::optional_bytes_lzma_data, protozero::pbf_wire_type::length_delimited):
|
||||
throw osmium::pbf_error{"lzma blobs not implemented"};
|
||||
default:
|
||||
throw osmium::pbf_error{"unknown compression"};
|
||||
}
|
||||
}
|
||||
|
||||
if (zlib_data.size() != 0 && raw_size != 0) {
|
||||
if (!zlib_data.empty() && raw_size != 0) {
|
||||
return osmium::io::detail::zlib_uncompress_string(
|
||||
zlib_data.data(),
|
||||
static_cast<unsigned long>(zlib_data.size()),
|
||||
static_cast<unsigned long>(raw_size),
|
||||
static_cast<unsigned long>(zlib_data.size()), // NOLINT(google-runtime-int)
|
||||
static_cast<unsigned long>(raw_size), // NOLINT(google-runtime-int)
|
||||
output
|
||||
);
|
||||
}
|
||||
@@ -767,17 +782,17 @@ namespace osmium {
|
||||
|
||||
protozero::pbf_message<OSMFormat::HeaderBBox> pbf_header_bbox{data};
|
||||
while (pbf_header_bbox.next()) {
|
||||
switch (pbf_header_bbox.tag()) {
|
||||
case OSMFormat::HeaderBBox::required_sint64_left:
|
||||
switch (pbf_header_bbox.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBBox::required_sint64_left, protozero::pbf_wire_type::varint):
|
||||
left = pbf_header_bbox.get_sint64();
|
||||
break;
|
||||
case OSMFormat::HeaderBBox::required_sint64_right:
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBBox::required_sint64_right, protozero::pbf_wire_type::varint):
|
||||
right = pbf_header_bbox.get_sint64();
|
||||
break;
|
||||
case OSMFormat::HeaderBBox::required_sint64_top:
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBBox::required_sint64_top, protozero::pbf_wire_type::varint):
|
||||
top = pbf_header_bbox.get_sint64();
|
||||
break;
|
||||
case OSMFormat::HeaderBBox::required_sint64_bottom:
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBBox::required_sint64_bottom, protozero::pbf_wire_type::varint):
|
||||
bottom = pbf_header_bbox.get_sint64();
|
||||
break;
|
||||
default:
|
||||
@@ -805,11 +820,11 @@ namespace osmium {
|
||||
|
||||
protozero::pbf_message<OSMFormat::HeaderBlock> pbf_header_block{data};
|
||||
while (pbf_header_block.next()) {
|
||||
switch (pbf_header_block.tag()) {
|
||||
case OSMFormat::HeaderBlock::optional_HeaderBBox_bbox:
|
||||
switch (pbf_header_block.tag_and_type()) {
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBlock::optional_HeaderBBox_bbox, protozero::pbf_wire_type::length_delimited):
|
||||
header.add_box(decode_header_bbox(pbf_header_block.get_view()));
|
||||
break;
|
||||
case OSMFormat::HeaderBlock::repeated_string_required_features:
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBlock::repeated_string_required_features, protozero::pbf_wire_type::length_delimited):
|
||||
{
|
||||
auto feature = pbf_header_block.get_view();
|
||||
if (!std::strncmp("OsmSchema-V0.6", feature.data(), feature.size())) {
|
||||
@@ -825,23 +840,23 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OSMFormat::HeaderBlock::repeated_string_optional_features:
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBlock::repeated_string_optional_features, protozero::pbf_wire_type::length_delimited):
|
||||
header.set("pbf_optional_feature_" + std::to_string(i++), pbf_header_block.get_string());
|
||||
break;
|
||||
case OSMFormat::HeaderBlock::optional_string_writingprogram:
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBlock::optional_string_writingprogram, protozero::pbf_wire_type::length_delimited):
|
||||
header.set("generator", pbf_header_block.get_string());
|
||||
break;
|
||||
case OSMFormat::HeaderBlock::optional_int64_osmosis_replication_timestamp:
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBlock::optional_int64_osmosis_replication_timestamp, protozero::pbf_wire_type::varint):
|
||||
{
|
||||
const auto timestamp = osmium::Timestamp{pbf_header_block.get_int64()}.to_iso();
|
||||
header.set("osmosis_replication_timestamp", timestamp);
|
||||
header.set("timestamp", timestamp);
|
||||
}
|
||||
break;
|
||||
case OSMFormat::HeaderBlock::optional_int64_osmosis_replication_sequence_number:
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBlock::optional_int64_osmosis_replication_sequence_number, protozero::pbf_wire_type::varint):
|
||||
header.set("osmosis_replication_sequence_number", std::to_string(pbf_header_block.get_int64()));
|
||||
break;
|
||||
case OSMFormat::HeaderBlock::optional_string_osmosis_replication_base_url:
|
||||
case protozero::tag_and_type(OSMFormat::HeaderBlock::optional_string_osmosis_replication_base_url, protozero::pbf_wire_type::length_delimited):
|
||||
header.set("osmosis_replication_base_url", pbf_header_block.get_string());
|
||||
break;
|
||||
default:
|
||||
@@ -879,14 +894,6 @@ namespace osmium {
|
||||
m_read_metadata(read_metadata) {
|
||||
}
|
||||
|
||||
PBFDataBlobDecoder(const PBFDataBlobDecoder&) = default;
|
||||
PBFDataBlobDecoder& operator=(const PBFDataBlobDecoder&) = default;
|
||||
|
||||
PBFDataBlobDecoder(PBFDataBlobDecoder&&) = default;
|
||||
PBFDataBlobDecoder& operator=(PBFDataBlobDecoder&&) = default;
|
||||
|
||||
~PBFDataBlobDecoder() noexcept = default;
|
||||
|
||||
osmium::memory::Buffer operator()() {
|
||||
std::string output;
|
||||
PBFPrimitiveBlockDecoder decoder{decode_blob(*m_input_buffer, output), m_read_types, m_read_metadata};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,18 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <protozero/pbf_message.hpp>
|
||||
#include <protozero/types.hpp>
|
||||
|
||||
#include <osmium/io/detail/input_format.hpp>
|
||||
#include <osmium/io/detail/pbf.hpp> // IWYU pragma: export
|
||||
#include <osmium/io/detail/pbf_decoder.hpp>
|
||||
@@ -56,6 +44,18 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/thread/util.hpp>
|
||||
#include <osmium/util/config.hpp>
|
||||
|
||||
#include <protozero/pbf_message.hpp>
|
||||
#include <protozero/types.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@@ -64,7 +64,7 @@ namespace osmium {
|
||||
|
||||
class PBFParser : public Parser {
|
||||
|
||||
std::string m_input_buffer;
|
||||
std::string m_input_buffer{};
|
||||
|
||||
/**
|
||||
* Read the given number of bytes from the input queue.
|
||||
@@ -105,7 +105,13 @@ namespace osmium {
|
||||
return 0; // EOF
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
const uint32_t size = ntohl(size_in_network_byte_order);
|
||||
#else
|
||||
uint32_t size = size_in_network_byte_order;
|
||||
protozero::detail::byteswap_inplace(&size);
|
||||
#endif
|
||||
|
||||
if (size > static_cast<uint32_t>(max_blob_header_size)) {
|
||||
throw osmium::pbf_error{"invalid BlobHeader size (> max_blob_header_size)"};
|
||||
}
|
||||
@@ -122,11 +128,11 @@ namespace osmium {
|
||||
size_t blob_header_datasize = 0;
|
||||
|
||||
while (pbf_blob_header.next()) {
|
||||
switch (pbf_blob_header.tag()) {
|
||||
case FileFormat::BlobHeader::required_string_type:
|
||||
switch (pbf_blob_header.tag_and_type()) {
|
||||
case protozero::tag_and_type(FileFormat::BlobHeader::required_string_type, protozero::pbf_wire_type::length_delimited):
|
||||
blob_header_type = pbf_blob_header.get_view();
|
||||
break;
|
||||
case FileFormat::BlobHeader::required_int32_datasize:
|
||||
case protozero::tag_and_type(FileFormat::BlobHeader::required_int32_datasize, protozero::pbf_wire_type::varint):
|
||||
blob_header_datasize = pbf_blob_header.get_int32();
|
||||
break;
|
||||
default:
|
||||
@@ -138,7 +144,7 @@ namespace osmium {
|
||||
throw osmium::pbf_error{"PBF format error: BlobHeader.datasize missing or zero."};
|
||||
}
|
||||
|
||||
if (std::strncmp(expected_type, blob_header_type.data(), blob_header_type.size())) {
|
||||
if (std::strncmp(expected_type, blob_header_type.data(), blob_header_type.size()) != 0) {
|
||||
throw osmium::pbf_error{"blob does not have expected type (OSMHeader in first blob, OSMData in following blobs)"};
|
||||
}
|
||||
|
||||
@@ -190,10 +196,15 @@ namespace osmium {
|
||||
public:
|
||||
|
||||
explicit PBFParser(parser_arguments& args) :
|
||||
Parser(args),
|
||||
m_input_buffer() {
|
||||
Parser(args) {
|
||||
}
|
||||
|
||||
PBFParser(const PBFParser&) = delete;
|
||||
PBFParser& operator=(const PBFParser&) = delete;
|
||||
|
||||
PBFParser(PBFParser&&) = delete;
|
||||
PBFParser& operator=(PBFParser&&) = delete;
|
||||
|
||||
~PBFParser() noexcept final = default;
|
||||
|
||||
void run() final {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,19 +33,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <protozero/pbf_builder.hpp>
|
||||
#include <protozero/pbf_writer.hpp>
|
||||
#include <protozero/types.hpp>
|
||||
|
||||
#include <osmium/handler.hpp>
|
||||
#include <osmium/io/detail/output_format.hpp>
|
||||
#include <osmium/io/detail/pbf.hpp> // IWYU pragma: export
|
||||
@@ -61,6 +48,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/osm/box.hpp>
|
||||
#include <osmium/osm/item_type.hpp>
|
||||
#include <osmium/osm/location.hpp>
|
||||
#include <osmium/osm/metadata_options.hpp>
|
||||
#include <osmium/osm/node.hpp>
|
||||
#include <osmium/osm/node_ref.hpp>
|
||||
#include <osmium/osm/object.hpp>
|
||||
@@ -72,8 +60,22 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <osmium/thread/pool.hpp>
|
||||
#include <osmium/util/cast.hpp>
|
||||
#include <osmium/util/delta.hpp>
|
||||
#include <osmium/util/misc.hpp>
|
||||
#include <osmium/visitor.hpp>
|
||||
|
||||
#include <protozero/pbf_builder.hpp>
|
||||
#include <protozero/pbf_writer.hpp>
|
||||
#include <protozero/types.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@@ -82,8 +84,11 @@ namespace osmium {
|
||||
|
||||
struct pbf_output_options {
|
||||
|
||||
/// Which metadata of objects should be added?
|
||||
osmium::metadata_options add_metadata;
|
||||
|
||||
/// Should nodes be encoded in DenseNodes?
|
||||
bool use_dense_nodes;
|
||||
bool use_dense_nodes = true;
|
||||
|
||||
/**
|
||||
* Should the PBF blobs contain zlib compressed data?
|
||||
@@ -93,21 +98,18 @@ namespace osmium {
|
||||
* the writing speed a little but the output will be 2x to 3x
|
||||
* bigger.
|
||||
*/
|
||||
bool use_compression;
|
||||
|
||||
/// Should metadata of objects be written?
|
||||
bool add_metadata;
|
||||
bool use_compression = true;
|
||||
|
||||
/// Add the "HistoricalInformation" header flag.
|
||||
bool add_historical_information_flag;
|
||||
bool add_historical_information_flag = false;
|
||||
|
||||
/// Should the visible flag be added to all OSM objects?
|
||||
bool add_visible_flag;
|
||||
bool add_visible_flag = false;
|
||||
|
||||
/// Should node locations be added to ways?
|
||||
bool locations_on_ways;
|
||||
bool locations_on_ways = false;
|
||||
|
||||
};
|
||||
}; // struct pbf_output_options
|
||||
|
||||
/**
|
||||
* Maximum number of items in a primitive block.
|
||||
@@ -185,7 +187,12 @@ namespace osmium {
|
||||
pbf_blob_header.add_string(FileFormat::BlobHeader::required_string_type, m_blob_type == pbf_blob_type::data ? "OSMData" : "OSMHeader");
|
||||
pbf_blob_header.add_int32(FileFormat::BlobHeader::required_int32_datasize, static_cast_with_assert<int32_t>(blob_data.size()));
|
||||
|
||||
#ifndef _WIN32
|
||||
const uint32_t sz = htonl(static_cast_with_assert<uint32_t>(blob_header_data.size()));
|
||||
#else
|
||||
uint32_t sz = static_cast_with_assert<uint32_t>(blob_header_data.size());
|
||||
protozero::detail::byteswap_inplace(&sz);
|
||||
#endif
|
||||
|
||||
// write to output: the 4-byte BlobHeader-Size followed by the BlobHeader followed by the Blob
|
||||
std::string output;
|
||||
@@ -224,15 +231,15 @@ namespace osmium {
|
||||
std::vector<int64_t> m_lons;
|
||||
std::vector<int32_t> m_tags;
|
||||
|
||||
osmium::util::DeltaEncode<object_id_type, int64_t> m_delta_id;
|
||||
osmium::DeltaEncode<object_id_type, int64_t> m_delta_id;
|
||||
|
||||
osmium::util::DeltaEncode<uint32_t, int64_t> m_delta_timestamp;
|
||||
osmium::util::DeltaEncode<changeset_id_type, int64_t> m_delta_changeset;
|
||||
osmium::util::DeltaEncode<user_id_type, int32_t> m_delta_uid;
|
||||
osmium::util::DeltaEncode<uint32_t, int32_t> m_delta_user_sid;
|
||||
osmium::DeltaEncode<uint32_t, int64_t> m_delta_timestamp;
|
||||
osmium::DeltaEncode<changeset_id_type, int64_t> m_delta_changeset;
|
||||
osmium::DeltaEncode<user_id_type, int32_t> m_delta_uid;
|
||||
osmium::DeltaEncode<uint32_t, int32_t> m_delta_user_sid;
|
||||
|
||||
osmium::util::DeltaEncode<int64_t, int64_t> m_delta_lat;
|
||||
osmium::util::DeltaEncode<int64_t, int64_t> m_delta_lon;
|
||||
osmium::DeltaEncode<int64_t, int64_t> m_delta_lat;
|
||||
osmium::DeltaEncode<int64_t, int64_t> m_delta_lon;
|
||||
|
||||
const pbf_output_options& m_options;
|
||||
|
||||
@@ -269,22 +276,30 @@ namespace osmium {
|
||||
m_delta_lon.clear();
|
||||
}
|
||||
|
||||
std::size_t size() const {
|
||||
std::size_t size() const noexcept {
|
||||
return m_ids.size() * 3 * sizeof(int64_t);
|
||||
}
|
||||
|
||||
void add_node(const osmium::Node& node) {
|
||||
m_ids.push_back(m_delta_id.update(node.id()));
|
||||
|
||||
if (m_options.add_metadata) {
|
||||
if (m_options.add_metadata.version()) {
|
||||
m_versions.push_back(static_cast_with_assert<int32_t>(node.version()));
|
||||
}
|
||||
if (m_options.add_metadata.timestamp()) {
|
||||
m_timestamps.push_back(m_delta_timestamp.update(uint32_t(node.timestamp())));
|
||||
}
|
||||
if (m_options.add_metadata.changeset()) {
|
||||
m_changesets.push_back(m_delta_changeset.update(node.changeset()));
|
||||
}
|
||||
if (m_options.add_metadata.uid()) {
|
||||
m_uids.push_back(m_delta_uid.update(node.uid()));
|
||||
}
|
||||
if (m_options.add_metadata.user()) {
|
||||
m_user_sids.push_back(m_delta_user_sid.update(m_stringtable.add(node.user())));
|
||||
if (m_options.add_visible_flag) {
|
||||
m_visibles.push_back(node.visible());
|
||||
}
|
||||
}
|
||||
if (m_options.add_visible_flag) {
|
||||
m_visibles.push_back(node.visible());
|
||||
}
|
||||
|
||||
m_lats.push_back(m_delta_lat.update(lonlat2int(node.location().lat_without_check())));
|
||||
@@ -303,14 +318,23 @@ namespace osmium {
|
||||
|
||||
pbf_dense_nodes.add_packed_sint64(OSMFormat::DenseNodes::packed_sint64_id, m_ids.cbegin(), m_ids.cend());
|
||||
|
||||
if (m_options.add_metadata) {
|
||||
if (m_options.add_metadata.any() || m_options.add_visible_flag) {
|
||||
protozero::pbf_builder<OSMFormat::DenseInfo> pbf_dense_info{pbf_dense_nodes, OSMFormat::DenseNodes::optional_DenseInfo_denseinfo};
|
||||
pbf_dense_info.add_packed_int32(OSMFormat::DenseInfo::packed_int32_version, m_versions.cbegin(), m_versions.cend());
|
||||
pbf_dense_info.add_packed_sint64(OSMFormat::DenseInfo::packed_sint64_timestamp, m_timestamps.cbegin(), m_timestamps.cend());
|
||||
pbf_dense_info.add_packed_sint64(OSMFormat::DenseInfo::packed_sint64_changeset, m_changesets.cbegin(), m_changesets.cend());
|
||||
pbf_dense_info.add_packed_sint32(OSMFormat::DenseInfo::packed_sint32_uid, m_uids.cbegin(), m_uids.cend());
|
||||
pbf_dense_info.add_packed_sint32(OSMFormat::DenseInfo::packed_sint32_user_sid, m_user_sids.cbegin(), m_user_sids.cend());
|
||||
|
||||
if (m_options.add_metadata.version()) {
|
||||
pbf_dense_info.add_packed_int32(OSMFormat::DenseInfo::packed_int32_version, m_versions.cbegin(), m_versions.cend());
|
||||
}
|
||||
if (m_options.add_metadata.timestamp()) {
|
||||
pbf_dense_info.add_packed_sint64(OSMFormat::DenseInfo::packed_sint64_timestamp, m_timestamps.cbegin(), m_timestamps.cend());
|
||||
}
|
||||
if (m_options.add_metadata.changeset()) {
|
||||
pbf_dense_info.add_packed_sint64(OSMFormat::DenseInfo::packed_sint64_changeset, m_changesets.cbegin(), m_changesets.cend());
|
||||
}
|
||||
if (m_options.add_metadata.uid()) {
|
||||
pbf_dense_info.add_packed_sint32(OSMFormat::DenseInfo::packed_sint32_uid, m_uids.cbegin(), m_uids.cend());
|
||||
}
|
||||
if (m_options.add_metadata.user()) {
|
||||
pbf_dense_info.add_packed_sint32(OSMFormat::DenseInfo::packed_sint32_user_sid, m_user_sids.cbegin(), m_user_sids.cend());
|
||||
}
|
||||
if (m_options.add_visible_flag) {
|
||||
pbf_dense_info.add_packed_bool(OSMFormat::DenseInfo::packed_bool_visible, m_visibles.cbegin(), m_visibles.cend());
|
||||
}
|
||||
@@ -332,18 +356,14 @@ namespace osmium {
|
||||
protozero::pbf_builder<OSMFormat::PrimitiveGroup> m_pbf_primitive_group;
|
||||
StringTable m_stringtable;
|
||||
DenseNodes m_dense_nodes;
|
||||
OSMFormat::PrimitiveGroup m_type;
|
||||
int m_count;
|
||||
OSMFormat::PrimitiveGroup m_type = OSMFormat::PrimitiveGroup::unknown;
|
||||
int m_count = 0;
|
||||
|
||||
public:
|
||||
|
||||
explicit PrimitiveBlock(const pbf_output_options& options) :
|
||||
m_pbf_primitive_group_data(),
|
||||
m_pbf_primitive_group(m_pbf_primitive_group_data),
|
||||
m_stringtable(),
|
||||
m_dense_nodes(m_stringtable, options),
|
||||
m_type(OSMFormat::PrimitiveGroup::unknown),
|
||||
m_count(0) {
|
||||
m_dense_nodes(m_stringtable, options) {
|
||||
}
|
||||
|
||||
const std::string& group_data() {
|
||||
@@ -367,7 +387,7 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
|
||||
protozero::pbf_builder<OSMFormat::PrimitiveGroup>& group() {
|
||||
protozero::pbf_builder<OSMFormat::PrimitiveGroup>& group() noexcept {
|
||||
++m_count;
|
||||
return m_pbf_primitive_group;
|
||||
}
|
||||
@@ -381,15 +401,15 @@ namespace osmium {
|
||||
return m_stringtable.add(s);
|
||||
}
|
||||
|
||||
int count() const {
|
||||
int count() const noexcept {
|
||||
return m_count;
|
||||
}
|
||||
|
||||
OSMFormat::PrimitiveGroup type() const {
|
||||
OSMFormat::PrimitiveGroup type() const noexcept {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
std::size_t size() const {
|
||||
std::size_t size() const noexcept {
|
||||
return m_pbf_primitive_group_data.size() + m_stringtable.size() + m_dense_nodes.size();
|
||||
}
|
||||
|
||||
@@ -401,7 +421,7 @@ namespace osmium {
|
||||
*/
|
||||
constexpr static std::size_t max_used_blob_size = max_uncompressed_blob_size * 95 / 100;
|
||||
|
||||
bool can_add(OSMFormat::PrimitiveGroup type) const {
|
||||
bool can_add(OSMFormat::PrimitiveGroup type) const noexcept {
|
||||
if (type != m_type) {
|
||||
return false;
|
||||
}
|
||||
@@ -457,14 +477,24 @@ namespace osmium {
|
||||
}
|
||||
}
|
||||
|
||||
if (m_options.add_metadata) {
|
||||
if (m_options.add_metadata.any() || m_options.add_visible_flag) {
|
||||
protozero::pbf_builder<OSMFormat::Info> pbf_info{pbf_object, T::enum_type::optional_Info_info};
|
||||
|
||||
pbf_info.add_int32(OSMFormat::Info::optional_int32_version, static_cast_with_assert<int32_t>(object.version()));
|
||||
pbf_info.add_int64(OSMFormat::Info::optional_int64_timestamp, uint32_t(object.timestamp()));
|
||||
pbf_info.add_int64(OSMFormat::Info::optional_int64_changeset, object.changeset());
|
||||
pbf_info.add_int32(OSMFormat::Info::optional_int32_uid, static_cast_with_assert<int32_t>(object.uid()));
|
||||
pbf_info.add_uint32(OSMFormat::Info::optional_uint32_user_sid, m_primitive_block.store_in_stringtable(object.user()));
|
||||
if (m_options.add_metadata.version()) {
|
||||
pbf_info.add_int32(OSMFormat::Info::optional_int32_version, static_cast_with_assert<int32_t>(object.version()));
|
||||
}
|
||||
if (m_options.add_metadata.timestamp()) {
|
||||
pbf_info.add_int64(OSMFormat::Info::optional_int64_timestamp, uint32_t(object.timestamp()));
|
||||
}
|
||||
if (m_options.add_metadata.changeset()) {
|
||||
pbf_info.add_int64(OSMFormat::Info::optional_int64_changeset, object.changeset());
|
||||
}
|
||||
if (m_options.add_metadata.uid()) {
|
||||
pbf_info.add_int32(OSMFormat::Info::optional_int32_uid, static_cast_with_assert<int32_t>(object.uid()));
|
||||
}
|
||||
if (m_options.add_metadata.user()) {
|
||||
pbf_info.add_uint32(OSMFormat::Info::optional_uint32_user_sid, m_primitive_block.store_in_stringtable(object.user()));
|
||||
}
|
||||
if (m_options.add_visible_flag) {
|
||||
pbf_info.add_bool(OSMFormat::Info::optional_bool_visible, object.visible());
|
||||
}
|
||||
@@ -482,21 +512,20 @@ namespace osmium {
|
||||
|
||||
PBFOutputFormat(osmium::thread::Pool& pool, const osmium::io::File& file, future_string_queue_type& output_queue) :
|
||||
OutputFormat(pool, output_queue),
|
||||
m_options(),
|
||||
m_primitive_block(m_options) {
|
||||
|
||||
if (!file.get("pbf_add_metadata").empty()) {
|
||||
throw std::invalid_argument{"The 'pbf_add_metadata' option is deprecated. Please use 'add_metadata' instead."};
|
||||
}
|
||||
|
||||
m_options.use_dense_nodes = file.is_not_false("pbf_dense_nodes");
|
||||
m_options.use_compression = file.get("pbf_compression") != "none" && file.is_not_false("pbf_compression");
|
||||
m_options.add_metadata = file.is_not_false("pbf_add_metadata") && file.is_not_false("add_metadata");
|
||||
m_options.add_metadata = osmium::metadata_options{file.get("add_metadata")};
|
||||
m_options.add_historical_information_flag = file.has_multiple_object_versions();
|
||||
m_options.add_visible_flag = file.has_multiple_object_versions();
|
||||
m_options.locations_on_ways = file.is_true("locations_on_ways");
|
||||
}
|
||||
|
||||
PBFOutputFormat(const PBFOutputFormat&) = delete;
|
||||
PBFOutputFormat& operator=(const PBFOutputFormat&) = delete;
|
||||
|
||||
~PBFOutputFormat() noexcept final = default;
|
||||
|
||||
void write_header(const osmium::io::Header& header) final {
|
||||
std::string data;
|
||||
protozero::pbf_builder<OSMFormat::HeaderBlock> pbf_header_block{data};
|
||||
@@ -535,7 +564,7 @@ namespace osmium {
|
||||
|
||||
const std::string osmosis_replication_sequence_number{header.get("osmosis_replication_sequence_number")};
|
||||
if (!osmosis_replication_sequence_number.empty()) {
|
||||
pbf_header_block.add_int64(OSMFormat::HeaderBlock::optional_int64_osmosis_replication_sequence_number, std::atoll(osmosis_replication_sequence_number.c_str()));
|
||||
pbf_header_block.add_int64(OSMFormat::HeaderBlock::optional_int64_osmosis_replication_sequence_number, osmium::detail::str_to_int<int64_t>(osmosis_replication_sequence_number.c_str()));
|
||||
}
|
||||
|
||||
const std::string osmosis_replication_base_url{header.get("osmosis_replication_base_url")};
|
||||
@@ -583,7 +612,7 @@ namespace osmium {
|
||||
add_meta(way, pbf_way);
|
||||
|
||||
{
|
||||
osmium::util::DeltaEncode<object_id_type, int64_t> delta_id;
|
||||
osmium::DeltaEncode<object_id_type, int64_t> delta_id;
|
||||
protozero::packed_field_sint64 field{pbf_way, protozero::pbf_tag_type(OSMFormat::Way::packed_sint64_refs)};
|
||||
for (const auto& node_ref : way.nodes()) {
|
||||
field.add_element(delta_id.update(node_ref.ref()));
|
||||
@@ -592,14 +621,14 @@ namespace osmium {
|
||||
|
||||
if (m_options.locations_on_ways) {
|
||||
{
|
||||
osmium::util::DeltaEncode<int64_t, int64_t> delta_id;
|
||||
osmium::DeltaEncode<int64_t, int64_t> delta_id;
|
||||
protozero::packed_field_sint64 field{pbf_way, protozero::pbf_tag_type(OSMFormat::Way::packed_sint64_lon)};
|
||||
for (const auto& node_ref : way.nodes()) {
|
||||
field.add_element(delta_id.update(lonlat2int(node_ref.location().lon_without_check())));
|
||||
}
|
||||
}
|
||||
{
|
||||
osmium::util::DeltaEncode<int64_t, int64_t> delta_id;
|
||||
osmium::DeltaEncode<int64_t, int64_t> delta_id;
|
||||
protozero::packed_field_sint64 field{pbf_way, protozero::pbf_tag_type(OSMFormat::Way::packed_sint64_lat)};
|
||||
for (const auto& node_ref : way.nodes()) {
|
||||
field.add_element(delta_id.update(lonlat2int(node_ref.location().lat_without_check())));
|
||||
@@ -623,7 +652,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
{
|
||||
osmium::util::DeltaEncode<object_id_type, int64_t> delta_id;
|
||||
osmium::DeltaEncode<object_id_type, int64_t> delta_id;
|
||||
protozero::packed_field_sint64 field{pbf_relation, protozero::pbf_tag_type(OSMFormat::Relation::packed_sint64_memids)};
|
||||
for (const auto& member : relation.members()) {
|
||||
field.add_element(delta_id.update(member.ref()));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2018 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,15 +33,15 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
#include <osmium/thread/queue.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <exception>
|
||||
#include <future>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <osmium/memory/buffer.hpp>
|
||||
#include <osmium/thread/queue.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace io {
|
||||
@@ -110,6 +110,12 @@ namespace osmium {
|
||||
m_has_reached_end_of_data(false) {
|
||||
}
|
||||
|
||||
queue_wrapper(const queue_wrapper&) = delete;
|
||||
queue_wrapper& operator=(const queue_wrapper&) = delete;
|
||||
|
||||
queue_wrapper(queue_wrapper&&) = delete;
|
||||
queue_wrapper& operator=(queue_wrapper&&) = delete;
|
||||
|
||||
~queue_wrapper() noexcept {
|
||||
drain();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user