PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ LWGEOM_numpoints_linestring()

Datum LWGEOM_numpoints_linestring ( PG_FUNCTION_ARGS  )

Definition at line 220 of file lwgeom_ogc.c.

221 {
222  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
223  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
224  int count = -1;
225  int type = lwgeom->type;
226 
227  if ( type == LINETYPE || type == CIRCSTRINGTYPE || type == COMPOUNDTYPE )
228  count = lwgeom_count_vertices(lwgeom);
229 
230  lwgeom_free(lwgeom);
231  PG_FREE_IF_COPY(geom, 0);
232 
233  /* OGC says this functions is only valid on LINESTRING */
234  if ( count < 0 )
235  PG_RETURN_NULL();
236 
237  PG_RETURN_INT32(count);
238 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:268
#define COMPOUNDTYPE
Definition: liblwgeom.h:110
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1218
#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:1309
#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: