2323#include " geom-transform.hpp"
2424#include " logging.hpp"
2525#include " lua-init.hpp"
26+ #include " lua-setup.hpp"
2627#include " lua-utils.hpp"
2728#include " middle.hpp"
2829#include " options.hpp"
@@ -44,8 +45,6 @@ extern "C"
4445#include < lualib.h>
4546}
4647
47- #include < boost/filesystem.hpp>
48-
4948#include < cassert>
5049#include < cstdlib>
5150#include < cstring>
@@ -1439,32 +1438,16 @@ void output_flex_t::init_lua(std::string const &filename)
14391438 m_lua_state.reset (luaL_newstate (),
14401439 [](lua_State *state) { lua_close (state); });
14411440
1442- // Set up global lua libs
1443- luaL_openlibs (lua_state ());
1444-
1445- // Set up global "osm2pgsql" object
1446- lua_newtable (lua_state ());
1441+ setup_lua_environment (lua_state (), filename, get_options ()->append );
14471442
1448- luaX_add_table_str (lua_state (), " version" , get_osm2pgsql_short_version ());
1449- luaX_add_table_str (lua_state (), " mode" ,
1450- get_options ()->append ? " append" : " create" );
14511443 luaX_add_table_int (lua_state (), " stage" , 1 );
14521444
1453- std::string dir_path =
1454- boost::filesystem::path{filename}.parent_path ().string ();
1455- if (!dir_path.empty ()) {
1456- dir_path += boost::filesystem::path::preferred_separator;
1457- }
1458- luaX_add_table_str (lua_state (), " config_dir" , dir_path.c_str ());
1459-
14601445 luaX_add_table_func (lua_state (), " define_table" ,
14611446 lua_trampoline_app_define_table);
14621447
14631448 luaX_add_table_func (lua_state (), " define_expire_output" ,
14641449 lua_trampoline_app_define_expire_output);
14651450
1466- lua_setglobal (lua_state (), " osm2pgsql" );
1467-
14681451 init_table_class (lua_state ());
14691452 init_expire_output_class (lua_state ());
14701453
0 commit comments