title: How can I check if a ring is contained in another ring using Boost.Geometry?
body: <p>I am trying to determine whether a ring is contained by another ring using the Boost.Geometry library.</p>
  
  <p>I wrote the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/geometry.hpp&gt;
  #include &lt;boost/geometry/geometries/geometries.hpp&gt;
  
  using namespace boost::geometry;
  
  int main (int argc, const char * argv[])
  {
      typedef model::d2::point_xy&lt;double&gt; P;
      model::ring&lt;P&gt; ring1, ring2;
  
      read_wkt("polygon((0 0,0 3,3 3,3 0,0 0))", ring1);
      read_wkt("polygon((1 1,1 2,2 2,2 1,1 1))", ring2);
  
      bool b = within(ring1, ring2);
      std::cout &lt;&lt; "Within: " &lt;&lt; (b ? "YES" : "NO") &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>But it does not compile (with Boost 1.48.0), because it fails a static assertion of <code>within</code>:</p>
  
  <pre><code>NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
  </code></pre>
  
  <p>It seems that <code>within</code> only supports checking whether a point is within another geometry (according to the <a href="http://www.boost.org/doc/libs/1_48_0/libs/geometry/doc/html/geometry/reference/algorithms/within/within_2.html#geometry.reference.algorithms.within.within_2.supported_geometries" rel="nofollow">documentation</a>).</p>
  
  <p>I was thinking about treating the rings as linestrings, then check whether they <code>intersect</code>, and if not - check if the first point of the ring is within the other ring; but I don't know  if it's possible to avoid copying each <code>ring</code> to a <code>linestring</code>.</p>
  
  <p>Is there any way to achieve the functionality of <code>within</code> for two rings (with reasonable performance)?</p>