PostGIS  2.4.9dev-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 472 of file lwstroke.c.

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

475 {
476  LWGEOM *geom;
477  POINTARRAY *ptarray = NULL, *ptarray_out = NULL;
478  LWLINE *tmp = NULL;
479  uint32_t i, j;
480  POINT4D p;
481 
482  LWDEBUG(2, "lwcompound_stroke called.");
483 
484  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icompound->flags), FLAGS_GET_M(icompound->flags), 64);
485 
486  for (i = 0; i < icompound->ngeoms; i++)
487  {
488  geom = icompound->geoms[i];
489  if (geom->type == CIRCSTRINGTYPE)
490  {
491  tmp = lwcircstring_linearize((LWCIRCSTRING *)geom, tol, tolerance_type, flags);
492  for (j = 0; j < tmp->points->npoints; j++)
493  {
494  getPoint4d_p(tmp->points, j, &p);
495  ptarray_append_point(ptarray, &p, LW_TRUE);
496  }
497  lwline_free(tmp);
498  }
499  else if (geom->type == LINETYPE)
500  {
501  tmp = (LWLINE *)geom;
502  for (j = 0; j < tmp->points->npoints; j++)
503  {
504  getPoint4d_p(tmp->points, j, &p);
505  ptarray_append_point(ptarray, &p, LW_TRUE);
506  }
507  }
508  else
509  {
510  lwerror("Unsupported geometry type %d found.",
511  geom->type, lwtype_name(geom->type));
512  return NULL;
513  }
514  }
515  ptarray_out = ptarray_remove_repeated_points(ptarray, 0.0);
516  ptarray_free(ptarray);
517  return lwline_construct(icompound->srid, NULL, ptarray_out);
518 }
int32_t srid
Definition: liblwgeom.h:519
#define LINETYPE
Definition: liblwgeom.h:86
POINTARRAY * ptarray_remove_repeated_points(const POINTARRAY *in, double tolerance)
Definition: ptarray.c:1546
int npoints
Definition: liblwgeom.h:371
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
void lwline_free(LWLINE *line)
Definition: lwline.c:76
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
LWGEOM ** geoms
Definition: liblwgeom.h:522
uint8_t flags
Definition: liblwgeom.h:517
unsigned int uint32_t
Definition: uthash.h:78
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
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, then a duplicate point will not be added.
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
static LWLINE * lwcircstring_linearize(const LWCIRCSTRING *icurve, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:412
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
int ngeoms
Definition: liblwgeom.h:520
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:122
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function:
Here is the caller graph for this function: