PostGIS  2.5.7dev-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 538 of file lwstroke.c.

541 {
542  LWPOLY *ogeom;
543  LWGEOM *tmp;
544  LWLINE *line;
545  POINTARRAY **ptarray;
546  uint32_t i;
547 
548  LWDEBUG(2, "lwcurvepoly_linearize called.");
549 
550  ptarray = lwalloc(sizeof(POINTARRAY *)*curvepoly->nrings);
551 
552  for (i = 0; i < curvepoly->nrings; i++)
553  {
554  tmp = curvepoly->rings[i];
555  if (tmp->type == CIRCSTRINGTYPE)
556  {
557  line = lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, tolerance_type, flags);
558  ptarray[i] = ptarray_clone_deep(line->points);
559  lwline_free(line);
560  }
561  else if (tmp->type == LINETYPE)
562  {
563  line = (LWLINE *)tmp;
564  ptarray[i] = ptarray_clone_deep(line->points);
565  }
566  else if (tmp->type == COMPOUNDTYPE)
567  {
568  line = lwcompound_linearize((LWCOMPOUND *)tmp, tol, tolerance_type, flags);
569  ptarray[i] = ptarray_clone_deep(line->points);
570  lwline_free(line);
571  }
572  else
573  {
574  lwerror("Invalid ring type found in CurvePoly.");
575  return NULL;
576  }
577  }
578 
579  ogeom = lwpoly_construct(curvepoly->srid, NULL, curvepoly->nrings, ptarray);
580  return ogeom;
581 }
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define LINETYPE
Definition: liblwgeom.h:86
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:628
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
void * lwalloc(size_t size)
Definition: lwutil.c:229
void lwline_free(LWLINE *line)
Definition: lwline.c:76
#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:413
static LWLINE * lwcompound_linearize(const LWCOMPOUND *icompound, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:473
int32_t srid
Definition: liblwgeom.h:535
LWGEOM ** rings
Definition: liblwgeom.h:538
uint32_t nrings
Definition: liblwgeom.h:536
uint8_t type
Definition: liblwgeom.h:399
POINTARRAY * points
Definition: liblwgeom.h:425
unsigned int uint32_t
Definition: uthash.h:78

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: