PostGIS  2.5.0dev-r@@SVN_REVISION@@
static LWPOLY* lwcurvepoly_linearize ( const LWCURVEPOLY curvepoly,
double  tol,
LW_LINEARIZE_TOLERANCE_TYPE  tolerance_type,
int  flags 
)
static

Definition at line 484 of file lwstroke.c.

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

487 {
488  LWPOLY *ogeom;
489  LWGEOM *tmp;
490  LWLINE *line;
491  POINTARRAY **ptarray;
492  uint32_t i;
493 
494  LWDEBUG(2, "lwcurvepoly_linearize called.");
495 
496  ptarray = lwalloc(sizeof(POINTARRAY *)*curvepoly->nrings);
497 
498  for (i = 0; i < curvepoly->nrings; i++)
499  {
500  tmp = curvepoly->rings[i];
501  if (tmp->type == CIRCSTRINGTYPE)
502  {
503  line = lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, tolerance_type, flags);
504  ptarray[i] = ptarray_clone_deep(line->points);
505  lwline_free(line);
506  }
507  else if (tmp->type == LINETYPE)
508  {
509  line = (LWLINE *)tmp;
510  ptarray[i] = ptarray_clone_deep(line->points);
511  }
512  else if (tmp->type == COMPOUNDTYPE)
513  {
514  line = lwcompound_linearize((LWCOMPOUND *)tmp, tol, tolerance_type, flags);
515  ptarray[i] = ptarray_clone_deep(line->points);
516  lwline_free(line);
517  }
518  else
519  {
520  lwerror("Invalid ring type found in CurvePoly.");
521  return NULL;
522  }
523  }
524 
525  ogeom = lwpoly_construct(curvepoly->srid, NULL, curvepoly->nrings, ptarray);
526  return ogeom;
527 }
#define LINETYPE
Definition: liblwgeom.h:85
LWGEOM ** rings
Definition: liblwgeom.h:534
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
static LWLINE * lwcompound_linearize(const LWCOMPOUND *icompound, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:419
void lwline_free(LWLINE *line)
Definition: lwline.c:76
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
unsigned int uint32_t
Definition: uthash.h:78
int32_t srid
Definition: liblwgeom.h:531
LWPOLY * lwpoly_construct(int 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:628
static LWLINE * lwcircstring_linearize(const LWCIRCSTRING *icurve, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:359
uint8_t type
Definition: liblwgeom.h:395
uint32_t nrings
Definition: liblwgeom.h:532
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
void * lwalloc(size_t size)
Definition: lwutil.c:229
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: