PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ lwcurvepoly_linearize()

static LWPOLY* lwcurvepoly_linearize ( const LWCURVEPOLY curvepoly,
double  tol,
LW_LINEARIZE_TOLERANCE_TYPE  tolerance_type,
int  flags 
)
static

Definition at line 641 of file lwstroke.c.

644 {
645  LWPOLY *ogeom;
646  LWGEOM *tmp;
647  LWLINE *line;
648  POINTARRAY **ptarray;
649  uint32_t i;
650 
651  LWDEBUG(2, "lwcurvepoly_linearize called.");
652 
653  ptarray = lwalloc(sizeof(POINTARRAY *)*curvepoly->nrings);
654 
655  for (i = 0; i < curvepoly->nrings; i++)
656  {
657  tmp = curvepoly->rings[i];
658  if (tmp->type == CIRCSTRINGTYPE)
659  {
660  line = lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, tolerance_type, flags);
661  ptarray[i] = ptarray_clone_deep(line->points);
662  lwline_free(line);
663  }
664  else if (tmp->type == LINETYPE)
665  {
666  line = (LWLINE *)tmp;
667  ptarray[i] = ptarray_clone_deep(line->points);
668  }
669  else if (tmp->type == COMPOUNDTYPE)
670  {
671  line = lwcompound_linearize((LWCOMPOUND *)tmp, tol, tolerance_type, flags);
672  ptarray[i] = ptarray_clone_deep(line->points);
673  lwline_free(line);
674  }
675  else
676  {
677  lwerror("Invalid ring type found in CurvePoly.");
678  return NULL;
679  }
680  }
681 
682  ogeom = lwpoly_construct(curvepoly->srid, NULL, curvepoly->nrings, ptarray);
683  return ogeom;
684 }
#define COMPOUNDTYPE
Definition: liblwgeom.h:110
#define LINETYPE
Definition: liblwgeom.h:103
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:647
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:109
void * lwalloc(size_t size)
Definition: lwutil.c:227
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
void lwline_free(LWLINE *line)
Definition: lwline.c:67
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static LWLINE * lwcircstring_linearize(const LWCIRCSTRING *icurve, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:524
static LWLINE * lwcompound_linearize(const LWCOMPOUND *icompound, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:584
int32_t srid
Definition: liblwgeom.h:604
LWGEOM ** rings
Definition: liblwgeom.h:603
uint32_t nrings
Definition: liblwgeom.h:608
uint8_t type
Definition: liblwgeom.h:462
POINTARRAY * points
Definition: liblwgeom.h:483

References CIRCSTRINGTYPE, COMPOUNDTYPE, LINETYPE, lwalloc(), lwcircstring_linearize(), lwcompound_linearize(), LWDEBUG, lwerror(), lwline_free(), lwpoly_construct(), LWCURVEPOLY::nrings, LWLINE::points, ptarray_clone_deep(), LWCURVEPOLY::rings, LWCURVEPOLY::srid, and LWGEOM::type.

Referenced by lwcollection_linearize(), lwcurve_linearize(), lwcurvepoly_stroke(), and lwmsurface_linearize().

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