PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwcompound_stroke()

LWLINE* lwcompound_stroke ( const LWCOMPOUND icompound,
uint32_t  perQuad 
)

Definition at line 242 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().

243 {
244  LWGEOM *geom;
245  POINTARRAY *ptarray = NULL, *ptarray_out = NULL;
246  LWLINE *tmp = NULL;
247  uint32_t i, j;
248  POINT4D p;
249 
250  LWDEBUG(2, "lwcompound_stroke called.");
251 
252  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icompound->flags), FLAGS_GET_M(icompound->flags), 64);
253 
254  for (i = 0; i < icompound->ngeoms; i++)
255  {
256  geom = icompound->geoms[i];
257  if (geom->type == CIRCSTRINGTYPE)
258  {
259  tmp = lwcircstring_stroke((LWCIRCSTRING *)geom, perQuad);
260  for (j = 0; j < tmp->points->npoints; j++)
261  {
262  getPoint4d_p(tmp->points, j, &p);
263  ptarray_append_point(ptarray, &p, LW_TRUE);
264  }
265  lwline_free(tmp);
266  }
267  else if (geom->type == LINETYPE)
268  {
269  tmp = (LWLINE *)geom;
270  for (j = 0; j < tmp->points->npoints; j++)
271  {
272  getPoint4d_p(tmp->points, j, &p);
273  ptarray_append_point(ptarray, &p, LW_TRUE);
274  }
275  }
276  else
277  {
278  lwerror("Unsupported geometry type %d found.",
279  geom->type, lwtype_name(geom->type));
280  return NULL;
281  }
282  }
283  ptarray_out = ptarray_remove_repeated_points(ptarray, 0.0);
284  ptarray_free(ptarray);
285  return lwline_construct(icompound->srid, NULL, ptarray_out);
286 }
int32_t srid
Definition: liblwgeom.h:503
#define LINETYPE
Definition: liblwgeom.h:71
int npoints
Definition: liblwgeom.h:355
POINTARRAY * ptarray_remove_repeated_points(POINTARRAY *in, double tolerance)
Definition: ptarray.c:1499
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:63
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
LWLINE * lwcircstring_stroke(const LWCIRCSTRING *icurve, uint32_t perQuad)
Definition: lwstroke.c:190
LWGEOM ** geoms
Definition: liblwgeom.h:506
uint8_t flags
Definition: liblwgeom.h:501
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
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_TRUE, 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:61
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:29
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
int ngeoms
Definition: liblwgeom.h:504
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
uint8_t type
Definition: liblwgeom.h:380
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:231
POINTARRAY * points
Definition: liblwgeom.h:406
Here is the call graph for this function:
Here is the caller graph for this function: