Opened 5 months ago
Last modified 4 months ago
#5740 closed defect
ST_DistanceSpheroid doesn't return 0 when one geometry contains the other — at Initial Version
Reported by: | cdestigter | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.4.3 |
Component: | postgis | Version: | 3.4.x |
Keywords: | Cc: |
Description
The docs say
Returns minimum distance in meters between two lon/lat geometries given a particular spheroid
Based on this description it seems that any intersection between the two geometries to cause the result to be 0 (the minimum distance between the geometries is 0 because they overlap)
However, perhaps it actually compares the _edges_ of the geometries and so if one geometry contains the other you get a positive number:
-- touching the edge of the polygon, the result is zero => select st_distancespheroid('SRID=4326;POLYGON((0 0,0 1,1 1,1 0,0 0))'::GEOMETRY, 'SRID=4326;POINT(0 0.5)'::geometry); 0 -- close to the edge, the result is nonzero => select st_distancespheroid('SRID=4326;POLYGON((0 0,0 1,1 1,1 0,0 0))'::GEOMETRY, 'SRID=4326;POINT(0.1 0.5)'::geometry); 11131.528045775543 -- the further you get from the edge, the larger the result => select st_distancespheroid('SRID=4326;POLYGON((0 0,0 1,1 1,1 0,0 0))'::GEOMETRY, 'SRID=4326;POINT(0.5 0.5)'::geometry); 55657.640177233385
Interestingly, ST_DistanceSphere
gives the expected result:
=> 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); 0
Note:
See TracTickets
for help on using tickets.