PostGIS  2.5.0dev-r@@SVN_REVISION@@
static LWMPOLY* lwmsurface_linearize ( const LWMSURFACE msurface,
double  tol,
LW_LINEARIZE_TOLERANCE_TYPE  type,
int  flags 
)
static
Parameters
msurfaceinput multi surface
toltolerance, semantic driven by tolerance_type
tolerance_typesee LW_LINEARIZE_TOLERANCE_TYPE
flagssee flags in lwarc_linearize
Returns
a newly allocated LWMPOLY

Definition at line 593 of file lwstroke.c.

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

Referenced by lwcurve_linearize().

596 {
597  LWMPOLY *ogeom;
598  LWGEOM *tmp;
599  LWPOLY *poly;
600  LWGEOM **polys;
601  POINTARRAY **ptarray;
602  uint32_t i, j;
603 
604  LWDEBUG(2, "lwmsurface_linearize called.");
605 
606  polys = lwalloc(sizeof(LWGEOM *)*msurface->ngeoms);
607 
608  for (i = 0; i < msurface->ngeoms; i++)
609  {
610  tmp = msurface->geoms[i];
611  if (tmp->type == CURVEPOLYTYPE)
612  {
613  polys[i] = (LWGEOM *)lwcurvepoly_linearize((LWCURVEPOLY *)tmp, tol, type, flags);
614  }
615  else if (tmp->type == POLYGONTYPE)
616  {
617  poly = (LWPOLY *)tmp;
618  ptarray = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
619  for (j = 0; j < poly->nrings; j++)
620  {
621  ptarray[j] = ptarray_clone_deep(poly->rings[j]);
622  }
623  polys[i] = (LWGEOM *)lwpoly_construct(msurface->srid, NULL, poly->nrings, ptarray);
624  }
625  }
626  ogeom = (LWMPOLY *)lwcollection_construct(MULTIPOLYGONTYPE, msurface->srid, NULL, msurface->ngeoms, polys);
627  return ogeom;
628 }
uint32_t ngeoms
Definition: liblwgeom.h:558
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
static LWPOLY * lwcurvepoly_linearize(const LWCURVEPOLY *curvepoly, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:484
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
uint32_t nrings
Definition: liblwgeom.h:454
unsigned int uint32_t
Definition: uthash.h:78
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:628
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:89
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:229

Here is the call graph for this function:

Here is the caller graph for this function: