PostGIS  2.4.9dev-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 537 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().

540 {
541  LWPOLY *ogeom;
542  LWGEOM *tmp;
543  LWLINE *line;
544  POINTARRAY **ptarray;
545  int i;
546 
547  LWDEBUG(2, "lwcurvepoly_linearize called.");
548 
549  ptarray = lwalloc(sizeof(POINTARRAY *)*curvepoly->nrings);
550 
551  for (i = 0; i < curvepoly->nrings; i++)
552  {
553  tmp = curvepoly->rings[i];
554  if (tmp->type == CIRCSTRINGTYPE)
555  {
556  line = lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, tolerance_type, flags);
557  ptarray[i] = ptarray_clone_deep(line->points);
558  lwline_free(line);
559  }
560  else if (tmp->type == LINETYPE)
561  {
562  line = (LWLINE *)tmp;
563  ptarray[i] = ptarray_clone_deep(line->points);
564  }
565  else if (tmp->type == COMPOUNDTYPE)
566  {
567  line = lwcompound_linearize((LWCOMPOUND *)tmp, tol, tolerance_type, flags);
568  ptarray[i] = ptarray_clone_deep(line->points);
569  lwline_free(line);
570  }
571  else
572  {
573  lwerror("Invalid ring type found in CurvePoly.");
574  return NULL;
575  }
576  }
577 
578  ogeom = lwpoly_construct(curvepoly->srid, NULL, curvepoly->nrings, ptarray);
579  return ogeom;
580 }
#define LINETYPE
Definition: liblwgeom.h:86
LWGEOM ** rings
Definition: liblwgeom.h:535
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
static LWLINE * lwcompound_linearize(const LWCOMPOUND *icompound, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:472
void lwline_free(LWLINE *line)
Definition: lwline.c:76
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
int32_t srid
Definition: liblwgeom.h:532
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:630
static LWLINE * lwcircstring_linearize(const LWCIRCSTRING *icurve, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:412
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
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:422
Here is the call graph for this function:
Here is the caller graph for this function: