PostGIS  2.5.7dev-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 647 of file lwstroke.c.

650 {
651  LWMPOLY *ogeom;
652  LWGEOM *tmp;
653  LWPOLY *poly;
654  LWGEOM **polys;
655  POINTARRAY **ptarray;
656  uint32_t i, j;
657 
658  LWDEBUG(2, "lwmsurface_linearize called.");
659 
660  polys = lwalloc(sizeof(LWGEOM *)*msurface->ngeoms);
661 
662  for (i = 0; i < msurface->ngeoms; i++)
663  {
664  tmp = msurface->geoms[i];
665  if (tmp->type == CURVEPOLYTYPE)
666  {
667  polys[i] = (LWGEOM *)lwcurvepoly_linearize((LWCURVEPOLY *)tmp, tol, type, flags);
668  }
669  else if (tmp->type == POLYGONTYPE)
670  {
671  poly = (LWPOLY *)tmp;
672  ptarray = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
673  for (j = 0; j < poly->nrings; j++)
674  {
675  ptarray[j] = ptarray_clone_deep(poly->rings[j]);
676  }
677  polys[i] = (LWGEOM *)lwpoly_construct(msurface->srid, NULL, poly->nrings, ptarray);
678  }
679  }
680  ogeom = (LWMPOLY *)lwcollection_construct(MULTIPOLYGONTYPE, msurface->srid, NULL, msurface->ngeoms, polys);
681  return ogeom;
682 }
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:628
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
static LWPOLY * lwcurvepoly_linearize(const LWCURVEPOLY *curvepoly, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:538
type
Definition: ovdump.py:41
uint8_t type
Definition: liblwgeom.h:399
int32_t srid
Definition: liblwgeom.h:561
uint32_t ngeoms
Definition: liblwgeom.h:562
LWGEOM ** geoms
Definition: liblwgeom.h:564
POINTARRAY ** rings
Definition: liblwgeom.h:460
uint32_t nrings
Definition: liblwgeom.h:458
unsigned int uint32_t
Definition: uthash.h:78

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

Referenced by lwcurve_linearize().

Here is the call graph for this function:
Here is the caller graph for this function: