PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ LWGEOM_z_point()

Datum LWGEOM_z_point ( PG_FUNCTION_ARGS  )

Definition at line 649 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().

650 {
651  GSERIALIZED *geom;
652  LWPOINT *point = NULL;
653  LWGEOM *lwgeom;
654  POINT3DZ p;
655 
656  geom = PG_GETARG_GSERIALIZED_P(0);
657 
658  if ( gserialized_get_type(geom) != POINTTYPE )
659  lwpgerror("Argument to ST_Z() must be a point");
660 
661  lwgeom = lwgeom_from_gserialized(geom);
662  point = lwgeom_as_lwpoint(lwgeom);
663 
664  if ( lwgeom_is_empty(lwgeom) )
665  PG_RETURN_NULL();
666 
667  /* no Z in input */
668  if ( ! gserialized_has_z(geom) ) PG_RETURN_NULL();
669 
670  getPoint3dz_p(point->point, 0, &p);
671 
672  PG_FREE_IF_COPY(geom, 0);
673 
674  PG_RETURN_FLOAT8(p.z);
675 }
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:69
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:93
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:38
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:332
#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:1310
Here is the call graph for this function:
Here is the caller graph for this function: