PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwcircstring_stroke()

LWLINE* lwcircstring_stroke ( const LWCIRCSTRING icurve,
uint32_t  perQuad 
)

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

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