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

Definition at line 243 of file lwsegmentize.c.

References CIRCSTRINGTYPE, LWCOMPOUND::flags, FLAGS_GET_M, FLAGS_GET_Z, LWCOMPOUND::geoms, getPoint4d_p(), LINETYPE, LW_TRUE, lwcircstring_segmentize(), 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_segmentize(), lwcurvepoly_segmentize(), lwgeom_segmentize(), and lwmcurve_segmentize().

244 {
245  LWGEOM *geom;
246  POINTARRAY *ptarray = NULL, *ptarray_out = NULL;
247  LWLINE *tmp = NULL;
248  uint32_t i, j;
249  POINT4D p;
250 
251  LWDEBUG(2, "lwcompound_segmentize called.");
252 
253  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icompound->flags), FLAGS_GET_M(icompound->flags), 64);
254 
255  for (i = 0; i < icompound->ngeoms; i++)
256  {
257  geom = icompound->geoms[i];
258  if (geom->type == CIRCSTRINGTYPE)
259  {
260  tmp = lwcircstring_segmentize((LWCIRCSTRING *)geom, perQuad);
261  for (j = 0; j < tmp->points->npoints; j++)
262  {
263  getPoint4d_p(tmp->points, j, &p);
264  ptarray_append_point(ptarray, &p, LW_TRUE);
265  }
266  lwline_free(tmp);
267  }
268  else if (geom->type == LINETYPE)
269  {
270  tmp = (LWLINE *)geom;
271  for (j = 0; j < tmp->points->npoints; j++)
272  {
273  getPoint4d_p(tmp->points, j, &p);
274  ptarray_append_point(ptarray, &p, LW_TRUE);
275  }
276  }
277  else
278  {
279  lwerror("Unsupported geometry type %d found.",
280  geom->type, lwtype_name(geom->type));
281  return NULL;
282  }
283  }
284  ptarray_out = ptarray_remove_repeated_points(ptarray);
285  ptarray_free(ptarray);
286  return lwline_construct(icompound->srid, NULL, ptarray_out);
287 }
int32_t srid
Definition: liblwgeom.h:475
#define LINETYPE
Definition: liblwgeom.h:61
int npoints
Definition: liblwgeom.h:327
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:57
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:315
void lwline_free(LWLINE *line)
Definition: lwline.c:63
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
LWGEOM ** geoms
Definition: liblwgeom.h:478
uint8_t flags
Definition: liblwgeom.h:473
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
LWLINE * lwcircstring_segmentize(const LWCIRCSTRING *icurve, uint32_t perQuad)
Definition: lwsegmentize.c:191
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
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:141
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:29
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
int ngeoms
Definition: liblwgeom.h:476
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
POINTARRAY * ptarray_remove_repeated_points(POINTARRAY *in)
Definition: ptarray.c:1401
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:217
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: