PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_x_point()

Datum LWGEOM_x_point ( PG_FUNCTION_ARGS  )

Definition at line 593 of file lwgeom_ogc.c.

594 {
595  GSERIALIZED *geom;
596  LWGEOM *lwgeom;
597  LWPOINT *point = NULL;
598  POINT2D p;
599 
600  geom = PG_GETARG_GSERIALIZED_P(0);
601 
602  if ( gserialized_get_type(geom) != POINTTYPE )
603  lwpgerror("Argument to ST_X() must be a point");
604 
605  lwgeom = lwgeom_from_gserialized(geom);
606  point = lwgeom_as_lwpoint(lwgeom);
607 
608  if ( lwgeom_is_empty(lwgeom) )
609  PG_RETURN_NULL();
610 
611  getPoint2d_p(point->point, 0, &p);
612 
613  PG_FREE_IF_COPY(geom, 0);
614  PG_RETURN_FLOAT8(p.x);
615 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: g_serialized.c:86
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:348
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:161
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwgeom.c:1393
POINTARRAY * point
Definition: liblwgeom.h:414
double x
Definition: liblwgeom.h:331

References getPoint2d_p(), gserialized_get_type(), lwgeom_as_lwpoint(), lwgeom_from_gserialized(), lwgeom_is_empty(), LWPOINT::point, POINTTYPE, and POINT2D::x.

Here is the call graph for this function: