1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>intersects (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="../intersects.html" title="intersects"> 9<link rel="prev" href="intersects_1_one_geometry.html" title="intersects (one geometry)"> 10<link rel="next" href="intersects_2_two_geometries.html" title="intersects (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="intersects_1_one_geometry.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intersects.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="intersects_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.intersects.intersects_3_with_strategy"></a><a class="link" href="intersects_3_with_strategy.html" title="intersects (with strategy)">intersects 28 (with strategy)</a> 29</h5></div></div></div> 30<p> 31 <a class="indexterm" name="idm45635695377904"></a> 32Checks if two geometries have at least one intersection. 33 </p> 34<h6> 35<a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.h0"></a> 36 <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.synopsis"></a></span><a class="link" href="intersects_3_with_strategy.html#geometry.reference.algorithms.intersects.intersects_3_with_strategy.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">Geometry1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Geometry2</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Strategy</span><span class="special">></span> 41<span class="keyword">bool</span> <span class="identifier">intersects</span><span class="special">(</span><span class="identifier">Geometry1</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">geometry1</span><span class="special">,</span> <span class="identifier">Geometry2</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">geometry2</span><span class="special">,</span> <span class="identifier">Strategy</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">strategy</span><span class="special">)</span></pre> 42<p> 43 </p> 44<h6> 45<a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.h1"></a> 46 <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.parameters"></a></span><a class="link" href="intersects_3_with_strategy.html#geometry.reference.algorithms.intersects.intersects_3_with_strategy.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> 78<tr> 79<td> 80 <p> 81 Geometry1 const & 82 </p> 83 </td> 84<td> 85 <p> 86 Any type fulfilling a Geometry Concept 87 </p> 88 </td> 89<td> 90 <p> 91 geometry1 92 </p> 93 </td> 94<td> 95 <p> 96 A model of the specified concept 97 </p> 98 </td> 99</tr> 100<tr> 101<td> 102 <p> 103 Geometry2 const & 104 </p> 105 </td> 106<td> 107 <p> 108 Any type fulfilling a Geometry Concept 109 </p> 110 </td> 111<td> 112 <p> 113 geometry2 114 </p> 115 </td> 116<td> 117 <p> 118 A model of the specified concept 119 </p> 120 </td> 121</tr> 122<tr> 123<td> 124 <p> 125 Strategy const & 126 </p> 127 </td> 128<td> 129 <p> 130 Any type fulfilling a Intersects Strategy Concept 131 </p> 132 </td> 133<td> 134 <p> 135 strategy 136 </p> 137 </td> 138<td> 139 <p> 140 The strategy which will be used for intersects calculations 141 </p> 142 </td> 143</tr> 144</tbody> 145</table></div> 146<h6> 147<a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.h2"></a> 148 <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.returns"></a></span><a class="link" href="intersects_3_with_strategy.html#geometry.reference.algorithms.intersects.intersects_3_with_strategy.returns">Returns</a> 149 </h6> 150<p> 151 Returns true if two geometries intersect each other 152 </p> 153<h6> 154<a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.h3"></a> 155 <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.header"></a></span><a class="link" href="intersects_3_with_strategy.html#geometry.reference.algorithms.intersects.intersects_3_with_strategy.header">Header</a> 156 </h6> 157<p> 158 Either 159 </p> 160<p> 161 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 162 </p> 163<p> 164 Or 165 </p> 166<p> 167 <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">intersects</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 168 </p> 169<h6> 170<a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.h4"></a> 171 <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.conformance"></a></span><a class="link" href="intersects_3_with_strategy.html#geometry.reference.algorithms.intersects.intersects_3_with_strategy.conformance">Conformance</a> 172 </h6> 173<p> 174 The function intersects implements function Intersects from the <a href="http://www.opengeospatial.org/standards/sfa" target="_top">OGC Simple Feature 175 Specification</a>. 176 </p> 177<p> 178 The version with one parameter is additional and not described in the 179 OGC standard 180 </p> 181<h6> 182<a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.h5"></a> 183 <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_3_with_strategy.examples"></a></span><a class="link" href="intersects_3_with_strategy.html#geometry.reference.algorithms.intersects.intersects_3_with_strategy.examples">Examples</a> 184 </h6> 185<p> 186 Check if two linestrings intersect each other 187 </p> 188<p> 189</p> 190<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 191 192<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> 193<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">linestring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 194<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> 195 196<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 197<span class="special">{</span> 198 <span class="comment">// Calculate the intersects of a cartesian polygon</span> 199 <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"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">P</span><span class="special">;</span> 200 <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"><</span><span class="identifier">P</span><span class="special">></span> <span class="identifier">line1</span><span class="special">,</span> <span class="identifier">line2</span><span class="special">;</span> 201 202 <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 1,2 2,3 3)"</span><span class="special">,</span> <span class="identifier">line1</span><span class="special">);</span> 203 <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(2 1,1 2,4 0)"</span><span class="special">,</span> <span class="identifier">line2</span><span class="special">);</span> 204 205 <span class="keyword">bool</span> <span class="identifier">b</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">intersects</span><span class="special">(</span><span class="identifier">line1</span><span class="special">,</span> <span class="identifier">line2</span><span class="special">);</span> 206 207 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Intersects: "</span> <span class="special"><<</span> <span class="special">(</span><span class="identifier">b</span> <span class="special">?</span> <span class="string">"YES"</span> <span class="special">:</span> <span class="string">"NO"</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 208 209 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 210<span class="special">}</span> 211</pre> 212<p> 213 </p> 214<p> 215 Output: 216 </p> 217<pre class="programlisting">Intersects: YES 218</pre> 219</div> 220<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 221<td align="left"></td> 222<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 223 Wulkiewicz, Oracle and/or its affiliates<p> 224 Distributed under the Boost Software License, Version 1.0. (See accompanying 225 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>) 226 </p> 227</div></td> 228</tr></table> 229<hr> 230<div class="spirit-nav"> 231<a accesskey="p" href="intersects_1_one_geometry.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intersects.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="intersects_2_two_geometries.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 232</div> 233</body> 234</html> 235