Boost C++ Libraries: Ticket #10713: Boost Geometry dissolve https://svn.boost.org/trac10/ticket/10713 <p> Dear Boost Geometry Contributors </p> <p> I was testing out the new 1.57 beta therefore also downloaded the latest \geometry\extensions\algorithms\dissolve.hpp file. </p> <p> Testing that I stumbled upon a strange thing which I thought would be interesting for you. </p> <p> Using the below example: </p> <p> using namespace boost::geometry; using namespace boost::geometry::model; using namespace boost::geometry::model::d2; </p> <p> int _tmain(int argc, _TCHAR* argv[]) { </p> <blockquote> <p> polygon&lt;point_xy&lt;float&gt;&gt; Poly; read_wkt("POLYGON((-0.7189743518829346 4.1308121681213379, 0.0831791982054710 4.1034231185913086, 0.1004156470298767 4.1107301712036133, 0.1044322624802589 4.1026973724365234, 0.0831791982054710 4.1034231185913086, -0.7711903452873230 3.7412264347076416, -0.7189743518829346 4.1308121681213379))", Poly); </p> </blockquote> <blockquote> <p> multi_polygon&lt;polygon&lt;point_xy&lt;float&gt;&gt;&gt; Dissolved; boost::geometry::dissolve(Poly, Dissolved); return 0; </p> </blockquote> <p> } </p> <p> I find that dissolve gives me 2 polygons back with 5 outline points in each. However the input polygon is like two triangles touching each other so I was expecting an output of two polygons with each 4 points. </p> <p> I then looked at the dissolve.hpp and wondered if it could be because of the no_rescale_policy() specified in the dissolve function. Modified the function to use the rescale policy found in other of your geometry functions: </p> <p> inline void dissolve(Geometry const&amp; geometry, Collection&amp; output_collection) { </p> <blockquote> <p> concept::check&lt;Geometry const&gt;(); </p> </blockquote> <p> </p> <blockquote> <p> typedef typename boost::range_value&lt;Collection&gt;::type geometry_out; </p> </blockquote> <p> </p> <blockquote> <p> concept::check&lt;geometry_out&gt;(); </p> </blockquote> <blockquote> <p> typedef typename geometry::point_type&lt;Geometry&gt;::type point_type; typedef typename geometry::rescale_policy_type&lt;point_type&gt;::type rescale_policy_type; </p> </blockquote> <blockquote> <p> rescale_policy_type robust_policy = geometry::get_rescale_policy&lt;rescale_policy_type&gt;(geometry); </p> </blockquote> <blockquote> <p> dispatch::dissolve &lt; </p> <blockquote> <p> typename tag&lt;Geometry&gt;::type, typename tag&lt;geometry_out&gt;::type, Geometry, geometry_out </p> <blockquote class="citation"> <p> ::apply(geometry, robust_policy, std::back_inserter(output_collection)); </p> </blockquote> </blockquote> </blockquote> <p> } </p> <p> Doing so made the dissolve function return two polygons with each 4 points. </p> <p> I then ran a lot of different other tests and none of those failed for me. </p> <p> I therefore wonder if there is a reason for the no_rescale_policy() or if it is better to use the “robust_policy” </p> <p> Best regards and thanks a lot for this great library </p> <p> Johan Doré </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10713 Trac 1.4.3 Barend Gehrels Wed, 05 Nov 2014 12:47:37 GMT status changed https://svn.boost.org/trac10/ticket/10713#comment:1 https://svn.boost.org/trac10/ticket/10713#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 Wed, 05 Nov 2014 13:01:00 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10713#comment:2 https://svn.boost.org/trac10/ticket/10713#comment:2 <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">fixed</span> </li> </ul> <p> The no_rescale_policy was added in the dissolve-extension during the development of robustness/rescaling, it was indeed the intention to replace it with proper rescaling. </p> <p> Done, thanks for your suggestion and your compliments. </p> Ticket anonymous Thu, 20 Nov 2014 19:24:43 GMT <link>https://svn.boost.org/trac10/ticket/10713#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10713#comment:3</guid> <description> <p> Hi Again, </p> <p> Thanks a lot for the fix. </p> <p> Maybe it is me but I thought that the changes should also be applied to the Dissolve function? </p> <p> Something like: </p> <p> template &lt; </p> <blockquote> <p> typename Geometry, typename Collection </p> <blockquote class="citation"> </blockquote> </blockquote> <p> inline void dissolve(Geometry const&amp; geometry, Collection&amp; output_collection) { </p> <blockquote> <p> concept::check&lt;Geometry const&gt;(); typedef typename boost::range_value&lt;Collection&gt;::type geometry_out; </p> </blockquote> <blockquote> <p> concept::check&lt;geometry_out&gt;(); </p> </blockquote> <blockquote> <p> typedef typename geometry::point_type&lt;Geometry&gt;::type point_type; typedef typename geometry::rescale_policy_type&lt;point_type&gt;::type rescale_policy_type; </p> </blockquote> <blockquote> <p> rescale_policy_type robust_policy = geometry::get_rescale_policy&lt;rescale_policy_type&gt;(geometry); </p> </blockquote> <blockquote> <p> dispatch::dissolve &lt; </p> <blockquote> <p> typename tag&lt;Geometry&gt;::type, typename tag&lt;geometry_out&gt;::type, Geometry, geometry_out </p> <blockquote class="citation"> <p> ::apply(geometry, robust_policy, std::back_inserter(output_collection)); </p> </blockquote> </blockquote> </blockquote> <p> } </p> <p> Best regards </p> <p> Johan </p> </description> <category>Ticket</category> </item> </channel> </rss>