PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ LWGEOM_numpoints_linestring()

Datum LWGEOM_numpoints_linestring ( PG_FUNCTION_ARGS  )

Definition at line 216 of file lwgeom_ogc.c.

217 {
218  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
219  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
220  int count = -1;
221  int type = lwgeom->type;
222 
223  if ( type == LINETYPE || type == CIRCSTRINGTYPE || type == COMPOUNDTYPE )
224  count = lwgeom_count_vertices(lwgeom);
225 
226  lwgeom_free(lwgeom);
227  PG_FREE_IF_COPY(geom, 0);
228 
229  /* OGC says this functions is only valid on LINESTRING */
230  if ( count < 0 )
231  PG_RETURN_NULL();
232 
233  PG_RETURN_INT32(count);
234 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
#define COMPOUNDTYPE
Definition: liblwgeom.h:110
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
#define LINETYPE
Definition: liblwgeom.h:103
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1246
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:109
int count
Definition: genraster.py:57
type
Definition: ovdump.py:42
uint8_t type
Definition: liblwgeom.h:462

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: