In PostGIS, why does ST_Covers return f on this query?

المشرف العام

Administrator
طاقم الإدارة
In general this query functions fine. In my PHP application I tested it with a large number of points, and they all seemed to be true or false as appropriate (when I pasted data into two online WKT converters). But there's a significant number of false negatives. Here's the query using a point PostGIS thinks doesn't go in the rectangle even though I'm quite sure it should:

SELECT ST_Covers(geog_poly, geog_pt) As poly_covers_pt FROM ( SELECT ST_GeogFromText('POLYGON((-53 83,-53 42,-141 42,-141 83,-53 83))') As geog_poly, ST_GeogFromText('POINT (-100 48)') As geog_pt ) AS result;That returns poly_covers_pt as f, even though 42 < 48 < 83 and -141 < -100 < -53. Also, mapping the point and the region with online tools shows the region to contain all of North Dakota and the point to be in North Dakota.

By contrast, I can change the 48 to a 60 and this returns a t, as it should:

SELECT ST_Covers(geog_poly, geog_pt) As poly_covers_pt FROM ( SELECT ST_GeogFromText('POLYGON((-53 83,-53 42,-141 42,-141 83,-53 83))') As geog_poly, ST_GeogFromText('POINT (-100 60)') As geog_pt ) AS result;What's going on?



أكثر...
 
أعلى