PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_y_point()

Datum LWGEOM_y_point ( PG_FUNCTION_ARGS  )

Definition at line 621 of file lwgeom_ogc.c.

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

Referenced by LWGEOM_x_point().

622 {
623  GSERIALIZED *geom;
624  LWPOINT *point = NULL;
625  LWGEOM *lwgeom;
626  POINT2D p;
627 
628  geom = PG_GETARG_GSERIALIZED_P(0);
629 
630  if ( gserialized_get_type(geom) != POINTTYPE )
631  lwpgerror("Argument to ST_Y() must be a point");
632 
633  lwgeom = lwgeom_from_gserialized(geom);
634  point = lwgeom_as_lwpoint(lwgeom);
635 
636  if ( lwgeom_is_empty(lwgeom) )
637  PG_RETURN_NULL();
638 
639  getPoint2d_p(point->point, 0, &p);
640 
641  PG_FREE_IF_COPY(geom, 0);
642 
643  PG_RETURN_FLOAT8(p.y);
644 }
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
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:129
POINTARRAY * point
Definition: liblwgeom.h:411
double y
Definition: liblwgeom.h:328
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:347
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
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:1346
Here is the call graph for this function:
Here is the caller graph for this function: