Boost C++ Libraries: Ticket #11783: distance between polygon https://svn.boost.org/trac10/ticket/11783 <p> Distance between polygon return 0 whereas it is not. </p> <p> For example, the following two polygons poly and poly2: </p> <p> typedef boost::geometry::model::d2::point_xy&lt;double&gt; point_type; typedef boost::geometry::model::polygon&lt;point_type&gt; polygon_type; </p> <p> polygon_type poly, poly2; </p> <p> boost::geometry::read_wkt("POLYGON((0.483707939991215 4.773920582819078, 0.5053006295162502 4.848900310429359, 0.5026276157353238 4.926851374195881, 0.47595271806952655 5.000142970012212, 0.42788885209344396 5.061604949484321, 0.36314153156370255 5.1052282121312595, 0.28804795065446004 5.12675006676153, 0.20995692111385858 5.124068426945231, 0.13651026810181627 5.097445647190528, 0.07489571249838214 5.049482920409928, 0.031143980177505432 4.984867693057649, 0.009538656296549554 4.909917885067861, 0.012196499626267798 4.831966193462844, 0.03885948446609647 4.758643661998902, 0.0869192454259704 4.697132255323741, 0.151671837534352 4.653459953523097, 0.22677805366317155 4.63190817924884, 0.30488425540802405 4.634590447230228, 0.37834282146581616 4.661244162857866, 0.43996148046825034 4.709256316654202))", poly); </p> <p> boost::geometry::read_wkt("POLYGON((-1.0557992498764188 4.746036929415318,-1.0993658333477525 4.810856267060861, -1.1608453480495324 4.859088577533509, -1.234220477005859 4.886019279588865, -1.312310562575837 4.889015578303403, -1.3874737831476758 4.867782698965993, -1.452354304963582 4.8243932756221835, -1.5006016515805882 4.763086838460696, -1.5274921589195156 4.689857989799479, -1.530391741605481 4.61187218939475, -1.5090144880022829 4.5367652713717845, -1.465451447333285 4.471894995746168, -1.4039664811460055 4.423618461729835, -1.3305789878636327 4.3966671418069225, -1.2524743477794593 4.393681706260662, -1.177299942608499 4.414952781113644, -1.1124158788230383 4.458393143311671, -1.0641739853613563 4.519743805317727,-1.0372958425476984 4.5929932717763435, -1.0344108128292469 4.670968207668558))",poly2); </p> <p> std::cout &lt;&lt; "distance: " &lt;&lt; boost::geometry::distance(poly, poly2) &lt;&lt; std::endl; </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11783 Trac 1.4.3 anonymous Tue, 03 Nov 2015 08:50:23 GMT attachment set https://svn.boost.org/trac10/ticket/11783 https://svn.boost.org/trac10/ticket/11783 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">dist_test.cpp</span> </li> </ul> <p> stand alone c++ source code to test bug </p> Ticket awulkiew Tue, 03 Nov 2015 13:19:29 GMT <link>https://svn.boost.org/trac10/ticket/11783#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11783#comment:1</guid> <description> <p> Thanks for the report. </p> <p> By default <code>bg::model::polygon</code> is clockwise and closed (the last point must be equal to the first one). On the other hand the polygons you defined in WKT are not. To fix it you may: </p> <ol><li>Pass closed WKTs </li><li>Call <code>bg::correct()</code> after reading the polygon from WKT </li><li>Use open polygon type, e.g. <code>bg::model::polygon&lt;point_type, true, false&gt;</code> </li></ol><p> Can you confirm that this is not a bug? </p> </description> <category>Ticket</category> </item> <item> <author>brahim.boudamouz@…</author> <pubDate>Tue, 03 Nov 2015 13:53:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11783#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11783#comment:2</guid> <description> <p> In fact that is not a bug! A call of boost::geomery::correct(mypolygon) before computing distance solve the problem Thanks for your quick answer and problem handling Grateful for the time you spent </p> </description> <category>Ticket</category> </item> <item> <dc:creator>awulkiew</dc:creator> <pubDate>Tue, 03 Nov 2015 16:46:29 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11783#comment:3 https://svn.boost.org/trac10/ticket/11783#comment:3 <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> Ticket