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

Definition at line 657 of file lwgeom_ogc.c.

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

658 {
659  GSERIALIZED *geom;
660  LWPOINT *point = NULL;
661  LWGEOM *lwgeom;
662  POINT3DM p;
663 
664  geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
665 
666  if ( gserialized_get_type(geom) != POINTTYPE )
667  lwerror("Argument to M() must be a point");
668 
669  lwgeom = lwgeom_from_gserialized(geom);
670  point = lwgeom_as_lwpoint(lwgeom);
671 
672  if ( lwgeom_is_empty(lwgeom) )
673  PG_RETURN_NULL();
674 
675  /* no M in input */
676  if ( ! FLAGS_GET_M(point->flags) ) PG_RETURN_NULL();
677 
678  getPoint3dm_p(point->point, 0, &p);
679 
680  PG_FREE_IF_COPY(geom, 0);
681 
682  PG_RETURN_FLOAT8(p.m);
683 }
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:56
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:355
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:80
POINTARRAY * point
Definition: liblwgeom.h:367
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
LWGEOM * geom
double m
Definition: liblwgeom.h:302
uint8_t flags
Definition: liblwgeom.h:364
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
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:1229

Here is the call graph for this function: