1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>discrete_frechet_distance (with strategy)</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="../discrete_frechet_distance.html" title="discrete_frechet_distance"> 9<link rel="prev" href="../discrete_frechet_distance.html" title="discrete_frechet_distance"> 10<link rel="next" href="discrete_frechet_distance_2.html" title="discrete_frechet_distance"> 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="../discrete_frechet_distance.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../discrete_frechet_distance.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="discrete_frechet_distance_2.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h5 class="title"> 27<a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy"></a><a class="link" href="discrete_frechet_distance_3_with_strategy.html" title="discrete_frechet_distance (with strategy)">discrete_frechet_distance 28 (with strategy)</a> 29</h5></div></div></div> 30<p> 31 <a class="indexterm" name="idm45635701104224"></a> 32Calculate discrete Frechet distance between two geometries (currently 33 works for LineString-LineString) using specified strategy. 34 </p> 35<h6> 36<a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.h0"></a> 37 <span class="phrase"><a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.synopsis"></a></span><a class="link" href="discrete_frechet_distance_3_with_strategy.html#geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.synopsis">Synopsis</a> 38 </h6> 39<p> 40</p> 41<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Geometry1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Geometry2</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Strategy</span><span class="special">></span> 42<span class="identifier">distance_result</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">point_type</span><span class="special"><</span><span class="identifier">Geometry1</span><span class="special">>::</span><span class="identifier">type</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">point_type</span><span class="special"><</span><span class="identifier">Geometry2</span><span class="special">>::</span><span class="identifier">type</span><span class="special">,</span> <span class="identifier">Strategy</span> <span class="special">>::</span><span class="identifier">type</span> <span class="identifier">discrete_frechet_distance</span><span class="special">(</span><span class="identifier">Geometry1</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">geometry1</span><span class="special">,</span> <span class="identifier">Geometry2</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">geometry2</span><span class="special">,</span> <span class="identifier">Strategy</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">strategy</span><span class="special">)</span></pre> 43<p> 44 </p> 45<h6> 46<a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.h1"></a> 47 <span class="phrase"><a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.parameters"></a></span><a class="link" href="discrete_frechet_distance_3_with_strategy.html#geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.parameters">Parameters</a> 48 </h6> 49<div class="informaltable"><table class="table"> 50<colgroup> 51<col> 52<col> 53<col> 54<col> 55</colgroup> 56<thead><tr> 57<th> 58 <p> 59 Type 60 </p> 61 </th> 62<th> 63 <p> 64 Concept 65 </p> 66 </th> 67<th> 68 <p> 69 Name 70 </p> 71 </th> 72<th> 73 <p> 74 Description 75 </p> 76 </th> 77</tr></thead> 78<tbody> 79<tr> 80<td> 81 <p> 82 Geometry1 const & 83 </p> 84 </td> 85<td> 86 <p> 87 Any type fulfilling a Geometry Concept 88 </p> 89 </td> 90<td> 91 <p> 92 geometry1 93 </p> 94 </td> 95<td> 96 <p> 97 Input geometry 98 </p> 99 </td> 100</tr> 101<tr> 102<td> 103 <p> 104 Geometry2 const & 105 </p> 106 </td> 107<td> 108 <p> 109 Any type fulfilling a Geometry Concept 110 </p> 111 </td> 112<td> 113 <p> 114 geometry2 115 </p> 116 </td> 117<td> 118 <p> 119 Input geometry 120 </p> 121 </td> 122</tr> 123<tr> 124<td> 125 <p> 126 Strategy const & 127 </p> 128 </td> 129<td> 130 <p> 131 A type fulfilling a DistanceStrategy concept 132 </p> 133 </td> 134<td> 135 <p> 136 strategy 137 </p> 138 </td> 139<td> 140 <p> 141 Distance strategy to be used to calculate Pt-Pt distance 142 </p> 143 </td> 144</tr> 145</tbody> 146</table></div> 147<h6> 148<a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.h2"></a> 149 <span class="phrase"><a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.header"></a></span><a class="link" href="discrete_frechet_distance_3_with_strategy.html#geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.header">Header</a> 150 </h6> 151<p> 152 Either 153 </p> 154<p> 155 <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">hpp</span><span class="special">></span></code> 156 </p> 157<p> 158 Or 159 </p> 160<p> 161 <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">algorithms</span><span class="special">/</span><span class="identifier">discrete_frechet_distance</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 162 </p> 163<h6> 164<a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.h3"></a> 165 <span class="phrase"><a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.behavior"></a></span><a class="link" href="discrete_frechet_distance_3_with_strategy.html#geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.behavior">Behavior</a> 166 </h6> 167<p> 168 The algorithm calculate discrete frechet distance between two geometries. 169 </p> 170<div class="note"><table border="0" summary="Note"> 171<tr> 172<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../doc/src/images/note.png"></td> 173<th align="left">Note</th> 174</tr> 175<tr><td align="left" valign="top"><p> 176 The units of the distance depends on strategy. In order to change the 177 default behavior a user has to create a strategy and pass it explicitly 178 into the algorithm. 179 </p></td></tr> 180</table></div> 181<h6> 182<a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.h4"></a> 183 <span class="phrase"><a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.available_strategies"></a></span><a class="link" href="discrete_frechet_distance_3_with_strategy.html#geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.available_strategies">Available 184 Strategies</a> 185 </h6> 186<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 187<li class="listitem"> 188 <a class="link" href="../../strategies/strategy_distance_pythagoras.html" title="strategy::distance::pythagoras">Pythagoras 189 (cartesian)</a> 190 </li> 191<li class="listitem"> 192 <a class="link" href="../../strategies/strategy_distance_haversine.html" title="strategy::distance::haversine">Haversine 193 (spherical)</a> 194 </li> 195</ul></div> 196<h6> 197<a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.h5"></a> 198 <span class="phrase"><a name="geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.example"></a></span><a class="link" href="discrete_frechet_distance_3_with_strategy.html#geometry.reference.algorithms.discrete_frechet_distance.discrete_frechet_distance_3_with_strategy.example">Example</a> 199 </h6> 200<p> 201 Calculate Similarity between two geometries as the discrete frechet distance 202 between them. 203 </p> 204<p> 205</p> 206<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 207 208<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">hpp</span><span class="special">></span> 209<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">geometries</span><span class="special">/</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 210<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">geometries</span><span class="special">/</span><span class="identifier">linestring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 211 212<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 213<span class="special">{</span> 214 <span class="keyword">namespace</span> <span class="identifier">bg</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">;</span> 215 <span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">geographic</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">degree</span><span class="special">></span> <span class="special">></span> <span class="identifier">point_type</span><span class="special">;</span> 216 <span class="keyword">typedef</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">linestring</span><span class="special"><</span><span class="identifier">point_type</span><span class="special">></span> <span class="identifier">linestring_type</span><span class="special">;</span> 217 218 <span class="identifier">linestring_type</span> <span class="identifier">ls1</span><span class="special">,</span> <span class="identifier">ls2</span><span class="special">;</span> 219 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">read_wkt</span><span class="special">(</span><span class="string">"LINESTRING(0 0,1 1,1 2,2 1,2 2)"</span><span class="special">,</span> <span class="identifier">ls1</span><span class="special">);</span> 220 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">read_wkt</span><span class="special">(</span><span class="string">"LINESTRING(1 0,0 1,1 1,2 1,3 1)"</span><span class="special">,</span> <span class="identifier">ls2</span><span class="special">);</span> 221 222 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">srs</span><span class="special">::</span><span class="identifier">spheroid</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">spheroid</span><span class="special">(</span><span class="number">6378137.0</span><span class="special">,</span> <span class="number">6356752.3142451793</span><span class="special">);</span> 223 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">strategy</span><span class="special">::</span><span class="identifier">distance</span><span class="special">::</span><span class="identifier">geographic</span><span class="special"><></span> <span class="identifier">strategy</span><span class="special">(</span><span class="identifier">spheroid</span><span class="special">);</span> 224 225 <span class="keyword">double</span> <span class="identifier">res</span> <span class="special">=</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">discrete_frechet_distance</span><span class="special">(</span><span class="identifier">ls1</span><span class="special">,</span> <span class="identifier">ls2</span><span class="special">,</span> <span class="identifier">strategy</span><span class="special">);</span> 226 227 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Discrete Frechet Distance: "</span> <span class="special"><<</span> <span class="identifier">res</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 228 229 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 230<span class="special">}</span> 231</pre> 232<p> 233 </p> 234<p> 235 Output: 236 </p> 237<pre class="programlisting">Discrete Frechet Distance: 156874 238</pre> 239</div> 240<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 241<td align="left"></td> 242<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 243 Wulkiewicz, Oracle and/or its affiliates<p> 244 Distributed under the Boost Software License, Version 1.0. (See accompanying 245 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>) 246 </p> 247</div></td> 248</tr></table> 249<hr> 250<div class="spirit-nav"> 251<a accesskey="p" href="../discrete_frechet_distance.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../discrete_frechet_distance.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="discrete_frechet_distance_2.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 252</div> 253</body> 254</html> 255