PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_m_point()

Datum LWGEOM_m_point ( PG_FUNCTION_ARGS  )

Definition at line 685 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().

686 {
687  GSERIALIZED *geom;
688  LWPOINT *point = NULL;
689  LWGEOM *lwgeom;
690  POINT3DM p;
691 
692  geom = PG_GETARG_GSERIALIZED_P(0);
693 
694  if ( gserialized_get_type(geom) != POINTTYPE )
695  lwpgerror("Argument to ST_M() must be a point");
696 
697  lwgeom = lwgeom_from_gserialized(geom);
698  point = lwgeom_as_lwpoint(lwgeom);
699 
700  if ( lwgeom_is_empty(lwgeom) )
701  PG_RETURN_NULL();
702 
703  /* no M in input */
704  if ( ! FLAGS_GET_M(point->flags) ) PG_RETURN_NULL();
705 
706  getPoint3dm_p(point->point, 0, &p);
707 
708  PG_FREE_IF_COPY(geom, 0);
709 
710  PG_RETURN_FLOAT8(p.m);
711 }
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.
int getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *point)
Definition: lwgeom_api.c:266
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:129
POINTARRAY * point
Definition: liblwgeom.h:411
double m
Definition: liblwgeom.h:346
uint8_t flags
Definition: liblwgeom.h:408
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#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:1346
Here is the call graph for this function:
Here is the caller graph for this function: