PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWPOLY* lwcurvepoly_segmentize ( const LWCURVEPOLY curvepoly,
uint32_t  perQuad 
)

Definition at line 290 of file lwsegmentize.c.

References CIRCSTRINGTYPE, COMPOUNDTYPE, LINETYPE, lwalloc(), lwcircstring_segmentize(), lwcompound_segmentize(), LWDEBUG, lwerror(), lwline_free(), lwpoly_construct(), LWCURVEPOLY::nrings, LWLINE::points, ptarray_clone_deep(), LWCURVEPOLY::rings, LWCURVEPOLY::srid, and LWGEOM::type.

Referenced by lwcollection_segmentize(), lwcurvepoly_area(), lwgeom_segmentize(), and lwmsurface_segmentize().

291 {
292  LWPOLY *ogeom;
293  LWGEOM *tmp;
294  LWLINE *line;
295  POINTARRAY **ptarray;
296  int i;
297 
298  LWDEBUG(2, "lwcurvepoly_segmentize called.");
299 
300  ptarray = lwalloc(sizeof(POINTARRAY *)*curvepoly->nrings);
301 
302  for (i = 0; i < curvepoly->nrings; i++)
303  {
304  tmp = curvepoly->rings[i];
305  if (tmp->type == CIRCSTRINGTYPE)
306  {
307  line = lwcircstring_segmentize((LWCIRCSTRING *)tmp, perQuad);
308  ptarray[i] = ptarray_clone_deep(line->points);
309  lwline_free(line);
310  }
311  else if (tmp->type == LINETYPE)
312  {
313  line = (LWLINE *)tmp;
314  ptarray[i] = ptarray_clone_deep(line->points);
315  }
316  else if (tmp->type == COMPOUNDTYPE)
317  {
318  line = lwcompound_segmentize((LWCOMPOUND *)tmp, perQuad);
319  ptarray[i] = ptarray_clone_deep(line->points);
320  lwline_free(line);
321  }
322  else
323  {
324  lwerror("Invalid ring type found in CurvePoly.");
325  return NULL;
326  }
327  }
328 
329  ogeom = lwpoly_construct(curvepoly->srid, NULL, curvepoly->nrings, ptarray);
330  return ogeom;
331 }
#define LINETYPE
Definition: liblwgeom.h:61
LWGEOM ** rings
Definition: liblwgeom.h:491
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
void lwline_free(LWLINE *line)
Definition: lwline.c:63
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
LWLINE * lwcircstring_segmentize(const LWCIRCSTRING *icurve, uint32_t perQuad)
Definition: lwsegmentize.c:191
int32_t srid
Definition: liblwgeom.h:488
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:29
LWLINE * lwcompound_segmentize(const LWCOMPOUND *icompound, uint32_t perQuad)
Definition: lwsegmentize.c:243
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:619
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
void * lwalloc(size_t size)
Definition: lwutil.c:175
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: