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

◆ lwcompound_linearize()

static LWLINE * lwcompound_linearize ( const LWCOMPOUND icompound,
double  tol,
LW_LINEARIZE_TOLERANCE_TYPE  tolerance_type,
int  flags 
)
static

Definition at line 584 of file lwstroke.c.

587{
588 LWGEOM *geom;
589 POINTARRAY *ptarray = NULL;
590 LWLINE *tmp = NULL;
591 uint32_t i, j;
592 POINT4D p;
593
594 LWDEBUG(2, "lwcompound_stroke called.");
595
596 ptarray = ptarray_construct_empty(FLAGS_GET_Z(icompound->flags), FLAGS_GET_M(icompound->flags), 64);
597
598 for (i = 0; i < icompound->ngeoms; i++)
599 {
600 geom = icompound->geoms[i];
601 if (geom->type == CIRCSTRINGTYPE)
602 {
603 tmp = lwcircstring_linearize((LWCIRCSTRING *)geom, tol, tolerance_type, flags);
604 for (j = 0; j < tmp->points->npoints; j++)
605 {
606 getPoint4d_p(tmp->points, j, &p);
607 ptarray_append_point(ptarray, &p, LW_TRUE);
608 }
609 lwline_free(tmp);
610 }
611 else if (geom->type == LINETYPE)
612 {
613 tmp = (LWLINE *)geom;
614 for (j = 0; j < tmp->points->npoints; j++)
615 {
616 getPoint4d_p(tmp->points, j, &p);
617 ptarray_append_point(ptarray, &p, LW_TRUE);
618 }
619 }
620 else
621 {
622 lwerror("%s: Unsupported geometry type: %s", __func__, lwtype_name(geom->type));
623 return NULL;
624 }
625 }
626
628 return lwline_construct(icompound->srid, NULL, ptarray);
629}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#define LINETYPE
Definition liblwgeom.h:103
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition ptarray.c:59
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:165
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition lwline.c:42
#define CIRCSTRINGTYPE
Definition liblwgeom.h:109
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:166
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition lwgeom_api.c:125
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
Definition ptarray.c:147
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
void lwline_free(LWLINE *line)
Definition lwline.c:67
void ptarray_remove_repeated_points_in_place(POINTARRAY *pa, double tolerance, uint32_t min_points)
Definition ptarray.c:1674
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
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
lwflags_t flags
Definition liblwgeom.h:591
int32_t srid
Definition liblwgeom.h:590
uint32_t ngeoms
Definition liblwgeom.h:594
LWGEOM ** geoms
Definition liblwgeom.h:589
uint8_t type
Definition liblwgeom.h:462
POINTARRAY * points
Definition liblwgeom.h:483
uint32_t npoints
Definition liblwgeom.h:427

References CIRCSTRINGTYPE, LWCOMPOUND::flags, FLAGS_GET_M, FLAGS_GET_Z, LWCOMPOUND::geoms, getPoint4d_p(), LINETYPE, LW_TRUE, lwcircstring_linearize(), LWDEBUG, lwerror(), lwline_construct(), lwline_free(), lwtype_name(), LWCOMPOUND::ngeoms, POINTARRAY::npoints, LWLINE::points, ptarray_append_point(), ptarray_construct_empty(), ptarray_remove_repeated_points_in_place(), LWCOMPOUND::srid, and LWGEOM::type.

Referenced by lwcollection_linearize(), lwcurve_linearize(), lwcurvepoly_linearize(), and lwmcurve_linearize().

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