GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — osm2pgsql/src/flex-lua-expire-output.cpp at master · osm2pgsql-dev/osm2pgsql Expand file tree/ Copy pathflex-lua-expire-output.cppMore file actions 192 lines (163 loc) · 6.25 KB / Copy pathflex-lua-expire-output.cppFile metadata and controls192 lines (163 loc) · 6.25 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 /** * SPDX-License-Identifier: GPL-2.0-or-later * * This file is part of osm2pgsql (https://osm2pgsql.org/). * * Copyright (C) 2006-2026 by the osm2pgsql developer community. * For a full list of authors see the git log. */ #include "flex-lua-expire-output.hpp" #include "expire-output.hpp" #include "format.hpp" #include "lua-utils.hpp" #include <lua.hpp> namespace { expire_output_t & create_expire_output(lua_State *lua_state, std::string const &default_schema, std::vector<expire_output_t> *expire_outputs) { auto &new_expire_output = expire_outputs->emplace_back(); // optional "filename" field auto const *filename = luaX_get_table_string(lua_state, "filename", -1, "The expire output", ""); new_expire_output.set_filename(filename); lua_pop(lua_state, 1); // "filename" // optional "schema" and "table" fields auto const *schema = luaX_get_table_string( lua_state, "schema", -1, "The expire output", default_schema.c_str()); check_identifier(schema, "schema field"); auto const *table = luaX_get_table_string(lua_state, "table", -2, "The expire output", ""); check_identifier(table, "table field"); new_expire_output.set_schema_and_table(schema, table); lua_pop(lua_state, 2); // "schema" and "table" if (new_expire_output.filename().empty() && new_expire_output.table().empty()) { throw std::runtime_error{ "Must set 'filename' and/or 'table' on expire output."}; } // required "maxzoom" field auto const maxzoom = luaX_get_table_optional_uint32( lua_state, "maxzoom", -1, "The 'maxzoom' field in a expire output", 1, 20, "1 and 20"); new_expire_output.set_minzoom(maxzoom); new_expire_output.set_maxzoom(maxzoom); lua_pop(lua_state, 1); // "maxzoom" // optional "minzoom" field auto const minzoom = luaX_get_table_optional_uint32( lua_state, "minzoom", -1, "The 'minzoom' field in a expire output", 1, maxzoom, "1 and 'maxzoom'"); if (minzoom > 0) { new_expire_output.set_minzoom(minzoom); } lua_pop(lua_state, 1); // "minzoom" // optional "max_tiles_geometry" field auto const max_tiles_geometry = luaX_get_table_optional_uint64( lua_state, "max_tiles_geometry", -1, "The 'max_tiles_geometry' field in a expire output", 1, (4ULL << 20ULL), "1 and 4 << 20"); if (max_tiles_geometry > 0) { new_expire_output.set_max_tiles_geometry(max_tiles_geometry); } lua_pop(lua_state, 1); // "max_tiles_geometry" // optional "max_tiles_overall" field auto const max_tiles_overall = luaX_get_table_optional_uint64( lua_state, "max_tiles_overall", -1, "The 'max_tiles_overall' field in a expire output", 1, (4ULL << 20ULL), "1 and 4 << 20"); if (max_tiles_overall > 0) { new_expire_output.set_max_tiles_overall(max_tiles_overall); } lua_pop(lua_state, 1); // "max_tiles_overall" return new_expire_output; } TRAMPOLINE_WRAPPED_OBJECT(expire_output, tostring) TRAMPOLINE_WRAPPED_OBJECT(expire_output, filename) TRAMPOLINE_WRAPPED_OBJECT(expire_output, maxzoom) TRAMPOLINE_WRAPPED_OBJECT(expire_output, minzoom) TRAMPOLINE_WRAPPED_OBJECT(expire_output, schema) TRAMPOLINE_WRAPPED_OBJECT(expire_output, table) TRAMPOLINE_WRAPPED_OBJECT(expire_output, max_tiles_geometry) TRAMPOLINE_WRAPPED_OBJECT(expire_output, max_tiles_overall) } // anonymous namespace int setup_flex_expire_output(lua_State *lua_state, std::string const &default_schema, std::vector<expire_output_t> *expire_outputs) { if (lua_type(lua_state, 1) != LUA_TTABLE) { throw std::runtime_error{ "Argument #1 to 'define_expire_output' must be a Lua table."}; } create_expire_output(lua_state, default_schema, expire_outputs); void *ptr = lua_newuserdata(lua_state, sizeof(std::size_t)); auto *num = new (ptr) std::size_t{}; *num = expire_outputs->size() - 1; luaL_getmetatable(lua_state, OSM2PGSQL_EXPIRE_OUTPUT_CLASS); lua_setmetatable(lua_state, -2); return 1; } /** * Define the osm2pgsql.ExpireOutput class/metatable. */ void lua_wrapper_expire_output_t::init(lua_State *lua_state) { luaX_set_up_metatable( lua_state, "ExpireOutput", OSM2PGSQL_EXPIRE_OUTPUT_CLASS, {{"__tostring", lua_trampoline_expire_output_tostring}, {"filename", lua_trampoline_expire_output_filename}, {"maxzoom", lua_trampoline_expire_output_maxzoom}, {"minzoom", lua_trampoline_expire_output_minzoom}, {"schema", lua_trampoline_expire_output_schema}, {"table", lua_trampoline_expire_output_table}, {"max_tiles_geometry", lua_trampoline_expire_output_max_tiles_geometry}, {"max_tiles_overall", lua_trampoline_expire_output_max_tiles_overall}}); } int lua_wrapper_expire_output_t::tostring() const { std::string const str = fmt::format("osm2pgsql.ExpireOutput[minzoom={},maxzoom={},filename={}," "schema={},table={}]", self().minzoom(), self().maxzoom(), self().filename(), self().schema(), self().table()); luaX_pushstring(lua_state(), str); return 1; } int lua_wrapper_expire_output_t::filename() const noexcept { luaX_pushstring(lua_state(), self().filename()); return 1; } int lua_wrapper_expire_output_t::maxzoom() const noexcept { lua_pushinteger(lua_state(), self().maxzoom()); return 1; } int lua_wrapper_expire_output_t::minzoom() const noexcept { lua_pushinteger(lua_state(), self().minzoom()); return 1; } int lua_wrapper_expire_output_t::schema() const noexcept { luaX_pushstring(lua_state(), self().schema()); return 1; } int lua_wrapper_expire_output_t::table() const noexcept { luaX_pushstring(lua_state(), self().table()); return 1; } int lua_wrapper_expire_output_t::max_tiles_geometry() const noexcept { lua_pushinteger(lua_state(), static_cast<lua_Integer>(self().max_tiles_geometry())); return 1; } int lua_wrapper_expire_output_t::max_tiles_overall() const noexcept { lua_pushinteger(lua_state(), static_cast<lua_Integer>(self().max_tiles_overall())); return 1; } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |