Skip to content

Commit 80a31ce

Browse files
committed
Process untagged ways/relations in stage 1c/2 correctly
The change in bc87ea2 did not handle untagged ways/relations correctly in stages 1c and 2. The normal process_* Lua callback was called for untagged objects instead of the new process_untagged_* callback. This commit fixes that.
1 parent 19b5c0f commit 80a31ce

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

src/output-flex.cpp

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -835,17 +835,12 @@ void output_flex_t::get_mutex_and_call_lua_function(
835835

836836
void output_flex_t::pending_way(osmid_t id)
837837
{
838-
if (!m_process_way) {
839-
return;
840-
}
841-
842838
if (!m_way_cache.init(middle(), id)) {
843839
return;
844840
}
845841

846842
way_delete(id);
847-
848-
get_mutex_and_call_lua_function(m_process_way, m_way_cache.get());
843+
process_way();
849844
}
850845

851846
void output_flex_t::select_relation_members()
@@ -892,9 +887,33 @@ void output_flex_t::select_relation_members(osmid_t id)
892887
select_relation_members();
893888
}
894889

890+
void output_flex_t::process_way()
891+
{
892+
auto const &func = m_way_cache.get().tags().empty() ? m_process_untagged_way
893+
: m_process_way;
894+
if (!func) {
895+
return;
896+
}
897+
898+
get_mutex_and_call_lua_function(func, m_way_cache.get());
899+
}
900+
901+
void output_flex_t::process_relation()
902+
{
903+
auto const &func = m_relation_cache.get().tags().empty()
904+
? m_process_untagged_relation
905+
: m_process_relation;
906+
if (!func) {
907+
return;
908+
}
909+
910+
get_mutex_and_call_lua_function(func, m_relation_cache.get());
911+
}
912+
895913
void output_flex_t::pending_relation(osmid_t id)
896914
{
897-
if (!m_process_relation && !m_select_relation_members) {
915+
if (!m_process_relation && !m_process_untagged_relation &&
916+
!m_select_relation_members) {
898917
return;
899918
}
900919

@@ -904,16 +923,12 @@ void output_flex_t::pending_relation(osmid_t id)
904923

905924
select_relation_members();
906925
delete_from_tables(osmium::item_type::relation, id);
907-
908-
if (m_process_relation) {
909-
get_mutex_and_call_lua_function(m_process_relation,
910-
m_relation_cache.get());
911-
}
926+
process_relation();
912927
}
913928

914929
void output_flex_t::pending_relation_stage1c(osmid_t id)
915930
{
916-
if (!m_process_relation) {
931+
if (!m_process_relation && !m_process_untagged_relation) {
917932
return;
918933
}
919934

@@ -922,7 +937,7 @@ void output_flex_t::pending_relation_stage1c(osmid_t id)
922937
}
923938

924939
m_disable_insert = true;
925-
get_mutex_and_call_lua_function(m_process_relation, m_relation_cache.get());
940+
process_relation();
926941
m_disable_insert = false;
927942
}
928943

@@ -1459,9 +1474,7 @@ void output_flex_t::reprocess_marked()
14591474
continue;
14601475
}
14611476
way_delete(id);
1462-
if (m_process_way) {
1463-
get_mutex_and_call_lua_function(m_process_way, m_way_cache.get());
1464-
}
1477+
process_way();
14651478
}
14661479

14671480
// We don't need these any more so can free the memory.

src/output-flex.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ class output_flex_t : public output_t
196196
void get_mutex_and_call_lua_function(prepared_lua_function_t func,
197197
osmium::OSMObject const &object);
198198

199+
void process_way();
200+
void process_relation();
201+
199202
void init_lua(std::string const &filename, properties_t const &properties);
200203

201204
void check_context_and_state(char const *name, char const *context,

0 commit comments

Comments
 (0)