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

◆ lwtriangle_clip_to_ordinate_range()

static LWCOLLECTION * lwtriangle_clip_to_ordinate_range ( const LWTRIANGLE tri,
char  ordinate,
double  from,
double  to 
)
inlinestatic

Clip an input LWTRIANGLE between two values, on any ordinate input.

Definition at line 760 of file lwlinearreferencing.c.

761{
762 assert(tri);
763 char hasz = FLAGS_GET_Z(tri->flags), hasm = FLAGS_GET_M(tri->flags);
764 LWCOLLECTION *lwgeom_out = lwcollection_construct_empty(TINTYPE, tri->srid, hasz, hasm);
765 POINTARRAY *pa = ptarray_clamp_to_ordinate_range(tri->points, ordinate, from, to, LW_TRUE);
766
767 if (pa->npoints >= 4)
768 {
769 POINT4D first = getPoint4d(pa, 0);
770 for (uint32_t i = 1; i < pa->npoints - 2; i++)
771 {
772 POINT4D p;
773 POINTARRAY *tpa = ptarray_construct_empty(hasz, hasm, 4);
774 ptarray_append_point(tpa, &first, LW_TRUE);
775 getPoint4d_p(pa, i, &p);
777 getPoint4d_p(pa, i + 1, &p);
779 ptarray_append_point(tpa, &first, LW_TRUE);
780 LWTRIANGLE *otri = lwtriangle_construct(tri->srid, NULL, tpa);
781 lwgeom_out = lwcollection_add_lwgeom(lwgeom_out, (LWGEOM *)otri);
782 }
783 }
784 ptarray_free(pa);
785 return lwgeom_out;
786}
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
Definition lwgeom_api.c:108
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:179
#define TINTYPE
Definition liblwgeom.h:130
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:180
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
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
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:107
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
LWTRIANGLE * lwtriangle_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition lwtriangle.c:40
static POINTARRAY * ptarray_clamp_to_ordinate_range(const POINTARRAY *ipa, char ordinate, double from, double to, uint8_t is_closed)
int32_t srid
Definition liblwgeom.h:482
lwflags_t flags
Definition liblwgeom.h:483
POINTARRAY * points
Definition liblwgeom.h:481
uint32_t npoints
Definition liblwgeom.h:413

References LWTRIANGLE::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d(), getPoint4d_p(), LW_TRUE, lwcollection_add_lwgeom(), lwcollection_construct_empty(), lwtriangle_construct(), POINTARRAY::npoints, LWTRIANGLE::points, ptarray_append_point(), ptarray_clamp_to_ordinate_range(), ptarray_construct_empty(), ptarray_free(), LWTRIANGLE::srid, and TINTYPE.

Referenced by lwgeom_clip_to_ordinate_range().

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