PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWLINE* lwcircstring_segmentize ( const LWCIRCSTRING icurve,
uint32_t  perQuad 
)

Definition at line 191 of file lwsegmentize.c.

References POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d_p(), LW_TRUE, lwcircle_segmentize(), LWDEBUG, LWDEBUGF, lwline_construct(), POINTARRAY::npoints, LWCIRCSTRING::points, ptarray_append_point(), ptarray_construct_empty(), ptarray_free(), and LWCIRCSTRING::srid.

Referenced by lwcollection_segmentize(), lwcompound_segmentize(), lwcurvepoly_segmentize(), lwgeom_segmentize(), and lwmcurve_segmentize().

192 {
193  LWLINE *oline;
194  POINTARRAY *ptarray;
195  POINTARRAY *tmp;
196  uint32_t i, j;
197  POINT4D p1, p2, p3, p4;
198 
199  LWDEBUGF(2, "lwcircstring_segmentize called., dim = %d", icurve->points->flags);
200 
201  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icurve->points->flags), FLAGS_GET_M(icurve->points->flags), 64);
202 
203  for (i = 2; i < icurve->points->npoints; i+=2)
204  {
205  LWDEBUGF(3, "lwcircstring_segmentize: arc ending at point %d", i);
206 
207  getPoint4d_p(icurve->points, i - 2, &p1);
208  getPoint4d_p(icurve->points, i - 1, &p2);
209  getPoint4d_p(icurve->points, i, &p3);
210  tmp = lwcircle_segmentize(&p1, &p2, &p3, perQuad);
211 
212  if (tmp)
213  {
214  LWDEBUGF(3, "lwcircstring_segmentize: generated %d points", tmp->npoints);
215 
216  for (j = 0; j < tmp->npoints; j++)
217  {
218  getPoint4d_p(tmp, j, &p4);
219  ptarray_append_point(ptarray, &p4, LW_TRUE);
220  }
221  ptarray_free(tmp);
222  }
223  else
224  {
225  LWDEBUG(3, "lwcircstring_segmentize: points are colinear, returning curve points as line");
226 
227  for (j = i - 2 ; j < i ; j++)
228  {
229  getPoint4d_p(icurve->points, j, &p4);
230  ptarray_append_point(ptarray, &p4, LW_TRUE);
231  }
232  }
233 
234  }
235  getPoint4d_p(icurve->points, icurve->points->npoints-1, &p1);
236  ptarray_append_point(ptarray, &p1, LW_TRUE);
237 
238  oline = lwline_construct(icurve->srid, NULL, ptarray);
239  return oline;
240 }
int npoints
Definition: liblwgeom.h:327
int32_t srid
Definition: liblwgeom.h:399
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
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
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
uint8_t flags
Definition: liblwgeom.h:325
#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
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
POINTARRAY * points
Definition: liblwgeom.h:400
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
static POINTARRAY * lwcircle_segmentize(POINT4D *p1, POINT4D *p2, POINT4D *p3, uint32_t perQuad)
Definition: lwsegmentize.c:103
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:217

Here is the call graph for this function:

Here is the caller graph for this function: