I've run into a peculiar situation where I am trying to find any geospatial objects that lie (partially) in a polygon. When I apply the ST_Intersect
function on two Geometries using the WGS84 SRID the intersection of a polygon and a point clearly North of the polygon returns FALSE
as expected:
SELECT ST_Intersects(
ST_GeomFromText('POLYGON((-12 0,12 0,12 50.7,-12 50.7,-12 0))', 4326),
ST_GeomFromText('POINT(6.0 50.9)', 4326)
);
Now when I run this same query, but with two geographies instead of geometries the query returns TRUE
:
SELECT ST_Intersects(
ST_GeogFromText('POLYGON((-12 0,12 0,12 50.7,-12 50.7,-12 0))'),
ST_GeogFromText('POINT(6 50.9)')
);
I expect that the geography version uses shortest great circle distance to create the polygon, while the geometry version creates the polygon on a flat plane and only then projects this on the WGS84 ellipse.
Can someone verify or debunk my suspicions?
I am running postgresql 9.6 with PostGis 2.4.4