Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Seems you are looking for <code>within</code>, no?</p> <p><a href="http://www.boost.org/libs/geometry/doc/html/geometry/reference/algorithms/within/within_2.html" rel="noreferrer">http://www.boost.org/libs/geometry/doc/html/geometry/reference/algorithms/within/within_2.html</a></p> <p>The example they give on the page is, in fact, point-in-polygon:</p> <pre><code>#include &lt;iostream&gt; #include &lt;list&gt; #include &lt;boost/geometry.hpp&gt; #include &lt;boost/geometry/geometries/point_xy.hpp&gt; #include &lt;boost/geometry/geometries/polygon.hpp&gt; #include &lt;boost/geometry/domains/gis/io/wkt/wkt.hpp&gt; int main() { typedef boost::geometry::model::d2::point_xy&lt;double&gt; point_type; typedef boost::geometry::model::polygon&lt;point_type&gt; polygon_type; polygon_type poly; boost::geometry::read_wkt( "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)" "(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))", poly); point_type p(4, 1); std::cout &lt;&lt; "within: " &lt;&lt; (boost::geometry::within(p, poly) ? "yes" : "no") &lt;&lt; std::endl; return 0; } </code></pre> <p><strong>UPDATE:</strong> as @ildjarn points out, you might rather use <code>covered_by</code> if you wanted points that lie on the polygon edge itself to count:</p> <p><a href="http://www.boost.org/libs/geometry/doc/html/geometry/reference/algorithms/covered_by/covered_by_2.html" rel="noreferrer">http://www.boost.org/libs/geometry/doc/html/geometry/reference/algorithms/covered_by/covered_by_2.html</a></p> <p>The behavior of <code>within</code> w.r.t. edges "depends", so take note of that nuance in the documentation.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload