PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwmcurve_stroke()

LWMLINE * lwmcurve_stroke ( const LWMCURVE mcurve,
uint32_t  perQuad 
)

Definition at line 349 of file lwstroke.c.

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

Referenced by lwgeom_stroke().

350 {
351  LWMLINE *ogeom;
352  LWGEOM **lines;
353  int i;
354 
355  LWDEBUGF(2, "lwmcurve_stroke called, geoms=%d, dim=%d.", mcurve->ngeoms, FLAGS_NDIMS(mcurve->flags));
356 
357  lines = lwalloc(sizeof(LWGEOM *)*mcurve->ngeoms);
358 
359  for (i = 0; i < mcurve->ngeoms; i++)
360  {
361  const LWGEOM *tmp = mcurve->geoms[i];
362  if (tmp->type == CIRCSTRINGTYPE)
363  {
364  lines[i] = (LWGEOM *)lwcircstring_stroke((LWCIRCSTRING *)tmp, perQuad);
365  }
366  else if (tmp->type == LINETYPE)
367  {
368  lines[i] = (LWGEOM *)lwline_construct(mcurve->srid, NULL, ptarray_clone_deep(((LWLINE *)tmp)->points));
369  }
370  else if (tmp->type == COMPOUNDTYPE)
371  {
372  lines[i] = (LWGEOM *)lwcompound_stroke((LWCOMPOUND *)tmp, perQuad);
373  }
374  else
375  {
376  lwerror("Unsupported geometry found in MultiCurve.");
377  return NULL;
378  }
379  }
380 
381  ogeom = (LWMLINE *)lwcollection_construct(MULTILINETYPE, mcurve->srid, NULL, mcurve->ngeoms, lines);
382  return ogeom;
383 }
int ngeoms
Definition: liblwgeom.h:545
#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
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
int32_t srid
Definition: liblwgeom.h:544
LWLINE * lwcircstring_stroke(const LWCIRCSTRING *icurve, uint32_t perQuad)
Definition: lwstroke.c:206
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
LWLINE * lwcompound_stroke(const LWCOMPOUND *icompound, uint32_t perQuad)
Definition: lwstroke.c:258
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:634
LWGEOM ** geoms
Definition: liblwgeom.h:547
uint8_t type
Definition: liblwgeom.h:395
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
void * lwalloc(size_t size)
Definition: lwutil.c:227
#define MULTILINETYPE
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:102
Here is the call graph for this function:
Here is the caller graph for this function: