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
6 changes: 3 additions & 3 deletions src/output-flex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ int output_flex_t::app_get_bbox()
osmium::Box bbox;

// Bounding boxes of all the member nodes
for (auto const &wnl :
m_relation_cache.members_buffer().select<osmium::WayNodeList>()) {
bbox.extend(wnl.envelope());
for (auto const &node :
m_relation_cache.members_buffer().select<osmium::Node>()) {
bbox.extend(node.location());
}

// Bounding boxes of all the member ways
Expand Down
36 changes: 35 additions & 1 deletion tests/bdd/flex/bbox.feature
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Feature: Test get_bbox() function
| 4326 | 20 10.1,20.1 10.1,20.1 10 |
| 3857 | 2226389.8 1130195.4,2237521.8 1130195.4,2237521.8 1118890.0 |

Scenario Outline: for relations
Scenario Outline: for relations with way members only
Given the 0.1 grid with origin 20.0 10.1
| 10 | 11 |
| | 12 |
Expand Down Expand Up @@ -124,3 +124,37 @@ Feature: Test get_bbox() function
| 4326 | 10, 11 | 10, 11, 12 |
| 3857 | 2226389.8 1130195.4,2237521.8 1130195.4 | 2226389.8 1130195.4,2237521.8 1130195.4,2237521.8 1118890.0 |

Scenario: for relations with node and way members
Given the 0.1 grid with origin 20.0 10.1
| 10 | 11 | |
| | 12 | 13 |
| 14 | | |
And the OSM data
"""
w20 v1 dV Nn10,n11
w21 v1 dV Nn11,n12
r30 v1 dV Ttype=route,route=bus Mw20@,w21@,n13@,n14@
"""
And the lua style
"""
local rels = osm2pgsql.define_relation_table('osm2pgsql_test_routes', {
{ column = 'min_x', type = 'real' },
{ column = 'min_y', type = 'real' },
{ column = 'max_x', type = 'real' },
{ column = 'max_y', type = 'real' },
{ column = 'geom', type = 'geometry', projection = 4326, not_null = true },
})

function osm2pgsql.process_relation(object)
local row = {}
row.min_x, row.min_y, row.max_x, row.max_y = object:get_bbox()
row.geom = object:as_geometrycollection()
rels:insert(row)
end
"""
When running osm2pgsql flex

Then table osm2pgsql_test_routes contains exactly
| relation_id | min_x | max_x | min_y | max_y |
| 30 | 20.0 | 20.2 | 9.9 | 10.1 |