• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>comparable_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="../distance.html" title="distance">
9<link rel="prev" href="comparable_distance_3_with_strategy.html" title="comparable_distance (with strategy)">
10<link rel="next" href="distance_3_with_strategy.html" title="distance (with strategy)">
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="comparable_distance_3_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../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="distance_3_with_strategy.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.distance.comparable_distance_2"></a><a class="link" href="comparable_distance_2.html" title="comparable_distance">comparable_distance</a>
28</h5></div></div></div>
29<p>
30            <a class="indexterm" name="idm45635699553040"></a>
31Calculate the comparable distance measurement of two geometries.
32          </p>
33<h6>
34<a name="geometry.reference.algorithms.distance.comparable_distance_2.h0"></a>
35            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.description"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.description">Description</a>
36          </h6>
37<p>
38            The free function comparable_distance does not necessarily calculate
39            the distance, but it calculates a distance measure such that two distances
40            are comparable to each other. For example: for the Cartesian coordinate
41            system, Pythagoras is used but the square root is not taken, which makes
42            it faster and the results of two point pairs can still be compared to
43            each other.
44          </p>
45<h6>
46<a name="geometry.reference.algorithms.distance.comparable_distance_2.h1"></a>
47            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.synopsis"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.synopsis">Synopsis</a>
48          </h6>
49<p>
50</p>
51<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>
52<span class="identifier">default_comparable_distance_result</span><span class="special">&lt;</span><span class="identifier">Geometry1</span><span class="special">,</span> <span class="identifier">Geometry2</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">comparable_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>
53<p>
54          </p>
55<h6>
56<a name="geometry.reference.algorithms.distance.comparable_distance_2.h2"></a>
57            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.parameters"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.parameters">Parameters</a>
58          </h6>
59<div class="informaltable"><table class="table">
60<colgroup>
61<col>
62<col>
63<col>
64<col>
65</colgroup>
66<thead><tr>
67<th>
68                    <p>
69                      Type
70                    </p>
71                  </th>
72<th>
73                    <p>
74                      Concept
75                    </p>
76                  </th>
77<th>
78                    <p>
79                      Name
80                    </p>
81                  </th>
82<th>
83                    <p>
84                      Description
85                    </p>
86                  </th>
87</tr></thead>
88<tbody>
89<tr>
90<td>
91                    <p>
92                      Geometry1 const &amp;
93                    </p>
94                  </td>
95<td>
96                    <p>
97                      first geometry type
98                    </p>
99                  </td>
100<td>
101                    <p>
102                      geometry1
103                    </p>
104                  </td>
105<td>
106                    <p>
107                      A model of the specified concept
108                    </p>
109                  </td>
110</tr>
111<tr>
112<td>
113                    <p>
114                      Geometry2 const &amp;
115                    </p>
116                  </td>
117<td>
118                    <p>
119                      second geometry type
120                    </p>
121                  </td>
122<td>
123                    <p>
124                      geometry2
125                    </p>
126                  </td>
127<td>
128                    <p>
129                      A model of the specified concept
130                    </p>
131                  </td>
132</tr>
133</tbody>
134</table></div>
135<h6>
136<a name="geometry.reference.algorithms.distance.comparable_distance_2.h3"></a>
137            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.returns"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.returns">Returns</a>
138          </h6>
139<p>
140            The calculated comparable distance
141          </p>
142<h6>
143<a name="geometry.reference.algorithms.distance.comparable_distance_2.h4"></a>
144            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.header"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.header">Header</a>
145          </h6>
146<p>
147            Either
148          </p>
149<p>
150            <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>
151          </p>
152<p>
153            Or
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">algorithms</span><span class="special">/</span><span class="identifier">comparable_distance</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
157          </p>
158<h6>
159<a name="geometry.reference.algorithms.distance.comparable_distance_2.h5"></a>
160            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.conformance"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.conformance">Conformance</a>
161          </h6>
162<p>
163            The function comparable_distance is not defined by OGC.
164          </p>
165<h6>
166<a name="geometry.reference.algorithms.distance.comparable_distance_2.h6"></a>
167            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.behaviour"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.behaviour">Behaviour</a>
168          </h6>
169<p>
170            It depends on the coordinate system of the geometry's point type if there
171            is a strategy available which can determine (more efficient than the
172            standard strategy) a measure of comparable distance.
173          </p>
174<h6>
175<a name="geometry.reference.algorithms.distance.comparable_distance_2.h7"></a>
176            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.supported_geometries"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.supported_geometries">Supported
177            geometries</a>
178          </h6>
179<div class="informaltable"><table class="table">
180<colgroup>
181<col>
182<col>
183<col>
184<col>
185<col>
186<col>
187<col>
188<col>
189<col>
190<col>
191<col>
192</colgroup>
193<thead><tr>
194<th>
195                  </th>
196<th>
197                    <p>
198                      Point
199                    </p>
200                  </th>
201<th>
202                    <p>
203                      Segment
204                    </p>
205                  </th>
206<th>
207                    <p>
208                      Box
209                    </p>
210                  </th>
211<th>
212                    <p>
213                      Linestring
214                    </p>
215                  </th>
216<th>
217                    <p>
218                      Ring
219                    </p>
220                  </th>
221<th>
222                    <p>
223                      Polygon
224                    </p>
225                  </th>
226<th>
227                    <p>
228                      MultiPoint
229                    </p>
230                  </th>
231<th>
232                    <p>
233                      MultiLinestring
234                    </p>
235                  </th>
236<th>
237                    <p>
238                      MultiPolygon
239                    </p>
240                  </th>
241<th>
242                    <p>
243                      Variant
244                    </p>
245                  </th>
246</tr></thead>
247<tbody>
248<tr>
249<td>
250                    <p>
251                      Point
252                    </p>
253                  </td>
254<td>
255                    <p>
256                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
257                    </p>
258                  </td>
259<td>
260                    <p>
261                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
262                    </p>
263                  </td>
264<td>
265                    <p>
266                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
267                    </p>
268                  </td>
269<td>
270                    <p>
271                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
272                    </p>
273                  </td>
274<td>
275                    <p>
276                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
277                    </p>
278                  </td>
279<td>
280                    <p>
281                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
282                    </p>
283                  </td>
284<td>
285                    <p>
286                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
287                    </p>
288                  </td>
289<td>
290                    <p>
291                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
292                    </p>
293                  </td>
294<td>
295                    <p>
296                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
297                    </p>
298                  </td>
299<td>
300                    <p>
301                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
302                    </p>
303                  </td>
304</tr>
305<tr>
306<td>
307                    <p>
308                      Segment
309                    </p>
310                  </td>
311<td>
312                    <p>
313                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
314                    </p>
315                  </td>
316<td>
317                    <p>
318                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
319                    </p>
320                  </td>
321<td>
322                    <p>
323                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
324                    </p>
325                  </td>
326<td>
327                    <p>
328                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
329                    </p>
330                  </td>
331<td>
332                    <p>
333                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
334                    </p>
335                  </td>
336<td>
337                    <p>
338                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
339                    </p>
340                  </td>
341<td>
342                    <p>
343                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
344                    </p>
345                  </td>
346<td>
347                    <p>
348                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
349                    </p>
350                  </td>
351<td>
352                    <p>
353                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
354                    </p>
355                  </td>
356<td>
357                    <p>
358                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
359                    </p>
360                  </td>
361</tr>
362<tr>
363<td>
364                    <p>
365                      Box
366                    </p>
367                  </td>
368<td>
369                    <p>
370                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
371                    </p>
372                  </td>
373<td>
374                    <p>
375                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
376                    </p>
377                  </td>
378<td>
379                    <p>
380                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
381                    </p>
382                  </td>
383<td>
384                    <p>
385                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
386                    </p>
387                  </td>
388<td>
389                    <p>
390                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
391                    </p>
392                  </td>
393<td>
394                    <p>
395                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
396                    </p>
397                  </td>
398<td>
399                    <p>
400                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
401                    </p>
402                  </td>
403<td>
404                    <p>
405                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
406                    </p>
407                  </td>
408<td>
409                    <p>
410                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
411                    </p>
412                  </td>
413<td>
414                    <p>
415                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
416                    </p>
417                  </td>
418</tr>
419<tr>
420<td>
421                    <p>
422                      Linestring
423                    </p>
424                  </td>
425<td>
426                    <p>
427                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
428                    </p>
429                  </td>
430<td>
431                    <p>
432                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
433                    </p>
434                  </td>
435<td>
436                    <p>
437                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
438                    </p>
439                  </td>
440<td>
441                    <p>
442                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
443                    </p>
444                  </td>
445<td>
446                    <p>
447                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
448                    </p>
449                  </td>
450<td>
451                    <p>
452                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
453                    </p>
454                  </td>
455<td>
456                    <p>
457                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
458                    </p>
459                  </td>
460<td>
461                    <p>
462                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
463                    </p>
464                  </td>
465<td>
466                    <p>
467                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
468                    </p>
469                  </td>
470<td>
471                    <p>
472                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
473                    </p>
474                  </td>
475</tr>
476<tr>
477<td>
478                    <p>
479                      Ring
480                    </p>
481                  </td>
482<td>
483                    <p>
484                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
485                    </p>
486                  </td>
487<td>
488                    <p>
489                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
490                    </p>
491                  </td>
492<td>
493                    <p>
494                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
495                    </p>
496                  </td>
497<td>
498                    <p>
499                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
500                    </p>
501                  </td>
502<td>
503                    <p>
504                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
505                    </p>
506                  </td>
507<td>
508                    <p>
509                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
510                    </p>
511                  </td>
512<td>
513                    <p>
514                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
515                    </p>
516                  </td>
517<td>
518                    <p>
519                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
520                    </p>
521                  </td>
522<td>
523                    <p>
524                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
525                    </p>
526                  </td>
527<td>
528                    <p>
529                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
530                    </p>
531                  </td>
532</tr>
533<tr>
534<td>
535                    <p>
536                      Polygon
537                    </p>
538                  </td>
539<td>
540                    <p>
541                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
542                    </p>
543                  </td>
544<td>
545                    <p>
546                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
547                    </p>
548                  </td>
549<td>
550                    <p>
551                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
552                    </p>
553                  </td>
554<td>
555                    <p>
556                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
557                    </p>
558                  </td>
559<td>
560                    <p>
561                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
562                    </p>
563                  </td>
564<td>
565                    <p>
566                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
567                    </p>
568                  </td>
569<td>
570                    <p>
571                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
572                    </p>
573                  </td>
574<td>
575                    <p>
576                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
577                    </p>
578                  </td>
579<td>
580                    <p>
581                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
582                    </p>
583                  </td>
584<td>
585                    <p>
586                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
587                    </p>
588                  </td>
589</tr>
590<tr>
591<td>
592                    <p>
593                      MultiPoint
594                    </p>
595                  </td>
596<td>
597                    <p>
598                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
599                    </p>
600                  </td>
601<td>
602                    <p>
603                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
604                    </p>
605                  </td>
606<td>
607                    <p>
608                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
609                    </p>
610                  </td>
611<td>
612                    <p>
613                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
614                    </p>
615                  </td>
616<td>
617                    <p>
618                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
619                    </p>
620                  </td>
621<td>
622                    <p>
623                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
624                    </p>
625                  </td>
626<td>
627                    <p>
628                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
629                    </p>
630                  </td>
631<td>
632                    <p>
633                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
634                    </p>
635                  </td>
636<td>
637                    <p>
638                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
639                    </p>
640                  </td>
641<td>
642                    <p>
643                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
644                    </p>
645                  </td>
646</tr>
647<tr>
648<td>
649                    <p>
650                      MultiLinestring
651                    </p>
652                  </td>
653<td>
654                    <p>
655                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
656                    </p>
657                  </td>
658<td>
659                    <p>
660                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
661                    </p>
662                  </td>
663<td>
664                    <p>
665                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
666                    </p>
667                  </td>
668<td>
669                    <p>
670                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
671                    </p>
672                  </td>
673<td>
674                    <p>
675                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
676                    </p>
677                  </td>
678<td>
679                    <p>
680                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
681                    </p>
682                  </td>
683<td>
684                    <p>
685                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
686                    </p>
687                  </td>
688<td>
689                    <p>
690                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
691                    </p>
692                  </td>
693<td>
694                    <p>
695                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
696                    </p>
697                  </td>
698<td>
699                    <p>
700                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
701                    </p>
702                  </td>
703</tr>
704<tr>
705<td>
706                    <p>
707                      MultiPolygon
708                    </p>
709                  </td>
710<td>
711                    <p>
712                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
713                    </p>
714                  </td>
715<td>
716                    <p>
717                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
718                    </p>
719                  </td>
720<td>
721                    <p>
722                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
723                    </p>
724                  </td>
725<td>
726                    <p>
727                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
728                    </p>
729                  </td>
730<td>
731                    <p>
732                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
733                    </p>
734                  </td>
735<td>
736                    <p>
737                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
738                    </p>
739                  </td>
740<td>
741                    <p>
742                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
743                    </p>
744                  </td>
745<td>
746                    <p>
747                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
748                    </p>
749                  </td>
750<td>
751                    <p>
752                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
753                    </p>
754                  </td>
755<td>
756                    <p>
757                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
758                    </p>
759                  </td>
760</tr>
761<tr>
762<td>
763                    <p>
764                      Variant
765                    </p>
766                  </td>
767<td>
768                    <p>
769                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
770                    </p>
771                  </td>
772<td>
773                    <p>
774                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
775                    </p>
776                  </td>
777<td>
778                    <p>
779                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
780                    </p>
781                  </td>
782<td>
783                    <p>
784                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
785                    </p>
786                  </td>
787<td>
788                    <p>
789                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
790                    </p>
791                  </td>
792<td>
793                    <p>
794                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
795                    </p>
796                  </td>
797<td>
798                    <p>
799                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
800                    </p>
801                  </td>
802<td>
803                    <p>
804                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
805                    </p>
806                  </td>
807<td>
808                    <p>
809                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
810                    </p>
811                  </td>
812<td>
813                    <p>
814                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
815                    </p>
816                  </td>
817</tr>
818</tbody>
819</table></div>
820<h6>
821<a name="geometry.reference.algorithms.distance.comparable_distance_2.h8"></a>
822            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.complexity"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.complexity">Complexity</a>
823          </h6>
824<p>
825            For point to geometry: linear
826          </p>
827<p>
828            For multi-point to ring/polygon/multi-polygon: currently quadratic
829          </p>
830<p>
831            For all other geometry combinations: linearithmic
832          </p>
833<h6>
834<a name="geometry.reference.algorithms.distance.comparable_distance_2.h9"></a>
835            <span class="phrase"><a name="geometry.reference.algorithms.distance.comparable_distance_2.example"></a></span><a class="link" href="comparable_distance_2.html#geometry.reference.algorithms.distance.comparable_distance_2.example">Example</a>
836          </h6>
837<p>
838            Shows how to efficiently get the closest point
839          </p>
840<p>
841</p>
842<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
843
844<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>
845<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>
846
847<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">numeric</span><span class="special">/</span><span class="identifier">conversion</span><span class="special">/</span><span class="identifier">bounds</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
848<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">foreach</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
849
850<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
851<span class="special">{</span>
852    <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>
853
854    <span class="identifier">point_type</span> <span class="identifier">p</span><span class="special">(</span><span class="number">1.4</span><span class="special">,</span> <span class="number">2.6</span><span class="special">);</span>
855
856    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">point_type</span><span class="special">&gt;</span> <span class="identifier">v</span><span class="special">;</span>
857    <span class="keyword">for</span> <span class="special">(</span><span class="keyword">double</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">0.0</span><span class="special">;</span> <span class="identifier">x</span> <span class="special">&lt;=</span> <span class="number">4.0</span><span class="special">;</span> <span class="identifier">x</span><span class="special">++)</span>
858    <span class="special">{</span>
859        <span class="keyword">for</span> <span class="special">(</span><span class="keyword">double</span> <span class="identifier">y</span> <span class="special">=</span> <span class="number">0.0</span><span class="special">;</span> <span class="identifier">y</span> <span class="special">&lt;=</span> <span class="number">4.0</span><span class="special">;</span> <span class="identifier">y</span><span class="special">++)</span>
860        <span class="special">{</span>
861            <span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">point_type</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">));</span>
862        <span class="special">}</span>
863    <span class="special">}</span>
864
865    <span class="identifier">point_type</span> <span class="identifier">min_p</span><span class="special">;</span>
866    <span class="keyword">double</span> <span class="identifier">min_d</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">bounds</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;::</span><span class="identifier">highest</span><span class="special">();</span>
867    <span class="identifier">BOOST_FOREACH</span><span class="special">(</span><span class="identifier">point_type</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">pv</span><span class="special">,</span> <span class="identifier">v</span><span class="special">)</span>
868    <span class="special">{</span>
869        <span class="keyword">double</span> <span class="identifier">d</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">comparable_distance</span><span class="special">(</span><span class="identifier">p</span><span class="special">,</span> <span class="identifier">pv</span><span class="special">);</span>
870        <span class="keyword">if</span> <span class="special">(</span><span class="identifier">d</span> <span class="special">&lt;</span> <span class="identifier">min_d</span><span class="special">)</span>
871        <span class="special">{</span>
872            <span class="identifier">min_d</span> <span class="special">=</span> <span class="identifier">d</span><span class="special">;</span>
873            <span class="identifier">min_p</span> <span class="special">=</span> <span class="identifier">pv</span><span class="special">;</span>
874        <span class="special">}</span>
875    <span class="special">}</span>
876
877    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span>
878        <span class="special">&lt;&lt;</span> <span class="string">"Closest: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">min_p</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span>
879        <span class="special">&lt;&lt;</span> <span class="string">"At: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">distance</span><span class="special">(</span><span class="identifier">p</span><span class="special">,</span> <span class="identifier">min_p</span><span class="special">)</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>
880
881    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
882<span class="special">}</span>
883</pre>
884<p>
885          </p>
886<p>
887            Output:
888          </p>
889<pre class="programlisting">Closest: (1, 3)
890At: 0.565685
891</pre>
892</div>
893<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
894<td align="left"></td>
895<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
896      Wulkiewicz, Oracle and/or its affiliates<p>
897        Distributed under the Boost Software License, Version 1.0. (See accompanying
898        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>)
899      </p>
900</div></td>
901</tr></table>
902<hr>
903<div class="spirit-nav">
904<a accesskey="p" href="comparable_distance_3_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../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="distance_3_with_strategy.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
905</div>
906</body>
907</html>
908