PostGIS  3.0.6dev-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 691 of file lwstroke.c.

694 {
695  LWMLINE *ogeom;
696  LWGEOM **lines;
697  uint32_t i;
698 
699  LWDEBUGF(2, "lwmcurve_linearize called, geoms=%d, dim=%d.", mcurve->ngeoms, FLAGS_NDIMS(mcurve->flags));
700 
701  lines = lwalloc(sizeof(LWGEOM *)*mcurve->ngeoms);
702 
703  for (i = 0; i < mcurve->ngeoms; i++)
704  {
705  const LWGEOM *tmp = mcurve->geoms[i];
706  if (tmp->type == CIRCSTRINGTYPE)
707  {
708  lines[i] = (LWGEOM *)lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, type, flags);
709  }
710  else if (tmp->type == LINETYPE)
711  {
712  lines[i] = (LWGEOM *)lwline_construct(mcurve->srid, NULL, ptarray_clone_deep(((LWLINE *)tmp)->points));
713  }
714  else if (tmp->type == COMPOUNDTYPE)
715  {
716  lines[i] = (LWGEOM *)lwcompound_linearize((LWCOMPOUND *)tmp, tol, type, flags);
717  }
718  else
719  {
720  lwerror("Unsupported geometry found in MultiCurve.");
721  return NULL;
722  }
723  }
724 
725  ogeom = (LWMLINE *)lwcollection_construct(MULTILINETYPE, mcurve->srid, NULL, mcurve->ngeoms, lines);
726  return ogeom;
727 }
#define COMPOUNDTYPE
Definition: liblwgeom.h:124
#define MULTILINETYPE
Definition: liblwgeom.h:120
#define LINETYPE
Definition: liblwgeom.h:117
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:626
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:193
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:123
void * lwalloc(size_t size)
Definition: lwutil.c:227
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:42
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static LWLINE * lwcircstring_linearize(const LWCIRCSTRING *icurve, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:512
static LWLINE * lwcompound_linearize(const LWCOMPOUND *icompound, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:572
type
Definition: ovdump.py:42
uint8_t type
Definition: liblwgeom.h:448
LWGEOM ** geoms
Definition: liblwgeom.h:603
lwflags_t flags
Definition: liblwgeom.h:605
uint32_t ngeoms
Definition: liblwgeom.h:608
int32_t srid
Definition: liblwgeom.h:604

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, LWGEOM::type, and ovdump::type.

Referenced by lwcurve_linearize().

Here is the call graph for this function:
Here is the caller graph for this function: