PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwcompound_linearize()

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

Definition at line 572 of file lwstroke.c.

575 {
576  LWGEOM *geom;
577  POINTARRAY *ptarray = NULL;
578  LWLINE *tmp = NULL;
579  uint32_t i, j;
580  POINT4D p;
581 
582  LWDEBUG(2, "lwcompound_stroke called.");
583 
584  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icompound->flags), FLAGS_GET_M(icompound->flags), 64);
585 
586  for (i = 0; i < icompound->ngeoms; i++)
587  {
588  geom = icompound->geoms[i];
589  if (geom->type == CIRCSTRINGTYPE)
590  {
591  tmp = lwcircstring_linearize((LWCIRCSTRING *)geom, tol, tolerance_type, flags);
592  for (j = 0; j < tmp->points->npoints; j++)
593  {
594  getPoint4d_p(tmp->points, j, &p);
595  ptarray_append_point(ptarray, &p, LW_TRUE);
596  }
597  lwline_free(tmp);
598  }
599  else if (geom->type == LINETYPE)
600  {
601  tmp = (LWLINE *)geom;
602  for (j = 0; j < tmp->points->npoints; j++)
603  {
604  getPoint4d_p(tmp->points, j, &p);
605  ptarray_append_point(ptarray, &p, LW_TRUE);
606  }
607  }
608  else
609  {
610  lwerror("%s: Unsupported geometry type: %s", __func__, lwtype_name(geom->type));
611  return NULL;
612  }
613  }
614 
616  return lwline_construct(icompound->srid, NULL, ptarray);
617 }
#define LINETYPE
Definition: liblwgeom.h:117
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:179
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:123
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:59
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:180
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:107
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:1452
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
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
lwflags_t flags
Definition: liblwgeom.h:577
int32_t srid
Definition: liblwgeom.h:576
uint32_t ngeoms
Definition: liblwgeom.h:580
LWGEOM ** geoms
Definition: liblwgeom.h:575
uint8_t type
Definition: liblwgeom.h:448
POINTARRAY * points
Definition: liblwgeom.h:469
uint32_t npoints
Definition: liblwgeom.h:413

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: