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