Skip to content

Commit

Permalink
Fix logic mistake in ST_Covers for geography
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Jan 9, 2024
1 parent fba5193 commit 9f1e041
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -13,6 +13,7 @@ Proj 6.1+, and PostgreSQL 14+.
- #5629, Handling EMPTY components in repeated point removal (Paul Ramsey)
- #5604, Handle distance between collections with empty elements (Paul Ramsey)
- #5635, Handle NaN points in ST_Split (Regina Obe)
- Logic error in ST_Covers(geography) (Paul Ramsey)


PostGIS 3.2.6
Expand Down
19 changes: 3 additions & 16 deletions liblwgeom/lwgeodetic.c
Expand Up @@ -2625,23 +2625,10 @@ int lwpoly_covers_lwpoly(const LWPOLY *poly1, const LWPOLY *poly2)
/* check if all vertices of poly2 are inside poly1 */
for (i = 0; i < poly2->nrings; i++)
{

/* every other ring is a hole, check if point is inside the actual polygon */
if ( i % 2 == 0)
{
if (LW_FALSE == lwpoly_covers_pointarray(poly1, poly2->rings[i]))
{
LWDEBUG(4,"returning false, geometry2 has point outside of geometry1");
return LW_FALSE;
}
}
else
if (LW_FALSE == lwpoly_covers_pointarray(poly1, poly2->rings[i]))
{
if (LW_TRUE == lwpoly_covers_pointarray(poly1, poly2->rings[i]))
{
LWDEBUG(4,"returning false, geometry2 has point inside a hole of geometry1");
return LW_FALSE;
}
LWDEBUG(4,"returning false, geometry2 has point outside of geometry1");
return LW_FALSE;
}
}

Expand Down

0 comments on commit 9f1e041

Please sign in to comment.