PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwmcurve_linearize()

static LWMLINE* lwmcurve_linearize ( const LWMCURVE mcurve,
double  tol,
LW_LINEARIZE_TOLERANCE_TYPE  type,
int  flags 
)
static
Parameters
mcurveinput compound curve
toltolerance, semantic driven by tolerance_type
tolerance_typesee LW_LINEARIZE_TOLERANCE_TYPE
flagssee flags in lwarc_linearize
Returns
a newly allocated LWMLINE

Definition at line 599 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, ovdump::type, and LWGEOM::type.

Referenced by lwcurve_linearize().

602 {
603  LWMLINE *ogeom;
604  LWGEOM **lines;
605  int i;
606 
607  LWDEBUGF(2, "lwmcurve_linearize called, geoms=%d, dim=%d.", mcurve->ngeoms, FLAGS_NDIMS(mcurve->flags));
608 
609  lines = lwalloc(sizeof(LWGEOM *)*mcurve->ngeoms);
610 
611  for (i = 0; i < mcurve->ngeoms; i++)
612  {
613  const LWGEOM *tmp = mcurve->geoms[i];
614  if (tmp->type == CIRCSTRINGTYPE)
615  {
616  lines[i] = (LWGEOM *)lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, type, flags);
617  }
618  else if (tmp->type == LINETYPE)
619  {
620  lines[i] = (LWGEOM *)lwline_construct(mcurve->srid, NULL, ptarray_clone_deep(((LWLINE *)tmp)->points));
621  }
622  else if (tmp->type == COMPOUNDTYPE)
623  {
624  lines[i] = (LWGEOM *)lwcompound_linearize((LWCOMPOUND *)tmp, tol, type, flags);
625  }
626  else
627  {
628  lwerror("Unsupported geometry found in MultiCurve.");
629  return NULL;
630  }
631  }
632 
633  ogeom = (LWMLINE *)lwcollection_construct(MULTILINETYPE, mcurve->srid, NULL, mcurve->ngeoms, lines);
634  return ogeom;
635 }
int ngeoms
Definition: liblwgeom.h:546
#define LINETYPE
Definition: liblwgeom.h:86
uint8_t flags
Definition: liblwgeom.h:543
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
#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
int32_t srid
Definition: liblwgeom.h:545
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:630
static LWLINE * lwcircstring_linearize(const LWCIRCSTRING *icurve, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:412
LWGEOM ** geoms
Definition: liblwgeom.h:548
uint8_t type
Definition: liblwgeom.h:396
type
Definition: ovdump.py:41
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
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: