Clearly missing a basic concept. Using ST_Covers, I'm getting "true" for a geography point that clearly exists outside of the polygon. Looking at a number of points, it appears latitudes are vertically shifted, whereby points a bit North of the polygon are considered "in" and points just above the Southern border are erroneously considered "out".
For example, a single point in the database is defined as geography(Point,4326)
, with latitude longitude (45º, -79º).
Using ST_MakeEnvelope, create a polygon ranging N/S 40 to 42º, and E/W from -102º to -50º. The point "should" be just north of the resulting polygon.
However ST_Covers(ST_MakeEnvelope(-102, 40, -50, 42, 4326), location)
returns true.
Yet ST_Covers(ST_MakeEnvelope(-102, 40, -50, 42, 4326), ST_Point(-79, 45, 4326))
returns false as expected.
You can see this in the following... shouldn't the location cast as geography(Point,4326) result in the same answer as the non-cast ST_Point?
(I'm storing global aviation positions & store locations as geography data types rather than geometry.)
select
PostGIS_Version(),
ST_Covers(ST_MakeEnvelope(-102, 40, -50, 42, 4326), ST_Point(-79, 45, 4326)) as AsPoint,
ST_Covers(ST_MakeEnvelope(-102, 40, -50, 42, 4326), ST_Point(-79, 45)::geography(Point,4326)) as AsPointGeo
Results in:
version | aspoint | aspointgeo |
---|---|---|
3.2<...> | false | true |