PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ LWGEOM_m_point()

Datum LWGEOM_m_point ( PG_FUNCTION_ARGS  )

Definition at line 686 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(), LWGEOM_startpoint_linestring(), POINT3DM::m, PG_FUNCTION_INFO_V1(), LWPOINT::point, and POINTTYPE.

Referenced by LWGEOM_z_point().

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 }
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
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:161
POINTARRAY * point
Definition: liblwgeom.h:413
double m
Definition: liblwgeom.h:348
uint8_t flags
Definition: liblwgeom.h:410
#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:1393
int getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *point)
Definition: lwgeom_api.c:257
Here is the call graph for this function:
Here is the caller graph for this function: