PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwcollection_make_geos_friendly()

LWGEOM * lwcollection_make_geos_friendly ( LWCOLLECTION g)

Definition at line 297 of file liblwgeom/lwgeom_geos_clean.c.

References LWCOLLECTION::bbox, free(), LWCOLLECTION::geoms, lwalloc(), lwgeom_make_geos_friendly(), LWCOLLECTION::maxgeoms, and LWCOLLECTION::ngeoms.

Referenced by LWGEOM_GEOS_getPointN(), and lwgeom_make_geos_friendly().

298 {
299  LWGEOM **new_geoms;
300  uint32_t i, new_ngeoms=0;
301  LWCOLLECTION *ret;
302 
303  /* enough space for all components */
304  new_geoms = lwalloc(sizeof(LWGEOM *)*g->ngeoms);
305 
306  ret = lwalloc(sizeof(LWCOLLECTION));
307  memcpy(ret, g, sizeof(LWCOLLECTION));
308  ret->maxgeoms = g->ngeoms;
309 
310  for (i=0; i<g->ngeoms; i++)
311  {
312  LWGEOM* newg = lwgeom_make_geos_friendly(g->geoms[i]);
313  if ( newg ) new_geoms[new_ngeoms++] = newg;
314  }
315 
316  ret->bbox = NULL; /* recompute later... */
317 
318  ret->ngeoms = new_ngeoms;
319  if ( new_ngeoms )
320  {
321  ret->geoms = new_geoms;
322  }
323  else
324  {
325  free(new_geoms);
326  ret->geoms = NULL;
327  ret->maxgeoms = 0;
328  }
329 
330  return (LWGEOM*)ret;
331 }
static LWGEOM * lwgeom_make_geos_friendly(LWGEOM *geom)
GBOX * bbox
Definition: liblwgeom.h:505
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:509
void free(void *)
void * lwalloc(size_t size)
Definition: lwutil.c:229
Here is the call graph for this function:
Here is the caller graph for this function: