• 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</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_3_with_strategy.html" title="discrete_hausdorff_distance (with strategy)">
10<link rel="next" href="../disjoint.html" title="disjoint">
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_3_with_strategy.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="../disjoint.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_2"></a><a class="link" href="discrete_hausdorff_distance_2.html" title="discrete_hausdorff_distance">discrete_hausdorff_distance</a>
28</h5></div></div></div>
29<p>
30            <a class="indexterm" name="idm45635700586800"></a>
31Calculate discrete Hausdorff distance between two geometries (currently
32            works for LineString-LineString, MultiPoint-MultiPoint, Point-MultiPoint,
33            MultiLineString-MultiLineString).
34          </p>
35<h6>
36<a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.h0"></a>
37            <span class="phrase"><a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.synopsis"></a></span><a class="link" href="discrete_hausdorff_distance_2.html#geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.synopsis">Synopsis</a>
38          </h6>
39<p>
40</p>
41<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">&gt;</span>
42<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">&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></pre>
43<p>
44          </p>
45<h6>
46<a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.h1"></a>
47            <span class="phrase"><a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.parameters"></a></span><a class="link" href="discrete_hausdorff_distance_2.html#geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.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 &amp;
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 &amp;
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</tbody>
124</table></div>
125<h6>
126<a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.h2"></a>
127            <span class="phrase"><a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.header"></a></span><a class="link" href="discrete_hausdorff_distance_2.html#geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.header">Header</a>
128          </h6>
129<p>
130            Either
131          </p>
132<p>
133            <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>
134          </p>
135<p>
136            Or
137          </p>
138<p>
139            <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>
140          </p>
141<h6>
142<a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.h3"></a>
143            <span class="phrase"><a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.behavior"></a></span><a class="link" href="discrete_hausdorff_distance_2.html#geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.behavior">Behavior</a>
144          </h6>
145<p>
146            The algorithm calculate discrete hausdorff distance between two geometries.
147          </p>
148<div class="note"><table border="0" summary="Note">
149<tr>
150<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../doc/src/images/note.png"></td>
151<th align="left">Note</th>
152</tr>
153<tr><td align="left" valign="top"><p>
154              The units of the distance depends on strategy. In order to change the
155              default behavior a user has to create a strategy and pass it explicitly
156              into the algorithm.
157            </p></td></tr>
158</table></div>
159<h6>
160<a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.h4"></a>
161            <span class="phrase"><a name="geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.example"></a></span><a class="link" href="discrete_hausdorff_distance_2.html#geometry.reference.algorithms.discrete_hausdorff_distance.discrete_hausdorff_distance_2.example">Example</a>
162          </h6>
163<p>
164            Calculate Similarity between two geometries as the discrete hasdorff
165            distance between them.
166          </p>
167<p>
168</p>
169<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
170
171<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>
172<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_xy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
173<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>
174
175<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
176<span class="special">{</span>
177    <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">d2</span><span class="special">::</span><span class="identifier">point_xy</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">point_type</span><span class="special">;</span>
178    <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</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>
179
180    <span class="identifier">linestring_type</span> <span class="identifier">ls1</span><span class="special">,</span> <span class="identifier">ls2</span><span class="special">;</span>
181    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</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">ls2</span><span class="special">);</span>
182    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</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>
183
184    <span class="keyword">double</span> <span class="identifier">res</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">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>
185
186    <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>
187
188    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
189<span class="special">}</span>
190</pre>
191<p>
192          </p>
193<p>
194            Output:
195          </p>
196<pre class="programlisting">Discrete Hausdorff Distance: 1.0
197</pre>
198</div>
199<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
200<td align="left"></td>
201<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
202      Wulkiewicz, Oracle and/or its affiliates<p>
203        Distributed under the Boost Software License, Version 1.0. (See accompanying
204        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>)
205      </p>
206</div></td>
207</tr></table>
208<hr>
209<div class="spirit-nav">
210<a accesskey="p" href="discrete_hausdorff_distance_3_with_strategy.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="../disjoint.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
211</div>
212</body>
213</html>
214