PostGIS  2.3.7dev-r@@SVN_REVISION@@
Datum LWGEOM_m_point ( PG_FUNCTION_ARGS  )

Definition at line 682 of file lwgeom_ogc.c.

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.

683 {
684  GSERIALIZED *geom;
685  LWPOINT *point = NULL;
686  LWGEOM *lwgeom;
687  POINT3DM p;
688 
689  geom = PG_GETARG_GSERIALIZED_P(0);
690 
691  if ( gserialized_get_type(geom) != POINTTYPE )
692  lwpgerror("Argument to ST_M() must be a point");
693 
694  lwgeom = lwgeom_from_gserialized(geom);
695  point = lwgeom_as_lwpoint(lwgeom);
696 
697  if ( lwgeom_is_empty(lwgeom) )
698  PG_RETURN_NULL();
699 
700  /* no M in input */
701  if ( ! FLAGS_GET_M(point->flags) ) PG_RETURN_NULL();
702 
703  getPoint3dm_p(point->point, 0, &p);
704 
705  PG_FREE_IF_COPY(geom, 0);
706 
707  PG_RETURN_FLOAT8(p.m);
708 }
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
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *point)
Definition: lwgeom_api.c:382
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:93
POINTARRAY * point
Definition: liblwgeom.h:410
double m
Definition: liblwgeom.h:345
uint8_t flags
Definition: liblwgeom.h:407
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
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: