Skip to content

Commit 5caa410

Browse files
authored
Merge pull request #1139 from joto/fix-line-relations
Bugfix: Adding relations to "linestring" tables works now
2 parents 30e154b + 4073816 commit 5caa410

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/flex-table.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,35 @@ class flex_table_t
100100
/// Does this table take objects of the specified type?
101101
bool matches_type(osmium::item_type type) const noexcept
102102
{
103+
// This table takes any type -> okay
103104
if (m_id_type == osmium::item_type::undefined) {
104105
return true;
105106
}
107+
108+
// Type and table type match -> okay
106109
if (type == m_id_type) {
107110
return true;
108111
}
112+
113+
// Relations can be written as linestrings into way tables -> okay
114+
if (type == osmium::item_type::relation &&
115+
m_id_type == osmium::item_type::way) {
116+
return true;
117+
}
118+
119+
// Area tables can take ways or relations, but not nodes
109120
return m_id_type == osmium::item_type::area &&
110121
type != osmium::item_type::node;
111122
}
112123

113124
/// Map way/node/relation ID to id value used in database table column
114125
osmid_t map_id(osmium::item_type type, osmid_t id) const noexcept
115126
{
116-
if (m_id_type == osmium::item_type::area &&
127+
if (m_id_type == osmium::item_type::undefined) {
128+
return id;
129+
}
130+
131+
if (m_id_type != osmium::item_type::relation &&
117132
type == osmium::item_type::relation) {
118133
return -id;
119134
}

0 commit comments

Comments
 (0)