PostGIS  2.3.7dev-r@@SVN_REVISION@@
LWLINE* lwcompound_stroke ( const LWCOMPOUND icompound,
uint32_t  perQuad 
)

Definition at line 258 of file lwstroke.c.

References CIRCSTRINGTYPE, LWCOMPOUND::flags, FLAGS_GET_M, FLAGS_GET_Z, LWCOMPOUND::geoms, getPoint4d_p(), LINETYPE, LW_TRUE, lwcircstring_stroke(), 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_stroke(), lwcurvepoly_stroke(), lwgeom_stroke(), and lwmcurve_stroke().

259 {
260  LWGEOM *geom;
261  POINTARRAY *ptarray = NULL, *ptarray_out = NULL;
262  LWLINE *tmp = NULL;
263  uint32_t i, j;
264  POINT4D p;
265 
266  LWDEBUG(2, "lwcompound_stroke called.");
267 
268  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icompound->flags), FLAGS_GET_M(icompound->flags), 64);
269 
270  for (i = 0; i < icompound->ngeoms; i++)
271  {
272  geom = icompound->geoms[i];
273  if (geom->type == CIRCSTRINGTYPE)
274  {
275  tmp = lwcircstring_stroke((LWCIRCSTRING *)geom, perQuad);
276  for (j = 0; j < tmp->points->npoints; j++)
277  {
278  getPoint4d_p(tmp->points, j, &p);
279  ptarray_append_point(ptarray, &p, LW_TRUE);
280  }
281  lwline_free(tmp);
282  }
283  else if (geom->type == LINETYPE)
284  {
285  tmp = (LWLINE *)geom;
286  for (j = 0; j < tmp->points->npoints; j++)
287  {
288  getPoint4d_p(tmp->points, j, &p);
289  ptarray_append_point(ptarray, &p, LW_TRUE);
290  }
291  }
292  else
293  {
294  lwerror("Unsupported geometry type %d found.",
295  geom->type, lwtype_name(geom->type));
296  return NULL;
297  }
298  }
299  ptarray_out = ptarray_remove_repeated_points(ptarray, 0.0);
300  ptarray_free(ptarray);
301  return lwline_construct(icompound->srid, NULL, ptarray_out);
302 }
int32_t srid
Definition: liblwgeom.h:518
#define LINETYPE
Definition: liblwgeom.h:85
POINTARRAY * ptarray_remove_repeated_points(const POINTARRAY *in, double tolerance)
Definition: ptarray.c:1499
int npoints
Definition: liblwgeom.h:370
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
LWLINE * lwcircstring_stroke(const LWCIRCSTRING *icurve, uint32_t perQuad)
Definition: lwstroke.c:206
LWGEOM ** geoms
Definition: liblwgeom.h:521
uint8_t flags
Definition: liblwgeom.h:516
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
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
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
int ngeoms
Definition: liblwgeom.h:519
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
uint8_t type
Definition: liblwgeom.h:395
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:244
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: