PostGIS  2.5.0dev-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 123 of file lwcollection.c.

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

Referenced by lwcollection_segmentize2d(), and lwgeom_clone().

124 {
125  uint32_t i;
126  LWCOLLECTION *ret = lwalloc(sizeof(LWCOLLECTION));
127  memcpy(ret, g, sizeof(LWCOLLECTION));
128  if ( g->ngeoms > 0 )
129  {
130  ret->geoms = lwalloc(sizeof(LWGEOM *)*g->ngeoms);
131  for (i=0; i<g->ngeoms; i++)
132  {
133  ret->geoms[i] = lwgeom_clone(g->geoms[i]);
134  }
135  if ( g->bbox ) ret->bbox = gbox_copy(g->bbox);
136  }
137  else
138  {
139  ret->bbox = NULL; /* empty collection */
140  ret->geoms = NULL;
141  }
142  return ret;
143 }
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
uint32_t ngeoms
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:511
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:482
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: