• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>relate</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="../relate.html" title="relate">
9<link rel="prev" href="relate_4_with_strategy.html" title="relate (with strategy)">
10<link rel="next" href="../relation.html" title="relation">
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="relate_4_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../relate.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="../relation.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.relate.relate_3"></a><a class="link" href="relate_3.html" title="relate">relate</a>
28</h5></div></div></div>
29<p>
30            <a class="indexterm" name="idm45635690025792"></a>
31Checks relation between a pair of geometries defined by a mask.
32          </p>
33<h6>
34<a name="geometry.reference.algorithms.relate.relate_3.h0"></a>
35            <span class="phrase"><a name="geometry.reference.algorithms.relate.relate_3.synopsis"></a></span><a class="link" href="relate_3.html#geometry.reference.algorithms.relate.relate_3.synopsis">Synopsis</a>
36          </h6>
37<p>
38</p>
39<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">,</span> <span class="keyword">typename</span> <span class="identifier">Mask</span><span class="special">&gt;</span>
40<span class="keyword">bool</span> <span class="identifier">relate</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> <span class="identifier">Mask</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">mask</span><span class="special">)</span></pre>
41<p>
42          </p>
43<h6>
44<a name="geometry.reference.algorithms.relate.relate_3.h1"></a>
45            <span class="phrase"><a name="geometry.reference.algorithms.relate.relate_3.parameters"></a></span><a class="link" href="relate_3.html#geometry.reference.algorithms.relate.relate_3.parameters">Parameters</a>
46          </h6>
47<div class="informaltable"><table class="table">
48<colgroup>
49<col>
50<col>
51<col>
52<col>
53</colgroup>
54<thead><tr>
55<th>
56                    <p>
57                      Type
58                    </p>
59                  </th>
60<th>
61                    <p>
62                      Concept
63                    </p>
64                  </th>
65<th>
66                    <p>
67                      Name
68                    </p>
69                  </th>
70<th>
71                    <p>
72                      Description
73                    </p>
74                  </th>
75</tr></thead>
76<tbody>
77<tr>
78<td>
79                    <p>
80                      Geometry1 const &amp;
81                    </p>
82                  </td>
83<td>
84                    <p>
85                      Any type fulfilling a Geometry Concept
86                    </p>
87                  </td>
88<td>
89                    <p>
90                      geometry1
91                    </p>
92                  </td>
93<td>
94                    <p>
95                      A model of the specified concept
96                    </p>
97                  </td>
98</tr>
99<tr>
100<td>
101                    <p>
102                      Geometry2 const &amp;
103                    </p>
104                  </td>
105<td>
106                    <p>
107                      Any type fulfilling a Geometry Concept
108                    </p>
109                  </td>
110<td>
111                    <p>
112                      geometry2
113                    </p>
114                  </td>
115<td>
116                    <p>
117                      A model of the specified concept
118                    </p>
119                  </td>
120</tr>
121<tr>
122<td>
123                    <p>
124                      Mask const &amp;
125                    </p>
126                  </td>
127<td>
128                    <p>
129                      An intersection model Mask type.
130                    </p>
131                  </td>
132<td>
133                    <p>
134                      mask
135                    </p>
136                  </td>
137<td>
138                    <p>
139                      An intersection model mask object.
140                    </p>
141                  </td>
142</tr>
143</tbody>
144</table></div>
145<h6>
146<a name="geometry.reference.algorithms.relate.relate_3.h2"></a>
147            <span class="phrase"><a name="geometry.reference.algorithms.relate.relate_3.returns"></a></span><a class="link" href="relate_3.html#geometry.reference.algorithms.relate.relate_3.returns">Returns</a>
148          </h6>
149<p>
150            true if the relation is compatible with the mask, false otherwise.
151          </p>
152<h6>
153<a name="geometry.reference.algorithms.relate.relate_3.h3"></a>
154            <span class="phrase"><a name="geometry.reference.algorithms.relate.relate_3.header"></a></span><a class="link" href="relate_3.html#geometry.reference.algorithms.relate.relate_3.header">Header</a>
155          </h6>
156<p>
157            Either
158          </p>
159<p>
160            <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>
161          </p>
162<p>
163            Or
164          </p>
165<p>
166            <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">relate</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
167          </p>
168<h6>
169<a name="geometry.reference.algorithms.relate.relate_3.h4"></a>
170            <span class="phrase"><a name="geometry.reference.algorithms.relate.relate_3.conformance"></a></span><a class="link" href="relate_3.html#geometry.reference.algorithms.relate.relate_3.conformance">Conformance</a>
171          </h6>
172<p>
173            The function relate implements function Relate from the <a href="http://www.opengeospatial.org/standards/sfa" target="_top">OGC
174            Simple Feature Specification</a>.
175          </p>
176<h6>
177<a name="geometry.reference.algorithms.relate.relate_3.h5"></a>
178            <span class="phrase"><a name="geometry.reference.algorithms.relate.relate_3.example"></a></span><a class="link" href="relate_3.html#geometry.reference.algorithms.relate.relate_3.example">Example</a>
179          </h6>
180<p>
181            Shows how to detect if a point is inside a polygon, or not
182          </p>
183<p>
184</p>
185<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
186
187<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>
188<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>
189<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">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
190
191
192<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
193<span class="special">{</span>
194    <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>
195    <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">polygon</span><span class="special">&lt;</span><span class="identifier">point_type</span><span class="special">&gt;</span> <span class="identifier">polygon_type</span><span class="special">;</span>
196
197    <span class="identifier">polygon_type</span> <span class="identifier">poly</span><span class="special">;</span>
198    <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>
199        <span class="string">"POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"</span>
200            <span class="string">"(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))"</span><span class="special">,</span> <span class="identifier">poly</span><span class="special">);</span>
201
202    <span class="identifier">point_type</span> <span class="identifier">p</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span>
203
204    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">de9im</span><span class="special">::</span><span class="identifier">mask</span> <span class="identifier">mask</span><span class="special">(</span><span class="string">"T*F**F***"</span><span class="special">);</span> <span class="comment">// within</span>
205    <span class="keyword">bool</span> <span class="identifier">check</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">relate</span><span class="special">(</span><span class="identifier">p</span><span class="special">,</span> <span class="identifier">poly</span><span class="special">,</span> <span class="identifier">mask</span><span class="special">);</span>
206
207    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"relate: "</span> <span class="special">&lt;&lt;</span> <span class="special">(</span><span class="identifier">check</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>
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">relate: yes
218
219<img src="../../../../img/algorithms/within.png" alt="within">
220</pre>
221<h6>
222<a name="geometry.reference.algorithms.relate.relate_3.h6"></a>
223            <span class="phrase"><a name="geometry.reference.algorithms.relate.relate_3.see_also"></a></span><a class="link" href="relate_3.html#geometry.reference.algorithms.relate.relate_3.see_also">See
224            also</a>
225          </h6>
226<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
227<li class="listitem">
228                <a class="link" href="../../de9im/de9im_mask.html" title="de9im::mask">de9im::mask</a>
229              </li>
230<li class="listitem">
231                <a class="link" href="../../de9im/de9im_static_mask.html" title="de9im::static_mask">de9im::static_mask</a>
232              </li>
233<li class="listitem">
234                <a class="link" href="../relation.html" title="relation">relation</a>
235              </li>
236</ul></div>
237</div>
238<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
239<td align="left"></td>
240<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
241      Wulkiewicz, Oracle and/or its affiliates<p>
242        Distributed under the Boost Software License, Version 1.0. (See accompanying
243        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>)
244      </p>
245</div></td>
246</tr></table>
247<hr>
248<div class="spirit-nav">
249<a accesskey="p" href="relate_4_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../relate.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="../relation.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
250</div>
251</body>
252</html>
253