assembler.hpp
Go to the documentation of this file.
#ifndef OSMIUM_AREA_ASSEMBLER_HPP
#define OSMIUM_AREA_ASSEMBLER_HPP
/*
This file is part of Osmium (http://osmcode.org/libosmium).
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <iterator>
#include <list>
#include <set>
#include <string>
#include <map>
#include <vector>
#include <osmium/builder/osm_object_builder.hpp>
#include <osmium/memory/buffer.hpp>
#include <osmium/osm/area.hpp>
#include <osmium/osm/location.hpp>
#include <osmium/osm/relation.hpp>
#include <osmium/tags/filter.hpp>
#include <osmium/area/detail/proto_ring.hpp>
#include <osmium/area/detail/node_ref_segment.hpp>
#include <osmium/area/detail/segment_list.hpp>
#include <osmium/area/problem_reporter.hpp>
namespace osmium {
namespace area {
using osmium::area::detail::ProtoRing;
struct AssemblerConfig {
osmium::area::ProblemReporter* problem_reporter;
// Enables debug output to stderr
bool debug;
explicit AssemblerConfig(osmium::area::ProblemReporter* pr = nullptr, bool d = false) :
problem_reporter(pr),
debug(d) {
}
void enable_debug_output(bool d = true) {
debug = d;
}
}; // struct AssemblerConfig
class Assembler {
const AssemblerConfig m_config;
// The way segments
osmium::area::detail::SegmentList m_segment_list;
// The rings we are building from the way segments
std::list<ProtoRing> m_rings;
std::vector<ProtoRing*> m_outer_rings;
std::vector<ProtoRing*> m_inner_rings;
int m_inner_outer_mismatches { 0 };
bool debug() const {
return m_config.debug;
}
bool has_same_location(const osmium::NodeRef& nr1, const osmium::NodeRef& nr2) {
if (nr1.location() != nr2.location()) {
return false;
}
if (nr1.ref() != nr2.ref()) {
if (m_config.problem_reporter) {
m_config.problem_reporter->report_duplicate_node(nr1.ref(), nr2.ref(), nr1.location());
}
}
return true;
}
void add_tags_to_area(osmium::builder::AreaBuilder& builder, const osmium::Way& way) const {
osmium::builder::TagListBuilder tl_builder(builder.buffer(), &builder);
for (const osmium::Tag& tag : way.tags()) {
tl_builder.add_tag(tag.key(), tag.value());
}
}
void add_common_tags(osmium::builder::TagListBuilder& tl_builder, std::set<const osmium::Way*>& ways) const {
std::map<std::string, size_t> counter;
for (const osmium::Way* way : ways) {
for (const auto& tag : way->tags()) {
std::string kv {tag.key()};
kv.append(1, '\0');
kv.append(tag.value());
++counter[kv];
}
}
size_t num_ways = ways.size();
for (const auto& t_c : counter) {
if (debug()) {
std::cerr << " tag " << t_c.first << " is used " << t_c.second << " times in " << num_ways << " ways\n";
}
if (t_c.second == num_ways) {
size_t len = std::strlen(t_c.first.c_str());
tl_builder.add_tag(t_c.first.c_str(), t_c.first.c_str() + len + 1);
}
}
}
struct MPFilter : public osmium::tags::KeyFilter {
MPFilter() : osmium::tags::KeyFilter(true) {
add(false, "type");
add(false, "created_by");
add(false, "source");
add(false, "note");
add(false, "test:id");
add(false, "test:section");
}
}; // struct MPFilter
static MPFilter& filter() {
static MPFilter filter;
return filter;
}
void add_tags_to_area(osmium::builder::AreaBuilder& builder, const osmium::Relation& relation) const {
const auto count = std::count_if(relation.tags().begin(), relation.tags().end(), filter());
if (debug()) {
std::cerr << " found " << count << " tags on relation (without ignored ones)\n";
}
if (count > 0) {
if (debug()) {
std::cerr << " use tags from relation\n";
}
// write out all tags except type=*
osmium::builder::TagListBuilder tl_builder(builder.buffer(), &builder);
for (const osmium::Tag& tag : relation.tags()) {
if (strcmp(tag.key(), "type")) {
tl_builder.add_tag(tag.key(), tag.value());
}
}
} else {
if (debug()) {
std::cerr << " use tags from outer ways\n";
}
std::set<const osmium::Way*> ways;
for (const auto& ring : m_outer_rings) {
ring->get_ways(ways);
}
if (ways.size() == 1) {
if (debug()) {
std::cerr << " only one outer way\n";
}
osmium::builder::TagListBuilder tl_builder(builder.buffer(), &builder);
for (const osmium::Tag& tag : (*ways.begin())->tags()) {
tl_builder.add_tag(tag.key(), tag.value());
}
} else {
if (debug()) {
std::cerr << " multiple outer ways, get common tags\n";
}
osmium::builder::TagListBuilder tl_builder(builder.buffer(), &builder);
add_common_tags(tl_builder, ways);
}
}
}
bool check_for_open_rings() {
bool open_rings = false;
for (const auto& ring : m_rings) {
if (!ring.closed()) {
open_rings = true;
if (m_config.problem_reporter) {
m_config.problem_reporter->report_ring_not_closed(ring.get_segment_front().first().location(), ring.get_segment_back().second().location());
}
}
}
return open_rings;
}
bool possibly_combine_rings_back(ProtoRing& ring) {
const osmium::NodeRef& nr = ring.get_segment_back().second();
if (debug()) {
std::cerr << " possibly_combine_rings_back()\n";
}
for (auto it = m_rings.begin(); it != m_rings.end(); ++it) {
if (&*it != &ring && !it->closed()) {
if (has_same_location(nr, it->get_segment_front().first())) {
if (debug()) {
std::cerr << " ring.last=it->first\n";
}
ring.merge_ring(*it, debug());
m_rings.erase(it);
return true;
}
if (has_same_location(nr, it->get_segment_back().second())) {
if (debug()) {
std::cerr << " ring.last=it->last\n";
}
ring.merge_ring_reverse(*it, debug());
m_rings.erase(it);
return true;
}
}
}
return false;
}
bool possibly_combine_rings_front(ProtoRing& ring) {
const osmium::NodeRef& nr = ring.get_segment_front().first();
if (debug()) {
std::cerr << " possibly_combine_rings_front()\n";
}
for (auto it = m_rings.begin(); it != m_rings.end(); ++it) {
if (&*it != &ring && !it->closed()) {
if (has_same_location(nr, it->get_segment_back().second())) {
if (debug()) {
std::cerr << " ring.first=it->last\n";
}
ring.swap_segments(*it);
ring.merge_ring(*it, debug());
m_rings.erase(it);
return true;
}
if (has_same_location(nr, it->get_segment_front().first())) {
if (debug()) {
std::cerr << " ring.first=it->first\n";
}
ring.reverse();
ring.merge_ring(*it, debug());
m_rings.erase(it);
return true;
}
}
}
return false;
}
void split_off_subring(osmium::area::detail::ProtoRing& ring, osmium::area::detail::ProtoRing::segments_type::iterator it, osmium::area::detail::ProtoRing::segments_type::iterator it_begin, osmium::area::detail::ProtoRing::segments_type::iterator it_end) {
if (debug()) {
std::cerr << " subring found at: " << *it << "\n";
}
ProtoRing new_ring(it_begin, it_end);
ring.remove_segments(it_begin, it_end);
if (debug()) {
std::cerr << " split into two rings:\n";
std::cerr << " " << new_ring << "\n";
std::cerr << " " << ring << "\n";
}
m_rings.push_back(std::move(new_ring));
}
bool has_closed_subring_back(ProtoRing& ring, const NodeRef& nr) {
if (ring.segments().size() < 3) {
return false;
}
if (debug()) {
std::cerr << " has_closed_subring_back()\n";
}
const auto end = ring.segments().end();
for (auto it = ring.segments().begin() + 1; it != end - 1; ++it) {
if (has_same_location(nr, it->first())) {
split_off_subring(ring, it, it, end);
return true;
}
}
return false;
}
bool has_closed_subring_front(ProtoRing& ring, const NodeRef& nr) {
if (ring.segments().size() < 3) {
return false;
}
if (debug()) {
std::cerr << " has_closed_subring_front()\n";
}
const auto end = ring.segments().end();
for (auto it = ring.segments().begin() + 1; it != end - 1; ++it) {
if (has_same_location(nr, it->second())) {
split_off_subring(ring, it, ring.segments().begin(), it+1);
return true;
}
}
return false;
}
bool check_for_closed_subring(ProtoRing& ring) {
if (debug()) {
std::cerr << " check_for_closed_subring()\n";
}
osmium::area::detail::ProtoRing::segments_type segments(ring.segments().size());
std::copy(ring.segments().begin(), ring.segments().end(), segments.begin());
std::sort(segments.begin(), segments.end());
const auto it = std::adjacent_find(segments.begin(), segments.end(), [this](const osmium::area::detail::NodeRefSegment& s1, const osmium::area::detail::NodeRefSegment& s2) {
return has_same_location(s1.first(), s2.first());
});
if (it == segments.end()) {
return false;
}
const auto r1 = std::find_first_of(ring.segments().begin(), ring.segments().end(), it, it+1);
assert(r1 != ring.segments().end());
const auto r2 = std::find_first_of(ring.segments().begin(), ring.segments().end(), it+1, it+2);
assert(r2 != ring.segments().end());
if (debug()) {
std::cerr << " found subring in ring " << ring << " at " << it->first() << "\n";
}
const auto m = std::minmax(r1, r2);
ProtoRing new_ring(m.first, m.second);
ring.remove_segments(m.first, m.second);
if (debug()) {
std::cerr << " split ring1=" << new_ring << "\n";
std::cerr << " split ring2=" << ring << "\n";
}
m_rings.emplace_back(new_ring);
return true;
}
void combine_rings_front(const osmium::area::detail::NodeRefSegment& segment, ProtoRing& ring) {
if (debug()) {
std::cerr << " => match at front of ring\n";
}
ring.add_segment_front(segment);
has_closed_subring_front(ring, segment.first());
if (possibly_combine_rings_front(ring)) {
check_for_closed_subring(ring);
}
}
void combine_rings_back(const osmium::area::detail::NodeRefSegment& segment, ProtoRing& ring) {
if (debug()) {
std::cerr << " => match at back of ring\n";
}
ring.add_segment_back(segment);
has_closed_subring_back(ring, segment.second());
if (possibly_combine_rings_back(ring)) {
check_for_closed_subring(ring);
}
}
void add_rings_to_area(osmium::builder::AreaBuilder& builder) const {
for (const ProtoRing* ring : m_outer_rings) {
if (debug()) {
std::cerr << " ring " << *ring << " is outer\n";
}
{
osmium::builder::OuterRingBuilder ring_builder(builder.buffer(), &builder);
ring_builder.add_node_ref(ring->get_segment_front().first());
for (const auto& segment : ring->segments()) {
ring_builder.add_node_ref(segment.second());
}
}
for (ProtoRing* inner : ring->inner_rings()) {
osmium::builder::InnerRingBuilder ring_builder(builder.buffer(), &builder);
ring_builder.add_node_ref(inner->get_segment_front().first());
for (const auto& segment : inner->segments()) {
ring_builder.add_node_ref(segment.second());
}
}
}
}
bool add_to_existing_ring(osmium::area::detail::NodeRefSegment segment) {
int n = 0;
for (auto& ring : m_rings) {
if (debug()) {
std::cerr << " check against ring " << n << " " << ring;
}
if (ring.closed()) {
if (debug()) {
std::cerr << " => ring CLOSED\n";
}
} else {
if (has_same_location(ring.get_segment_back().second(), segment.first())) {
combine_rings_back(segment, ring);
return true;
}
if (has_same_location(ring.get_segment_back().second(), segment.second())) {
segment.swap_locations();
combine_rings_back(segment, ring);
return true;
}
if (has_same_location(ring.get_segment_front().first(), segment.first())) {
segment.swap_locations();
combine_rings_front(segment, ring);
return true;
}
if (has_same_location(ring.get_segment_front().first(), segment.second())) {
combine_rings_front(segment, ring);
return true;
}
if (debug()) {
std::cerr << " => no match\n";
}
}
++n;
}
return false;
}
void check_inner_outer(ProtoRing& ring) {
const osmium::NodeRef& min_node = ring.min_node();
if (debug()) {
std::cerr << " check_inner_outer min_node=" << min_node << "\n";
}
int count = 0;
int above = 0;
for (auto it = m_segment_list.begin(); it != m_segment_list.end() && it->first().location().x() <= min_node.location().x(); ++it) {
if (!ring.contains(*it)) {
if (debug()) {
std::cerr << " segments for count: " << *it;
}
if (it->to_left_of(min_node.location())) {
++count;
if (debug()) {
std::cerr << " counted\n";
}
} else {
if (debug()) {
std::cerr << " not counted\n";
}
}
if (it->first().location() == min_node.location()) {
if (it->second().location().y() > min_node.location().y()) {
++above;
}
}
if (it->second().location() == min_node.location()) {
if (it->first().location().y() > min_node.location().y()) {
++above;
}
}
}
}
if (debug()) {
std::cerr << " count=" << count << " above=" << above << "\n";
}
count += above % 2;
if (count % 2) {
ring.set_inner();
}
}
void check_inner_outer_roles() {
if (debug()) {
std::cerr << " check_inner_outer_roles\n";
}
for (const auto ringptr : m_outer_rings) {
for (const auto& segment : ringptr->segments()) {
if (!segment.role_outer()) {
++m_inner_outer_mismatches;
if (debug()) {
std::cerr << " segment " << segment << " from way " << segment.way()->id() << " should have role 'outer'\n";
}
if (m_config.problem_reporter) {
m_config.problem_reporter->report_role_should_be_outer(segment.way()->id(), segment.first().location(), segment.second().location());
}
}
}
}
for (const auto ringptr : m_inner_rings) {
for (const auto& segment : ringptr->segments()) {
if (!segment.role_inner()) {
++m_inner_outer_mismatches;
if (debug()) {
std::cerr << " segment " << segment << " from way " << segment.way()->id() << " should have role 'inner'\n";
}
if (m_config.problem_reporter) {
m_config.problem_reporter->report_role_should_be_inner(segment.way()->id(), segment.first().location(), segment.second().location());
}
}
}
}
}
bool create_rings() {
m_segment_list.sort();
m_segment_list.erase_duplicate_segments();
// Now we look for segments crossing each other. If there are
// any, the multipolygon is invalid.
// In the future this could be improved by trying to fix those
// cases.
if (m_segment_list.find_intersections(m_config.problem_reporter)) {
return false;
}
// Now iterator over all segments and add them to rings. Each segment
// is tacked on to either end of an existing ring if possible, or a
// new ring is started with it.
for (const auto& segment : m_segment_list) {
if (debug()) {
std::cerr << " checking segment " << segment << "\n";
}
if (!add_to_existing_ring(segment)) {
if (debug()) {
std::cerr << " new ring for segment " << segment << "\n";
}
m_rings.emplace_back(segment);
}
}
if (debug()) {
std::cerr << " Rings:\n";
for (const auto& ring : m_rings) {
std::cerr << " " << ring;
if (ring.closed()) {
std::cerr << " (closed)";
}
std::cerr << "\n";
}
}
if (check_for_open_rings()) {
if (debug()) {
std::cerr << " not all rings are closed\n";
}
return false;
}
if (debug()) {
std::cerr << " Find inner/outer...\n";
}
if (m_rings.size() == 1) {
m_outer_rings.push_back(&m_rings.front());
} else {
for (auto& ring : m_rings) {
check_inner_outer(ring);
if (ring.outer()) {
if (!ring.is_cw()) {
ring.reverse();
}
m_outer_rings.push_back(&ring);
} else {
if (ring.is_cw()) {
ring.reverse();
}
m_inner_rings.push_back(&ring);
}
}
if (m_outer_rings.size() == 1) {
for (auto inner : m_inner_rings) {
m_outer_rings.front()->add_inner_ring(inner);
}
} else {
// sort outer rings by size, smallest first
std::sort(m_outer_rings.begin(), m_outer_rings.end(), [](ProtoRing* a, ProtoRing* b) {
return a->area() < b->area();
});
for (auto inner : m_inner_rings) {
for (auto outer : m_outer_rings) {
if (inner->is_in(outer)) {
outer->add_inner_ring(inner);
break;
}
}
}
}
}
check_inner_outer_roles();
return true;
}
public:
typedef osmium::area::AssemblerConfig config_type;
explicit Assembler(const config_type& config) :
m_config(config),
m_segment_list(config.debug) {
}
~Assembler() = default;
void operator()(const osmium::Way& way, osmium::memory::Buffer& out_buffer) {
if (m_config.problem_reporter) {
m_config.problem_reporter->set_object(osmium::item_type::way, way.id());
}
if (!way.ends_have_same_id()) {
if (m_config.problem_reporter) {
m_config.problem_reporter->report_duplicate_node(way.nodes().front().ref(), way.nodes().back().ref(), way.nodes().front().location());
}
}
m_segment_list.extract_segments_from_way(way, "outer");
if (debug()) {
std::cerr << "\nBuild way id()=" << way.id() << " segments.size()=" << m_segment_list.size() << "\n";
}
// Now create the Area object and add the attributes and tags
// from the relation.
{
osmium::builder::AreaBuilder builder(out_buffer);
builder.initialize_from_object(way);
if (create_rings()) {
add_tags_to_area(builder, way);
add_rings_to_area(builder);
}
}
out_buffer.commit();
}
void operator()(const osmium::Relation& relation, const std::vector<size_t>& members, const osmium::memory::Buffer& in_buffer, osmium::memory::Buffer& out_buffer) {
if (m_config.problem_reporter) {
m_config.problem_reporter->set_object(osmium::item_type::relation, relation.id());
}
m_segment_list.extract_segments_from_ways(relation, members, in_buffer);
if (debug()) {
std::cerr << "\nBuild relation id()=" << relation.id() << " members.size()=" << members.size() << " segments.size()=" << m_segment_list.size() << "\n";
}
size_t area_offset = out_buffer.committed();
// Now create the Area object and add the attributes and tags
// from the relation.
{
osmium::builder::AreaBuilder builder(out_buffer);
builder.initialize_from_object(relation);
if (create_rings()) {
add_tags_to_area(builder, relation);
add_rings_to_area(builder);
}
}
out_buffer.commit();
const osmium::TagList& area_tags = out_buffer.get<osmium::Area>(area_offset).tags(); // tags of the area we just built
// Find all closed ways that are inner rings and check their
// tags. If they are not the same as the tags of the area we
// just built, add them to a list and later build areas for
// them, too.
std::vector<const osmium::Way*> ways_that_should_be_areas;
if (m_inner_outer_mismatches == 0) {
auto memit = relation.members().begin();
for (size_t offset : members) {
if (!std::strcmp(memit->role(), "inner")) {
const osmium::Way& way = in_buffer.get<const osmium::Way>(offset);
if (!way.nodes().empty() && way.is_closed() && way.tags().size() > 0) {
auto d = std::count_if(way.tags().begin(), way.tags().end(), filter());
if (d > 0) {
osmium::tags::KeyFilter::iterator way_fi_begin(filter(), way.tags().begin(), way.tags().end());
osmium::tags::KeyFilter::iterator way_fi_end(filter(), way.tags().end(), way.tags().end());
osmium::tags::KeyFilter::iterator area_fi_begin(filter(), area_tags.begin(), area_tags.end());
osmium::tags::KeyFilter::iterator area_fi_end(filter(), area_tags.end(), area_tags.end());
if (!std::equal(way_fi_begin, way_fi_end, area_fi_begin) || d != std::distance(area_fi_begin, area_fi_end)) {
ways_that_should_be_areas.push_back(&way);
}
}
}
}
++memit;
}
}
// Now build areas for all ways found in the last step.
for (const osmium::Way* way : ways_that_should_be_areas) {
Assembler assembler(m_config);
assembler(*way, out_buffer);
}
}
}; // class Assembler
} // namespace area
} // namespace osmium
#endif // OSMIUM_AREA_ASSEMBLER_HPP
osmium::Way::nodes
WayNodeList & nodes()
Definition: way.hpp:75
osmium::Tag
Definition: tag.hpp:48
osmium::item_type::way
osmium::area::Assembler::m_outer_rings
std::vector< ProtoRing * > m_outer_rings
Definition: assembler.hpp:102
osmium::area::AssemblerConfig::problem_reporter
osmium::area::ProblemReporter * problem_reporter
Definition: assembler.hpp:67
osmium::memory::Collection::end
iterator end()
Definition: collection.hpp:133
osmium::tags::Filter
Definition: filter.hpp:77
osmium::builder::Builder::buffer
osmium::memory::Buffer & buffer() noexcept
Return the buffer this builder is using.
Definition: builder.hpp:179
osmium::TagList
Definition: tag.hpp:105
location.hpp
osmium::Relation::members
RelationMemberList & members()
Definition: relation.hpp:177
osmium::area::ProblemReporter::report_duplicate_node
virtual void report_duplicate_node(osmium::object_id_type node_id1, osmium::object_id_type node_id2, osmium::Location location)
Definition: problem_reporter.hpp:94
osmium::area::ProblemReporter::report_role_should_be_inner
virtual void report_role_should_be_inner(osmium::object_id_type way_id, osmium::Location seg_start, osmium::Location seg_end)
Definition: problem_reporter.hpp:138
osmium::builder::AreaBuilder::initialize_from_object
void initialize_from_object(const osmium::OSMObject &source)
Definition: osm_object_builder.hpp:387
osmium::area::Assembler::add_rings_to_area
void add_rings_to_area(osmium::builder::AreaBuilder &builder) const
Definition: assembler.hpp:429
osmium::Way::ends_have_same_id
bool ends_have_same_id() const
Definition: way.hpp:102
osmium::area::Assembler::operator()
void operator()(const osmium::Way &way, osmium::memory::Buffer &out_buffer)
Definition: assembler.hpp:681
osmium::Relation
Definition: relation.hpp:165
osmium::area::Assembler::check_inner_outer
void check_inner_outer(ProtoRing &ring)
Definition: assembler.hpp:490
osmium::Area
Definition: area.hpp:113
osmium::area::AssemblerConfig
Definition: assembler.hpp:65
osmium::area::Assembler::combine_rings_back
void combine_rings_back(const osmium::area::detail::NodeRefSegment &segment, ProtoRing &ring)
Definition: assembler.hpp:414
osmium::osm_entity_bits::area
Definition: entity_bits.hpp:67
osmium::area::Assembler::operator()
void operator()(const osmium::Relation &relation, const std::vector< size_t > &members, const osmium::memory::Buffer &in_buffer, osmium::memory::Buffer &out_buffer)
Definition: assembler.hpp:718
osmium::area::Assembler::add_tags_to_area
void add_tags_to_area(osmium::builder::AreaBuilder &builder, const osmium::Relation &relation) const
Definition: assembler.hpp:177
osmium::area::Assembler::split_off_subring
void split_off_subring(osmium::area::detail::ProtoRing &ring, osmium::area::detail::ProtoRing::segments_type::iterator it, osmium::area::detail::ProtoRing::segments_type::iterator it_begin, osmium::area::detail::ProtoRing::segments_type::iterator it_end)
Definition: assembler.hpp:317
osmium::memory::Collection::begin
iterator begin()
Definition: collection.hpp:129
osmium::geom::haversine::distance
double distance(const osmium::geom::Coordinates &c1, const osmium::geom::Coordinates &c2)
Definition: haversine.hpp:64
osmium::item_type::relation
osmium::area::AssemblerConfig::debug
bool debug
Definition: assembler.hpp:70
osmium::Way
Definition: way.hpp:65
osmium::area::Assembler::add_common_tags
void add_common_tags(osmium::builder::TagListBuilder &tl_builder, std::set< const osmium::Way * > &ways) const
Definition: assembler.hpp:136
osmium::area::Assembler::m_rings
std::list< ProtoRing > m_rings
Definition: assembler.hpp:100
osmium::area::ProblemReporter::report_role_should_be_outer
virtual void report_role_should_be_outer(osmium::object_id_type way_id, osmium::Location seg_start, osmium::Location seg_end)
Definition: problem_reporter.hpp:128
osmium::builder::NodeRefListBuilder
Definition: osm_object_builder.hpp:166
osmium::area::Assembler::m_segment_list
osmium::area::detail::SegmentList m_segment_list
Definition: assembler.hpp:97
osmium::NodeRef::ref
constexpr osmium::object_id_type ref() const noexcept
Definition: node_ref.hpp:65
osmium::NodeRefList::empty
bool empty() const noexcept
Definition: node_ref_list.hpp:61
osmium::area::Assembler::has_closed_subring_front
bool has_closed_subring_front(ProtoRing &ring, const NodeRef &nr)
Definition: assembler.hpp:348
osmium
Namespace for everything in the Osmium library.
Definition: assembler.hpp:59
osmium::area::Assembler::check_inner_outer_roles
void check_inner_outer_roles()
Definition: assembler.hpp:538
osmium::area::Assembler::check_for_closed_subring
bool check_for_closed_subring(ProtoRing &ring)
Definition: assembler.hpp:365
osmium::area::ProblemReporter::report_ring_not_closed
virtual void report_ring_not_closed(osmium::Location end1, osmium::Location end2)
Definition: problem_reporter.hpp:118
area.hpp
osmium::area::ProblemReporter
Definition: problem_reporter.hpp:55
osm_object_builder.hpp
osmium::area::Assembler::possibly_combine_rings_front
bool possibly_combine_rings_front(ProtoRing &ring)
Definition: assembler.hpp:286
osmium::area::ProblemReporter::set_object
void set_object(osmium::item_type object_type, osmium::object_id_type object_id) noexcept
Definition: problem_reporter.hpp:77
problem_reporter.hpp
relation.hpp
osmium::area::Assembler::MPFilter
Definition: assembler.hpp:159
std::end
osmium::io::InputIterator< osmium::io::Reader > end(osmium::io::Reader &)
Definition: reader_iterator.hpp:45
osmium::Location::y
constexpr int32_t y() const noexcept
Definition: location.hpp:167
osmium::tags::Filter::iterator
boost::filter_iterator< filter_type, osmium::TagList::const_iterator > iterator
Definition: filter.hpp:112
osmium::OSMObject::tags
const TagList & tags() const
Get the list of tags for this object.
Definition: object.hpp:295
osmium::area::AssemblerConfig::AssemblerConfig
AssemblerConfig(osmium::area::ProblemReporter *pr=nullptr, bool d=false)
Definition: assembler.hpp:72
osmium::area::Assembler::filter
static MPFilter & filter()
Definition: assembler.hpp:172
osmium::area::Assembler::has_closed_subring_back
bool has_closed_subring_back(ProtoRing &ring, const NodeRef &nr)
Definition: assembler.hpp:331
osmium::area::Assembler::add_tags_to_area
void add_tags_to_area(osmium::builder::AreaBuilder &builder, const osmium::Way &way) const
Definition: assembler.hpp:129
osmium::area::Assembler::m_config
const AssemblerConfig m_config
Definition: assembler.hpp:94
osmium::area::Assembler::Assembler
Assembler(const config_type &config)
Definition: assembler.hpp:670
osmium::NodeRef::location
osmium::Location & location() noexcept
Definition: node_ref.hpp:79
osmium::area::Assembler::config_type
osmium::area::AssemblerConfig config_type
Definition: assembler.hpp:668
osmium::area::Assembler::add_to_existing_ring
bool add_to_existing_ring(osmium::area::detail::NodeRefSegment segment)
Definition: assembler.hpp:451
osmium::OSMObject::id
object_id_type id() const noexcept
Get ID of this object.
Definition: object.hpp:110
osmium::memory::Buffer::committed
size_t committed() const noexcept
Definition: buffer.hpp:241
osmium::area::Assembler::debug
bool debug() const
Definition: assembler.hpp:107
osmium::area::Assembler::combine_rings_front
void combine_rings_front(const osmium::area::detail::NodeRefSegment &segment, ProtoRing &ring)
Definition: assembler.hpp:403
osmium::memory::Buffer
Definition: buffer.hpp:97
osmium::memory::Buffer::get
T & get(const size_t offset) const
Definition: buffer.hpp:379
osmium::area::Assembler::m_inner_rings
std::vector< ProtoRing * > m_inner_rings
Definition: assembler.hpp:103
buffer.hpp
osmium::area::Assembler::create_rings
bool create_rings()
Definition: assembler.hpp:574
osmium::Way::is_closed
bool is_closed() const
Definition: way.hpp:98
osmium::NodeRefList::front
const NodeRef & front() const noexcept
Definition: node_ref_list.hpp:92
osmium::area::Assembler::check_for_open_rings
bool check_for_open_rings()
Definition: assembler.hpp:228
osmium::Location::x
constexpr int32_t x() const noexcept
Definition: location.hpp:163
osmium::NodeRefList::back
const NodeRef & back() const noexcept
Definition: node_ref_list.hpp:102
osmium::area::Assembler::MPFilter::MPFilter
MPFilter()
Definition: assembler.hpp:161
osmium::area::Assembler::has_same_location
bool has_same_location(const osmium::NodeRef &nr1, const osmium::NodeRef &nr2)
Definition: assembler.hpp:117
osmium::tags::KeyFilter
Filter< std::string > KeyFilter
Definition: filter.hpp:155
osmium::NodeRef
Definition: node_ref.hpp:50
osmium::area::Assembler
Definition: assembler.hpp:92
osmium::area::Assembler::possibly_combine_rings_back
bool possibly_combine_rings_back(ProtoRing &ring)
Definition: assembler.hpp:250
osmium::area::AssemblerConfig::enable_debug_output
void enable_debug_output(bool d=true)
Definition: assembler.hpp:81
filter.hpp
osmium::TagList::size
size_type size() const noexcept
Definition: tag.hpp:115
osmium::builder::TagListBuilder::add_tag
void add_tag(const char *key, const char *value)
Definition: osm_object_builder.hpp:81
osmium::builder::TagListBuilder
Definition: osm_object_builder.hpp:63
osmium::memory::Buffer::commit
size_t commit()
Definition: buffer.hpp:335
osmium::builder::NodeRefListBuilder::add_node_ref
void add_node_ref(const NodeRef &node_ref)
Definition: osm_object_builder.hpp:178
osmium::builder::AreaBuilder
Definition: osm_object_builder.hpp:376