1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>strategy::distance::haversine</title> 5<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../index.html" title="Chapter 1. Geometry"> 8<link rel="up" href="../strategies.html" title="Strategies"> 9<link rel="prev" href="strategy_distance_pythagoras_point_box.html" title="strategy::distance::pythagoras_point_box"> 10<link rel="next" href="strategy_distance_projected_point.html" title="strategy::distance::projected_point"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="strategy_distance_pythagoras_point_box.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../strategies.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="strategy_distance_projected_point.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="geometry.reference.strategies.strategy_distance_haversine"></a><a class="link" href="strategy_distance_haversine.html" title="strategy::distance::haversine">strategy::distance::haversine</a> 28</h4></div></div></div> 29<p> 30 <a class="indexterm" name="idm45635669017968"></a><a class="indexterm" name="idm45635669017280"></a><a class="indexterm" name="idm45635669016592"></a> 31Distance calculation for spherical coordinates on a perfect sphere using 32 haversine. 33 </p> 34<h6> 35<a name="geometry.reference.strategies.strategy_distance_haversine.h0"></a> 36 <span class="phrase"><a name="geometry.reference.strategies.strategy_distance_haversine.synopsis"></a></span><a class="link" href="strategy_distance_haversine.html#geometry.reference.strategies.strategy_distance_haversine.synopsis">Synopsis</a> 37 </h6> 38<p> 39</p> 40<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">RadiusTypeOrSphere</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">CalculationType</span><span class="special">></span> 41<span class="keyword">class</span> <span class="identifier">strategy</span><span class="special">::</span><span class="identifier">distance</span><span class="special">::</span><span class="identifier">haversine</span> 42<span class="special">{</span> 43 <span class="comment">// ...</span> 44<span class="special">};</span> 45</pre> 46<p> 47 </p> 48<h6> 49<a name="geometry.reference.strategies.strategy_distance_haversine.h1"></a> 50 <span class="phrase"><a name="geometry.reference.strategies.strategy_distance_haversine.template_parameter_s_"></a></span><a class="link" href="strategy_distance_haversine.html#geometry.reference.strategies.strategy_distance_haversine.template_parameter_s_">Template 51 parameter(s)</a> 52 </h6> 53<div class="informaltable"><table class="table"> 54<colgroup> 55<col> 56<col> 57<col> 58</colgroup> 59<thead><tr> 60<th> 61 <p> 62 Parameter 63 </p> 64 </th> 65<th> 66 <p> 67 Default 68 </p> 69 </th> 70<th> 71 <p> 72 Description 73 </p> 74 </th> 75</tr></thead> 76<tbody> 77<tr> 78<td> 79 <p> 80 typename RadiusTypeOrSphere 81 </p> 82 </td> 83<td> 84 <p> 85 double 86 </p> 87 </td> 88<td> 89 <p> 90 numeric type for radius (of sphere, earth) or sphere model 91 </p> 92 </td> 93</tr> 94<tr> 95<td> 96 <p> 97 typename CalculationType 98 </p> 99 </td> 100<td> 101 <p> 102 void 103 </p> 104 </td> 105<td> 106 <p> 107 numeric type for calculation (e.g. high precision); if <span class="bold"><strong>void</strong></span> then it is extracted automatically 108 from the coordinate type and (if necessary) promoted to floating 109 point 110 </p> 111 </td> 112</tr> 113</tbody> 114</table></div> 115<h6> 116<a name="geometry.reference.strategies.strategy_distance_haversine.h2"></a> 117 <span class="phrase"><a name="geometry.reference.strategies.strategy_distance_haversine.constructor_s_"></a></span><a class="link" href="strategy_distance_haversine.html#geometry.reference.strategies.strategy_distance_haversine.constructor_s_">Constructor(s)</a> 118 </h6> 119<div class="informaltable"><table class="table"> 120<colgroup> 121<col> 122<col> 123<col> 124</colgroup> 125<thead><tr> 126<th> 127 <p> 128 Function 129 </p> 130 </th> 131<th> 132 <p> 133 Description 134 </p> 135 </th> 136<th> 137 <p> 138 Parameters 139 </p> 140 </th> 141</tr></thead> 142<tbody> 143<tr> 144<td> 145 <p> 146</p> 147<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">haversine</span><span class="special">()</span></pre> 148<p> 149 </p> 150 </td> 151<td> 152 <p> 153 Default constructor, radius set to 1.0 for the unit sphere. 154 </p> 155 </td> 156<td> 157 </td> 158</tr> 159<tr> 160<td> 161 <p> 162</p> 163<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">RadiusOrSphere</span><span class="special">></span> 164<span class="identifier">haversine</span><span class="special">(</span><span class="identifier">RadiusOrSphere</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">radius_or_sphere</span><span class="special">)</span></pre> 165<p> 166 </p> 167 </td> 168<td> 169 <p> 170 Constructor. 171 </p> 172 </td> 173<td> 174 <p> 175 <span class="bold"><strong>RadiusOrSphere const &</strong></span>: 176 <span class="emphasis"><em>radius_or_sphere</em></span>: radius of the sphere or 177 sphere model 178 </p> 179 </td> 180</tr> 181</tbody> 182</table></div> 183<h6> 184<a name="geometry.reference.strategies.strategy_distance_haversine.h3"></a> 185 <span class="phrase"><a name="geometry.reference.strategies.strategy_distance_haversine.member_function_s_"></a></span><a class="link" href="strategy_distance_haversine.html#geometry.reference.strategies.strategy_distance_haversine.member_function_s_">Member 186 Function(s)</a> 187 </h6> 188<div class="informaltable"><table class="table"> 189<colgroup> 190<col> 191<col> 192<col> 193<col> 194</colgroup> 195<thead><tr> 196<th> 197 <p> 198 Function 199 </p> 200 </th> 201<th> 202 <p> 203 Description 204 </p> 205 </th> 206<th> 207 <p> 208 Parameters 209 </p> 210 </th> 211<th> 212 <p> 213 Returns 214 </p> 215 </th> 216</tr></thead> 217<tbody> 218<tr> 219<td> 220 <p> 221</p> 222<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Point1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Point2</span><span class="special">></span> 223<span class="identifier">calculation_type</span><span class="special"><</span> <span class="identifier">Point1</span><span class="special">,</span> <span class="identifier">Point2</span> <span class="special">>::</span><span class="identifier">type</span> <span class="identifier">apply</span><span class="special">(</span><span class="identifier">Point1</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">p1</span><span class="special">,</span> <span class="identifier">Point2</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">p2</span><span class="special">)</span></pre> 224<p> 225 </p> 226 </td> 227<td> 228 <p> 229 applies the distance calculation 230 </p> 231 </td> 232<td> 233 <p> 234 <span class="bold"><strong>Point1 const &</strong></span>: <span class="emphasis"><em>p1</em></span>: 235 first point 236 </p> 237 <p> 238 <span class="bold"><strong>Point2 const &</strong></span>: <span class="emphasis"><em>p2</em></span>: 239 second point 240 </p> 241 </td> 242<td> 243 <p> 244 the calculated distance (including multiplying with radius) 245 </p> 246 </td> 247</tr> 248<tr> 249<td> 250 <p> 251</p> 252<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">radius_type</span> <span class="identifier">radius</span><span class="special">()</span></pre> 253<p> 254 </p> 255 </td> 256<td> 257 <p> 258 access to radius value 259 </p> 260 </td> 261<td> 262 </td> 263<td> 264 <p> 265 the radius 266 </p> 267 </td> 268</tr> 269</tbody> 270</table></div> 271<h6> 272<a name="geometry.reference.strategies.strategy_distance_haversine.h4"></a> 273 <span class="phrase"><a name="geometry.reference.strategies.strategy_distance_haversine.header"></a></span><a class="link" href="strategy_distance_haversine.html#geometry.reference.strategies.strategy_distance_haversine.header">Header</a> 274 </h6> 275<p> 276 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">strategies</span><span class="special">/</span><span class="identifier">spherical</span><span class="special">/</span><span class="identifier">distance_haversine</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 277 </p> 278</div> 279<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 280<td align="left"></td> 281<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 282 Wulkiewicz, Oracle and/or its affiliates<p> 283 Distributed under the Boost Software License, Version 1.0. (See accompanying 284 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 285 </p> 286</div></td> 287</tr></table> 288<hr> 289<div class="spirit-nav"> 290<a accesskey="p" href="strategy_distance_pythagoras_point_box.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../strategies.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="strategy_distance_projected_point.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 291</div> 292</body> 293</html> 294