PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwcollection_clone_deep()

LWCOLLECTION* lwcollection_clone_deep ( const LWCOLLECTION g)

Deep clone LWCOLLECTION object.

POINTARRAY are copied.

Definition at line 136 of file lwcollection.c.

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

Referenced by lwgeom_clone_deep(), and lwgeom_node().

137 {
138  uint32_t i;
139  LWCOLLECTION *ret = lwalloc(sizeof(LWCOLLECTION));
140  memcpy(ret, g, sizeof(LWCOLLECTION));
141  if ( g->ngeoms > 0 )
142  {
143  ret->geoms = lwalloc(sizeof(LWGEOM *)*g->ngeoms);
144  for (i=0; i<g->ngeoms; i++)
145  {
146  ret->geoms[i] = lwgeom_clone_deep(g->geoms[i]);
147  }
148  if ( g->bbox ) ret->bbox = gbox_copy(g->bbox);
149  }
150  else
151  {
152  ret->bbox = NULL; /* empty collection */
153  ret->geoms = NULL;
154  }
155  return ret;
156 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:403
GBOX * bbox
Definition: liblwgeom.h:489
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:433
LWGEOM ** geoms
Definition: liblwgeom.h:493
void * lwalloc(size_t size)
Definition: lwutil.c:199
Here is the call graph for this function:
Here is the caller graph for this function: