本文整理汇总了C++中taglist_t类的典型用法代码示例。如果您正苦于以下问题:C++ taglist_t类的具体用法?C++ taglist_t怎么用?C++ taglist_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了taglist_t类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ways_set
void middle_pgsql_t::ways_set(osmid_t way_id, const idlist_t &nds, const taglist_t &tags)
{
copy_buffer.reserve(nds.size() * 10 + tags.size() * 24 + 64);
bool copy = way_table->copyMode;
char delim = copy ? '\t' : '\0';
// Three params: id, nodes, tags */
const char *paramValues[4] = { copy_buffer.c_str(), };
copy_buffer = std::to_string(way_id);
copy_buffer += delim;
paramValues[1] = paramValues[0] + copy_buffer.size();
buffer_store_nodes(nds);
copy_buffer += delim;
if (tags.size() == 0) {
paramValues[2] = nullptr;
copy_buffer += "\\N";
} else {
paramValues[2] = paramValues[0] + copy_buffer.size();
buffer_store_tags(tags, copy);
}
if (copy) {
copy_buffer += '\n';
pgsql_CopyData(__FUNCTION__, way_table->sql_conn, copy_buffer);
} else {
buffer_correct_params(paramValues, 3);
pgsql_execPrepared(way_table->sql_conn, "insert_way", 3,
(const char * const *)paramValues, PGRES_COMMAND_OK);
}
}
开发者ID:math1985,项目名称:osm2pgsql,代码行数:32,代码来源:middle-pgsql.cpp
示例2: local_nodes_set
void middle_pgsql_t::local_nodes_set(osmid_t id, double lat, double lon,
const taglist_t &tags)
{
copy_buffer.reserve(tags.size() * 24 + 64);
bool copy = node_table->copyMode;
char delim = copy ? '\t' : '\0';
const char *paramValues[4] = { copy_buffer.c_str(), };
copy_buffer = std::to_string(id);
copy_buffer += delim;
#ifdef FIXED_POINT
ramNode n(lon, lat);
paramValues[1] = paramValues[0] + copy_buffer.size();
copy_buffer += std::to_string(n.int_lat());
copy_buffer += delim;
paramValues[2] = paramValues[0] + copy_buffer.size();
copy_buffer += std::to_string(n.int_lon());
copy_buffer += delim;
#else
paramValues[1] = paramValues[0] + copy_buffer.size();
copy_buffer += std::to_string(lat);
copy_buffer += delim;
paramValues[2] = paramValues[0] + copy_buffer.size();
copy_buffer += std::to_string(lon);
copy_buffer += delim;
#endif
if (tags.size() == 0) {
paramValues[3] = nullptr;
copy_buffer += "\\N";
} else {
paramValues[3] = paramValues[0] + copy_buffer.size();
buffer_store_tags(tags, copy);
}
if (copy) {
copy_buffer += '\n';
pgsql_CopyData(__FUNCTION__, node_table->sql_conn, copy_buffer);
} else {
buffer_correct_params(paramValues, 4);
pgsql_execPrepared(node_table->sql_conn, "insert_node", 4,
(const char * const *)paramValues, PGRES_COMMAND_OK);
}
}
开发者ID:math1985,项目名称:osm2pgsql,代码行数:48,代码来源:middle-pgsql.cpp
示例3: write_tags_column
void table_t::write_tags_column(const taglist_t &tags, std::string& values,
const std::vector<bool> &used)
{
//iterate through the list of tags, first one is always null
bool added = false;
for (size_t i = 0; i < tags.size(); ++i)
{
const tag_t& xtag = tags[i];
//skip z_order tag and keys which have their own column
if (used[i] || ("z_order" == xtag.key))
continue;
//hstore ASCII representation looks like "key"=>"value"
if(added)
values.push_back(',');
escape4hstore(xtag.key.c_str(), values);
values.append("=>");
escape4hstore(xtag.value.c_str(), values);
//we did at least one so we need commas from here on out
added = true;
}
//finish the hstore column by placing a TAB into the data stream
values.push_back('\t');
}
开发者ID:hholzgra,项目名称:osm2pgsql,代码行数:26,代码来源:table.cpp
示例4: planet_osm
/*
COPY planet_osm (osm_id, name, place, landuse, leisure, "natural", man_made, waterway, highway, railway, amenity, tourism, learning, bu
ilding, bridge, layer, way) FROM stdin;
198497 Bedford Road \N \N \N \N \N \N residential \N \N \N \N \N \N \N 0102000020E610000004000000452BF702B342D5BF1C60E63BF8DF49406B9C4D470037D5BF5471E316F3DF4940DFA815A6EF35D5BF9AE95E27F5DF4940B41EB
E4C1421D5BF24D06053E7DF4940
212696 Oswald Road \N \N \N \N \N \N minor \N \N \N \N \N \N \N 0102000020E610000004000000467D923B6C22D5BFA359D93EE4DF4940B3976DA7AD11D5BF84BBB376DBDF4940997FF44D9A06D5BF4223D8B8FEDF49404D158C4AEA04D
5BF5BB39597FCDF4940
*/
int output_pgsql_t::pgsql_out_way(osmid_t id, taglist_t &outtags,
const nodelist_t &nodes,
int polygon, int roads)
{
/* Split long ways after around 1 degree or 100km */
double split_at;
if (m_options.projection->target_latlon())
split_at = 1;
else
split_at = 100 * 1000;
char tmp[32];
auto wkbs = builder.get_wkb_split(nodes, polygon, split_at);
for (const auto& wkb: wkbs) {
/* FIXME: there should be a better way to detect polygons */
if (wkb.is_polygon()) {
expire.from_nodes_poly(nodes, id);
if ((wkb.area > 0.0) && m_enable_way_area) {
snprintf(tmp, sizeof(tmp), "%g", wkb.area);
outtags.push_override(tag_t("way_area", tmp));
}
m_tables[t_poly]->write_row(id, outtags, wkb.geom);
} else {
expire.from_nodes_line(nodes);
m_tables[t_line]->write_row(id, outtags, wkb.geom);
if (roads)
m_tables[t_roads]->write_row(id, outtags, wkb.geom);
}
}
return 0;
}
开发者ID:abihf,项目名称:osm2pgsql,代码行数:40,代码来源:output-pgsql.cpp
示例5: planet_osm
/*
COPY planet_osm (osm_id, name, place, landuse, leisure, "natural", man_made, waterway, highway, railway, amenity, tourism, learning, bu
ilding, bridge, layer, way) FROM stdin;
198497 Bedford Road \N \N \N \N \N \N residential \N \N \N \N \N \N \N 0102000020E610000004000000452BF702B342D5BF1C60E63BF8DF49406B9C4D470037D5BF5471E316F3DF4940DFA815A6EF35D5BF9AE95E27F5DF4940B41EB
E4C1421D5BF24D06053E7DF4940
212696 Oswald Road \N \N \N \N \N \N minor \N \N \N \N \N \N \N 0102000020E610000004000000467D923B6C22D5BFA359D93EE4DF4940B3976DA7AD11D5BF84BBB376DBDF4940997FF44D9A06D5BF4223D8B8FEDF49404D158C4AEA04D
5BF5BB39597FCDF4940
*/
int output_pgsql_t::pgsql_out_way(osmid_t id, taglist_t &outtags,
const nodelist_t &nodes,
int polygon, int roads)
{
/* Split long ways after around 1 degree or 100km */
double split_at;
if (m_options.projection->get_proj_id() == PROJ_LATLONG)
split_at = 1;
else
split_at = 100 * 1000;
tag_t *areatag = 0;
auto wkbs = builder.get_wkb_split(nodes, polygon, split_at);
for (const auto& wkb: wkbs) {
/* FIXME: there should be a better way to detect polygons */
if (wkb.is_polygon()) {
expire->from_nodes_poly(nodes, id);
if ((wkb.area > 0.0) && m_enable_way_area) {
char tmp[32];
snprintf(tmp, sizeof(tmp), "%g", wkb.area);
if (!areatag) {
outtags.push_dedupe(tag_t("way_area", tmp));
areatag = outtags.find("way_area");
} else
areatag->value = tmp;
}
m_tables[t_poly]->write_row(id, outtags, wkb.geom);
} else {
expire->from_nodes_line(nodes);
m_tables[t_line]->write_row(id, outtags, wkb.geom);
if (roads)
m_tables[t_roads]->write_row(id, outtags, wkb.geom);
}
}
return 0;
}
开发者ID:AFDudley,项目名称:osm2pgsql,代码行数:45,代码来源:output-pgsql.cpp
示例6: 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');
}
}
开发者ID:hholzgra,项目名称:osm2pgsql,代码行数:38,代码来源:table.cpp
示例7: relation_add
int output_pgsql_t::relation_add(osmid_t id, const memberlist_t &members, const taglist_t &tags)
{
const std::string *type = tags.get("type");
/* Must have a type field or we ignore it */
if (!type)
return 0;
/* Only a limited subset of type= is supported, ignore other */
if ( (*type != "route") && (*type != "multipolygon") && (*type != "boundary"))
return 0;
return pgsql_process_relation(id, members, tags, 0);
}
开发者ID:AFDudley,项目名称:osm2pgsql,代码行数:15,代码来源:output-pgsql.cpp
示例8: write_row
void table_t::write_row(const osmid_t id, const taglist_t &tags, const std::string &geom)
{
//add the osm id
buffer.append((single_fmt % id).str());
buffer.push_back('\t');
// used to remember which columns have been written out already.
std::vector<bool> used;
if (hstore_mode != HSTORE_NONE)
used.assign(tags.size(), false);
//get the regular columns' values
write_columns(tags, buffer, hstore_mode == HSTORE_NORM?&used:nullptr);
//get the hstore columns' values
write_hstore_columns(tags, buffer);
//get the key value pairs for the tags column
if (hstore_mode != HSTORE_NONE)
write_tags_column(tags, buffer, used);
//give the geometry an srid
buffer.append("SRID=");
buffer.append(srid);
buffer.push_back(';');
//add the geometry
buffer.append(geom);
//we need \n because we are copying from stdin
buffer.push_back('\n');
//tell the db we are copying if for some reason we arent already
if (!copyMode)
{
pgsql_exec_simple(sql_conn, PGRES_COPY_IN, copystr);
copyMode = true;
}
//send all the data to postgres
if(buffer.length() > BUFFER_SEND_SIZE)
{
pgsql_CopyData(name.c_str(), sql_conn, buffer);
buffer.clear();
}
}
开发者ID:hholzgra,项目名称:osm2pgsql,代码行数:45,代码来源:table.cpp
示例9: write_columns
void table_t::write_columns(const taglist_t &tags, string& values, std::vector<bool> *used)
{
//for each column
for(columns_t::const_iterator column = columns.begin(); column != columns.end(); ++column)
{
int idx;
if ((idx = tags.indexof(column->first)) >= 0)
{
escape_type(tags[idx].value, column->second, values);
//remember we already used this one so we cant use again later in the hstore column
if (used)
(*used)[idx] = true;
}
else
values.append("\\N");
values.push_back('\t');
}
}
开发者ID:hholzgra,项目名称:osm2pgsql,代码行数:18,代码来源:table.cpp
示例10: 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 (const auto& item: tags) {
if (boost::ends_with(item.key, "source")) {
// ignore
} else if (item.key == "name:prefix" ||
item.key == "name:botanical" ||
boost::ends_with(item.key, "wikidata")) {
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 == "footway") {
auto *footway = tags.get("footway");
if (footway == nullptr || *footway != "sidewalk")
places.push_back(item);
} else 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" &&
//.........这里部分代码省略.........
开发者ID:JesseCrocker,项目名称:osm2pgsql,代码行数:101,代码来源:output-gazetteer.cpp
示例11: delete_unused_full
int output_gazetteer_t::process_relation(osmid_t id, const memberlist_t &members,
const taglist_t &tags)
{
const std::string *type = tags.get("type");
if (!type) {
delete_unused_full('R', id);
return 0;
}
int cmp_waterway = type->compare("waterway");
if (*type == "associatedStreet"
|| !(*type == "boundary" || *type == "multipolygon" || !cmp_waterway)) {
delete_unused_full('R', id);
return 0;
}
places.process_tags(tags);
if (m_options.append)
delete_unused_classes('R', id);
/* Are we interested in this item? */
if (!places.has_data())
return 0;
/* get the boundary path (ways) */
idlist_t xid2;
for (const auto& member: members) {
/* only interested in ways */
if (member.type == OSMTYPE_WAY)
xid2.push_back(member.id);
}
if (xid2.empty()) {
if (m_options.append)
delete_unused_full('R', id);
return 0;
}
multitaglist_t xtags;
multinodelist_t xnodes;
idlist_t xid;
m_mid->ways_get_list(xid2, xid, xtags, xnodes);
if (cmp_waterway) {
auto geoms = builder.build_both(xnodes, 1, 1, 1000000, id);
for (const auto& geom: geoms) {
if (geom.is_polygon()) {
places.copy_out('R', id, geom.geom, buffer);
flush_place_buffer();
} else {
/* add_polygon_error('R', id, "boundary", "adminitrative", &names, countrycode, wkt); */
}
}
} else {
/* waterways result in multilinestrings */
auto geom = builder.build_multilines(xnodes, id);
if (geom.valid()) {
places.copy_out('R', id, geom.geom, buffer);
flush_place_buffer();
}
}
return 0;
}
开发者ID:JesseCrocker,项目名称:osm2pgsql,代码行数:67,代码来源:output-gazetteer.cpp
示例12: relations_set
void middle_pgsql_t::relations_set(osmid_t id, const memberlist_t &members, const taglist_t &tags)
{
taglist_t member_list;
char buf[64];
idlist_t all_parts, node_parts, way_parts, rel_parts;
all_parts.reserve(members.size());
node_parts.reserve(members.size());
way_parts.reserve(members.size());
rel_parts.reserve(members.size());
for (memberlist_t::const_iterator it = members.begin(); it != members.end(); ++it) {
char type = 0;
switch (it->type)
{
case OSMTYPE_NODE: node_parts.push_back(it->id); type = 'n'; break;
case OSMTYPE_WAY: way_parts.push_back(it->id); type = 'w'; break;
case OSMTYPE_RELATION: rel_parts.push_back(it->id); type = 'r'; break;
default:
fprintf(stderr, "Internal error: Unknown member type %d\n", it->type);
util::exit_nicely();
}
sprintf( buf, "%c%" PRIdOSMID, type, it->id );
member_list.push_back(tag_t(buf, it->role));
}
all_parts.insert(all_parts.end(), node_parts.begin(), node_parts.end());
all_parts.insert(all_parts.end(), way_parts.begin(), way_parts.end());
all_parts.insert(all_parts.end(), rel_parts.begin(), rel_parts.end());
copy_buffer.reserve(all_parts.size() * 10 + member_list.size() * 24
+ tags.size() * 24 + 64);
// Params: id, way_off, rel_off, parts, members, tags */
const char *paramValues[6] = { copy_buffer.c_str(), };
bool copy = rel_table->copyMode;
char delim = copy ? '\t' : '\0';
copy_buffer = std::to_string(id);
copy_buffer+= delim;
paramValues[1] = paramValues[0] + copy_buffer.size();
copy_buffer += std::to_string(node_parts.size());
copy_buffer+= delim;
paramValues[2] = paramValues[0] + copy_buffer.size();
copy_buffer += std::to_string(node_parts.size() + way_parts.size());
copy_buffer+= delim;
paramValues[3] = paramValues[0] + copy_buffer.size();
buffer_store_nodes(all_parts);
copy_buffer+= delim;
if (member_list.size() == 0) {
paramValues[4] = nullptr;
copy_buffer += "\\N";
} else {
paramValues[4] = paramValues[0] + copy_buffer.size();
buffer_store_tags(member_list, copy);
}
copy_buffer+= delim;
if (tags.size() == 0) {
paramValues[5] = nullptr;
copy_buffer += "\\N";
} else {
paramValues[5] = paramValues[0] + copy_buffer.size();
buffer_store_tags(tags, copy);
}
if (copy) {
copy_buffer+= '\n';
pgsql_CopyData(__FUNCTION__, rel_table->sql_conn, copy_buffer);
} else {
buffer_correct_params(paramValues, 6);
pgsql_execPrepared(rel_table->sql_conn, "insert_rel", 6,
(const char * const *)paramValues, PGRES_COMMAND_OK);
}
}
开发者ID:math1985,项目名称:osm2pgsql,代码行数:79,代码来源:middle-pgsql.cpp
示例13: filter_rel_member_tags
unsigned lua_tagtransform_t::filter_rel_member_tags(
taglist_t const &rel_tags, multitaglist_t const &members_tags,
rolelist_t const &member_roles, int *member_superseded, int *make_boundary,
int *make_polygon, int *roads, export_list const &, taglist_t &out_tags,
bool)
{
lua_getglobal(L, m_rel_mem_func.c_str());
lua_newtable(L); /* relations key value table */
for (const auto &rel_tag : rel_tags) {
lua_pushstring(L, rel_tag.key.c_str());
lua_pushstring(L, rel_tag.value.c_str());
lua_rawset(L, -3);
}
lua_newtable(L); /* member tags table */
int idx = 1;
for (const auto &member_tags : members_tags) {
lua_pushnumber(L, idx++);
lua_newtable(L); /* member key value table */
for (const auto &member_tag : member_tags) {
lua_pushstring(L, member_tag.key.c_str());
lua_pushstring(L, member_tag.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]);
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 = (int)lua_tointeger(L, -1);
lua_pop(L, 1);
*make_polygon = (int)lua_tointeger(L, -1);
lua_pop(L, 1);
*make_boundary = (int)lua_tointeger(L, -1);
lua_pop(L, 1);
lua_pushnil(L);
for (size_t i = 0; i < members_tags.size(); i++) {
if (lua_next(L, -2)) {
member_superseded[i] = (int)lua_tointeger(L, -1);
lua_pop(L, 1);
} else {
fprintf(stderr,
"Failed to read member_superseded 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_t(key, value));
lua_pop(L, 1);
}
lua_pop(L, 1);
unsigned filter = (unsigned)lua_tointeger(L, -1);
lua_pop(L, 1);
return filter;
}
开发者ID:alex85k,项目名称:osm2pgsql,代码行数:83,代码来源:tagtransform-lua.cpp
示例14: switch
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;
}
开发者ID:alex85k,项目名称:osm2pgsql,代码行数:73,代码来源:tagtransform-lua.cpp
示例15: delete_unused_full
int output_gazetteer_t::process_relation(osmid_t id, const memberlist_t &members,
const taglist_t &tags)
{
const std::string *type = tags.get("type");
if (!type) {
delete_unused_full('R', id);
return 0;
}
int cmp_waterway = type->compare("waterway");
if (*type == "associatedStreet"
|| !(*type == "boundary" || *type == "multipolygon" || !cmp_waterway)) {
delete_unused_full('R', id);
return 0;
}
places.process_tags(tags);
if (m_options.append)
delete_unused_classes('R', id);
/* Are we interested in this item? */
if (!places.has_data())
return 0;
/* get the boundary path (ways) */
idlist_t xid2;
for (memberlist_t::const_iterator it = members.begin(); it != members.end(); ++it) {
/* only interested in ways */
if (it->type == OSMTYPE_WAY)
xid2.push_back(it->id);
}
if (xid2.empty()) {
if (m_options.append)
delete_unused_full('R', id);
return 0;
}
multitaglist_t xtags;
multinodelist_t xnodes;
idlist_t xid;
m_mid->ways_get_list(xid2, xid, xtags, xnodes);
if (cmp_waterway) {
geometry_builder::maybe_wkts_t wkts = builder.build_both(xnodes, 1, 1, 1000000, id);
for (const auto& wkt: *wkts) {
if (boost::starts_with(wkt.geom, "POLYGON")
|| boost::starts_with(wkt.geom, "MULTIPOLYGON")) {
places.copy_out('R', id, wkt.geom, buffer);
flush_place_buffer();
} else {
/* add_polygon_error('R', id, "boundary", "adminitrative", &names, countrycode, wkt); */
}
}
} else {
/* waterways result in multilinestrings */
geometry_builder::maybe_wkt_t wkt = builder.build_multilines(xnodes, id);
if ((wkt->geom).length() > 0) {
places.copy_out('R', id, wkt->geom, buffer);
flush_place_buffer();
}
}
return 0;
}
开发者ID:MapQuest,项目名称:osm2pgsql,代码行数:68,代码来源:output-gazetteer.cpp
示例16: lua_getglobal
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;
}
开发者ID:beemogmbh,项目名称:osm2pgsql,代码行数:79,代码来源:tagtransform.cpp
示例17: switch
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
}
开发者ID:beemogmbh,项目名称:osm2pgsql,代码行数:61,代码来源:tagtransform.cpp
示例18: 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"));
//.........这里部分代码省略.........
开发者ID:beemogmbh,项目名称:osm2pgsql,代码行数:101,代码来源:tagtransform.cpp
注:本文中的taglist_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论