PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lwcollection_clone_deep()

LWCOLLECTION* lwcollection_clone_deep ( const LWCOLLECTION g)

Deep clone LWCOLLECTION object.

POINTARRAY are copied.

Definition at line 151 of file lwcollection.c.

152 {
153  uint32_t i;
154  LWCOLLECTION *ret = lwalloc(sizeof(LWCOLLECTION));
155  memcpy(ret, g, sizeof(LWCOLLECTION));
156  if ( g->ngeoms > 0 )
157  {
158  ret->geoms = lwalloc(sizeof(LWGEOM *)*g->ngeoms);
159  for (i=0; i<g->ngeoms; i++)
160  {
161  ret->geoms[i] = lwgeom_clone_deep(g->geoms[i]);
162  }
163  if ( g->bbox ) ret->bbox = gbox_copy(g->bbox);
164  }
165  else
166  {
167  ret->bbox = NULL; /* empty collection */
168  ret->geoms = NULL;
169  }
170  return ret;
171 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: gbox.c:438
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:529
void * lwalloc(size_t size)
Definition: lwutil.c:227
uint32_t ngeoms
Definition: liblwgeom.h:580
GBOX * bbox
Definition: liblwgeom.h:574
LWGEOM ** geoms
Definition: liblwgeom.h:575

References LWCOLLECTION::bbox, gbox_copy(), LWCOLLECTION::geoms, lwalloc(), lwgeom_clone_deep(), and LWCOLLECTION::ngeoms.

Referenced by lwgeom_clone_deep(), and lwgeom_node().

Here is the call graph for this function:
Here is the caller graph for this function: