PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ 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 727 of file lwlinearreferencing.c.

728 {
729  assert(poly);
730  char hasz = FLAGS_GET_Z(poly->flags), hasm = FLAGS_GET_M(poly->flags);
731  LWPOLY *poly_res = lwpoly_construct_empty(poly->srid, hasz, hasm);
732  LWCOLLECTION *lwgeom_out = lwcollection_construct_empty(MULTIPOLYGONTYPE, poly->srid, hasz, hasm);
733 
734  for (uint32_t i = 0; i < poly->nrings; i++)
735  {
736  /* Ret number of points */
737  POINTARRAY *pa = ptarray_clamp_to_ordinate_range(poly->rings[i], ordinate, from, to, LW_TRUE);
738 
739  if (pa->npoints >= 4)
740  lwpoly_add_ring(poly_res, pa);
741  else
742  {
743  ptarray_free(pa);
744  if (i == 0)
745  break;
746  }
747  }
748  if (poly_res->nrings > 0)
749  lwgeom_out = lwcollection_add_lwgeom(lwgeom_out, (LWGEOM *)poly_res);
750  else
751  lwpoly_free(poly_res);
752 
753  return lwgeom_out;
754 }
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:179
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:121
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
Definition: lwcollection.c:92
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:180
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:319
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
Definition: lwcollection.c:188
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:175
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:107
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:505
uint32_t nrings
Definition: liblwgeom.h:510
lwflags_t flags
Definition: liblwgeom.h:507
int32_t srid
Definition: liblwgeom.h:506
uint32_t npoints
Definition: liblwgeom.h:413

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: