PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_m_point()

Datum LWGEOM_m_point ( PG_FUNCTION_ARGS  )

Definition at line 686 of file lwgeom_ogc.c.

687 {
688  GSERIALIZED *geom;
689  LWPOINT *point = NULL;
690  LWGEOM *lwgeom;
691  POINT3DM p;
692 
693  geom = PG_GETARG_GSERIALIZED_P(0);
694 
695  if ( gserialized_get_type(geom) != POINTTYPE )
696  lwpgerror("Argument to ST_M() must be a point");
697 
698  lwgeom = lwgeom_from_gserialized(geom);
699  point = lwgeom_as_lwpoint(lwgeom);
700 
701  if ( lwgeom_is_empty(lwgeom) )
702  PG_RETURN_NULL();
703 
704  /* no M in input */
705  if ( ! FLAGS_GET_M(point->flags) ) PG_RETURN_NULL();
706 
707  getPoint3dm_p(point->point, 0, &p);
708 
709  PG_FREE_IF_COPY(geom, 0);
710 
711  PG_RETURN_FLOAT8(p.m);
712 }
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
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
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
int getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *point)
Definition: lwgeom_api.c:267
POINTARRAY * point
Definition: liblwgeom.h:414
uint8_t flags
Definition: liblwgeom.h:411
double m
Definition: liblwgeom.h:349

References LWPOINT::flags, FLAGS_GET_M, getPoint3dm_p(), gserialized_get_type(), lwgeom_as_lwpoint(), lwgeom_from_gserialized(), lwgeom_is_empty(), POINT3DM::m, LWPOINT::point, and POINTTYPE.

Here is the call graph for this function: