PostGIS  2.5.0dev-r@@SVN_REVISION@@
static LWLINE* lwcircstring_linearize ( const LWCIRCSTRING icurve,
double  tol,
LW_LINEARIZE_TOLERANCE_TYPE  tolerance_type,
int  flags 
)
static

Definition at line 359 of file lwstroke.c.

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

Referenced by lwcollection_linearize(), lwcompound_linearize(), lwcurve_linearize(), lwcurvepoly_linearize(), and lwmcurve_linearize().

362 {
363  LWLINE *oline;
364  POINTARRAY *ptarray;
365  uint32_t i, j;
366  POINT4D p1, p2, p3, p4;
367  int ret;
368 
369  LWDEBUGF(2, "lwcircstring_linearize called., dim = %d", icurve->points->flags);
370 
371  ptarray = ptarray_construct_empty(FLAGS_GET_Z(icurve->points->flags), FLAGS_GET_M(icurve->points->flags), 64);
372 
373  for (i = 2; i < icurve->points->npoints; i+=2)
374  {
375  LWDEBUGF(3, "lwcircstring_linearize: arc ending at point %d", i);
376 
377  getPoint4d_p(icurve->points, i - 2, &p1);
378  getPoint4d_p(icurve->points, i - 1, &p2);
379  getPoint4d_p(icurve->points, i, &p3);
380 
381  ret = lwarc_linearize(ptarray, &p1, &p2, &p3, tol, tolerance_type, flags);
382  if ( ret > 0 )
383  {
384  LWDEBUGF(3, "lwcircstring_linearize: generated %d points", ptarray->npoints);
385  }
386  else if ( ret == 0 )
387  {
388  LWDEBUG(3, "lwcircstring_linearize: points are colinear, returning curve points as line");
389 
390  for (j = i - 2 ; j < i ; j++)
391  {
392  getPoint4d_p(icurve->points, j, &p4);
393  ptarray_append_point(ptarray, &p4, LW_TRUE);
394  }
395  }
396  else
397  {
398  /* An error occurred, lwerror should have been called by now */
399  ptarray_free(ptarray);
400  return NULL;
401  }
402  }
403  getPoint4d_p(icurve->points, icurve->points->npoints-1, &p1);
404  ptarray_append_point(ptarray, &p1, LW_TRUE);
405 
406  oline = lwline_construct(icurve->srid, NULL, ptarray);
407  return oline;
408 }
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:328
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
static int lwarc_linearize(POINTARRAY *to, const POINT4D *p1, const POINT4D *p2, const POINT4D *p3, double tol, LW_LINEARIZE_TOLERANCE_TYPE tolerance_type, int flags)
Segmentize an arc.
Definition: lwstroke.c:134
unsigned int uint32_t
Definition: uthash.h:78
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
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:113
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
POINTARRAY * points
Definition: liblwgeom.h:443
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
uint32_t npoints
Definition: liblwgeom.h:370

Here is the call graph for this function:

Here is the caller graph for this function: