PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwmsurface_stroke()

LWMPOLY * lwmsurface_stroke ( const LWMSURFACE msurface,
uint32_t  perQuad 
)

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

387 {
388  LWMPOLY *ogeom;
389  LWGEOM *tmp;
390  LWPOLY *poly;
391  LWGEOM **polys;
392  POINTARRAY **ptarray;
393  int i, j;
394 
395  LWDEBUG(2, "lwmsurface_stroke called.");
396 
397  polys = lwalloc(sizeof(LWGEOM *)*msurface->ngeoms);
398 
399  for (i = 0; i < msurface->ngeoms; i++)
400  {
401  tmp = msurface->geoms[i];
402  if (tmp->type == CURVEPOLYTYPE)
403  {
404  polys[i] = (LWGEOM *)lwcurvepoly_stroke((LWCURVEPOLY *)tmp, perQuad);
405  }
406  else if (tmp->type == POLYGONTYPE)
407  {
408  poly = (LWPOLY *)tmp;
409  ptarray = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
410  for (j = 0; j < poly->nrings; j++)
411  {
412  ptarray[j] = ptarray_clone_deep(poly->rings[j]);
413  }
414  polys[i] = (LWGEOM *)lwpoly_construct(msurface->srid, NULL, poly->nrings, ptarray);
415  }
416  }
417  ogeom = (LWMPOLY *)lwcollection_construct(MULTIPOLYGONTYPE, msurface->srid, NULL, msurface->ngeoms, polys);
418  return ogeom;
419 }
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
#define POLYGONTYPE
Definition: liblwgeom.h:86
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
LWPOLY * lwcurvepoly_stroke(const LWCURVEPOLY *curvepoly, uint32_t perQuad)
Definition: lwstroke.c:305
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
POINTARRAY ** rings
Definition: liblwgeom.h:456
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:634
int nrings
Definition: liblwgeom.h:454
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
int ngeoms
Definition: liblwgeom.h:558
LWGEOM ** geoms
Definition: liblwgeom.h:560
int32_t srid
Definition: liblwgeom.h:557
uint8_t type
Definition: liblwgeom.h:395
void * lwalloc(size_t size)
Definition: lwutil.c:227
Here is the call graph for this function:
Here is the caller graph for this function: