PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwcircstring_linearize()

static LWLINE * lwcircstring_linearize ( const LWCIRCSTRING icurve,
double  tol,
LW_LINEARIZE_TOLERANCE_TYPE  tolerance_type,
int  flags 
)
static

Definition at line 524 of file lwstroke.c.

527{
528 LWLINE *oline;
529 POINTARRAY *ptarray;
530 uint32_t i, j;
531 POINT4D p1, p2, p3, p4;
532 int ret;
533
534 LWDEBUGF(2, "lwcircstring_linearize called., dim = %d", icurve->points->flags);
535
536 ptarray = ptarray_construct_empty(FLAGS_GET_Z(icurve->points->flags), FLAGS_GET_M(icurve->points->flags), 64);
537
538 for (i = 2; i < icurve->points->npoints; i+=2)
539 {
540 LWDEBUGF(3, "lwcircstring_linearize: arc ending at point %d", i);
541
542 getPoint4d_p(icurve->points, i - 2, &p1);
543 getPoint4d_p(icurve->points, i - 1, &p2);
544 getPoint4d_p(icurve->points, i, &p3);
545
546 ret = lwarc_linearize(ptarray, &p1, &p2, &p3, tol, tolerance_type, flags);
547 if ( ret > 0 )
548 {
549 LWDEBUGF(3, "lwcircstring_linearize: generated %d points", ptarray->npoints);
550 }
551 else if ( ret == 0 )
552 {
553 LWDEBUG(3, "lwcircstring_linearize: points are colinear, returning curve points as line");
554
555 for (j = i - 2 ; j < i ; j++)
556 {
557 getPoint4d_p(icurve->points, j, &p4);
558 ptarray_append_point(ptarray, &p4, LW_TRUE);
559 }
560 }
561 else
562 {
563 /* An error occurred, lwerror should have been called by now */
564 ptarray_free(ptarray);
565 return NULL;
566 }
567 }
568 getPoint4d_p(icurve->points, icurve->points->npoints-1, &p1);
569 ptarray_append_point(ptarray, &p1, LW_FALSE);
570
571 oline = lwline_construct(icurve->srid, NULL, ptarray);
572 return oline;
573}
#define LW_FALSE
Definition liblwgeom.h:94
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition ptarray.c:59
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:165
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition lwline.c:42
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:166
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition lwgeom_api.c:125
void ptarray_free(POINTARRAY *pa)
Definition ptarray.c:327
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,...
Definition ptarray.c:147
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
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:251
int32_t srid
Definition liblwgeom.h:508
POINTARRAY * points
Definition liblwgeom.h:507
lwflags_t flags
Definition liblwgeom.h:431
uint32_t npoints
Definition liblwgeom.h:427

References POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d_p(), LW_FALSE, 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().

Here is the call graph for this function:
Here is the caller graph for this function: