Boost C++ Libraries: Ticket #11982: distance between point and linestring on spherical_equatorial ignores radius when using haversine. https://svn.boost.org/trac10/ticket/11982 <p> Distance between a point and a linestring is incorrect when using spherical_equatorial coordinates and haversine strategy. It looks like it is always using radius = 1.0. </p> <p> Example: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/geometry.hpp&gt; namespace bg = boost::geometry; typedef bg::model::point&lt;double, 2, bg::cs::spherical_equatorial&lt;bg::degree&gt; &gt; pt; typedef bg::model::linestring&lt;pt&gt; pt_line; int main() { const double earthRadius = 6371.0 * 1000.0; pt oslo(10.733557, 59.911923); pt sandvika(10.521812, 59.887214); pt trondheim(10.4, 63.43); // works correct double d1 = bg::distance(sandvika, trondheim, bg::strategy::distance::haversine&lt;double&gt;(earthRadius)); double d2 = bg::distance(oslo, trondheim, bg::strategy::distance::haversine&lt;double&gt;(earthRadius)); std::cout &lt;&lt; "Sandvika-Trondheim " &lt;&lt; d1 &lt;&lt; std::endl; std::cout &lt;&lt; "Oslo-Trondheim " &lt;&lt; d2 &lt;&lt; std::endl; pt_line ll; ll.push_back(oslo); ll.push_back(sandvika); // Does not work double d3 = bg::distance(trondheim, ll, bg::strategy::distance::haversine&lt;double&gt;(earthRadius)); std::cout &lt;&lt; "Oslo-Sandvika - Trondheim " &lt;&lt; d3 &lt;&lt; std::endl; return 0; } </pre><p> Output: </p> <pre class="wiki">Sandvika-Trondheim 393992 Oslo-Trondheim 391587 Oslo-Sandvika - Trondheim 0.0614639 </pre><p> Note that the last number differs with a factor of 6371000 from the correct 391587. </p> <p> It looks like distance/backward_compatibility.hpp is ignoring the incoming strategy in last argument to apply. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11982 Trac 1.4.3 anonymous Fri, 12 Feb 2016 12:05:57 GMT attachment set https://svn.boost.org/trac10/ticket/11982 https://svn.boost.org/trac10/ticket/11982 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test_distance.cc</span> </li> </ul> <p> Example program. </p> Ticket awulkiew Fri, 12 Feb 2016 22:12:25 GMT <link>https://svn.boost.org/trac10/ticket/11982#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11982#comment:1</guid> <description> <p> That's because <code>distance()</code> for Point-Linestring requires <a class="missing wiki">Point/Segment</a> strategy, not <a class="missing wiki">Point/Point</a> strategy. If you passed: </p> <pre class="wiki"> bg::strategy::distance::cross_track&lt;&gt;(earthRadius) </pre><p> the result would be correct. </p> <p> We have a few options: </p> <ol><li>As you suggest somehow pass radius from input strategy into the <a class="missing wiki">Point/Segment</a> strategy created in <code>backward_compatibility.hpp</code>. This may be problematic currently. </li><li>Remove backward compatibility since it allows to use strategies incorrectly. </li><li>Something else? </li></ol><p> Barend do you have a preference? </p> </description> <category>Ticket</category> </item> </channel> </rss>