PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_z_point()

Datum LWGEOM_z_point ( PG_FUNCTION_ARGS  )

Definition at line 653 of file lwgeom_ogc.c.

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

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

Here is the call graph for this function: