Skip to content

Commit 69f4849

Browse files
authored
Merge pull request #1721 from joto/fix-is-closed
way.is_closed() should only be called when there are way nodes
2 parents 4e1ce03 + 11dc797 commit 69f4849

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/output-flex.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ static void push_osm_object_to_lua_stack(lua_State *lua_state,
191191

192192
if (object.type() == osmium::item_type::way) {
193193
auto const &way = static_cast<osmium::Way const &>(object);
194-
luaX_add_table_bool(lua_state, "is_closed", way.is_closed());
194+
luaX_add_table_bool(lua_state, "is_closed",
195+
!way.nodes().empty() && way.is_closed());
195196
luaX_add_table_array(lua_state, "nodes", way.nodes(),
196197
[&](osmium::NodeRef const &wn) {
197198
lua_pushinteger(lua_state, wn.ref());

src/output-gazetteer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ bool output_gazetteer_t::process_way(osmium::Way *way)
137137

138138
// Get the geometry of the object.
139139
geom::geometry_t geom;
140-
if (way->is_closed()) {
140+
if (!way->nodes().empty() && way->is_closed()) {
141141
geom = geom::transform(geom::create_polygon(*way), *m_proj);
142142
}
143143
if (geom.is_null()) {

src/output-pgsql.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static double calculate_area(bool reproject_area,
6161
void output_pgsql_t::pgsql_out_way(osmium::Way const &way, taglist_t *tags,
6262
bool polygon, bool roads)
6363
{
64-
if (polygon && way.is_closed()) {
64+
if (polygon && !way.nodes().empty() && way.is_closed()) {
6565
auto const geom = geom::create_polygon(way);
6666
auto const projected_geom = geom::transform(geom, *m_proj);
6767

0 commit comments

Comments
 (0)