PostGIS  2.5.7dev-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 473 of file lwstroke.c.

476 {
477  LWGEOM *geom;
478  POINTARRAY *ptarray = NULL, *ptarray_out = NULL;
479  LWLINE *tmp = NULL;
480  uint32_t i, j;
481  POINT4D p;
482 
483  LWDEBUG(2, "lwcompound_stroke called.");
484 
485  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icompound->flags), FLAGS_GET_M(icompound->flags), 64);
486 
487  for (i = 0; i < icompound->ngeoms; i++)
488  {
489  geom = icompound->geoms[i];
490  if (geom->type == CIRCSTRINGTYPE)
491  {
492  tmp = lwcircstring_linearize((LWCIRCSTRING *)geom, tol, tolerance_type, flags);
493  for (j = 0; j < tmp->points->npoints; j++)
494  {
495  getPoint4d_p(tmp->points, j, &p);
496  ptarray_append_point(ptarray, &p, LW_TRUE);
497  }
498  lwline_free(tmp);
499  }
500  else if (geom->type == LINETYPE)
501  {
502  tmp = (LWLINE *)geom;
503  for (j = 0; j < tmp->points->npoints; j++)
504  {
505  getPoint4d_p(tmp->points, j, &p);
506  ptarray_append_point(ptarray, &p, LW_TRUE);
507  }
508  }
509  else
510  {
511  lwerror("Unsupported geometry type %d found.",
512  geom->type, lwtype_name(geom->type));
513  return NULL;
514  }
515  }
516  ptarray_out = ptarray_remove_repeated_points(ptarray, 0.0);
517  ptarray_free(ptarray);
518  return lwline_construct(icompound->srid, NULL, ptarray_out);
519 }
#define LINETYPE
Definition: liblwgeom.h:86
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:123
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:328
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:156
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
void lwline_free(LWLINE *line)
Definition: lwline.c:76
POINTARRAY * ptarray_remove_repeated_points(const POINTARRAY *in, double tolerance)
Definition: ptarray.c:1446
#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:413
uint8_t flags
Definition: liblwgeom.h:520
int32_t srid
Definition: liblwgeom.h:522
uint32_t ngeoms
Definition: liblwgeom.h:523
LWGEOM ** geoms
Definition: liblwgeom.h:525
uint8_t type
Definition: liblwgeom.h:399
POINTARRAY * points
Definition: liblwgeom.h:425
uint32_t npoints
Definition: liblwgeom.h:374
unsigned int uint32_t
Definition: uthash.h:78

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_free(), ptarray_remove_repeated_points(), LWCOMPOUND::srid, and LWGEOM::type.

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

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