• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>intersects (two geometries)</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_3_with_strategy.html" title="intersects (with strategy)">
10<link rel="next" href="../is_empty.html" title="is_empty">
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_3_with_strategy.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="../is_empty.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_2_two_geometries"></a><a class="link" href="intersects_2_two_geometries.html" title="intersects (two geometries)">intersects
28          (two geometries)</a>
29</h5></div></div></div>
30<p>
31            <a class="indexterm" name="idm45635695227616"></a>
32Checks if two geometries have at least one intersection.
33          </p>
34<h6>
35<a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.h0"></a>
36            <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.synopsis"></a></span><a class="link" href="intersects_2_two_geometries.html#geometry.reference.algorithms.intersects.intersects_2_two_geometries.synopsis">Synopsis</a>
37          </h6>
38<p>
39</p>
40<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>
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">&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>
42<p>
43          </p>
44<h6>
45<a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.h1"></a>
46            <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.parameters"></a></span><a class="link" href="intersects_2_two_geometries.html#geometry.reference.algorithms.intersects.intersects_2_two_geometries.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 &amp;
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 &amp;
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</tbody>
123</table></div>
124<h6>
125<a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.h2"></a>
126            <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.returns"></a></span><a class="link" href="intersects_2_two_geometries.html#geometry.reference.algorithms.intersects.intersects_2_two_geometries.returns">Returns</a>
127          </h6>
128<p>
129            Returns true if two geometries intersect each other
130          </p>
131<h6>
132<a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.h3"></a>
133            <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.header"></a></span><a class="link" href="intersects_2_two_geometries.html#geometry.reference.algorithms.intersects.intersects_2_two_geometries.header">Header</a>
134          </h6>
135<p>
136            Either
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">hpp</span><span class="special">&gt;</span></code>
140          </p>
141<p>
142            Or
143          </p>
144<p>
145            <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">intersects</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
146          </p>
147<h6>
148<a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.h4"></a>
149            <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.conformance"></a></span><a class="link" href="intersects_2_two_geometries.html#geometry.reference.algorithms.intersects.intersects_2_two_geometries.conformance">Conformance</a>
150          </h6>
151<p>
152            The function intersects implements function Intersects from the <a href="http://www.opengeospatial.org/standards/sfa" target="_top">OGC Simple Feature
153            Specification</a>.
154          </p>
155<p>
156            The version with one parameter is additional and not described in the
157            OGC standard
158          </p>
159<h6>
160<a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.h5"></a>
161            <span class="phrase"><a name="geometry.reference.algorithms.intersects.intersects_2_two_geometries.examples"></a></span><a class="link" href="intersects_2_two_geometries.html#geometry.reference.algorithms.intersects.intersects_2_two_geometries.examples">Examples</a>
162          </h6>
163<p>
164            Check if two linestrings intersect each other
165          </p>
166<p>
167</p>
168<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
169
170<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>
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">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>
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
174<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
175<span class="special">{</span>
176    <span class="comment">// Calculate the intersects of a cartesian polygon</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">P</span><span class="special">;</span>
178    <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">P</span><span class="special">&gt;</span> <span class="identifier">line1</span><span class="special">,</span> <span class="identifier">line2</span><span class="special">;</span>
179
180    <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>
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(2 1,1 2,4 0)"</span><span class="special">,</span> <span class="identifier">line2</span><span class="special">);</span>
182
183    <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>
184
185    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Intersects: "</span> <span class="special">&lt;&lt;</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">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
186
187    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
188<span class="special">}</span>
189</pre>
190<p>
191          </p>
192<p>
193            Output:
194          </p>
195<pre class="programlisting">Intersects: YES
196</pre>
197</div>
198<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
199<td align="left"></td>
200<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
201      Wulkiewicz, Oracle and/or its affiliates<p>
202        Distributed under the Boost Software License, Version 1.0. (See accompanying
203        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>)
204      </p>
205</div></td>
206</tr></table>
207<hr>
208<div class="spirit-nav">
209<a accesskey="p" href="intersects_3_with_strategy.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="../is_empty.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
210</div>
211</body>
212</html>
213