PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_numpoints_linestring()

Datum LWGEOM_numpoints_linestring ( PG_FUNCTION_ARGS  )

Definition at line 208 of file lwgeom_ogc.c.

209 {
210  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
211  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
212  int count = -1;
213  int type = lwgeom->type;
214 
215  if ( type == LINETYPE || type == CIRCSTRINGTYPE || type == COMPOUNDTYPE )
216  count = lwgeom_count_vertices(lwgeom);
217 
218  lwgeom_free(lwgeom);
219  PG_FREE_IF_COPY(geom, 0);
220 
221  /* OGC says this functions is only valid on LINESTRING */
222  if ( count < 0 )
223  PG_RETURN_NULL();
224 
225  PG_RETURN_INT32(count);
226 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LINETYPE
Definition: liblwgeom.h:86
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1235
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
int count
Definition: genraster.py:56
type
Definition: ovdump.py:41
uint8_t type
Definition: liblwgeom.h:399

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

Here is the call graph for this function: