本文整理汇总了C++中taglist_t::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ taglist_t::begin方法的具体用法?C++ taglist_t::begin怎么用?C++ taglist_t::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglist_t
的用法示例。
在下文中一共展示了taglist_t::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_hstore_columns
/* write an hstore column to the database */
void table_t::write_hstore_columns(const taglist_t &tags, std::string& values)
{
//iterate over all configured hstore columns in the options
for(hstores_t::const_iterator hstore_column = hstore_columns.begin(); hstore_column != hstore_columns.end(); ++hstore_column)
{
bool added = false;
//iterate through the list of tags, first one is always null
for (taglist_t::const_iterator xtags = tags.begin(); xtags != tags.end(); ++xtags)
{
//check if the tag's key starts with the name of the hstore column
if(xtags->key.compare(0, hstore_column->size(), *hstore_column) == 0)
{
//generate the short key name, somehow pointer arithmetic works against the key string...
const char* shortkey = xtags->key.c_str() + hstore_column->size();
//and pack the shortkey with its value into the hstore
//hstore ASCII representation looks like "key"=>"value"
if(added)
values.push_back(',');
escape4hstore(shortkey, values);
values.append("=>");
escape4hstore(xtags->value.c_str(), values);
//we did at least one so we need commas from here on out
added = true;
}
}
//if you found not matching tags write a NUL
if(!added)
values.append("\\N");
//finish the column off with a tab
values.push_back('\t');
}
}
示例2: process_tags
void place_tag_processor::process_tags(const taglist_t &tags)
{
bool placeadmin = false;
bool placehouse = false;
bool placebuilding = false;
const tag_t *place = 0;
const tag_t *junction = 0;
const tag_t *landuse = 0;
bool isnamed = false;
bool isinterpolation = false;
const std::string *house_nr = 0;
const std::string *conscr_nr = 0;
const std::string *street_nr = 0;
clear();
src = &tags;
for (taglist_t::const_iterator item = tags.begin(); item != tags.end(); ++item) {
if (item->key == "name:prefix") {
extratags.push_back(&*item);
} else if (item->key == "ref" ||
item->key == "int_ref" ||
item->key == "nat_ref" ||
item->key == "reg_ref" ||
item->key == "loc_ref" ||
item->key == "old_ref" ||
item->key == "iata" ||
item->key == "icao" ||
item->key == "operator" ||
item->key == "pcode" ||
boost::starts_with(item->key, "pcode:")) {
names.push_back(&*item);
} else if (item->key == "name" ||
boost::starts_with(item->key, "name:") ||
item->key == "int_name" ||
boost::starts_with(item->key, "int_name:") ||
item->key == "nat_name" ||
boost::starts_with(item->key, "nat_name:") ||
item->key == "reg_name" ||
boost::starts_with(item->key, "reg_name:") ||
item->key == "loc_name" ||
boost::starts_with(item->key, "loc_name:") ||
item->key == "old_name" ||
boost::starts_with(item->key, "old_name:") ||
item->key == "alt_name" ||
boost::starts_with(item->key, "alt_name:") ||
boost::starts_with(item->key, "alt_name_") ||
item->key == "official_name" ||
boost::starts_with(item->key, "official_name:") ||
item->key == "place_name" ||
boost::starts_with(item->key, "place_name:") ||
item->key == "short_name" ||
boost::starts_with(item->key, "short_name:") ||
item->key == "brand") {
names.push_back(&*item);
isnamed = true;
} else if (item->key == "addr:housename") {
names.push_back(&*item);
placehouse = true;
} else if (item->key == "emergency") {
if (item->value != "fire_hydrant" &&
item->value != "yes" &&
item->value != "no")
places.push_back(*item);
} else if (item->key == "tourism" ||
item->key == "historic" ||
item->key == "military") {
if (item->value != "no" && item->value != "yes")
places.push_back(*item);
} else if (item->key == "natural") {
if (item->value != "no" &&
item->value != "yes" &&
item->value != "coastline")
places.push_back(*item);
} else if (item->key == "landuse") {
if (item->value == "cemetry")
places.push_back(*item);
else
landuse = &*item;
} else if (item->key == "highway") {
if (item->value != "no" &&
item->value != "turning_circle" &&
item->value != "mini_roundabout" &&
item->value != "noexit" &&
item->value != "crossing")
places.push_back(*item);
} else if (item->key == "railway") {
if (item->value != "level_crossing" &&
item->value != "no")
places.push_back(*item);
} else if (item->key == "man_made") {
if (item->value != "survey_point" &&
item->value != "cutline")
places.push_back(*item);
} else if (item->key == "aerialway") {
if (item->value != "pylon" &&
item->value != "no")
places.push_back(*item);
} else if (item->key == "boundary") {
if (item->value == "administrative")
//.........这里部分代码省略.........
示例3: c_filter_basic_tags
/* Go through the given tags and determine the union of flags. Also remove
* any tags from the list that we don't know about */
unsigned int tagtransform::c_filter_basic_tags(OsmType type, const taglist_t &tags, int *polygon,
int *roads, const export_list &exlist,
taglist_t &out_tags, bool strict)
{
//assume we dont like this set of tags
int filter = 1;
int flags = 0;
int add_area_tag = 0;
OsmType export_type;
if (type == OSMTYPE_RELATION) {
export_type = OSMTYPE_WAY;
} else {
export_type = type;
}
const std::vector<taginfo> &infos = exlist.get(export_type);
/* We used to only go far enough to determine if it's a polygon or not,
but now we go through and filter stuff we don't need
pop each tag off and keep it in the temp list if we like it */
for (taglist_t::const_iterator item = tags.begin(); item != tags.end(); ++item) {
//if we want to do more than the export list says
if(!strict) {
if (type == OSMTYPE_RELATION && "type" == item->key) {
out_tags.push_back(*item);
filter = 0;
continue;
}
/* Allow named islands to appear as polygons */
if ("natural" == item->key && "coastline" == item->value) {
add_area_tag = 1;
/* Discard natural=coastline tags (we render these from a shapefile instead) */
if (!options->keep_coastlines) {
continue;
}
}
}
//go through the actual tags found on the item and keep the ones in the export list
size_t i = 0;
for (; i < infos.size(); i++) {
const taginfo &info = infos[i];
if (wildMatch(info.name.c_str(), item->key.c_str())) {
if (info.flags & FLAG_DELETE) {
break;
}
filter = 0;
flags |= info.flags;
out_tags.push_back(*item);
break;
}
}
// if we didn't find any tags that we wanted to export
// and we aren't strictly adhering to the list
if (i == infos.size() && !strict) {
if (options->hstore_mode != HSTORE_NONE) {
/* with hstore, copy all tags... */
out_tags.push_back(*item);
/* ... but if hstore_match_only is set then don't take this
as a reason for keeping the object */
if (!options->hstore_match_only && "osm_uid" != item->key
&& "osm_user" != item->key
&& "osm_timestamp" != item->key
&& "osm_version" != item->key
&& "osm_changeset" != item->key)
filter = 0;
} else if (options->hstore_columns.size() > 0) {
/* does this column match any of the hstore column prefixes? */
size_t j = 0;
for(; j < options->hstore_columns.size(); ++j) {
size_t pos = item->key.find(options->hstore_columns[j]);
if (pos == 0) {
out_tags.push_back(*item);
/* ... but if hstore_match_only is set then don't take this
as a reason for keeping the object */
if (!options->hstore_match_only
&& "osm_uid" != item->key
&& "osm_user" != item->key
&& "osm_timestamp" != item->key
&& "osm_version" != item->key
&& "osm_changeset" != item->key)
filter = 0;
break;
}
}
}
}
}
if (polygon) {
if (add_area_tag) {
/* If we need to force this as a polygon, append an area tag */
out_tags.push_dedupe(tag("area", "yes"));
//.........这里部分代码省略.........
示例4: lua_filter_basic_tags
unsigned tagtransform::lua_filter_basic_tags(OsmType type, const taglist_t &tags,
int *polygon, int *roads, taglist_t &out_tags)
{
#ifdef HAVE_LUA
switch (type) {
case OSMTYPE_NODE: {
lua_getglobal(L, m_node_func.c_str());
break;
}
case OSMTYPE_WAY: {
lua_getglobal(L, m_way_func.c_str());
break;
}
case OSMTYPE_RELATION: {
lua_getglobal(L, m_rel_func.c_str());
break;
}
}
lua_newtable(L); /* key value table */
for (taglist_t::const_iterator it = tags.begin(); it != tags.end(); ++it) {
lua_pushstring(L, it->key.c_str());
lua_pushstring(L, it->value.c_str());
lua_rawset(L, -3);
}
lua_pushinteger(L, tags.size());
if (lua_pcall(L,2,type == OSMTYPE_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 (type == OSMTYPE_WAY) {
assert(roads);
*roads = lua_tointeger(L, -1);
lua_pop(L,1);
assert(polygon);
*polygon = 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.push_back(tag(key, value));
lua_pop(L,1);
}
int filter = lua_tointeger(L, -2);
lua_pop(L,2);
return filter;
#else
return 1;
#endif
}
示例5: lua_filter_rel_member_tags
unsigned tagtransform::lua_filter_rel_member_tags(const taglist_t &rel_tags,
const multitaglist_t &member_tags, const rolelist_t &member_roles,
int *member_superseeded, int *make_boundary, int *make_polygon, int *roads,
taglist_t &out_tags)
{
lua_getglobal(L, m_rel_mem_func.c_str());
lua_newtable(L); /* relations key value table */
for (taglist_t::const_iterator it = rel_tags.begin(); it != rel_tags.end(); ++it) {
lua_pushstring(L, it->key.c_str());
lua_pushstring(L, it->value.c_str());
lua_rawset(L, -3);
}
lua_newtable(L); /* member tags table */
int idx = 1;
for (multitaglist_t::const_iterator list = member_tags.begin();
list != member_tags.end(); ++list) {
lua_pushnumber(L, idx++);
lua_newtable(L); /* member key value table */
for (taglist_t::const_iterator it = list->begin(); it != list->end(); ++it) {
lua_pushstring(L, it->key.c_str());
lua_pushstring(L, it->value.c_str());
lua_rawset(L, -3);
}
lua_rawset(L, -3);
}
lua_newtable(L); /* member roles table */
for (size_t i = 0; i < member_roles.size(); i++) {
lua_pushnumber(L, i + 1);
lua_pushstring(L, member_roles[i]->c_str());
lua_rawset(L, -3);
}
lua_pushnumber(L, member_roles.size());
if (lua_pcall(L,4,6,0)) {
fprintf(stderr, "Failed to execute lua function for relation tag processing: %s\n", lua_tostring(L, -1));
/* lua function failed */
return 1;
}
*roads = lua_tointeger(L, -1);
lua_pop(L,1);
*make_polygon = lua_tointeger(L, -1);
lua_pop(L,1);
*make_boundary = lua_tointeger(L,-1);
lua_pop(L,1);
lua_pushnil(L);
for (size_t i = 0; i < member_tags.size(); i++) {
if (lua_next(L,-2)) {
member_superseeded[i] = lua_tointeger(L,-1);
lua_pop(L,1);
} else {
fprintf(stderr, "Failed to read member_superseeded from lua function\n");
}
}
lua_pop(L,2);
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.push_back(tag(key, value));
lua_pop(L,1);
}
lua_pop(L,1);
int filter = lua_tointeger(L, -1);
lua_pop(L,1);
return filter;
}