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

632 {
633  LWPOLY *ogeom;
634  LWGEOM *tmp;
635  LWLINE *line;
636  POINTARRAY **ptarray;
637  uint32_t i;
638 
639  LWDEBUG(2, "lwcurvepoly_linearize called.");
640 
641  ptarray = lwalloc(sizeof(POINTARRAY *)*curvepoly->nrings);
642 
643  for (i = 0; i < curvepoly->nrings; i++)
644  {
645  tmp = curvepoly->rings[i];
646  if (tmp->type == CIRCSTRINGTYPE)
647  {
648  line = lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, tolerance_type, flags);
649  ptarray[i] = ptarray_clone_deep(line->points);
650  lwline_free(line);
651  }
652  else if (tmp->type == LINETYPE)
653  {
654  line = (LWLINE *)tmp;
655  ptarray[i] = ptarray_clone_deep(line->points);
656  }
657  else if (tmp->type == COMPOUNDTYPE)
658  {
659  line = lwcompound_linearize((LWCOMPOUND *)tmp, tol, tolerance_type, flags);
660  ptarray[i] = ptarray_clone_deep(line->points);
661  lwline_free(line);
662  }
663  else
664  {
665  lwerror("Invalid ring type found in CurvePoly.");
666  return NULL;
667  }
668  }
669 
670  ogeom = lwpoly_construct(curvepoly->srid, NULL, curvepoly->nrings, ptarray);
671  return ogeom;
672 }
#define COMPOUNDTYPE
Definition: liblwgeom.h:124
#define LINETYPE
Definition: liblwgeom.h:117
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:626
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:123
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:512
static LWLINE * lwcompound_linearize(const LWCOMPOUND *icompound, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:572
int32_t srid
Definition: liblwgeom.h:590
LWGEOM ** rings
Definition: liblwgeom.h:589
uint32_t nrings
Definition: liblwgeom.h:594
uint8_t type
Definition: liblwgeom.h:448
POINTARRAY * points
Definition: liblwgeom.h:469

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: