1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>relation (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="../relation.html" title="relation"> 9<link rel="prev" href="../relation.html" title="relation"> 10<link rel="next" href="relation_2.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="../relation.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../relation.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_2.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.relation.relation_3_with_strategy"></a><a class="link" href="relation_3_with_strategy.html" title="relation (with strategy)">relation 28 (with strategy)</a> 29</h5></div></div></div> 30<p> 31 <a class="indexterm" name="idm45635689774160"></a> 32Calculates the relation between a pair of geometries as defined in DE-9IM. 33 </p> 34<h6> 35<a name="geometry.reference.algorithms.relation.relation_3_with_strategy.h0"></a> 36 <span class="phrase"><a name="geometry.reference.algorithms.relation.relation_3_with_strategy.synopsis"></a></span><a class="link" href="relation_3_with_strategy.html#geometry.reference.algorithms.relation.relation_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="identifier">de9im</span><span class="special">::</span><span class="identifier">matrix</span> <span class="identifier">relation</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.relation.relation_3_with_strategy.h1"></a> 46 <span class="phrase"><a name="geometry.reference.algorithms.relation.relation_3_with_strategy.parameters"></a></span><a class="link" href="relation_3_with_strategy.html#geometry.reference.algorithms.relation.relation_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 Relation 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 relation calculations 141 </p> 142 </td> 143</tr> 144</tbody> 145</table></div> 146<h6> 147<a name="geometry.reference.algorithms.relation.relation_3_with_strategy.h2"></a> 148 <span class="phrase"><a name="geometry.reference.algorithms.relation.relation_3_with_strategy.returns"></a></span><a class="link" href="relation_3_with_strategy.html#geometry.reference.algorithms.relation.relation_3_with_strategy.returns">Returns</a> 149 </h6> 150<p> 151 The DE-9IM matrix expressing the relation between geometries. 152 </p> 153<h6> 154<a name="geometry.reference.algorithms.relation.relation_3_with_strategy.h3"></a> 155 <span class="phrase"><a name="geometry.reference.algorithms.relation.relation_3_with_strategy.header"></a></span><a class="link" href="relation_3_with_strategy.html#geometry.reference.algorithms.relation.relation_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">relation</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.relation.relation_3_with_strategy.h4"></a> 171 <span class="phrase"><a name="geometry.reference.algorithms.relation.relation_3_with_strategy.conformance"></a></span><a class="link" href="relation_3_with_strategy.html#geometry.reference.algorithms.relation.relation_3_with_strategy.conformance">Conformance</a> 172 </h6> 173<p> 174 This function is additional and not described in the OGC standard. The 175 spatial relation is represented by DE-9IM matrix. 176 </p> 177<h6> 178<a name="geometry.reference.algorithms.relation.relation_3_with_strategy.h5"></a> 179 <span class="phrase"><a name="geometry.reference.algorithms.relation.relation_3_with_strategy.example"></a></span><a class="link" href="relation_3_with_strategy.html#geometry.reference.algorithms.relation.relation_3_with_strategy.example">Example</a> 180 </h6> 181<p> 182 Shows how to calculate the spatial relation between a point and a polygon 183 </p> 184<p> 185</p> 186<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 187<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">string</span><span class="special">></span> 188 189<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> 190<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> 191<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> 192 193 194<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 195<span class="special">{</span> 196 <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">point_type</span><span class="special">;</span> 197 <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"><</span><span class="identifier">point_type</span><span class="special">></span> <span class="identifier">polygon_type</span><span class="special">;</span> 198 199 <span class="identifier">polygon_type</span> <span class="identifier">poly</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">read_wkt</span><span class="special">(</span> 201 <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> 202 <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> 203 204 <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> 205 206 <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">matrix</span> <span class="identifier">matrix</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">relation</span><span class="special">(</span><span class="identifier">p</span><span class="special">,</span> <span class="identifier">poly</span><span class="special">);</span> 207 <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">code</span> <span class="special">=</span> <span class="identifier">matrix</span><span class="special">.</span><span class="identifier">str</span><span class="special">();</span> 208 209 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"relation: "</span> <span class="special"><<</span> <span class="identifier">code</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 210 211 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 212<span class="special">}</span> 213</pre> 214<p> 215 </p> 216<p> 217 Output: 218 </p> 219<pre class="programlisting">relation: 0FFFFF212 220 221<img src="../../../../img/algorithms/within.png" alt="within"> 222</pre> 223<h6> 224<a name="geometry.reference.algorithms.relation.relation_3_with_strategy.h6"></a> 225 <span class="phrase"><a name="geometry.reference.algorithms.relation.relation_3_with_strategy.see_also"></a></span><a class="link" href="relation_3_with_strategy.html#geometry.reference.algorithms.relation.relation_3_with_strategy.see_also">See 226 also</a> 227 </h6> 228<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 229<li class="listitem"> 230 <a class="link" href="../../de9im/de9im_matrix.html" title="de9im::matrix">de9im::matrix</a> 231 </li> 232<li class="listitem"> 233 <a class="link" href="../relate.html" title="relate">relate</a> 234 </li> 235</ul></div> 236</div> 237<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 238<td align="left"></td> 239<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 240 Wulkiewicz, Oracle and/or its affiliates<p> 241 Distributed under the Boost Software License, Version 1.0. (See accompanying 242 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>) 243 </p> 244</div></td> 245</tr></table> 246<hr> 247<div class="spirit-nav"> 248<a accesskey="p" href="../relation.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../relation.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_2.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 249</div> 250</body> 251</html> 252