PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 703 of file lwstroke.c.

706{
707 LWMLINE *ogeom;
708 LWGEOM **lines;
709 uint32_t i;
710
711 LWDEBUGF(2, "lwmcurve_linearize called, geoms=%d, dim=%d.", mcurve->ngeoms, FLAGS_NDIMS(mcurve->flags));
712
713 lines = lwalloc(sizeof(LWGEOM *)*mcurve->ngeoms);
714
715 for (i = 0; i < mcurve->ngeoms; i++)
716 {
717 const LWGEOM *tmp = mcurve->geoms[i];
718 if (tmp->type == CIRCSTRINGTYPE)
719 {
720 lines[i] = (LWGEOM *)lwcircstring_linearize((LWCIRCSTRING *)tmp, tol, type, flags);
721 }
722 else if (tmp->type == LINETYPE)
723 {
724 lines[i] = (LWGEOM *)lwline_construct(mcurve->srid, NULL, ptarray_clone_deep(((LWLINE *)tmp)->points));
725 }
726 else if (tmp->type == COMPOUNDTYPE)
727 {
728 lines[i] = (LWGEOM *)lwcompound_linearize((LWCOMPOUND *)tmp, tol, type, flags);
729 }
730 else
731 {
732 lwerror("Unsupported geometry found in MultiCurve.");
733 return NULL;
734 }
735 }
736
737 ogeom = (LWMLINE *)lwcollection_construct(MULTILINETYPE, mcurve->srid, NULL, mcurve->ngeoms, lines);
738 return ogeom;
739}
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
#define COMPOUNDTYPE
Definition liblwgeom.h:110
#define MULTILINETYPE
Definition liblwgeom.h:106
#define LINETYPE
Definition liblwgeom.h:103
void * lwalloc(size_t size)
Definition lwutil.c:227
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition lwline.c:42
#define FLAGS_NDIMS(flags)
Definition liblwgeom.h:179
#define CIRCSTRINGTYPE
Definition liblwgeom.h:109
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition ptarray.c:643
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static LWLINE * lwcircstring_linearize(const LWCIRCSTRING *icurve, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition lwstroke.c:524
static LWLINE * lwcompound_linearize(const LWCOMPOUND *icompound, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition lwstroke.c:584
uint8_t type
Definition liblwgeom.h:462
LWGEOM ** geoms
Definition liblwgeom.h:617
lwflags_t flags
Definition liblwgeom.h:619
uint32_t ngeoms
Definition liblwgeom.h:622
int32_t srid
Definition liblwgeom.h:618

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().

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