PostGIS  3.0.6dev-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 738 of file lwstroke.c.

741 {
742  LWMPOLY *ogeom;
743  LWGEOM *tmp;
744  LWPOLY *poly;
745  LWGEOM **polys;
746  POINTARRAY **ptarray;
747  uint32_t i, j;
748 
749  LWDEBUG(2, "lwmsurface_linearize called.");
750 
751  polys = lwalloc(sizeof(LWGEOM *)*msurface->ngeoms);
752 
753  for (i = 0; i < msurface->ngeoms; i++)
754  {
755  tmp = msurface->geoms[i];
756  if (tmp->type == CURVEPOLYTYPE)
757  {
758  polys[i] = (LWGEOM *)lwcurvepoly_linearize((LWCURVEPOLY *)tmp, tol, type, flags);
759  }
760  else if (tmp->type == POLYGONTYPE)
761  {
762  poly = (LWPOLY *)tmp;
763  ptarray = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
764  for (j = 0; j < poly->nrings; j++)
765  {
766  ptarray[j] = ptarray_clone_deep(poly->rings[j]);
767  }
768  polys[i] = (LWGEOM *)lwpoly_construct(msurface->srid, NULL, poly->nrings, ptarray);
769  }
770  }
771  ogeom = (LWMPOLY *)lwcollection_construct(MULTIPOLYGONTYPE, msurface->srid, NULL, msurface->ngeoms, polys);
772  return ogeom;
773 }
#define CURVEPOLYTYPE
Definition: liblwgeom.h:125
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:626
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:121
#define POLYGONTYPE
Definition: liblwgeom.h:118
void * lwalloc(size_t size)
Definition: lwutil.c:227
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:42
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
#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:629
type
Definition: ovdump.py:42
uint8_t type
Definition: liblwgeom.h:448
int32_t srid
Definition: liblwgeom.h:618
uint32_t ngeoms
Definition: liblwgeom.h:622
LWGEOM ** geoms
Definition: liblwgeom.h:617
POINTARRAY ** rings
Definition: liblwgeom.h:505
uint32_t nrings
Definition: liblwgeom.h:510

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: