PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ lwmsurface_linearize()

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 639 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, ovdump::type, and LWGEOM::type.

Referenced by lwcurve_linearize().

642 {
643  LWMPOLY *ogeom;
644  LWGEOM *tmp;
645  LWPOLY *poly;
646  LWGEOM **polys;
647  POINTARRAY **ptarray;
648  uint32_t i, j;
649 
650  LWDEBUG(2, "lwmsurface_linearize called.");
651 
652  polys = lwalloc(sizeof(LWGEOM *)*msurface->ngeoms);
653 
654  for (i = 0; i < msurface->ngeoms; i++)
655  {
656  tmp = msurface->geoms[i];
657  if (tmp->type == CURVEPOLYTYPE)
658  {
659  polys[i] = (LWGEOM *)lwcurvepoly_linearize((LWCURVEPOLY *)tmp, tol, type, flags);
660  }
661  else if (tmp->type == POLYGONTYPE)
662  {
663  poly = (LWPOLY *)tmp;
664  ptarray = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
665  for (j = 0; j < poly->nrings; j++)
666  {
667  ptarray[j] = ptarray_clone_deep(poly->rings[j]);
668  }
669  polys[i] = (LWGEOM *)lwpoly_construct(msurface->srid, NULL, poly->nrings, ptarray);
670  }
671  }
672  ogeom = (LWMPOLY *)lwcollection_construct(MULTIPOLYGONTYPE, msurface->srid, NULL, msurface->ngeoms, polys);
673  return ogeom;
674 }
uint32_t ngeoms
Definition: liblwgeom.h:561
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:530
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
uint32_t nrings
Definition: liblwgeom.h:457
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:459
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:563
int32_t srid
Definition: liblwgeom.h:560
uint8_t type
Definition: liblwgeom.h:398
type
Definition: ovdump.py:41
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: