[postgis-tickets] [PostGIS] #5096: ST_DWithin does not include a point within the radius

PostGIS trac at osgeo.org
Tue Feb 15 01:39:17 PST 2022


#5096: ST_DWithin does not include a point within the radius
---------------------+---------------------------
 Reporter:  lybin    |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:  PostGIS 2.5.6
Component:  postgis  |    Version:  2.5.x
 Keywords:           |
---------------------+---------------------------
 {{{
 POSTGIS="2.5.5" [EXTENSION] PGSQL="110" (procs need upgrade for use with
 "130") GEOS="3.8.0-CAPI-1.13.1 " PROJ="Rel. 6.3.1, February 10th, 2020"
 GDAL="GDAL 3.0.4, released 2020/01/28 GDAL_DATA not found" LIBXML="2.9.10"
 LIBJSON="0.13.1
 " LIBPROTOBUF="1.3.3" RASTER
 }}}

 {{{
 PostgreSQL 13.4 (Ubuntu 13.4-1.pgdg20.04+1) on x86_64-pc-linux-gnu,
 compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
 }}}

 I use image from https://registry.hub.docker.com/r/postgis/postgis/, I've
 tried 13-master and 14-master

 DB dump attached to reproduce.

 There are two points:
 {{{
 30.318, 53.917 - Mogilev, Belarus
 20.94, 52.255 - Warsaw, Poland
 }}}

 Distance between points is around 620-660km, but does not exceed 1000km.
 I've check by formula and google maps.

 # (Earth radius) * PI / 180
 6370.986 * pi / 180 = 111.19468229846346

 Converting km to degrees for select with ST_DWithin.

 When I filter by 1000km / 111 = 8.993235821438365 {{{ST_DWithin(location,
 'SRID=4326;POINT(20.94 52.2)', 8.993235821438365)}}} DB doesn't select
 point {{{30.318, 53.917 - Mogilev, Belarus}}} ID:4

 If I filter by 9.6 * 111.19468229846346 = 1067.4689500652491 km, result
 below:

 {{{
 soul=# select id, ST_DistanceSphere(location, 'SRID=4326;POINT(20.94
 52.2)'), ST_Distance(location, 'SRID=4326;POINT(20.94 52.2)'),
 ST_Distance(location, 'SRID=4326;POINT(20.94 52.2)') * 111194.68229846346
 from search_search where ST_DWithin(location, 'SRID=4326;POINT(20.94
 52.2)', 9.6);
  id | st_distancesphere |     st_distance      |     ?column?
 ----+-------------------+----------------------+-------------------
   4 |   654581.31171121 |     9.53388551431157 | 1060117.370833798
   3 |      6115.7293854 | 0.054999999999999716 | 6115.707526415459
 (2 rows)
 }}}

 For point ID: 3, st_distancesphere - displays correct distance in meters,
 also st_distance and ?column? are correct too.

 But for point ID:4 {{{30.318, 53.917 - Mogilev, Belarus}}} st_distance and
 ?column? are much bigger than st_distancesphere, so that why when I filter
 by 1000km this point not in result.

 Where I mistake, or that is bug? Thank you.

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5096>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list