本文整理汇总了C++中osmium::Relation::members方法的典型用法代码示例。如果您正苦于以下问题:C++ Relation::members方法的具体用法?C++ Relation::members怎么用?C++ Relation::members使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osmium::Relation
的用法示例。
在下文中一共展示了Relation::members方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: relation
void relation(const osmium::Relation& relation) {
if (m_write_change_ops) {
open_close_op_tag(relation.visible() ? (relation.version() == 1 ? operation::op_create : operation::op_modify) : operation::op_delete);
}
write_prefix();
m_out += "<relation";
write_meta(relation);
if (relation.tags().empty() && relation.members().empty()) {
m_out += "/>\n";
return;
}
m_out += ">\n";
for (const auto& member : relation.members()) {
write_prefix();
m_out += " <member type=\"";
m_out += item_type_to_name(member.type());
oprintf(m_out, "\" ref=\"%" PRId64 "\" role=\"", member.ref());
xml_string(m_out, member.role());
m_out += "\"/>\n";
}
write_tags(relation.tags());
write_prefix();
m_out += "</relation>\n";
}
示例2: relation
void relation( osmium::Relation& relation ) {
const char* bus = relation.tags()["route"];
if(bus && !strcmp(bus, "bus")) {
const char* name = relation.tags().get_value_by_key("ref");
if(!name) name = relation.tags().get_value_by_key("name");
std::cout << name;
osmium::unsigned_object_id_type temp1, temp2;
int db = 0;
for( auto &member : relation.members()){
if(db == 0 && member.type() == osmium::item_type::node) {
temp1 = member.positive_ref();
db++;
} else if(db !=0 && member.type() == osmium::item_type::node){
temp2 = member.positive_ref();
}
}
std::cout << " (" << map[temp1] << " - " << map[temp2] << ")" << std::endl;
for ( auto &member : relation.members()) {
if( member.type() == osmium::item_type::node){
std::cout << " " << locations.get(member.positive_ref()).lat() << ", " << locations.get(member.positive_ref()).lon() << " " << map[member.positive_ref()] << std::endl;
}
}
std::cout << std::endl;
}
}
示例3: switch
osmium::osm_entity_bits::type CommandAddRefs::add_members(const osmium::Relation& relation) {
osmium::osm_entity_bits::type read_types = osmium::osm_entity_bits::nothing;
for (const auto& member : relation.members()) {
switch (member.type()) {
case osmium::item_type::node:
m_node_ids.insert(member.ref());
break;
case osmium::item_type::way:
if (m_way_ids.count(member.ref()) == 0) {
m_way_ids.insert(member.ref());
read_types |= osmium::osm_entity_bits::way;
}
break;
case osmium::item_type::relation:
if (m_relation_ids.count(member.ref()) == 0) {
m_relation_ids.insert(member.ref());
read_types |= osmium::osm_entity_bits::relation;
}
break;
default:
break;
}
}
return read_types;
}
示例4: new_relation
/**
* We are interested in all relations tagged with type=multipolygon
* or type=boundary with at least one way member.
*/
bool new_relation(const osmium::Relation& relation) const {
const char* type = relation.tags().get_value_by_key("type");
// ignore relations without "type" tag
if (!type) {
return false;
}
if ((!std::strcmp(type, "multipolygon")) || (!std::strcmp(type, "boundary"))) {
return std::any_of(relation.members().cbegin(), relation.members().cend(), [](const RelationMember& member) {
return member.type() == osmium::item_type::way;
});
}
return false;
}
示例5: relation
void relation(osmium::Relation& rel) {
const char* bus = rel.tags() ["route"];
if (bus && !strcmp(bus, "bus")) {
const char* busRef = rel.tags()["ref"];
if (busRef) {
buses.push_back(Bus(busRef, id));
id++;
osmium::RelationMemberList& rml = rel.members();
for (osmium::RelationMember& rm : rml) {
if (rm.type() == osmium::item_type::way) {
std::vector<osmium::Location> tmpVec;
for (auto& nd : ways[rm.ref()]) {
osmium::Location loc = locations.get(nd);
tmpVec.push_back(loc);
}
buses.at(id - 1).locs.push_back(tmpVec);
} else if(rm.type() == osmium::item_type::node &&
!strcmp(rm.role(), "stop")) {
buses.at(id - 1).busStopNames[rm.ref()] = nodes[rm.ref()];
}
}
}
}
}
示例6: relation
// - walk over all relations-versions
// - walk over all relations-nodes
// - Adds the nodes and ways that aren't in node-tracker to a vector
// - if node or way is in the box hit becames true
// - if hit is true and the vector is not empty (it means their are nodes or ways that belong to a relation that has at least one node or way inside the box)
// - Records the id of node or way to outside_node_tracker or outside_way_tracker
void relation(const osmium::Relation& relation) {
bool hit = false;
if (debug) {
std::cerr << "cut_administrative relation " << relation.id() << " v" << relation.version() << "\n";
}
std::vector<const osmium::RelationMember*> members;
std::vector<const osmium::TagList*> tags;
for (auto& tag : relation.tags()) {
if (strcmp(tag.key(), "boundary") == 0 && strcmp(tag.value(), "administrative") == 0)
hit = true;
}
for (const auto& extract : info->extracts) {
if (hit){
if(!extract->relation_tracker.get(relation.id())){
extract->relation_tracker.set(relation.id());
}
//Add only the nodes and ways that were not yet in the respective trackers if hit is true
for (const auto& member : relation.members()) {
if (member.type() == osmium::item_type::way && !extract->way_tracker.get(member.ref())){
extract->way_tracker.set(member.ref());
}
}
}
}
}
示例7: extract_segments_from_ways
/**
* Extract all segments from all ways that make up this
* multipolygon relation and add them to the list.
*/
void extract_segments_from_ways(const osmium::Relation& relation, const std::vector<size_t>& members, const osmium::memory::Buffer& in_buffer) {
auto member_it = relation.members().begin();
for (size_t offset : members) {
const osmium::Way& way = in_buffer.get<const osmium::Way>(offset);
extract_segments_from_way(way, member_it->role());
++member_it;
}
}
示例8: relation
void relation(const osmium::Relation& relation) {
*m_out += 'r';
write_meta(relation);
*m_out += " M";
if (!relation.members().empty()) {
auto it = relation.members().begin();
relation_member(*it);
for (++it; it != relation.members().end(); ++it) {
*m_out += ',';
relation_member(*it);
}
}
*m_out += '\n';
}
示例9: complete_relation
/**
* This is called when a relation is complete, ie. all members
* were found in the input. It will build the area using the
* assembler.
*/
void complete_relation(const osmium::Relation& relation) {
std::vector<const osmium::Way*> ways;
ways.reserve(relation.members().size());
for (const auto& member : relation.members()) {
if (member.ref() != 0) {
ways.push_back(this->get_member_way(member.ref()));
assert(ways.back() != nullptr);
}
}
try {
TAssembler assembler{m_assembler_config};
assembler(relation, ways, this->buffer());
m_stats += assembler.stats();
} catch (const osmium::invalid_location&) {
// XXX ignore
}
}
示例10: for_each_member
inline void for_each_member(const osmium::Relation& relation, const std::vector<const osmium::Way*>& ways, F&& func) {
auto way_it = ways.cbegin();
for (const osmium::RelationMember& member : relation.members()) {
if (member.type() == osmium::item_type::way) {
assert(way_it != ways.cend());
func(member, **way_it);
++way_it;
}
}
}
示例11: complete_relation
void complete_relation(const osmium::Relation& relation) noexcept {
for (const auto& member : relation.members()) {
if (member.type() == osmium::item_type::node) {
++count_nodes;
const auto* node = get_member_node(member.ref());
REQUIRE(node);
buffer().add_item(*node);
buffer().commit();
}
}
}
示例12: relation
// The relation handler is called for each node in the input data.
void relation(const osmium::Relation& relation) {
{
osmium::builder::RelationBuilder builder{m_buffer};
copy_attributes(builder, relation);
copy_tags(builder, relation.tags());
// Copy the relation member list over to the new way.
builder.add_item(relation.members());
}
m_buffer.commit();
}
示例13: create_ways
/***
* Iterate through members. Create linestrings of each. First as GEOS
* linestring to union them later. Then as ORG linestring to insert
* them into table ways.
*/
void create_ways(const osmium::Relation &relation,
const osmium::object_id_type relation_id,
bool &contains_nowaterway_ways,
vector<geos::geom::Geometry *> *linestrings) {
for (auto& member : relation.members()) {
if (member_is_valid(member)) {
const osmium::Way& way = way_from(member);
linestring_type *linestr = nullptr;
try {
linestr = osmium_geos_factory.create_linestring(way,
osmium::geom::use_nodes::unique,
osmium::geom::direction::forward).release();
} catch (osmium::geometry_error) {
insert_way_error(way);
continue;
} catch (...) {
cerr << "Error at way: " << way.id() << endl;
cerr << " Unexpected error" << endl;
continue;
}
if (linestr) {
linestrings->push_back(linestr);
} else {
continue;
}
if (TagCheck::has_waterway_tag(way)) {
contains_nowaterway_ways = true;
}
OGRGeometry *ogr_linestring = nullptr;
ogr_linestring = geos2ogr(linestr);
try {
ds.insert_way_feature(ogr_linestring, way, relation_id);
} catch (osmium::geometry_error&) {
cerr << "Inserting to table failed for way: "
<< way.id() << endl;
} catch (...) {
cerr << "Inserting to table failed for way: "
<< way.id() << endl;;
cerr << " Unexpected error" << endl;
}
OGRGeometryFactory::destroyGeometry(ogr_linestring);
}
}
}
示例14: rel_way_members_get
size_t middle_ram_t::rel_way_members_get(osmium::Relation const &rel,
rolelist_t *roles,
osmium::memory::Buffer &buffer) const
{
size_t count = 0;
for (auto const &m : rel.members()) {
if (m.type() == osmium::item_type::way && ways_get(m.ref(), buffer)) {
if (roles) {
roles->emplace_back(m.role());
}
++count;
}
}
return count;
}
示例15: extract_segments_from_ways
/**
* Extract all segments from all ways that make up this
* multipolygon relation and add them to the list.
*/
uint32_t extract_segments_from_ways(osmium::area::ProblemReporter* problem_reporter, const osmium::Relation& relation, const std::vector<const osmium::Way*>& members) {
assert(relation.members().size() >= members.size());
const size_t num_segments = get_num_segments(members);
if (problem_reporter) {
problem_reporter->set_nodes(num_segments);
}
m_segments.reserve(num_segments);
uint32_t duplicate_nodes = 0;
for_each_member(relation, members, [this, &problem_reporter, &duplicate_nodes](const osmium::RelationMember& member, const osmium::Way& way) {
duplicate_nodes += extract_segments_from_way_impl(problem_reporter, way, parse_role(member.role()));
});
return duplicate_nodes;
}