PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ lwcollection_clone_deep()

LWCOLLECTION* lwcollection_clone_deep ( const LWCOLLECTION g)

Deep clone LWCOLLECTION object.

POINTARRAY are copied.

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

150 {
151  uint32_t i;
152  LWCOLLECTION *ret = lwalloc(sizeof(LWCOLLECTION));
153  memcpy(ret, g, sizeof(LWCOLLECTION));
154  if ( g->ngeoms > 0 )
155  {
156  ret->geoms = lwalloc(sizeof(LWGEOM *)*g->ngeoms);
157  for (i=0; i<g->ngeoms; i++)
158  {
159  ret->geoms[i] = lwgeom_clone_deep(g->geoms[i]);
160  }
161  if ( g->bbox ) ret->bbox = gbox_copy(g->bbox);
162  }
163  else
164  {
165  ret->bbox = NULL; /* empty collection */
166  ret->geoms = NULL;
167  }
168  return ret;
169 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:433
GBOX * bbox
Definition: liblwgeom.h:507
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:520
uint32_t ngeoms
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:511
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: