]> granicus.if.org Git - postgis/commitdiff
Ensure index filters on expanded boxes are large enough to encompass
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 24 Jul 2018 20:50:08 +0000 (20:50 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 24 Jul 2018 20:50:08 +0000 (20:50 +0000)
the radii they are searching, closes #4081

git-svn-id: http://svn.osgeo.org/postgis/trunk@16668 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/geography_measurement.c
regress/tickets.sql
regress/tickets_expected

index 9deba4fcee870a394d58a02d456a932370e7dcdd..5d37814211e4303d50def806dcbcf54b6d1e02fe 100644 (file)
@@ -466,16 +466,20 @@ Datum geography_expand(PG_FUNCTION_ARGS)
 {
        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 )
index eedeafbc4a1da3b36208e30f4462ab49591e8fdb..e4d8bbd3a3aefdca04bf2a0207d6be60deabf4f0 100644 (file)
@@ -1090,5 +1090,14 @@ select '#4089', st_astext(st_geomfromtwkb(st_AsTWKB(st_GeometryFromText('LINESTR
 
 select '#4103', ST_Intersects(ST_PointOnSurface('0103000020110F0000010000000A000000000000C41E644741000000EEA2A75A41000000F420644741000000629EA75A410000007A2D644741000000E49FA75A41000000C02E644741000000409DA75A41000000286A64474100000064A4A75A410000007867644741000000FAA9A75A41000000E82B644741000000D2A2A75A41000000222D64474100000046A0A75A41000000242B6447410000006CA4A75A41000000C41E644741000000EEA2A75A41'::geometry), '0103000020110F0000010000000A000000000000C41E644741000000EEA2A75A41000000F420644741000000629EA75A410000007A2D644741000000E49FA75A41000000C02E644741000000409DA75A41000000286A64474100000064A4A75A410000007867644741000000FAA9A75A41000000E82B644741000000D2A2A75A41000000222D64474100000046A0A75A41000000242B6447410000006CA4A75A41000000C41E644741000000EEA2A75A41'::geometry);
 
+-- #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;
index e727304ea34f27732bbaec84e8952d00e958d68a..1a874187a632423032eb2fdc0fb1d420320d9ccd 100644 (file)
@@ -354,3 +354,4 @@ NOTICE:  Self-intersection
 NOTICE:  Your geometry dataset is not valid per OGC Specification. Please fix it with manual review of entries that are not ST_IsValid(geom). Retrying GEOS operation with ST_MakeValid of your input.
 NOTICE:  Self-intersection
 #4103|t
+#4081|f|t