/** * This is called when a way is not in any multipolygon * relation. * * Overwritten from the base class. */ void way_not_in_any_relation(const osmium::Way& way) { if (way.nodes().size() > 3 && way.ends_have_same_location()) { // way is closed and has enough nodes, build simple multipolygon try { TAssembler assembler(m_assembler_config); assembler(way, m_output_buffer); possibly_flush_output_buffer(); } catch (osmium::invalid_location&) { // XXX ignore } } }
/** * This is called when a way is not in any multipolygon * relation. * * Overwritten from the base class. */ void way_not_in_any_relation(const osmium::Way& way) { // you need at least 4 nodes to make up a polygon if (way.nodes().size() <= 3) { return; } try { if (!way.nodes().front().location() || !way.nodes().back().location()) { throw osmium::invalid_location("invalid location"); } if (way.ends_have_same_location()) { // way is closed and has enough nodes, build simple multipolygon TAssembler assembler(m_assembler_config); assembler(way, m_output_buffer); possibly_flush_output_buffer(); } } catch (osmium::invalid_location&) { // XXX ignore } }
void complete_relation(osmium::relations::RelationMeta& relation_meta) { const osmium::Relation& relation = this->get_relation(relation_meta); std::vector<size_t> offsets; for (const auto& member : relation.members()) { if (member.ref() != 0) { offsets.push_back(this->get_offset(member.type(), member.ref())); } } try { TAssembler assembler(m_assembler_config); assembler(relation, offsets, this->members_buffer(), m_output_buffer); possibly_flush_output_buffer(); } catch (osmium::invalid_location&) { // XXX ignore } // clear member metas for (const auto& member : relation.members()) { if (member.ref() != 0) { auto& mmv = this->member_meta(member.type()); auto range = std::equal_range(mmv.begin(), mmv.end(), osmium::relations::MemberMeta(member.ref())); assert(range.first != range.second); // if this is the last time this object was needed // then mark it as removed if (osmium::relations::count_not_removed(range.first, range.second) == 1) { this->get_member(range.first->buffer_offset()).set_removed(true); } for (auto it = range.first; it != range.second; ++it) { if (!it->removed() && relation.id() == this->get_relation(it->relation_pos()).id()) { it->remove(); break; } } } } }