PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_z_point()

Datum LWGEOM_z_point ( PG_FUNCTION_ARGS  )

Definition at line 623 of file lwgeom_ogc.c.

References getPoint3dz_p(), gserialized_get_type(), gserialized_has_z(), lwgeom_as_lwpoint(), lwgeom_from_gserialized(), lwgeom_is_empty(), LWGEOM_m_point(), PG_FUNCTION_INFO_V1(), LWPOINT::point, POINTTYPE, and POINT3DZ::z.

Referenced by LWGEOM_y_point().

624 {
625  GSERIALIZED *geom;
626  LWPOINT *point = NULL;
627  LWGEOM *lwgeom;
628  POINT3DZ p;
629 
630  geom = PG_GETARG_GSERIALIZED_P(0);
631 
632  if ( gserialized_get_type(geom) != POINTTYPE )
633  lwpgerror("Argument to ST_Z() must be a point");
634 
635  lwgeom = lwgeom_from_gserialized(geom);
636  point = lwgeom_as_lwpoint(lwgeom);
637 
638  if ( lwgeom_is_empty(lwgeom) )
639  PG_RETURN_NULL();
640 
641  /* no Z in input */
642  if ( ! gserialized_has_z(geom) ) PG_RETURN_NULL();
643 
644  getPoint3dz_p(point->point, 0, &p);
645 
646  PG_FREE_IF_COPY(geom, 0);
647 
648  PG_RETURN_FLOAT8(p.z);
649 }
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
double z
Definition: liblwgeom.h:318
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
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:24
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:319
#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:
Here is the caller graph for this function: