PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_z_point()

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(), LWGEOM_m_point(), PG_FUNCTION_INFO_V1(), LWPOINT::point, POINTTYPE, and POINT3DZ::z.

Referenced by LWGEOM_y_point().

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:334
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
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, int n, POINT3DZ *point)
Definition: lwgeom_api.c:214
#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: