PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ lwcollection_make_geos_friendly()

LWGEOM * lwcollection_make_geos_friendly ( LWCOLLECTION g)

Definition at line 283 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().

284 {
285  LWGEOM** new_geoms;
286  uint32_t i, new_ngeoms = 0;
287  LWCOLLECTION* ret;
288 
289  /* enough space for all components */
290  new_geoms = lwalloc(sizeof(LWGEOM*) * g->ngeoms);
291 
292  ret = lwalloc(sizeof(LWCOLLECTION));
293  memcpy(ret, g, sizeof(LWCOLLECTION));
294  ret->maxgeoms = g->ngeoms;
295 
296  for (i = 0; i < g->ngeoms; i++)
297  {
298  LWGEOM* newg = lwgeom_make_geos_friendly(g->geoms[i]);
299  if (newg) new_geoms[new_ngeoms++] = newg;
300  }
301 
302  ret->bbox = NULL; /* recompute later... */
303 
304  ret->ngeoms = new_ngeoms;
305  if (new_ngeoms)
306  ret->geoms = new_geoms;
307  else
308  {
309  free(new_geoms);
310  ret->geoms = NULL;
311  ret->maxgeoms = 0;
312  }
313 
314  return (LWGEOM*)ret;
315 }
static LWGEOM * lwgeom_make_geos_friendly(LWGEOM *geom)
GBOX * bbox
Definition: liblwgeom.h:507
uint32_t maxgeoms
Definition: liblwgeom.h:510
uint32_t ngeoms
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:511
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: