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

◆ lwpoly_clip_to_ordinate_range()

static LWCOLLECTION * lwpoly_clip_to_ordinate_range ( const LWPOLY poly,
char  ordinate,
double  from,
double  to 
)
inlinestatic

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

Definition at line 715 of file lwlinearreferencing.c.

716{
717 assert(poly);
718 char hasz = FLAGS_GET_Z(poly->flags), hasm = FLAGS_GET_M(poly->flags);
719 LWPOLY *poly_res = lwpoly_construct_empty(poly->srid, hasz, hasm);
720 LWCOLLECTION *lwgeom_out = lwcollection_construct_empty(MULTIPOLYGONTYPE, poly->srid, hasz, hasm);
721
722 for (uint32_t i = 0; i < poly->nrings; i++)
723 {
724 /* Ret number of points */
725 POINTARRAY *pa = ptarray_clamp_to_ordinate_range(poly->rings[i], ordinate, from, to, LW_TRUE);
726
727 if (!pa)
728 return NULL;
729
730 if (pa->npoints >= 4)
731 lwpoly_add_ring(poly_res, pa);
732 else
733 {
734 ptarray_free(pa);
735 if (i == 0)
736 break;
737 }
738 }
739 if (poly_res->nrings > 0)
740 lwgeom_out = lwcollection_add_lwgeom(lwgeom_out, (LWGEOM *)poly_res);
741 else
742 lwpoly_free(poly_res);
743
744 return lwgeom_out;
745}
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring, allocating extra space if necessary.
Definition lwpoly.c:247
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:165
#define MULTIPOLYGONTYPE
Definition liblwgeom.h:107
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:166
void ptarray_free(POINTARRAY *pa)
Definition ptarray.c:327
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
void lwpoly_free(LWPOLY *poly)
Definition lwpoly.c:175
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
Definition lwpoly.c:161
static POINTARRAY * ptarray_clamp_to_ordinate_range(const POINTARRAY *ipa, char ordinate, double from, double to, uint8_t is_closed)
POINTARRAY ** rings
Definition liblwgeom.h:519
uint32_t nrings
Definition liblwgeom.h:524
lwflags_t flags
Definition liblwgeom.h:521
int32_t srid
Definition liblwgeom.h:520
uint32_t npoints
Definition liblwgeom.h:427

References LWPOLY::flags, FLAGS_GET_M, FLAGS_GET_Z, LW_TRUE, lwcollection_add_lwgeom(), lwcollection_construct_empty(), lwpoly_add_ring(), lwpoly_construct_empty(), lwpoly_free(), MULTIPOLYGONTYPE, POINTARRAY::npoints, LWPOLY::nrings, ptarray_clamp_to_ordinate_range(), ptarray_free(), LWPOLY::rings, and LWPOLY::srid.

Referenced by lwgeom_clip_to_ordinate_range().

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