PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwcollection_clone_deep()

LWCOLLECTION* lwcollection_clone_deep ( const LWCOLLECTION g)

Deep clone LWCOLLECTION object.

POINTARRAY are copied.

Definition at line 150 of file lwcollection.c.

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

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: