{
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 )
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;