1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>touches (one geometry)</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="../touches.html" title="touches"> 9<link rel="prev" href="../touches.html" title="touches"> 10<link rel="next" href="touches_2_two_geometries.html" title="touches (two geometries)"> 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="../touches.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../touches.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="touches_2_two_geometries.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.touches.touches_1_one_geometry"></a><a class="link" href="touches_1_one_geometry.html" title="touches (one geometry)">touches 28 (one geometry)</a> 29</h5></div></div></div> 30<p> 31 <a class="indexterm" name="idm45635688490736"></a> 32Checks if a geometry has at least one touching point (self-tangency) 33 </p> 34<h6> 35<a name="geometry.reference.algorithms.touches.touches_1_one_geometry.h0"></a> 36 <span class="phrase"><a name="geometry.reference.algorithms.touches.touches_1_one_geometry.synopsis"></a></span><a class="link" href="touches_1_one_geometry.html#geometry.reference.algorithms.touches.touches_1_one_geometry.synopsis">Synopsis</a> 37 </h6> 38<p> 39</p> 40<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Geometry</span><span class="special">></span> 41<span class="keyword">bool</span> <span class="identifier">touches</span><span class="special">(</span><span class="identifier">Geometry</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">geometry</span><span class="special">)</span></pre> 42<p> 43 </p> 44<h6> 45<a name="geometry.reference.algorithms.touches.touches_1_one_geometry.h1"></a> 46 <span class="phrase"><a name="geometry.reference.algorithms.touches.touches_1_one_geometry.parameters"></a></span><a class="link" href="touches_1_one_geometry.html#geometry.reference.algorithms.touches.touches_1_one_geometry.parameters">Parameters</a> 47 </h6> 48<div class="informaltable"><table class="table"> 49<colgroup> 50<col> 51<col> 52<col> 53<col> 54</colgroup> 55<thead><tr> 56<th> 57 <p> 58 Type 59 </p> 60 </th> 61<th> 62 <p> 63 Concept 64 </p> 65 </th> 66<th> 67 <p> 68 Name 69 </p> 70 </th> 71<th> 72 <p> 73 Description 74 </p> 75 </th> 76</tr></thead> 77<tbody><tr> 78<td> 79 <p> 80 Geometry const & 81 </p> 82 </td> 83<td> 84 <p> 85 Any type fulfilling a Geometry Concept 86 </p> 87 </td> 88<td> 89 <p> 90 geometry 91 </p> 92 </td> 93<td> 94 <p> 95 A model of the specified concept 96 </p> 97 </td> 98</tr></tbody> 99</table></div> 100<h6> 101<a name="geometry.reference.algorithms.touches.touches_1_one_geometry.h2"></a> 102 <span class="phrase"><a name="geometry.reference.algorithms.touches.touches_1_one_geometry.returns"></a></span><a class="link" href="touches_1_one_geometry.html#geometry.reference.algorithms.touches.touches_1_one_geometry.returns">Returns</a> 103 </h6> 104<p> 105 Returns true if the geometry is self-touching 106 </p> 107<h6> 108<a name="geometry.reference.algorithms.touches.touches_1_one_geometry.h3"></a> 109 <span class="phrase"><a name="geometry.reference.algorithms.touches.touches_1_one_geometry.header"></a></span><a class="link" href="touches_1_one_geometry.html#geometry.reference.algorithms.touches.touches_1_one_geometry.header">Header</a> 110 </h6> 111<p> 112 Either 113 </p> 114<p> 115 <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> 116 </p> 117<p> 118 Or 119 </p> 120<p> 121 <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">touches</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 122 </p> 123<h6> 124<a name="geometry.reference.algorithms.touches.touches_1_one_geometry.h4"></a> 125 <span class="phrase"><a name="geometry.reference.algorithms.touches.touches_1_one_geometry.conformance"></a></span><a class="link" href="touches_1_one_geometry.html#geometry.reference.algorithms.touches.touches_1_one_geometry.conformance">Conformance</a> 126 </h6> 127<p> 128 The function touches implements function Touches from the <a href="http://www.opengeospatial.org/standards/sfa" target="_top">OGC 129 Simple Feature Specification</a>. 130 </p> 131<p> 132 The version with one parameter is additional and not described in the 133 OGC standard 134 </p> 135<div class="note"><table border="0" summary="Note"> 136<tr> 137<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../doc/src/images/note.png"></td> 138<th align="left">Note</th> 139</tr> 140<tr><td align="left" valign="top"><p> 141 Implemented for Point/Linestring/MultiLinestring/Polygon/MultiPolygon. 142 </p></td></tr> 143</table></div> 144<h6> 145<a name="geometry.reference.algorithms.touches.touches_1_one_geometry.h5"></a> 146 <span class="phrase"><a name="geometry.reference.algorithms.touches.touches_1_one_geometry.examples"></a></span><a class="link" href="touches_1_one_geometry.html#geometry.reference.algorithms.touches.touches_1_one_geometry.examples">Examples</a> 147 </h6> 148<p> 149 Checks if a geometry has at least one touching point (self-tangency) 150 </p> 151<p> 152</p> 153<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 154 155<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> 156<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_xy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 157<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">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 158 159<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> <a class="co" name="geometry.reference.algorithms.touches.touches_1_one_geometry.c0" href="touches_1_one_geometry.html#geometry.reference.algorithms.touches.touches_1_one_geometry.c1"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> 160 161<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 162<span class="special">{</span> 163 <span class="comment">// Checks if the geometry has self-tangency.</span> 164 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">polygon</span><span class="special"><</span><span class="identifier">bg</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"><</span><span class="keyword">double</span><span class="special">></span> <span class="special">></span> <span class="identifier">poly1</span><span class="special">;</span> 165 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">read_wkt</span><span class="special">(</span><span class="string">"POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2,3 2,3 0,0 0))"</span><span class="special">,</span> <span class="identifier">poly1</span><span class="special">);</span> 166 <span class="keyword">bool</span> <span class="identifier">check_touches</span> <span class="special">=</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">touches</span><span class="special">(</span><span class="identifier">poly1</span><span class="special">);</span> 167 <span class="keyword">if</span> <span class="special">(</span><span class="identifier">check_touches</span><span class="special">)</span> <span class="special">{</span> 168 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Touches: Yes"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 169 <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span> 170 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Touches: No"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 171 <span class="special">}</span> 172 173 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">polygon</span><span class="special"><</span><span class="identifier">bg</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"><</span><span class="keyword">double</span><span class="special">></span> <span class="special">></span> <span class="identifier">poly2</span><span class="special">;</span> 174 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">read_wkt</span><span class="special">(</span><span class="string">"POLYGON((0 0,0 4,4 4,4 0,2 3,0 0))"</span><span class="special">,</span> <span class="identifier">poly2</span><span class="special">);</span> 175 <span class="identifier">check_touches</span> <span class="special">=</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">touches</span><span class="special">(</span><span class="identifier">poly2</span><span class="special">);</span> 176 <span class="keyword">if</span> <span class="special">(</span><span class="identifier">check_touches</span><span class="special">)</span> <span class="special">{</span> 177 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Touches: Yes"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 178 <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span> 179 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Touches: No"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 180 <span class="special">}</span> 181 182 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 183<span class="special">}</span> 184</pre> 185<p> 186 </p> 187<div class="calloutlist"><table border="0" summary="Callout list"><tr> 188<td width="5%" valign="top" align="left"><p><a name="geometry.reference.algorithms.touches.touches_1_one_geometry.c1"></a><a href="#geometry.reference.algorithms.touches.touches_1_one_geometry.c0"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> 189<td valign="top" align="left"><p> 190 Convenient namespace alias 191 </p></td> 192</tr></table></div> 193<p> 194 Output: 195 </p> 196<pre class="programlisting">Touches: Yes 197 198<img src="../../../../img/algorithms/touches_one_geometry.png" alt="touches_one_geometry"> 199 200Touches: No 201</pre> 202</div> 203<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 204<td align="left"></td> 205<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 206 Wulkiewicz, Oracle and/or its affiliates<p> 207 Distributed under the Boost Software License, Version 1.0. (See accompanying 208 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>) 209 </p> 210</div></td> 211</tr></table> 212<hr> 213<div class="spirit-nav"> 214<a accesskey="p" href="../touches.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../touches.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="touches_2_two_geometries.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 215</div> 216</body> 217</html> 218