[postgis-tickets] r16669 - Ensure index filters on expanded boxes are large enough to encompass
Paul Ramsey
pramsey at cleverelephant.ca
Tue Jul 24 01:55:20 PDT 2018
Author: pramsey
Date: 2018-07-24 13:55:20 -0700 (Tue, 24 Jul 2018)
New Revision: 16669
Modified:
branches/2.4/NEWS
branches/2.4/postgis/geography_measurement.c
branches/2.4/regress/tickets.sql
branches/2.4/regress/tickets_expected
Log:
Ensure index filters on expanded boxes are large enough to encompass
the radii they are searching, references #4081
Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS 2018-07-24 20:50:08 UTC (rev 16668)
+++ branches/2.4/NEWS 2018-07-24 20:55:20 UTC (rev 16669)
@@ -15,6 +15,7 @@
- #4090, PG 11 support (Paul Ramsey, Raúl Marín)
- #3997, fix bug in lwgeom_median and avoid division by zero (Raúl Marín)
- #4093, Inconsistent results from qsort callback (yugr)
+ - #4081, Geography DWithin() issues for certain cases (Paul Ramsey)
- #4105, Parallel build of tarball (Bas Couwenberg)
Modified: branches/2.4/postgis/geography_measurement.c
===================================================================
--- branches/2.4/postgis/geography_measurement.c 2018-07-24 20:50:08 UTC (rev 16668)
+++ branches/2.4/postgis/geography_measurement.c 2018-07-24 20:55:20 UTC (rev 16669)
@@ -466,16 +466,20 @@
{
GSERIALIZED *g = NULL;
GSERIALIZED *g_out = NULL;
- double distance;
+ double unit_distance, distance;
/* Get a wholly-owned pointer to the geography */
g = PG_GETARG_GSERIALIZED_P_COPY(0);
/* Read our distance value and normalize to unit-sphere. */
- distance = PG_GETARG_FLOAT8(1) / WGS84_RADIUS;
+ distance = PG_GETARG_FLOAT8(1);
+ /* Magic 1% expansion is to bridge difference between potential */
+ /* spheroidal input distance and fact that expanded box filter is */
+ /* calculated on sphere */
+ unit_distance = 1.01 * distance / WGS84_RADIUS;
/* Try the expansion */
- g_out = gserialized_expand(g, distance);
+ g_out = gserialized_expand(g, unit_distance);
/* If the expansion fails, the return our input */
if ( g_out == NULL )
Modified: branches/2.4/regress/tickets.sql
===================================================================
--- branches/2.4/regress/tickets.sql 2018-07-24 20:50:08 UTC (rev 16668)
+++ branches/2.4/regress/tickets.sql 2018-07-24 20:55:20 UTC (rev 16669)
@@ -1032,5 +1032,14 @@
--#4089
select '#4089', st_astext(st_geomfromtwkb(st_AsTWKB(st_GeometryFromText('LINESTRING Z(1 1 1, 3 3 1)'), 1, 0, 0, false, true)));
+-- #4081
+select '#4081',
+ST_DWithin(a, b, 110575, true) as within_110575_true,
+ST_DWithin(a, b, 110576, true) as within_110576_true
+from (
+ select ST_GeogFromText('SRID=4326;POINT(1.0 2.0)') as a, ST_GeogFromText('SRID=4326;POINT(1.0 1.0)') as b
+) as points;
+
+
-- Clean up
DELETE FROM spatial_ref_sys;
Modified: branches/2.4/regress/tickets_expected
===================================================================
--- branches/2.4/regress/tickets_expected 2018-07-24 20:50:08 UTC (rev 16668)
+++ branches/2.4/regress/tickets_expected 2018-07-24 20:55:20 UTC (rev 16669)
@@ -309,3 +309,4 @@
#4055a|4326
#4055b|4326
#4089|LINESTRING Z (1 1 1,3 3 1)
+#4081|f|t
More information about the postgis-tickets
mailing list