PostGIS  2.5.0beta1dev-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 465 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().

468 {
469  LWGEOM *geom;
470  POINTARRAY *ptarray = NULL, *ptarray_out = NULL;
471  LWLINE *tmp = NULL;
472  uint32_t i, j;
473  POINT4D p;
474 
475  LWDEBUG(2, "lwcompound_stroke called.");
476 
477  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icompound->flags), FLAGS_GET_M(icompound->flags), 64);
478 
479  for (i = 0; i < icompound->ngeoms; i++)
480  {
481  geom = icompound->geoms[i];
482  if (geom->type == CIRCSTRINGTYPE)
483  {
484  tmp = lwcircstring_linearize((LWCIRCSTRING *)geom, tol, tolerance_type, flags);
485  for (j = 0; j < tmp->points->npoints; j++)
486  {
487  getPoint4d_p(tmp->points, j, &p);
488  ptarray_append_point(ptarray, &p, LW_TRUE);
489  }
490  lwline_free(tmp);
491  }
492  else if (geom->type == LINETYPE)
493  {
494  tmp = (LWLINE *)geom;
495  for (j = 0; j < tmp->points->npoints; j++)
496  {
497  getPoint4d_p(tmp->points, j, &p);
498  ptarray_append_point(ptarray, &p, LW_TRUE);
499  }
500  }
501  else
502  {
503  lwerror("Unsupported geometry type %d found.",
504  geom->type, lwtype_name(geom->type));
505  return NULL;
506  }
507  }
508  ptarray_out = ptarray_remove_repeated_points(ptarray, 0.0);
509  ptarray_free(ptarray);
510  return lwline_construct(icompound->srid, NULL, ptarray_out);
511 }
int32_t srid
Definition: liblwgeom.h:521
#define LINETYPE
Definition: liblwgeom.h:85
POINTARRAY * ptarray_remove_repeated_points(const POINTARRAY *in, double tolerance)
Definition: ptarray.c:1439
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:328
void lwline_free(LWLINE *line)
Definition: lwline.c:76
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
LWGEOM ** geoms
Definition: liblwgeom.h:524
uint8_t flags
Definition: liblwgeom.h:519
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:75
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
uint32_t ngeoms
Definition: liblwgeom.h:522
static LWLINE * lwcircstring_linearize(const LWCIRCSTRING *icurve, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Definition: lwstroke.c:405
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:139
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:113
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
uint8_t type
Definition: liblwgeom.h:398
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:424
uint32_t npoints
Definition: liblwgeom.h:373
Here is the call graph for this function:
Here is the caller graph for this function: