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; }