@@ -99,6 +99,19 @@ static flex_table_t &create_flex_table(lua_State *lua_state,
9999 return new_table;
100100}
101101
102+ static void parse_create_index (lua_State *lua_state, flex_table_t *table)
103+ {
104+ std::string const create_index = luaX_get_table_string (
105+ lua_state, " create_index" , -1 , " The ids field" , " auto" );
106+ lua_pop (lua_state, 1 ); // "create_index"
107+ if (create_index == " always" ) {
108+ table->set_always_build_id_index ();
109+ } else if (create_index != " auto" ) {
110+ throw fmt_error (" Unknown value '{}' for 'create_index' field of ids" ,
111+ create_index);
112+ }
113+ }
114+
102115static void setup_flex_table_id_columns (lua_State *lua_state,
103116 flex_table_t *table)
104117{
@@ -119,15 +132,15 @@ static void setup_flex_table_id_columns(lua_State *lua_state,
119132 lua_pop (lua_state, 1 ); // "type"
120133
121134 if (type == " node" ) {
122- table->set_id_type (osmium::item_type ::node);
135+ table->set_id_type (flex_table_index_type ::node);
123136 } else if (type == " way" ) {
124- table->set_id_type (osmium::item_type ::way);
137+ table->set_id_type (flex_table_index_type ::way);
125138 } else if (type == " relation" ) {
126- table->set_id_type (osmium::item_type ::relation);
139+ table->set_id_type (flex_table_index_type ::relation);
127140 } else if (type == " area" ) {
128- table->set_id_type (osmium::item_type ::area);
141+ table->set_id_type (flex_table_index_type ::area);
129142 } else if (type == " any" ) {
130- table->set_id_type (osmium::item_type::undefined );
143+ table->set_id_type (flex_table_index_type::any_object );
131144 lua_getfield (lua_state, -1 , " type_column" );
132145 if (lua_isstring (lua_state, -1 )) {
133146 std::string const column_name =
@@ -139,6 +152,13 @@ static void setup_flex_table_id_columns(lua_State *lua_state,
139152 throw std::runtime_error{" type_column must be a string or nil." };
140153 }
141154 lua_pop (lua_state, 1 ); // "type_column"
155+ } else if (type == " tile" ) {
156+ table->set_id_type (flex_table_index_type::tile);
157+ parse_create_index (lua_state, table);
158+ table->add_column (" x" , " int" , " int" ).set_not_null ();
159+ table->add_column (" y" , " int" , " int" ).set_not_null ();
160+ lua_pop (lua_state, 1 ); // "ids"
161+ return ;
142162 } else {
143163 throw fmt_error (" Unknown ids type: {}." , type);
144164 }
@@ -148,15 +168,7 @@ static void setup_flex_table_id_columns(lua_State *lua_state,
148168 lua_pop (lua_state, 1 ); // "id_column"
149169 check_identifier (name, " column names" );
150170
151- std::string const create_index = luaX_get_table_string (
152- lua_state, " create_index" , -1 , " The ids field" , " auto" );
153- lua_pop (lua_state, 1 ); // "create_index"
154- if (create_index == " always" ) {
155- table->set_always_build_id_index ();
156- } else if (create_index != " auto" ) {
157- throw fmt_error (" Unknown value '{}' for 'create_index' field of ids" ,
158- create_index);
159- }
171+ parse_create_index (lua_state, table);
160172
161173 auto &column = table->add_column (name, " id_num" , " " );
162174 column.set_not_null ();
0 commit comments