Boost C++ Libraries: Ticket #10823: IsValid or dissolve problem? https://svn.boost.org/trac10/ticket/10823 <p> Dear Boost Geometry contributors. </p> <p> As always: Thanks for your great work. Your work is an incredible help every day. </p> <p> I discovered a problem, which I guess you can help me with. </p> <p> If you look at the below test case you will see a small polygon where two points touches each other and forms a "hole" in the polygon. </p> <p> If I call is_valid with this polygon it tells me that the polygon is invalid. </p> <p> If I then tries to dissolve it, the output is again not valid. </p> <p> My question is therefore if it could be a problem with is_valid or dissolve. Alternatively what could I do to make it valid so that it can be used for calls to e.g sym_difference? </p> <p> Thanks a lot </p> <p> Johan </p> <p> BOOST_AUTO_TEST_CASE(Boost_IsValidOrDissolve_Fails) { </p> <blockquote> <p> polygon&lt;point_xy&lt;float&gt;&gt; Poly; read_wkt("POLYGON((0 3, 3 3, 3 1, 2 1, 2 2, 1 2, 1 1, 2 1, 2 0, 0 0, 0 3))", Poly); </p> </blockquote> <blockquote> <p> BOOST_CHECK(!is_valid(Poly)); </p> </blockquote> <blockquote> <p> multi_polygon&lt;polygon&lt;point_xy&lt;float&gt;&gt;&gt; Polys; dissolve(Poly, Polys); </p> </blockquote> <blockquote> <p> BOOST_CHECK(!is_valid(Polys)); </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10823 Trac 1.4.3 mkaravel Tue, 24 Mar 2015 08:13:18 GMT cc set https://svn.boost.org/trac10/ticket/10823#comment:1 https://svn.boost.org/trac10/ticket/10823#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">mkaravel</span> added </li> </ul> Ticket mkaravel Tue, 24 Mar 2015 09:46:06 GMT attachment set https://svn.boost.org/trac10/ticket/10823 https://svn.boost.org/trac10/ticket/10823 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket_10823.cpp</span> </li> </ul> <p> File showing the validity of the correctly defined polygon </p> Ticket mkaravel Tue, 24 Mar 2015 09:52:19 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10823#comment:2 https://svn.boost.org/trac10/ticket/10823#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Hi Johan. </p> <p> According to the OGC standard the outer and inner rings of a polygon must be simple rings (the standard uses the term <strong><a class="missing wiki">LinearRing</a></strong> for these). As such, a ring of a polygon cannot touch itself. </p> <p> This is what is implemented in Boost.Geometry (a bit relaxed though as we do allow for duplicate consecutive points). For your polygon to be valid, you need to define the inner ring separately; see the following WKT: </p> <p> <code> POLYGON((0 3,3 3,3 1,2 1,2 0,0 0,0 3),(2 1,2 2,1 2,1 1,2 1))</code> </p> <p> I have also attached a small program exhibiting what I am claiming above; if you re-define your polygon as per the WKT above, it is detected as valid. </p> Ticket