PostGIS  2.5.0beta2dev-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 530 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().

533 {
534  LWPOLY *ogeom;
535  LWGEOM *tmp;
536  LWLINE *line;
537  POINTARRAY **ptarray;
538  uint32_t i;
539 
540  LWDEBUG(2, "lwcurvepoly_linearize called.");
541 
542  ptarray = lwalloc(sizeof(POINTARRAY *)*curvepoly->nrings);
543 
544  for (i = 0; i < curvepoly->nrings; i++)
545  {
546  tmp = curvepoly->rings[i];
547  if (tmp->type == CIRCSTRINGTYPE)
548  {
549  line = lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, tolerance_type, flags);
550  ptarray[i] = ptarray_clone_deep(line->points);
551  lwline_free(line);
552  }
553  else if (tmp->type == LINETYPE)
554  {
555  line = (LWLINE *)tmp;
556  ptarray[i] = ptarray_clone_deep(line->points);
557  }
558  else if (tmp->type == COMPOUNDTYPE)
559  {
560  line = lwcompound_linearize((LWCOMPOUND *)tmp, tol, tolerance_type, flags);
561  ptarray[i] = ptarray_clone_deep(line->points);
562  lwline_free(line);
563  }
564  else
565  {
566  lwerror("Invalid ring type found in CurvePoly.");
567  return NULL;
568  }
569  }
570 
571  ogeom = lwpoly_construct(curvepoly->srid, NULL, curvepoly->nrings, ptarray);
572  return ogeom;
573 }
#define LINETYPE
Definition: liblwgeom.h:85
LWGEOM ** rings
Definition: liblwgeom.h:537
#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:465
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:534
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:405
uint8_t type
Definition: liblwgeom.h:398
uint32_t nrings
Definition: liblwgeom.h:535
#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:424
Here is the call graph for this function:
Here is the caller graph for this function: