PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 750 of file lwstroke.c.

753{
754 LWMPOLY *ogeom;
755 LWGEOM *tmp;
756 LWPOLY *poly;
757 LWGEOM **polys;
758 POINTARRAY **ptarray;
759 uint32_t i, j;
760
761 LWDEBUG(2, "lwmsurface_linearize called.");
762
763 polys = lwalloc(sizeof(LWGEOM *)*msurface->ngeoms);
764
765 for (i = 0; i < msurface->ngeoms; i++)
766 {
767 tmp = msurface->geoms[i];
768 if (tmp->type == CURVEPOLYTYPE)
769 {
770 polys[i] = (LWGEOM *)lwcurvepoly_linearize((LWCURVEPOLY *)tmp, tol, type, flags);
771 }
772 else if (tmp->type == POLYGONTYPE)
773 {
774 poly = (LWPOLY *)tmp;
775 ptarray = lwalloc(sizeof(POINTARRAY *)*poly->nrings);
776 for (j = 0; j < poly->nrings; j++)
777 {
778 ptarray[j] = ptarray_clone_deep(poly->rings[j]);
779 }
780 polys[i] = (LWGEOM *)lwpoly_construct(msurface->srid, NULL, poly->nrings, ptarray);
781 }
782 }
783 ogeom = (LWMPOLY *)lwcollection_construct(MULTIPOLYGONTYPE, msurface->srid, NULL, msurface->ngeoms, polys);
784 return ogeom;
785}
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
#define CURVEPOLYTYPE
Definition liblwgeom.h:111
void * lwalloc(size_t size)
Definition lwutil.c:227
#define MULTIPOLYGONTYPE
Definition liblwgeom.h:107
#define POLYGONTYPE
Definition liblwgeom.h:104
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition lwpoly.c:43
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition ptarray.c:643
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
static LWPOLY * lwcurvepoly_linearize(const LWCURVEPOLY *curvepoly, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition lwstroke.c:641
uint8_t type
Definition liblwgeom.h:462
int32_t srid
Definition liblwgeom.h:632
uint32_t ngeoms
Definition liblwgeom.h:636
LWGEOM ** geoms
Definition liblwgeom.h:631
POINTARRAY ** rings
Definition liblwgeom.h:519
uint32_t nrings
Definition liblwgeom.h:524

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().

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