PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWMPOLY * lwmsurface_segmentize ( LWMSURFACE msurface,
uint32_t  perQuad 
)

Definition at line 372 of file lwsegmentize.c.

References CURVEPOLYTYPE, LWMSURFACE::geoms, lwalloc(), lwcollection_construct(), lwcurvepoly_segmentize(), LWDEBUG, lwpoly_construct(), MULTIPOLYGONTYPE, LWMSURFACE::ngeoms, LWPOLY::nrings, POLYGONTYPE, ptarray_clone_deep(), LWPOLY::rings, LWMSURFACE::srid, and LWGEOM::type.

Referenced by lwgeom_segmentize().

373 {
374  LWMPOLY *ogeom;
375  LWGEOM *tmp;
376  LWPOLY *poly;
377  LWGEOM **polys;
378  POINTARRAY **ptarray;
379  int i, j;
380 
381  LWDEBUG(2, "lwmsurface_segmentize called.");
382 
383  polys = lwalloc(sizeof(LWGEOM *)*msurface->ngeoms);
384 
385  for (i = 0; i < msurface->ngeoms; i++)
386  {
387  tmp = msurface->geoms[i];
388  if (tmp->type == CURVEPOLYTYPE)
389  {
390  polys[i] = (LWGEOM *)lwcurvepoly_segmentize((LWCURVEPOLY *)tmp, perQuad);
391  }
392  else if (tmp->type == POLYGONTYPE)
393  {
394  poly = (LWPOLY *)tmp;
395  ptarray = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
396  for (j = 0; j < poly->nrings; j++)
397  {
398  ptarray[j] = ptarray_clone_deep(poly->rings[j]);
399  }
400  polys[i] = (LWGEOM *)lwpoly_construct(msurface->srid, NULL, poly->nrings, ptarray);
401  }
402  }
403  ogeom = (LWMPOLY *)lwcollection_construct(MULTIPOLYGONTYPE, msurface->srid, NULL, msurface->ngeoms, polys);
404  return ogeom;
405 }
LWPOLY * lwcurvepoly_segmentize(const LWCURVEPOLY *curvepoly, uint32_t perQuad)
Definition: lwsegmentize.c:290
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:30
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:29
POINTARRAY ** rings
Definition: liblwgeom.h:413
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:619
int nrings
Definition: liblwgeom.h:411
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
int ngeoms
Definition: liblwgeom.h:515
LWGEOM ** geoms
Definition: liblwgeom.h:517
int32_t srid
Definition: liblwgeom.h:514
uint8_t type
Definition: liblwgeom.h:352
void * lwalloc(size_t size)
Definition: lwutil.c:175

Here is the call graph for this function:

Here is the caller graph for this function: