Skip to content

Commit 0f9110b

Browse files
committed
Process untagged ways/relations in stage 1b/c correctly
When we introduced the "untagged" callbacks in bc87ea2, we did not call the process_untagged_way/relation callbacks for untagged ways/relations in stage 1b and 1c, but called the normal process_way/relation callbacks. That's not correct. So this is changed in this commit. For stage2 processing the answer which callback to call is a bit more complicated: On first glance we should also call the "untagged" function for untagged objects. But if we call the "untagged" function in that case, we would have to implement that function and it would be called for the millions of untagged objects we are not interested in. So it is arguably better to call the normal processing functions here. After all we explicitly requested the processing function to be called with the select_relation_members() call. So we are keeping this behaviour.
1 parent 19b5c0f commit 0f9110b

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

src/output-flex.cpp

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ 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) {
838+
if (!m_process_way && !m_process_untagged_way) {
839839
return;
840840
}
841841

@@ -844,8 +844,13 @@ void output_flex_t::pending_way(osmid_t id)
844844
}
845845

846846
way_delete(id);
847+
auto const &func = m_way_cache.get().tags().empty() ? m_process_untagged_way
848+
: m_process_way;
849+
if (!func) {
850+
return;
851+
}
847852

848-
get_mutex_and_call_lua_function(m_process_way, m_way_cache.get());
853+
get_mutex_and_call_lua_function(func, m_way_cache.get());
849854
}
850855

851856
void output_flex_t::select_relation_members()
@@ -892,9 +897,22 @@ void output_flex_t::select_relation_members(osmid_t id)
892897
select_relation_members();
893898
}
894899

900+
void output_flex_t::process_relation()
901+
{
902+
auto const &func = m_relation_cache.get().tags().empty()
903+
? m_process_untagged_relation
904+
: m_process_relation;
905+
if (!func) {
906+
return;
907+
}
908+
909+
get_mutex_and_call_lua_function(func, m_relation_cache.get());
910+
}
911+
895912
void output_flex_t::pending_relation(osmid_t id)
896913
{
897-
if (!m_process_relation && !m_select_relation_members) {
914+
if (!m_process_relation && !m_process_untagged_relation &&
915+
!m_select_relation_members) {
898916
return;
899917
}
900918

@@ -904,16 +922,12 @@ void output_flex_t::pending_relation(osmid_t id)
904922

905923
select_relation_members();
906924
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-
}
925+
process_relation();
912926
}
913927

914928
void output_flex_t::pending_relation_stage1c(osmid_t id)
915929
{
916-
if (!m_process_relation) {
930+
if (!m_process_relation && !m_process_untagged_relation) {
917931
return;
918932
}
919933

@@ -922,7 +936,7 @@ void output_flex_t::pending_relation_stage1c(osmid_t id)
922936
}
923937

924938
m_disable_insert = true;
925-
get_mutex_and_call_lua_function(m_process_relation, m_relation_cache.get());
939+
process_relation();
926940
m_disable_insert = false;
927941
}
928942

src/output-flex.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ 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_relation();
200+
199201
void init_lua(std::string const &filename, properties_t const &properties);
200202

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

0 commit comments

Comments
 (0)