PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_numpoints_linestring()

Datum LWGEOM_numpoints_linestring ( PG_FUNCTION_ARGS  )

Definition at line 207 of file lwgeom_ogc.c.

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

Referenced by geometry_geometrytype().

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