<div dir="ltr">Hi Christian,<div><br></div><div>To understand the query please try plotting your polygon on a globe and then imagine axis aligned box that will contain it (one side parallel to equator, other parallel to 0 and third to 90th meridian). You will see that your "large" geometry is really 40 degrees wide spot around antimeridian. To visualize it better using common planar GIS tools, feed it into geography ST_Segmentize - it will produce the actual 'curved' geometry used in calculation. To see closer to behavior you expect, make sure there are no points connected by longer, not shorter, part of Great Circle, as in your example.<br><br>Hope thisĀ helps.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 8, 2019 at 2:46 AM Christian Pschierer <<a href="mailto:christian.pschierer@gmx.net">christian.pschierer@gmx.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF">
    <p>
    </p>
    <div class="gmail-m_1897330942917048909moz-text-plain" style="font-family:-moz-fixed;font-size:14px" lang="x-unicode">
      <pre class="gmail-m_1897330942917048909moz-quote-pre">Hi,

we found some unexpected results when doing spatial queries on very
large geography polygons. For example

    SELECT ST_Distance(ST_SetSRID( ST_MakeBox2D(ST_Point(160,
60),ST_Point(-160,-60)), 4326)::geography,ST_SetSRID(ST_Point(0, 0),
4326)::geography)/1000

returns 13130km instead of 0 as the point 0,0 should be inside this polygon.

Queries on smaller search areas, or geometry queries return 0.

    SELECT ST_Distance(ST_SetSRID( ST_MakeBox2D(ST_Point(60,
60),ST_Point(-60,-60)), 4326)::geography,ST_SetSRID(ST_Point(0,
0),4326)::geography)/1000

    SELECT ST_Distance(ST_SetSRID( ST_MakeBox2D(ST_Point(160,
60),ST_Point(-160,-60)), 4326),ST_SetSRID(ST_Point(0, 0), 4326))/1000

It seems like PostGis switches inside/outside on geographies if they
exceed a certain size. Is this correct? Is there a way to control this
behaviour?

Greetings
Christian
</pre>
    </div>
  </div>

_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div>Darafei Praliaskouski</div><div>Support me: <a href="http://patreon.com/komzpa" target="_blank">http://patreon.com/komzpa</a></div></div></div></div>