PostGIS  2.5.0dev-r@@SVN_REVISION@@
static LWMLINE* lwmcurve_linearize ( const LWMCURVE mcurve,
double  tol,
int  flags 
mcurveinput compound curve
toltolerance, semantic driven by tolerance_type
flagssee flags in lwarc_linearize
a newly allocated LWMLINE

Definition at line 546 of file lwstroke.c.

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

Referenced by lwcurve_linearize().

549 {
550  LWMLINE *ogeom;
551  LWGEOM **lines;
552  uint32_t i;
554  LWDEBUGF(2, "lwmcurve_linearize called, geoms=%d, dim=%d.", mcurve->ngeoms, FLAGS_NDIMS(mcurve->flags));
556  lines = lwalloc(sizeof(LWGEOM *)*mcurve->ngeoms);
558  for (i = 0; i < mcurve->ngeoms; i++)
559  {
560  const LWGEOM *tmp = mcurve->geoms[i];
561  if (tmp->type == CIRCSTRINGTYPE)
562  {
563  lines[i] = (LWGEOM *)lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, type, flags);
564  }
565  else if (tmp->type == LINETYPE)
566  {
567  lines[i] = (LWGEOM *)lwline_construct(mcurve->srid, NULL, ptarray_clone_deep(((LWLINE *)tmp)->points));
568  }
569  else if (tmp->type == COMPOUNDTYPE)
570  {
571  lines[i] = (LWGEOM *)lwcompound_linearize((LWCOMPOUND *)tmp, tol, type, flags);
572  }
573  else
574  {
575  lwerror("Unsupported geometry found in MultiCurve.");
576  return NULL;
577  }
578  }
580  ogeom = (LWMLINE *)lwcollection_construct(MULTILINETYPE, mcurve->srid, NULL, mcurve->ngeoms, lines);
581  return ogeom;
582 }
#define LINETYPE
Definition: liblwgeom.h:85
uint8_t flags
Definition: liblwgeom.h:542
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
Definition: liblwgeom.h:92
static LWLINE * lwcompound_linearize(const LWCOMPOUND *icompound, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:419
int32_t srid
Definition: liblwgeom.h:544
unsigned int uint32_t
Definition: uthash.h:78
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
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:359
LWGEOM ** geoms
Definition: liblwgeom.h:547
uint8_t type
Definition: liblwgeom.h:395
Definition: liblwgeom.h:91
void * lwalloc(size_t size)
Definition: lwutil.c:229
uint32_t ngeoms
Definition: liblwgeom.h:545
Definition: liblwgeom.h:88
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:151
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190

Here is the call graph for this function:

Here is the caller graph for this function: