Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/flex-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ bool flex_table_t::has_id_column() const noexcept

bool flex_table_t::matches_type(osmium::item_type type) const noexcept
{
// This table takes any type -> okay
if (m_id_type == flex_table_index_type::any_object) {
// This table takes any type or has no ids -> okay
if (m_id_type == flex_table_index_type::any_object ||
m_id_type == flex_table_index_type::no_index) {
return true;
}

Expand Down
57 changes: 57 additions & 0 deletions tests/bdd/flex/table-ids.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Feature: Test for correct id column generation

Background:
Given the 0.1 grid
| 1 | | 2 |
| 3 | | 4 |

Scenario: Data can be inserted into tables without an iD column
Given the lua style
"""
local simple = osm2pgsql.define_table{
name = 'simple',
columns = {{ column = 'id', type = 'bigint'}}
}

function osm2pgsql.process_node(object)
simple:insert{ id = object.id }
end

function osm2pgsql.process_way(object)
simple:insert{ id = object.id }
end

function osm2pgsql.process_relation(object)
simple:insert{ id = object.id }
end
"""
And the OSM data
"""
n1 Tp=1
n2 Tp=2
w10 Tp=10 Nn1,n2,n4
r100 Tp=100 Mn1@,n2@
"""
When running osm2pgsql flex with parameters
| --slim |
Then table simple contains
| id |
| 1 |
| 2 |
| 10 |
| 100 |
Given the OSM data
"""
n1 v2 dD
w11 Tp=11 Nn1,n3
"""
When running osm2pgsql flex with parameters
| --slim | -a |
Then table simple contains
| id |
| 1 |
| 2 |
| 10 |
| 11 |
| 100 |

2 changes: 1 addition & 1 deletion tests/bdd/steps/geometry_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def complete_node_list(self, nodes):
assert ' y' not in line

coords = self.grid_node(nid)
assert coords is not None, f"Coordinates missing for node {node}"
assert coords is not None, f"Coordinates missing for node {nid}"
nodes[i] = f"{line} x{coords[0]:.{self.grid_precision}f} y{coords[1]:.{self.grid_precision}f}"

todos.discard(nid)
Expand Down