PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwmsurface_stroke()

LWMPOLY * lwmsurface_stroke ( const LWMSURFACE msurface,
uint32_t  perQuad 
)

Definition at line 370 of file lwstroke.c.

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

Referenced by lwgeom_stroke().

371 {
372  LWMPOLY *ogeom;
373  LWGEOM *tmp;
374  LWPOLY *poly;
375  LWGEOM **polys;
376  POINTARRAY **ptarray;
377  int i, j;
378 
379  LWDEBUG(2, "lwmsurface_stroke called.");
380 
381  polys = lwalloc(sizeof(LWGEOM *)*msurface->ngeoms);
382 
383  for (i = 0; i < msurface->ngeoms; i++)
384  {
385  tmp = msurface->geoms[i];
386  if (tmp->type == CURVEPOLYTYPE)
387  {
388  polys[i] = (LWGEOM *)lwcurvepoly_stroke((LWCURVEPOLY *)tmp, perQuad);
389  }
390  else if (tmp->type == POLYGONTYPE)
391  {
392  poly = (LWPOLY *)tmp;
393  ptarray = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
394  for (j = 0; j < poly->nrings; j++)
395  {
396  ptarray[j] = ptarray_clone_deep(poly->rings[j]);
397  }
398  polys[i] = (LWGEOM *)lwpoly_construct(msurface->srid, NULL, poly->nrings, ptarray);
399  }
400  }
401  ogeom = (LWMPOLY *)lwcollection_construct(MULTIPOLYGONTYPE, msurface->srid, NULL, msurface->ngeoms, polys);
402  return ogeom;
403 }
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:30
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
LWPOLY * lwcurvepoly_stroke(const LWCURVEPOLY *curvepoly, uint32_t perQuad)
Definition: lwstroke.c:289
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:29
POINTARRAY ** rings
Definition: liblwgeom.h:441
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:634
int nrings
Definition: liblwgeom.h:439
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
int ngeoms
Definition: liblwgeom.h:543
LWGEOM ** geoms
Definition: liblwgeom.h:545
int32_t srid
Definition: liblwgeom.h:542
uint8_t type
Definition: liblwgeom.h:380
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: