@@ -210,7 +210,7 @@ TEST_CASE("geom::simplify", "[NoDB]")
210210
211211 SECTION (" large tolerance simplifies linestring" )
212212 {
213- auto const geom = geom::simplify (input, 2 .0 );
213+ auto const geom = geom::simplify (input, 10 .0 );
214214
215215 REQUIRE (geom.is_linestring ());
216216 auto const &l = geom.get <geom::linestring_t >();
@@ -219,3 +219,42 @@ TEST_CASE("geom::simplify", "[NoDB]")
219219 REQUIRE (l[1 ] == input.get <geom::linestring_t >()[5 ]);
220220 }
221221}
222+
223+ TEST_CASE (" geom::simplify of a loop" , " [NoDB]" )
224+ {
225+ geom::geometry_t const input{
226+ geom::linestring_t {{0 , 0 }, {0 , 1 }, {1 , 1 }, {1 , 0 }, {0.1 , 0.1 }, {0 , 0 }}};
227+
228+ SECTION (" small tolerance leaves linestring as is" )
229+ {
230+ auto const geom = geom::simplify (input, 0.01 );
231+
232+ REQUIRE (geom.is_linestring ());
233+ auto const &l = geom.get <geom::linestring_t >();
234+ REQUIRE (l.size () == 6 );
235+ REQUIRE (l == input.get <geom::linestring_t >());
236+ }
237+
238+ SECTION (" medium tolerance simplifies linestring" )
239+ {
240+ auto const geom = geom::simplify (input, 0.5 );
241+
242+ REQUIRE (geom.is_linestring ());
243+ auto const &l = geom.get <geom::linestring_t >();
244+ REQUIRE (l.size () == 5 );
245+
246+ auto const &il = input.get <geom::linestring_t >();
247+ REQUIRE (l[0 ] == il[0 ]);
248+ REQUIRE (l[1 ] == il[1 ]);
249+ REQUIRE (l[2 ] == il[2 ]);
250+ REQUIRE (l[3 ] == il[3 ]);
251+ REQUIRE (l[4 ] == il[5 ]);
252+ }
253+
254+ SECTION (" large tolerance breaks linestring, null geometry is returned" )
255+ {
256+ auto const geom = geom::simplify (input, 10.0 );
257+
258+ REQUIRE (geom.is_null ());
259+ }
260+ }
0 commit comments