PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum LWGEOM_z_point ( PG_FUNCTION_ARGS  )

Definition at line 652 of file lwgeom_ogc.c.

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

653 {
654  GSERIALIZED *geom;
655  LWPOINT *point = NULL;
656  LWGEOM *lwgeom;
657  POINT3DZ p;
658 
659  geom = PG_GETARG_GSERIALIZED_P(0);
660 
661  if ( gserialized_get_type(geom) != POINTTYPE )
662  lwpgerror("Argument to ST_Z() must be a point");
663 
664  lwgeom = lwgeom_from_gserialized(geom);
665  point = lwgeom_as_lwpoint(lwgeom);
666 
667  if ( lwgeom_is_empty(lwgeom) )
668  PG_RETURN_NULL();
669 
670  /* no Z in input */
671  if ( ! gserialized_has_z(geom) ) PG_RETURN_NULL();
672 
673  getPoint3dz_p(point->point, 0, &p);
674 
675  PG_FREE_IF_COPY(geom, 0);
676 
677  PG_RETURN_FLOAT8(p.z);
678 }
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
double z
Definition: liblwgeom.h:333
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:160
POINTARRAY * point
Definition: liblwgeom.h:410
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:45
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition: lwgeom_api.c:205
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
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:1386

Here is the call graph for this function: