PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ geography_point_outside()

Datum geography_point_outside ( PG_FUNCTION_ARGS  )

Definition at line 688 of file geography_measurement.c.

689 {
690  GBOX gbox;
691  GSERIALIZED *g = NULL;
692  GSERIALIZED *g_out = NULL;
693  size_t g_out_size;
694  LWGEOM *lwpoint = NULL;
695  POINT2D pt;
696 
697  /* Get our geometry object loaded into memory. */
698  g = PG_GETARG_GSERIALIZED_P(0);
699 
700  /* We need the bounding box to get an outside point for area algorithm */
701  if ( gserialized_get_gbox_p(g, &gbox) == LW_FAILURE )
702  {
703  POSTGIS_DEBUG(4,"gserialized_get_gbox_p returned LW_FAILURE");
704  elog(ERROR, "Error in gserialized_get_gbox_p calculation.");
705  PG_RETURN_NULL();
706  }
707  POSTGIS_DEBUGF(4, "got gbox %s", gbox_to_string(&gbox));
708 
709  /* Get an exterior point, based on this gbox */
710  gbox_pt_outside(&gbox, &pt);
711 
712  lwpoint = (LWGEOM*) lwpoint_make2d(4326, pt.x, pt.y);
713  /* TODO: Investigate where this is used, this was probably not
714  * returning a geography object before. How did this miss checking
715  */
716  lwgeom_set_geodetic(lwpoint, true);
717  g_out = gserialized_from_lwgeom(lwpoint, &g_out_size);
718  SET_VARSIZE(g_out, g_out_size);
719 
720  PG_FREE_IF_COPY(g, 0);
721  PG_RETURN_POINTER(g_out);
722 
723 }
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
Definition: g_box.c:399
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:640
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
Definition: lwgeom.c:952
LWPOINT * lwpoint_make2d(int srid, double x, double y)
Definition: lwpoint.c:163
#define LW_FAILURE
Definition: liblwgeom.h:79
int gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside)
Calculate a spherical point that falls outside the geocentric gbox.
Definition: lwgeodetic.c:1552
double y
Definition: liblwgeom.h:331
double x
Definition: liblwgeom.h:331

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

Here is the call graph for this function: