PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWMLINE * lwmcurve_segmentize ( LWMCURVE mcurve,
uint32_t  perQuad 
)

Definition at line 334 of file lwsegmentize.c.

References CIRCSTRINGTYPE, COMPOUNDTYPE, LWMCURVE::flags, FLAGS_NDIMS, LWMCURVE::geoms, LINETYPE, lwalloc(), lwcircstring_segmentize(), lwcollection_construct(), lwcompound_segmentize(), LWDEBUGF, lwerror(), lwline_construct(), MULTILINETYPE, LWMCURVE::ngeoms, ptarray_clone_deep(), LWMCURVE::srid, and LWGEOM::type.

Referenced by lwgeom_segmentize().

335 {
336  LWMLINE *ogeom;
337  LWGEOM *tmp;
338  LWGEOM **lines;
339  int i;
340 
341  LWDEBUGF(2, "lwmcurve_segmentize called, geoms=%d, dim=%d.", mcurve->ngeoms, FLAGS_NDIMS(mcurve->flags));
342 
343  lines = lwalloc(sizeof(LWGEOM *)*mcurve->ngeoms);
344 
345  for (i = 0; i < mcurve->ngeoms; i++)
346  {
347  tmp = mcurve->geoms[i];
348  if (tmp->type == CIRCSTRINGTYPE)
349  {
350  lines[i] = (LWGEOM *)lwcircstring_segmentize((LWCIRCSTRING *)tmp, perQuad);
351  }
352  else if (tmp->type == LINETYPE)
353  {
354  lines[i] = (LWGEOM *)lwline_construct(mcurve->srid, NULL, ptarray_clone_deep(((LWLINE *)tmp)->points));
355  }
356  else if (tmp->type == COMPOUNDTYPE)
357  {
358  lines[i] = (LWGEOM *)lwcompound_segmentize((LWCOMPOUND *)tmp, perQuad);
359  }
360  else
361  {
362  lwerror("Unsupported geometry found in MultiCurve.");
363  return NULL;
364  }
365  }
366 
367  ogeom = (LWMLINE *)lwcollection_construct(MULTILINETYPE, mcurve->srid, NULL, mcurve->ngeoms, lines);
368  return ogeom;
369 }
int ngeoms
Definition: liblwgeom.h:502
#define LINETYPE
Definition: liblwgeom.h:61
uint8_t flags
Definition: liblwgeom.h:499
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:30
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
int32_t srid
Definition: liblwgeom.h:501
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
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.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
LWGEOM ** geoms
Definition: liblwgeom.h:504
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
void * lwalloc(size_t size)
Definition: lwutil.c:175
#define MULTILINETYPE
Definition: liblwgeom.h:64
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:118

Here is the call graph for this function:

Here is the caller graph for this function: