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

Definition at line 199 of file lwgeom_ogc.c.

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

200 {
201  GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
202  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
203  int count = -1;
204 
205  if ( lwgeom->type == LINETYPE || lwgeom->type == CIRCSTRINGTYPE )
206  count = lwgeom_count_vertices(lwgeom);
207 
208  lwgeom_free(lwgeom);
209  PG_FREE_IF_COPY(geom, 0);
210 
211  /* OGC says this functions is only valid on LINESTRING */
212  if ( count < 0 )
213  PG_RETURN_NULL();
214 
215  PG_RETURN_INT32(count);
216 }
#define LINETYPE
Definition: liblwgeom.h:61
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
LWGEOM * geom
int count
Definition: genraster.py:57
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
int lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1072

Here is the call graph for this function: