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

Definition at line 592 of file lwgeom_ogc.c.

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

593 {
594  GSERIALIZED *geom;
595  LWPOINT *point = NULL;
596  LWGEOM *lwgeom;
597  POINT2D p;
598 
599  geom = PG_GETARG_GSERIALIZED_P(0);
600 
601  if ( gserialized_get_type(geom) != POINTTYPE )
602  lwpgerror("Argument to ST_Y() must be a point");
603 
604  lwgeom = lwgeom_from_gserialized(geom);
605  point = lwgeom_as_lwpoint(lwgeom);
606 
607  if ( lwgeom_is_empty(lwgeom) )
608  PG_RETURN_NULL();
609 
610  getPoint2d_p(point->point, 0, &p);
611 
612  PG_FREE_IF_COPY(geom, 0);
613 
614  PG_RETURN_FLOAT8(p.y);
615 }
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:55
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:80
POINTARRAY * point
Definition: liblwgeom.h:395
double y
Definition: liblwgeom.h:312
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:448
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
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:1297

Here is the call graph for this function: