Skip to content

Commit

Permalink
Merge branch 'empty-crash-unary-union' of https://github.com/sir-sigu…
Browse files Browse the repository at this point in the history
…rd/libgeos into sir-sigurd-empty-crash-unary-union
  • Loading branch information
dbaston committed Sep 24, 2018
2 parents 52c516f + 2af4f06 commit d5141be
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/operation/union/UnaryUnionOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ UnaryUnionOp::Union()
*/
unionLines.reset( CascadedUnion::Union( lines.begin(),
lines.end() ) );
unionLines = unionNoOpt(*unionLines);
if (unionLines.get()) {
unionLines = unionNoOpt(*unionLines);
}
}

GeomPtr unionPolygons;
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/capi/GEOSUnaryUnionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,18 @@ namespace tut

}

// Self-union an empty linestring
template<>
template<>
void object::test<10>()
{
geom1_ = GEOSGeomFromWKT("LINESTRING EMPTY");
ensure( nullptr != geom1_ );

geom2_ = GEOSUnaryUnion(geom1_);
ensure( nullptr != geom2_ );

ensure_equals(toWKT(geom2_), std::string("GEOMETRYCOLLECTION EMPTY"));
}
} // namespace tut

12 changes: 12 additions & 0 deletions tests/unit/operation/union/UnaryUnionOpTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,17 @@ namespace tut
doTest(geoms, "MULTILINESTRING ((0 0, 5 0), (5 0, 10 0, 5 -5, 5 0), (5 0, 5 5))");
}

template<>
template<>
void object::test<7>()
{
static char const* const geoms[] =
{
"LINESTRING EMPTY",
nullptr
};
doTest(geoms, "GEOMETRYCOLLECTION EMPTY");
}

} // namespace tut

0 comments on commit d5141be

Please sign in to comment.