Changes between Initial Version and Version 1 of Ticket #5740, comment 2


Ignore:
Timestamp:
Jun 12, 2024, 12:31:00 PM (6 weeks ago)
Author:
cdestigter

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #5740, comment 2

    initial v1  
    11I've had a browse around the code, and it seems like the bug is [https://github.com/koordinates/postgis/blob/c055f1acdd1af5a03408c1b67743abc3b4bdf7a8/liblwgeom/lwgeodetic.c#L1983-L1988 here] - the code checks for edge intersections and returns 0 if there are any but it doesn't check for containment.
    22
    3 I'm not sure how ST_DistanceSphere avoids the issue since it looks like it probably goes down a similar codepath
     3~~I'm not sure how ST_DistanceSphere avoids the issue since it looks like it probably goes down a similar codepath~~
     4
     5ST_DistanceSphere actually has the same issue **IF** you explicitly provide the optional third parameter (world radius in metres)
     6
     7{{{
     8#!sql
     9=> select st_distancesphere('SRID=4326;POLYGON((0 0,0 1,1 1,1 0,0 0))'::GEOMETRY, 'SRID=4326;POINT(0.5 0.5)'::geometry, 6371008);
     10 55595.41609801024
     11}}}
     12
     13It looks like if you omit that parameter it doesn't use the buggy codepath - instead it casts your geometries to geographies and calls `geography_distance` which doesn't have the same problem.