Boost C++ Libraries: Ticket #12725: boost::geometry::distance compile errors with 3D segment primitives https://svn.boost.org/trac10/ticket/12725 <p> When trying to calculate the nearest segment from another segment in a 3-dimensional space using the boost::geometry::index::nearest query on a boost:: boost::geometry::index::rtree but I get the following compilation error on VS2010: </p> <pre class="wiki">&gt; error C2664: 'boost::mpl::assertion_failed' : cannot convert parameter &gt; 1 from 'boost::mpl::failed ************(__cdecl &gt; boost::geometry::nyi::not_implemented_error&lt;Term1,Term2,Term3&gt;::THIS_OPERATION_IS_NOT_OR_NOT_YET_IMPLEMENTED::* &gt; ***********)(boost::mpl::assert_::types&lt;T1,T2,T3&gt;)' to 'boost::mpl::assert&lt;false&gt;::type' </pre><p> I have managed to narrow down the same issue to using just the <code>boost::geometry::distance</code> function: </p> <pre class="wiki"> typedef boost::geometry::model::point &lt;float, 3, boost::geometry::cs::cartesian&gt; point; typedef boost::geometry::model::segment &lt;point&gt; segment; point pa = point(x1, y1, z1); point pc = point(x2, y2, z2); point pb = point(x3, y3, z3); float dist = boost::geometry::distance(segment(pa, pb), segment(pa, pc)); </pre><p> According to the documentation of the version of Boost I'm using (1.60) this should be supported, however it works just fine when using two dimensions. </p> <p> <a href="http://www.boost.org/doc/libs/1_60_0/libs/geometry/doc/html/geometry/reference/algorithms/distance/distance_2.html#geometry.reference.algorithms.distance.distance_2.supported_geometries">http://www.boost.org/doc/libs/1_60_0/libs/geometry/doc/html/geometry/reference/algorithms/distance/distance_2.html#geometry.reference.algorithms.distance.distance_2.supported_geometries</a> </p> <p> I could not find anything in the docs either about how to extend the functionality or whether it's possible at all and could not find any relevant changes regarding this issue since this version. </p> <p> Is this a bug or something in the roadmap that hasn't yet been addressed? </p> <p> <a class="ext-link" href="http://stackoverflow.com/questions/41453792/boostgeometrydistance-compile-errors-with-3d-primitives"><span class="icon">​</span>http://stackoverflow.com/questions/41453792/boostgeometrydistance-compile-errors-with-3d-primitives</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12725 Trac 1.4.3 Arturo Blas <arturoblas@…> Sun, 08 Jan 2017 19:59:58 GMT version, severity changed; cc set https://svn.boost.org/trac10/ticket/12725#comment:1 https://svn.boost.org/trac10/ticket/12725#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">arturoblas@…</span> added </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.61.0</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Showstopper</span> </li> </ul> Ticket Arturo Blas <arturoblas@…> Mon, 16 Jan 2017 00:02:05 GMT <link>https://svn.boost.org/trac10/ticket/12725#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12725#comment:2</guid> <description> <p> Can you please give some feedback about this ticket to know whether to rely on Boost for this functionality or try to find other options? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>awulkiew</dc:creator> <pubDate>Mon, 16 Jan 2017 02:39:25 GMT</pubDate> <title>type changed https://svn.boost.org/trac10/ticket/12725#comment:3 https://svn.boost.org/trac10/ticket/12725#comment:3 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> </ul> <p> Yes, it seems that disjoint/intersects is not yet implemented for N-dimensional segments. And distance() calls this algorithm. </p> <p> As a workaround you could store bounding boxes of segments in the R-tree, then search for Boxes nearest to some query Box using iterative query, in each iteration check the actual distance between segments using your own implementation and stop if your k-th found segment is closer than the distance between the bounding box passed into the query and the bounding box found in the current iteration. So basically use the index how you'd use it for any other Geometry. </p> Ticket Arturo Blas <arturoblas@…> Mon, 16 Jan 2017 02:54:04 GMT <link>https://svn.boost.org/trac10/ticket/12725#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12725#comment:4</guid> <description> <p> Thanks for your feedback, this is what I had in mind but I was hoping I could just hook in my own intersection/distance function providing segment distance in 3D space. </p> <p> Also, the main issue from a user's perspective is the lack of an statement in the documentation so it's explicitly stated that algorithms may not work for primitives with 2+ dimensions. </p> <p> Is there an ETA for implementing this? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>awulkiew</dc:creator> <pubDate>Mon, 16 Jan 2017 08:02:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12725#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12725#comment:5</guid> <description> <p> I'd discourage you from hooking in your own functions in case something changed in the future internally in the rtree (e.g. different functions were used). But if you'd like to try it you could overload <code>bg::comparable_distance(segment, segment)</code> and <code>bg::comparable_distance(segment, box)</code>, e.g. like that: </p> <pre class="wiki">namespace boost { namespace geometry { template &lt;typename Box&gt; float comparable_distance(segment const&amp; s, Box const&amp; b) { return 0; } float comparable_distance(segment const&amp; s1, segment const&amp; s2) { return 0; } }} </pre><p> Box would be of type internally used in the R-tree to represent nodes, so <code>bg::model::box&lt;...&gt;</code>. </p> <p> No ETA, currently we're adding support for 2d geographic CS. But you could consider contributing your own implementation. :) </p> </description> <category>Ticket</category> </item> <item> <author>Arturo Blas <arturoblas@…></author> <pubDate>Mon, 16 Jan 2017 19:28:28 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12725#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12725#comment:6</guid> <description> <p> Thanks again for your help. That looks like a good way to test things actually work but not a long term solution obviously. </p> <p> I could share with you my 3D segment distance implementation if that would help in any way. </p> <p> Best. </p> </description> <category>Ticket</category> </item> </channel> </rss>