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

Definition at line 206 of file lwstroke.c.

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

Referenced by lwcollection_stroke(), lwcompound_stroke(), lwcurvepoly_stroke(), lwgeom_stroke(), and lwmcurve_stroke().

207 {
208  LWLINE *oline;
209  POINTARRAY *ptarray;
210  POINTARRAY *tmp;
211  uint32_t i, j;
212  POINT4D p1, p2, p3, p4;
213 
214  LWDEBUGF(2, "lwcircstring_stroke called., dim = %d", icurve->points->flags);
215 
216  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icurve->points->flags), FLAGS_GET_M(icurve->points->flags), 64);
217 
218  for (i = 2; i < icurve->points->npoints; i+=2)
219  {
220  LWDEBUGF(3, "lwcircstring_stroke: arc ending at point %d", i);
221 
222  getPoint4d_p(icurve->points, i - 2, &p1);
223  getPoint4d_p(icurve->points, i - 1, &p2);
224  getPoint4d_p(icurve->points, i, &p3);
225  tmp = lwcircle_stroke(&p1, &p2, &p3, perQuad);
226 
227  if (tmp)
228  {
229  LWDEBUGF(3, "lwcircstring_stroke: generated %d points", tmp->npoints);
230 
231  for (j = 0; j < tmp->npoints; j++)
232  {
233  getPoint4d_p(tmp, j, &p4);
234  ptarray_append_point(ptarray, &p4, LW_TRUE);
235  }
236  ptarray_free(tmp);
237  }
238  else
239  {
240  LWDEBUG(3, "lwcircstring_stroke: points are colinear, returning curve points as line");
241 
242  for (j = i - 2 ; j < i ; j++)
243  {
244  getPoint4d_p(icurve->points, j, &p4);
245  ptarray_append_point(ptarray, &p4, LW_TRUE);
246  }
247  }
248 
249  }
250  getPoint4d_p(icurve->points, icurve->points->npoints-1, &p1);
251  ptarray_append_point(ptarray, &p1, LW_TRUE);
252 
253  oline = lwline_construct(icurve->srid, NULL, ptarray);
254  return oline;
255 }
static POINTARRAY * lwcircle_stroke(const POINT4D *p1, const POINT4D *p2, const POINT4D *p3, uint32_t perQuad)
Definition: lwstroke.c:118
int npoints
Definition: liblwgeom.h:370
int32_t srid
Definition: liblwgeom.h:442
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
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
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
uint8_t flags
Definition: liblwgeom.h:368
#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
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
POINTARRAY * points
Definition: liblwgeom.h:443
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:244

Here is the call graph for this function:

Here is the caller graph for this function: