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

Definition at line 578 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.

579 {
580  GBOX gbox;
581  GSERIALIZED *g = NULL;
582  GSERIALIZED *g_out = NULL;
583  size_t g_out_size;
584  LWPOINT *lwpoint = NULL;
585  POINT2D pt;
586 
587  /* Get our geometry object loaded into memory. */
588  g = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
589 
590  /* We need the bounding box to get an outside point for area algorithm */
591  if ( gserialized_get_gbox_p(g, &gbox) == LW_FAILURE )
592  {
593  POSTGIS_DEBUG(4,"gserialized_get_gbox_p returned LW_FAILURE");
594  elog(ERROR, "Error in gserialized_get_gbox_p calculation.");
595  PG_RETURN_NULL();
596  }
597  POSTGIS_DEBUGF(4, "got gbox %s", gbox_to_string(&gbox));
598 
599  /* Get an exterior point, based on this gbox */
600  gbox_pt_outside(&gbox, &pt);
601 
602  lwpoint = lwpoint_make2d(4326, pt.x, pt.y);
603 
604  g_out = gserialized_from_lwgeom((LWGEOM*)lwpoint, 1, &g_out_size);
605  SET_VARSIZE(g_out, g_out_size);
606 
607  PG_FREE_IF_COPY(g, 0);
608  PG_RETURN_POINTER(g_out);
609 
610 }
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:373
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
Definition: g_box.c:328
LWPOINT * lwpoint_make2d(int srid, double x, double y)
Definition: lwpoint.c:130
#define LW_FAILURE
Definition: liblwgeom.h:54
double x
Definition: liblwgeom.h:284
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, int is_geodetic, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
Definition: g_serialized.c:908
double y
Definition: liblwgeom.h:284
void gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside)
Calculate a spherical point that falls outside the geocentric gbox.
Definition: lwgeodetic.c:1443

Here is the call graph for this function: