Boost C++ Libraries: Ticket #10412: Offsetting polygons with buffer strategies fails for some distances https://svn.boost.org/trac10/ticket/10412 <p> Offsetting a polygon (see attached code and images) with a 1.5m distance creates an incorrect result. The polygon seems to be self intersecting. </p> <p> <em>Notes</em> </p> <ul><li>Boost 1.56.0 patched with <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/10398"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/10398</a> </li><li>Windows 7 64bit </li><li>VC++ 2010 </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10412 Trac 1.4.3 Olivier Tournaire <olivier.tournaire@…> Wed, 27 Aug 2014 16:04:20 GMT attachment set https://svn.boost.org/trac10/ticket/10412 https://svn.boost.org/trac10/ticket/10412 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">input.png</span> </li> </ul> <p> Input polygon </p> Ticket Olivier Tournaire <olivier.tournaire@…> Wed, 27 Aug 2014 16:04:37 GMT attachment set https://svn.boost.org/trac10/ticket/10412 https://svn.boost.org/trac10/ticket/10412 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">output.png</span> </li> </ul> <p> Offsetting result </p> Ticket Olivier Tournaire <olivier.tournaire@…> Wed, 27 Aug 2014 16:05:17 GMT attachment set https://svn.boost.org/trac10/ticket/10412 https://svn.boost.org/trac10/ticket/10412 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">overlay.png</span> </li> </ul> <p> Overlaying input and offsetted polygon (with transparency) </p> Ticket Olivier Tournaire <olivier.tournaire@…> Wed, 27 Aug 2014 16:07:46 GMT attachment set https://svn.boost.org/trac10/ticket/10412 https://svn.boost.org/trac10/ticket/10412 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main_boost_geometry_incorrect_polygon_offset.cpp</span> </li> </ul> <p> Sample code </p> Ticket Barend Gehrels Sat, 30 Aug 2014 09:16:39 GMT status changed https://svn.boost.org/trac10/ticket/10412#comment:1 https://svn.boost.org/trac10/ticket/10412#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Barend Gehrels Sat, 30 Aug 2014 10:09:16 GMT <link>https://svn.boost.org/trac10/ticket/10412#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10412#comment:2</guid> <description> <p> I cannot reproduce this. I tried: </p> <ul><li>branch master (= 1.56) with VC 2010 and clang </li><li>branch develop with gcc </li><li>branch feature/buffer with gcc </li></ul><p> All give the same correct result </p> <p> The expected and detected area is 3109.6616 </p> <p> One thing, you specify: </p> <pre class="wiki"> boost::geometry::strategy::buffer::join_miter join_strategy(offset_distance); </pre><p> but this is probably not your intention, the miter limit should be in terms of a factor of the distance, for example 5, or 10. See also </p> <p> <a href="http://www.boost.org/doc/libs/1_56_0/libs/geometry/doc/html/geometry/reference/strategies/strategy_buffer_join_miter.html">http://www.boost.org/doc/libs/1_56_0/libs/geometry/doc/html/geometry/reference/strategies/strategy_buffer_join_miter.html</a> </p> <p> But I tried with and without this limit, both give non-intersecting output. </p> </description> <category>Ticket</category> </item> <item> <author>Olivier Tournaire <olivier.tournaire@…></author> <pubDate>Sat, 30 Aug 2014 11:54:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10412#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10412#comment:3</guid> <description> <p> Barend, </p> <p> Here is the WKT output of the result I have with properly setting the join_miter strategy </p> <pre class="wiki">boost::geometry::strategy::buffer::join_miter join_strategy(5); </pre><pre class="wiki">MULTIPOLYGON(((897758.022176 6270477.86127,897753.924459 6270479.79837,897753.260513 6270478.36834,897752.590961 6270476.92625,897751.19031 6270477.67851,897745.79031 6270480.57851,897744.589559 6270481.2233,897744.578987 6270481.20053,897743.167095 6270481.99124,897740.667095 6270483.39124,897739.456815 6270484.06895,897740.038061 6270485.32859,897740.628807 6270486.60855,897740.158704 6270486.8436,897739.681451 6270485.71554,897739.030794 6270484.17788,897737.571536 6270484.98877,897734.871536 6270486.48877,897734.322818 6270486.79342,897734.154723 6270487.39854,897731.662883 6270496.36917,897729.772209 6270502.24021,897729.349234 6270503.55367,897730.5627 6270504.05945,897730.521382 6270504.19259,897729.321449 6270503.79231,897728.867404 6270505.2554,897724.367404 6270519.7554,897723.989739 6270520.97227,897724.950215 6270521.45221,897724.583255 6270522.50722,897724.091322 6270523.92089,897725.504474 6270524.41579,897726.166015 6270524.64733,897724.858639 6270529.1847,897724.446665 6270530.61434,897725.872977 6270531.03794,897740.935934 6270535.51118,897739.761803 6270539.47387,897739.3533246270540.85215,897740.713158 6270541.3188,897749.631289 6270544.37894,897749.239238 6270546.05916,897748.924674 6270547.40667,897750.242836 6270547.82864,897751.319656 6270548.17321,897746.369626 6270563.84831,897745.922589 6270565.26383,897747.333441 6270565.7256,897763.833441 6270571.1256,897765.290232 6270571.60234,897765.735356 6270570.13561,897777.935356 6270529.93561,897778.378151 6270528.47657,897776.912082 6270528.05772,897768.512082 6270525.65772,897766.973821 6270525.21819,897766.634235 6270526.78136,897766.484462 6270527.47033,897756.764653 6270524.37375,897747.679795 6270521.34548,897753.428807 6270503.35663,897753.857197 6270502.01612,897752.546599 6270501.50314,897751.949361 6270501.26944,897753.07992 6270500.5813,897754.011277 6270500.01439,897754.470123 6270500.89385,897755.181727 6270502.25806,897756.527452 6270501.5118,897767.527452 6270495.4118,897768.615091 6270494.80865,897768.426519 6270495.64354,897769.778325 6270496.03951,897779.678325 6270498.93951,897781.094901 6270499.35448,897781.532596 6270497.9446,897781.973939 6270496.52252,897786.311014 6270498.01806,897787.810238 6270498.53502,897788.243056 6270497.00938,897792.243056 6270482.90938,897792.636401 6270481.5228,897791.266559 6270481.07441,897787.081458 6270479.70474,897787.358581 6270478.55006,897787.691239 6270477.16332,897786.323249 6270476.76095,897769.323249 6270471.76095,897767.902001 6270471.34296,897767.466331 6270472.75887,897767.104364 6270473.93527,897766.531022 6270473.76326,897765.934035 6270473.58454,897765.386724 6270473.88044,897758.022176 6270477.86127),(897745.949075 6270483.99703,897745.891685 6270484.02777,897745.512854 6270483.21183,897745.949075 6270483.99703),(897751.587432 6270501.12781,897751.644105 6270500.96346,897751.828698 6270501.22222,897751.587432 6270501.12781),(897768.669004 6270494.56997,897768.161939 6270493.47142,897767.641372 6270492.34352,897768.290014 6270492.10328,897769.151215 6270492.43451,897768.736838 6270494.26961,897768.669004 6270494.56997))) </pre><p> Can you please copy / paste your result as WKT? And maybe a screenshot? </p> <p> Please also find attached some new screenshots showing the self intersecting parts. </p> </description> <category>Ticket</category> </item> <item> <author>Olivier Tournaire <olivier.tournaire@…></author> <pubDate>Sat, 30 Aug 2014 11:55:25 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/10412 https://svn.boost.org/trac10/ticket/10412 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">self-intersection.png</span> </li> </ul> <p> Self intersection global view </p> Ticket Olivier Tournaire <olivier.tournaire@…> Sat, 30 Aug 2014 11:55:46 GMT attachment set https://svn.boost.org/trac10/ticket/10412 https://svn.boost.org/trac10/ticket/10412 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">self-intersection_zoom1.png</span> </li> </ul> <p> Self intersection zoom (1) </p> Ticket Olivier Tournaire <olivier.tournaire@…> Sat, 30 Aug 2014 11:56:01 GMT attachment set https://svn.boost.org/trac10/ticket/10412 https://svn.boost.org/trac10/ticket/10412 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">self-intersection_zoom2.png</span> </li> </ul> <p> Self intersection zoom (2) </p> Ticket Olivier Tournaire <olivier.tournaire@…> Sat, 30 Aug 2014 11:56:15 GMT attachment set https://svn.boost.org/trac10/ticket/10412 https://svn.boost.org/trac10/ticket/10412 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">self-intersection_zoom3.png</span> </li> </ul> <p> Self intersection zoom (3) </p> Ticket Barend Gehrels Wed, 03 Sep 2014 09:23:31 GMT <link>https://svn.boost.org/trac10/ticket/10412#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10412#comment:4</guid> <description> <p> Here is my WKT: </p> <pre class="wiki">MULTIPOLYGON(((897758.022243459 6270477.861234601,897753.924459903 6270479.798371551,897753.260513452 6270478.368333041,897752.591068108 6270476.926373008,897751.190310043 6270477.678508356,897745.790310043 6270480.578508357,897744.589615228 6270481.223436671,897744.578966663 6270481.200488646,897743.167094946 6270481.991240976,897740.667094946 6270483.391240977,897739.456837573 6270484.068880935,897740.038060923 6270485.328587267,897740.628808432 6270486.608544801,897740.158700434 6270486.843598800,897739.681450877 6270485.715540013,897739.031042301 6270484.177832222,897737.571535603 6270484.988764086,897734.871535603 6270486.488764086,897734.322756104 6270486.793546775,897734.154723136 6270487.398534204,897731.662908147 6270496.369085054,897729.772209163 6270502.240202951,897729.349346908 6270503.553399346,897730.562701685 6270504.059441308,897730.521345249 6270504.192700830,897729.321261906 6270503.792947748,897728.867403795 6270505.255401178,897724.367403795 6270519.755401178,897723.989972015 6270520.971548507,897724.950253781 6270521.452097005,897724.583254805 6270522.507219062,897724.091192668 6270523.921258853,897725.504474363 6270524.415787535,897726.166015197 6270524.647330281,897724.858639568 6270529.184692756,897724.446725107 6270530.614360224,897725.872977430 6270531.037933143,897740.935934062 6270535.511174599,897739.761802831 6270539.473867506,897739.353439741 6270540.852221156,897740.713157910 6270541.318796949,897749.631288888 6270544.378938279,897749.239238185 6270546.059155577,897748.924945065 6270547.406696783,897750.242836409 6270547.828636222,897751.319651870 6270548.173221033,897746.369626002 6270563.848302948,897745.922576824 6270565.263898157,897747.333441409 6270565.725595693,897763.833441409 6270571.125595693,897765.290216073 6270571.602398275,897765.735356305 6270570.135605645,897777.935356305 6270529.935605645,897778.378144925 6270528.476599928,897776.912081692 6270528.057714079,897768.512081692 6270525.657714078,897766.974157739 6270525.218317875,897766.634235454 6270526.781355533,897766.484462079 6270527.470324830,897756.765366213 6270524.373983241,897747.679798682 6270521.345462041,897753.428807151 6270503.356629089,897753.857155358 6270502.016303432,897752.546599023 6270501.503135831,897751.949602705 6270501.269525220,897753.079920420 6270500.581297833,897754.011272513 6270500.014387864,897754.470122731 6270500.893849011,897755.181852602 6270502.258039968,897756.527451643 6270501.511798044,897767.527451643 6270495.411798043,897768.615142868 6270494.808665982,897768.426663356 6270495.643546053,897769.778325217 6270496.039510464,897779.678325217 6270498.939510465,897781.094911640 6270499.354447067,897781.532596205 6270497.944598822,897781.973935068 6270496.522515021,897786.311013975 6270498.018059472,897787.810215579 6270498.534991667,897788.243055798 6270497.009377531,897792.243055798 6270482.909377531,897792.636379616 6270481.522763436,897791.266558591 6270481.074404307,897787.081457471 6270479.704740603,897787.358580953 6270478.550059428,897787.691396409 6270477.163370267,897786.323249486 6270476.760951748,897769.323249486 6270471.760951748,897767.901864364 6270471.342919666,897767.466331487 6270472.758871227,897767.104366342 6270473.935257948,897766.531021828 6270473.763260572,897765.934519701 6270473.584387909,897765.386724448 6270473.880440230,897758.022243459 6270477.861234601),(897745.949080980 6270483.997023027,897745.891677269 6270484.027775016,897745.512754197 6270483.211646596,897745.949080980 6270483.997023027),(897751.587431134 6270501.127809266,897751.644374972 6270500.962671074,897751.830216437 6270501.222812210,897751.587431134 6270501.127809266),(897768.669017661 6270494.570000764,897768.161939077 6270493.471412733,897767.641367904 6270492.343508526,897768.290004930 6270492.103277466,897769.151214979 6270492.434512842,897768.736838497 6270494.269608692,897768.669017661 6270494.570000764))) </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Wed, 03 Sep 2014 09:31:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10412#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10412#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10412#comment:3" title="Comment 3">Olivier Tournaire &lt;olivier.tournaire@…&gt;</a>: </p> <p> Hi Olivier, Your WKT is wrong in one place (column 1124). Anyway I could correct that. But your WKT looks then as a perfect result. It gives no self-intersections and the area is correct. Verified also in SQL Server. </p> <p> So I don't know where your screendump comes from, but it does not correspond with your WKT. </p> <pre class="wiki">with viewy as ( select geometry::STGeomFromText('MULTIPOLYGON(((897758.022176 6270477.86127,897753.924459 6270479.79837,897753.260513 6270478.36834,897752.590961 6270476.92625,897751.19031 6270477.67851,897745.79031 6270480.57851,897744.589559 6270481.2233,897744.578987 6270481.20053,897743.167095 6270481.99124,897740.667095 6270483.39124,897739.456815 6270484.06895,897740.038061 6270485.32859,897740.628807 6270486.60855,897740.158704 6270486.8436,897739.681451 6270485.71554,897739.030794 6270484.17788,897737.571536 6270484.98877,897734.871536 6270486.48877,897734.322818 6270486.79342,897734.154723 6270487.39854,897731.662883 6270496.36917,897729.772209 6270502.24021,897729.349234 6270503.55367,897730.5627 6270504.05945,897730.521382 6270504.19259,897729.321449 6270503.79231,897728.867404 6270505.2554,897724.367404 6270519.7554,897723.989739 6270520.97227,897724.950215 6270521.45221,897724.583255 6270522.50722,897724.091322 6270523.92089,897725.504474 6270524.41579,897726.166015 6270524.64733,897724.858639 6270529.1847,897724.446665 6270530.61434,897725.872977 6270531.03794,897740.935934 6270535.51118,897739.761803 6270539.47387,897739.353324 6270540.85215,897740.713158 6270541.3188,897749.631289 6270544.37894,897749.239238 6270546.05916,897748.924674 6270547.40667,897750.242836 6270547.82864,897751.319656 6270548.17321,897746.369626 6270563.84831,897745.922589 6270565.26383,897747.333441 6270565.7256,897763.833441 6270571.1256,897765.290232 6270571.60234,897765.735356 6270570.13561,897777.935356 6270529.93561,897778.378151 6270528.47657,897776.912082 6270528.05772,897768.512082 6270525.65772,897766.973821 6270525.21819,897766.634235 6270526.78136,897766.484462 6270527.47033,897756.764653 6270524.37375,897747.679795 6270521.34548,897753.428807 6270503.35663,897753.857197 6270502.01612,897752.546599 6270501.50314,897751.949361 6270501.26944,897753.07992 6270500.5813,897754.011277 6270500.01439,897754.470123 6270500.89385,897755.181727 6270502.25806,897756.527452 6270501.5118,897767.527452 6270495.4118,897768.615091 6270494.80865,897768.426519 6270495.64354,897769.778325 6270496.03951,897779.678325 6270498.93951,897781.094901 6270499.35448,897781.532596 6270497.9446,897781.973939 6270496.52252,897786.311014 6270498.01806,897787.810238 6270498.53502,897788.243056 6270497.00938,897792.243056 6270482.90938,897792.636401 6270481.5228,897791.266559 6270481.07441,897787.081458 6270479.70474,897787.358581 6270478.55006,897787.691239 6270477.16332,897786.323249 6270476.76095,897769.323249 6270471.76095,897767.902001 6270471.34296,897767.466331 6270472.75887,897767.104364 6270473.93527,897766.531022 6270473.76326,897765.934035 6270473.58454,897765.386724 6270473.88044,897758.022176 6270477.86127),(897745.949075 6270483.99703,897745.891685 6270484.02777,897745.512854 6270483.21183,897745.949075 6270483.99703),(897751.587432 6270501.12781,897751.644105 6270500.96346,897751.828698 6270501.22222,897751.587432 6270501.12781),(897768.669004 6270494.56997,897768.161939 6270493.47142,897767.641372 6270492.34352,897768.290014 6270492.10328,897769.151215 6270492.43451,897768.736838 6270494.26961,897768.669004 6270494.56997)))',0) as geo1 ) select geo1.STArea() from viewy </pre> </description> <category>Ticket</category> </item> <item> <author>Olivier Tournaire <olivier.tournaire@…></author> <pubDate>Wed, 03 Sep 2014 12:35:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10412#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10412#comment:6</guid> <description> <p> Barend, </p> <p> Thanks. It was a mistake in my code. Sorry for that, and thanks again for your help! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Wed, 03 Sep 2014 13:08:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10412#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10412#comment:7</guid> <description> <p> OK, you are welcome. So do I understand correctly that the problem is solved and I can close the ticket? </p> </description> <category>Ticket</category> </item> <item> <author>Olivier Tournaire <olivier.tournaire@…></author> <pubDate>Wed, 03 Sep 2014 13:40:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10412#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10412#comment:8</guid> <description> <p> Yes, ticket can be consider invalid and closed . </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Barend Gehrels</dc:creator> <pubDate>Wed, 03 Sep 2014 14:23:12 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/10412#comment:9 https://svn.boost.org/trac10/ticket/10412#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.57.0</span> </li> </ul> <p> OK, closing it. </p> Ticket