PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ geography_point_outside()

Datum geography_point_outside ( PG_FUNCTION_ARGS  )

Definition at line 684 of file geography_measurement.c.

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

Referenced by geography_length().

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