PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwcollection_clone()

LWCOLLECTION* lwcollection_clone ( const LWCOLLECTION g)

Clone LWCOLLECTION object.

POINTARRAY are not copied. Bbox is cloned if present in input.

Definition at line 110 of file lwcollection.c.

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

Referenced by lwcollection_segmentize2d(), and lwgeom_clone().

111 {
112  uint32_t i;
113  LWCOLLECTION *ret = lwalloc(sizeof(LWCOLLECTION));
114  memcpy(ret, g, sizeof(LWCOLLECTION));
115  if ( g->ngeoms > 0 )
116  {
117  ret->geoms = lwalloc(sizeof(LWGEOM *)*g->ngeoms);
118  for (i=0; i<g->ngeoms; i++)
119  {
120  ret->geoms[i] = lwgeom_clone(g->geoms[i]);
121  }
122  if ( g->bbox ) ret->bbox = gbox_copy(g->bbox);
123  }
124  else
125  {
126  ret->bbox = NULL; /* empty collection */
127  ret->geoms = NULL;
128  }
129  return ret;
130 }
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 ** geoms
Definition: liblwgeom.h:493
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:395
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: