PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ geography_expand()

Datum geography_expand ( PG_FUNCTION_ARGS  )

Definition at line 464 of file geography_measurement.c.

References distance(), geography_area(), gserialized_expand(), PG_FUNCTION_INFO_V1(), and WGS84_RADIUS.

Referenced by geography_dwithin_uncached().

465 {
466  GSERIALIZED *g = NULL;
467  GSERIALIZED *g_out = NULL;
468  double unit_distance, distance;
469 
470  /* Get a wholly-owned pointer to the geography */
471  g = PG_GETARG_GSERIALIZED_P_COPY(0);
472 
473  /* Read our distance value and normalize to unit-sphere. */
474  distance = PG_GETARG_FLOAT8(1);
475  /* Magic 1% expansion is to bridge difference between potential */
476  /* spheroidal input distance and fact that expanded box filter is */
477  /* calculated on sphere */
478  unit_distance = 1.01 * distance / WGS84_RADIUS;
479 
480  /* Try the expansion */
481  g_out = gserialized_expand(g, unit_distance);
482 
483  /* If the expansion fails, the return our input */
484  if ( g_out == NULL )
485  {
486  PG_RETURN_POINTER(g);
487  }
488 
489  if ( g_out != g )
490  {
491  pfree(g);
492  }
493 
494  PG_RETURN_POINTER(g_out);
495 }
#define WGS84_RADIUS
Definition: liblwgeom.h:130
GSERIALIZED * gserialized_expand(GSERIALIZED *g, double distance)
Return a GSERIALIZED with an expanded bounding box.
Datum distance(PG_FUNCTION_ARGS)
Here is the call graph for this function:
Here is the caller graph for this function: