PostGIS  3.4.0dev-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)
740  return NULL;
741 
742  if (pa->npoints >= 4)
743  lwpoly_add_ring(poly_res, pa);
744  else
745  {
746  ptarray_free(pa);
747  if (i == 0)
748  break;
749  }
750  }
751  if (poly_res->nrings > 0)
752  lwgeom_out = lwcollection_add_lwgeom(lwgeom_out, (LWGEOM *)poly_res);
753  else
754  lwpoly_free(poly_res);
755 
756  return lwgeom_out;
757 }
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
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:166
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:93
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: