<p>So the root problem is that, for enclosing features defined by a way, we ask overpass for a geometry clipped to the current view:</p>

<pre><code>out tags geom(....)
</code></pre>

<p>Now normally that returns a bounding box as well as the clipped geometry, and I assumed that was the full bounding box, but it turns out it is the bounding box of the clipped geometry.</p>

<p>That causes two problem - firstly this exception if the geometry is completely clipped away so that there is nothing left and hence no bounding box and secondly it means we are sorting features incorrectly because we use the bounding boxes to sort them by size.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/openstreetmap/openstreetmap-website/issues/1156#issuecomment-192967401">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABWnLSchiVInlx9eqwkwJcJVAgVVWj8iks5pqynDgaJpZM4HbSi1.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/openstreetmap/openstreetmap-website/issues/1156#issuecomment-192967401"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>