本文整理汇总了C++中osmium::OSMObject::tags方法的典型用法代码示例。如果您正苦于以下问题:C++ OSMObject::tags方法的具体用法?C++ OSMObject::tags怎么用?C++ OSMObject::tags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osmium::OSMObject
的用法示例。
在下文中一共展示了OSMObject::tags方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: output_pubs
void output_pubs(const osmium::OSMObject& object) {
const char* amenity = object.tags()["amenity"];
if (amenity && !strcmp(amenity, "pub")) {
const char* name = object.tags()["name"];
if (name) {
std::cout << name << std::endl;
}
}
}
示例2: update
void update(const osmium::OSMObject& object) {
update_int64(object.id());
update_bool(object.visible());
update_int32(object.version());
update(object.timestamp());
update_int32(object.uid());
update_string(object.user());
update(object.tags());
}
示例3: add_tags
static void add_tags(gdalcpp::Feature& feature, const osmium::OSMObject& object) {
std::string tags;
for (const auto& tag : object.tags()) {
tags += tag.key();
tags += "=";
tags += tag.value();
tags += ",";
}
if (!tags.empty()) {
tags.pop_back();
}
feature.set_field("tags", tags.c_str());
}
示例4: write_meta
void write_meta(const osmium::OSMObject& object) {
output_int(object.id());
if (m_options.add_metadata) {
*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());
}
write_tags(object.tags());
}
示例5: write_meta
void write_meta(const osmium::OSMObject& object) {
output_formatted("%" PRId64 " v%d d", object.id(), object.version());
*m_out += (object.visible() ? 'V' : 'D');
output_formatted(" c%d t", object.changeset());
*m_out += object.timestamp().to_iso();
output_formatted(" i%d u", object.uid());
append_encoded_string(object.user());
*m_out += " T";
bool first = true;
for (const auto& tag : object.tags()) {
if (first) {
first = false;
} else {
*m_out += ',';
}
append_encoded_string(tag.key());
*m_out += '=';
append_encoded_string(tag.value());
}
}
示例6: filter_tags
bool lua_tagtransform_t::filter_tags(osmium::OSMObject const &o, int *polygon,
int *roads, export_list const &,
taglist_t &out_tags, bool)
{
switch (o.type()) {
case osmium::item_type::node:
lua_getglobal(L, m_node_func.c_str());
break;
case osmium::item_type::way:
lua_getglobal(L, m_way_func.c_str());
break;
case osmium::item_type::relation:
lua_getglobal(L, m_rel_func.c_str());
break;
default:
throw std::runtime_error("Unknown OSM type");
}
lua_newtable(L); /* key value table */
lua_Integer sz = 0;
for (auto const &t : o.tags()) {
lua_pushstring(L, t.key());
lua_pushstring(L, t.value());
lua_rawset(L, -3);
++sz;
}
if (m_extra_attributes && o.version() > 0) {
taglist_t tags;
tags.add_attributes(o);
for (auto const &t : tags) {
lua_pushstring(L, t.key.c_str());
lua_pushstring(L, t.value.c_str());
lua_rawset(L, -3);
}
sz += tags.size();
}
lua_pushinteger(L, sz);
if (lua_pcall(L, 2, (o.type() == osmium::item_type::way) ? 4 : 2, 0)) {
fprintf(stderr,
"Failed to execute lua function for basic tag processing: %s\n",
lua_tostring(L, -1));
/* lua function failed */
return 1;
}
if (o.type() == osmium::item_type::way) {
if (roads) {
*roads = (int)lua_tointeger(L, -1);
}
lua_pop(L, 1);
if (polygon) {
*polygon = (int)lua_tointeger(L, -1);
}
lua_pop(L, 1);
}
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
const char *key = lua_tostring(L, -2);
const char *value = lua_tostring(L, -1);
out_tags.emplace_back(key, value);
lua_pop(L, 1);
}
bool filter = lua_tointeger(L, -2);
lua_pop(L, 2);
return filter;
}
示例7: copy_out_maintag
bool gazetteer_style_t::copy_out_maintag(pmaintag_t const &tag,
osmium::OSMObject const &o,
std::string const &geom,
db_copy_mgr_t &buffer)
{
std::vector<osmium::Tag const *> domain_name;
if (std::get<2>(tag) & SF_MAIN_NAMED_KEY) {
domain_name = domain_names(std::get<0>(tag), o.tags());
if (domain_name.empty())
return false;
}
if (std::get<2>(tag) & SF_MAIN_NAMED) {
if (domain_name.empty() && !m_is_named) {
return false;
}
}
buffer.new_line(place_table);
// osm_id
buffer.add_column(o.id());
// osm_type
char const osm_type[2] = { (char)toupper(osmium::item_type_to_char(o.type())), '\0'};
buffer.add_column(osm_type);
// class
buffer.add_column(std::get<0>(tag));
// type
buffer.add_column(std::get<1>(tag));
// names
if (!domain_name.empty()) {
auto prefix_len = strlen(std::get<0>(tag)) + 1; // class name and ':'
buffer.new_hash();
for (auto *t : domain_name) {
buffer.add_hash_elem(t->key() + prefix_len, t->value());
}
buffer.finish_hash();
} else {
bool first = true;
// operator will be ignored on anything but these classes
if (m_operator && (std::get<2>(tag) & SF_MAIN_OPERATOR)) {
buffer.new_hash();
buffer.add_hash_elem("operator", m_operator);
first = false;
}
for (auto const &entry : m_names) {
if (first) {
buffer.new_hash();
first = false;
}
buffer.add_hash_elem(entry.first, entry.second);
}
if (first) {
buffer.add_null_column();
} else {
buffer.finish_hash();
}
}
// admin_level
buffer.add_column(m_admin_level);
// address
if (m_address.empty()) {
buffer.add_null_column();
} else {
buffer.new_hash();
for (auto const &a : m_address) {
if (strcmp(a.first, "tiger:county") == 0) {
std::string term;
auto *end = strchr(a.second, ',');
if (end) {
auto len = (std::string::size_type)(end - a.second);
term = std::string(a.second, len);
} else {
term = a.second;
}
term += " county";
buffer.add_hash_elem(a.first, term);
} else {
buffer.add_hash_elem(a.first, a.second);
}
}
buffer.finish_hash();
}
// extra tags
if (m_extra.empty()) {
buffer.add_null_column();
} else {
buffer.new_hash();
for (auto const &entry : m_extra) {
buffer.add_hash_elem(entry.first, entry.second);
}
buffer.finish_hash();
}
// add the geometry - encoding it to hex along the way
buffer.add_hex_geom(geom);
buffer.finish_line();
return true;
//.........这里部分代码省略.........
示例8: process_tags
void gazetteer_style_t::process_tags(osmium::OSMObject const &o)
{
clear();
char const *postcode = nullptr;
char const *country = nullptr;
char const *place = nullptr;
flag_t place_flag;
bool address_point = false;
bool interpolation = false;
bool admin_boundary = false;
bool postcode_fallback = false;
for (auto const &item : o.tags()) {
char const *k = item.key();
char const *v = item.value();
if (strcmp(k, "admin_level") == 0) {
m_admin_level = atoi(v);
if (m_admin_level <= 0 || m_admin_level > MAX_ADMINLEVEL)
m_admin_level = MAX_ADMINLEVEL;
continue;
}
if (m_any_operator_matches && strcmp(k, "operator") == 0) {
m_operator = v;
}
flag_t flag = find_flag(k, v);
if (flag == 0) {
continue;
}
if (flag & SF_MAIN) {
if (strcmp(k, "place") == 0) {
place = v;
place_flag = flag;
} else {
m_main.emplace_back(k, v, flag);
if ((flag & SF_BOUNDARY) && strcmp(v, "administrative") == 0) {
admin_boundary = true;
}
}
}
if (flag & (SF_NAME | SF_REF)) {
m_names.emplace_back(k, v);
if (flag & SF_NAME) {
m_is_named = true;
}
}
if (flag & SF_ADDRESS) {
char const *addr_key;
if (strncmp(k, "addr:", 5) == 0) {
addr_key = k + 5;
} else if (strncmp(k, "is_in:", 6) == 0) {
addr_key = k + 6;
} else {
addr_key = k;
}
if (strcmp(addr_key, "postcode") == 0) {
if (!postcode) {
postcode = v;
}
} else if (strcmp(addr_key, "country") == 0) {
if (!country && strlen(v) == 2) {
country = v;
}
} else {
bool first = std::none_of(
m_address.begin(), m_address.end(), [&](ptag_t const &t) {
return strcmp(t.first, addr_key) == 0;
});
if (first) {
m_address.emplace_back(addr_key, v);
}
}
}
if (flag & SF_ADDRESS_POINT) {
address_point = true;
m_is_named = true;
}
if ((flag & SF_POSTCODE) && !postcode) {
postcode = v;
if (flag & SF_MAIN_FALLBACK) {
postcode_fallback = true;
}
}
if ((flag & SF_COUNTRY) && !country && std::strlen(v) == 2) {
country = v;
}
if (flag & SF_EXTRA) {
m_extra.emplace_back(k, v);
//.........这里部分代码省略.........