@@ -334,6 +334,54 @@ void check_for_object(lua_State *lua_state, char const *const function_name)
334334 function_name);
335335}
336336
337+ /* *
338+ * Expects a Lua (hash) table on the stack, reads the field with name of the
339+ * 'type' parameter which must be either nil or a Lua (array) table, in which
340+ * case all (integer) ids in that table are reads into the 'ids' out
341+ * parameter.
342+ */
343+ void get_object_ids (lua_State *lua_state, char const *const type, idlist_t *ids)
344+ {
345+ lua_getfield (lua_state, -1 , type);
346+ int const ltype = lua_type (lua_state, -1 );
347+
348+ if (ltype == LUA_TNIL) {
349+ lua_pop (lua_state, 1 );
350+ return ;
351+ }
352+
353+ if (ltype != LUA_TTABLE) {
354+ lua_pop (lua_state, 1 );
355+ throw fmt_error (
356+ " Table returned from select_relation_members() contains '{}' "
357+ " field, but it isn't an array table." ,
358+ type);
359+ }
360+
361+ if (!luaX_is_array (lua_state)) {
362+ lua_pop (lua_state, 1 );
363+ throw fmt_error (
364+ " Table returned from select_relation_members() contains '{}' "
365+ " field, but it isn't an array table." ,
366+ type);
367+ }
368+
369+ luaX_for_each (lua_state, [&]() {
370+ osmid_t const id = lua_tointeger (lua_state, -1 );
371+ if (id == 0 ) {
372+ throw fmt_error (
373+ " Table returned from select_relation_members() contains "
374+ " '{}' field, which must contain an array of non-zero "
375+ " integer node ids." ,
376+ type);
377+ }
378+
379+ ids->push_back (id);
380+ });
381+
382+ lua_pop (lua_state, 1 );
383+ }
384+
337385} // anonymous namespace
338386
339387/* *
@@ -899,54 +947,6 @@ void output_flex_t::pending_way(osmid_t id)
899947 get_mutex_and_call_lua_function (m_process_way, m_way_cache.get ());
900948}
901949
902- /* *
903- * Expects a Lua (hash) table on the stack, reads the field with name of the
904- * 'type' parameter which must be either nil or a Lua (array) table, in which
905- * case all (integer) ids in that table are reads into the 'ids' out
906- * parameter.
907- */
908- void get_object_ids (lua_State *lua_state, char const *const type, idlist_t *ids)
909- {
910- lua_getfield (lua_state, -1 , type);
911- int const ltype = lua_type (lua_state, -1 );
912-
913- if (ltype == LUA_TNIL) {
914- lua_pop (lua_state, 1 );
915- return ;
916- }
917-
918- if (ltype != LUA_TTABLE) {
919- lua_pop (lua_state, 1 );
920- throw fmt_error (
921- " Table returned from select_relation_members() contains '{}' "
922- " field, but it isn't an array table." ,
923- type);
924- }
925-
926- if (!luaX_is_array (lua_state)) {
927- lua_pop (lua_state, 1 );
928- throw fmt_error (
929- " Table returned from select_relation_members() contains '{}' "
930- " field, but it isn't an array table." ,
931- type);
932- }
933-
934- luaX_for_each (lua_state, [&]() {
935- osmid_t const id = lua_tointeger (lua_state, -1 );
936- if (id == 0 ) {
937- throw fmt_error (
938- " Table returned from select_relation_members() contains "
939- " '{}' field, which must contain an array of non-zero "
940- " integer node ids." ,
941- type);
942- }
943-
944- ids->push_back (id);
945- });
946-
947- lua_pop (lua_state, 1 );
948- }
949-
950950void output_flex_t::select_relation_members ()
951951{
952952 if (!m_select_relation_members) {
0 commit comments