PostGIS  2.4.9dev-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 646 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().

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