PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ LWGEOM_numpatches()

Datum LWGEOM_numpatches ( PG_FUNCTION_ARGS  )

Definition at line 294 of file lwgeom_ogc.c.

295 {
296  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
297  LWGEOM *lwgeom;
298  int32 ret = 0;
299 
300  lwgeom = lwgeom_from_gserialized(geom);
301 
302  if (!lwgeom_has_patches(lwgeom))
303  {
304  lwgeom_free(lwgeom);
305  PG_FREE_IF_COPY(geom, 0);
306  elog(ERROR, "ST_NumPatches only supports TIN and PolyhedralSurface geometries");
307  }
308 
309  ret = lwgeom_count_geometries(lwgeom, true);
310 
311  lwgeom_free(lwgeom);
312  PG_FREE_IF_COPY(geom, 0);
313  PG_RETURN_INT32(ret);
314 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:268
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1218
int lwgeom_has_patches(const LWGEOM *geom)
Definition: lwgeom.c:1126
static int32 lwgeom_count_geometries(LWGEOM *lwgeom, bool patches_as_geometries)
Definition: lwgeom_ogc.c:246
unsigned int int32
Definition: shpopen.c:54

References lwgeom_count_geometries(), lwgeom_free(), lwgeom_from_gserialized(), and lwgeom_has_patches().

Here is the call graph for this function: