PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum LWGEOM_numpoints_linestring ( PG_FUNCTION_ARGS  )

Definition at line 193 of file lwgeom_ogc.c.

References CIRCSTRINGTYPE, COMPOUNDTYPE, genraster::count, LINETYPE, lwgeom_count_vertices(), lwgeom_free(), lwgeom_from_gserialized(), and LWGEOM::type.

194 {
195  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
196  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
197  int count = -1;
198  int type = lwgeom->type;
199 
200  if ( type == LINETYPE || type == CIRCSTRINGTYPE || type == COMPOUNDTYPE )
201  count = lwgeom_count_vertices(lwgeom);
202 
203  lwgeom_free(lwgeom);
204  PG_FREE_IF_COPY(geom, 0);
205 
206  /* OGC says this functions is only valid on LINESTRING */
207  if ( count < 0 )
208  PG_RETURN_NULL();
209 
210  PG_RETURN_INT32(count);
211 }
#define LINETYPE
Definition: liblwgeom.h:71
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
int count
Definition: genraster.py:56
uint8_t type
Definition: liblwgeom.h:380
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
int lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1140

Here is the call graph for this function: