PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum geography_point_outside ( PG_FUNCTION_ARGS  )

Definition at line 670 of file geography_measurement.c.

References gbox_pt_outside(), gbox_to_string(), gserialized_from_lwgeom(), gserialized_get_gbox_p(), LW_FAILURE, lwpoint_make2d(), POINT2D::x, and POINT2D::y.

671 {
672  GBOX gbox;
673  GSERIALIZED *g = NULL;
674  GSERIALIZED *g_out = NULL;
675  size_t g_out_size;
676  LWPOINT *lwpoint = NULL;
677  POINT2D pt;
678 
679  /* Get our geometry object loaded into memory. */
680  g = PG_GETARG_GSERIALIZED_P(0);
681 
682  /* We need the bounding box to get an outside point for area algorithm */
683  if ( gserialized_get_gbox_p(g, &gbox) == LW_FAILURE )
684  {
685  POSTGIS_DEBUG(4,"gserialized_get_gbox_p returned LW_FAILURE");
686  elog(ERROR, "Error in gserialized_get_gbox_p calculation.");
687  PG_RETURN_NULL();
688  }
689  POSTGIS_DEBUGF(4, "got gbox %s", gbox_to_string(&gbox));
690 
691  /* Get an exterior point, based on this gbox */
692  gbox_pt_outside(&gbox, &pt);
693 
694  lwpoint = lwpoint_make2d(4326, pt.x, pt.y);
695 
696  g_out = gserialized_from_lwgeom((LWGEOM*)lwpoint, 1, &g_out_size);
697  SET_VARSIZE(g_out, g_out_size);
698 
699  PG_FREE_IF_COPY(g, 0);
700  PG_RETURN_POINTER(g_out);
701 
702 }
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box)
Read the bounding box off a serialization and calculate one if it is not already there.
Definition: g_serialized.c:371
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
Definition: g_box.c:369
LWPOINT * lwpoint_make2d(int srid, double x, double y)
Definition: lwpoint.c:132
#define LW_FAILURE
Definition: liblwgeom.h:64
double x
Definition: liblwgeom.h:312
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
Definition: g_serialized.c:906
double y
Definition: liblwgeom.h:312
void gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside)
Calculate a spherical point that falls outside the geocentric gbox.
Definition: lwgeodetic.c:1444

Here is the call graph for this function: