PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwcollection_clip_to_ordinate_range()

static LWCOLLECTION* lwcollection_clip_to_ordinate_range ( const LWCOLLECTION icol,
char  ordinate,
double  from,
double  to 
)
inlinestatic

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

Definition at line 792 of file lwlinearreferencing.c.

793 {
794  LWCOLLECTION *lwgeom_out;
795 
796  assert(icol);
797  if (icol->ngeoms == 1)
798  lwgeom_out = lwgeom_clip_to_ordinate_range(icol->geoms[0], ordinate, from, to, 0);
799  else
800  {
801  LWCOLLECTION *col;
802  char hasz = lwgeom_has_z(lwcollection_as_lwgeom(icol));
803  char hasm = lwgeom_has_m(lwcollection_as_lwgeom(icol));
804  uint32_t i;
805  lwgeom_out = lwcollection_construct_empty(icol->type, icol->srid, hasz, hasm);
806  FLAGS_SET_Z(lwgeom_out->flags, hasz);
807  FLAGS_SET_M(lwgeom_out->flags, hasm);
808  for (i = 0; i < icol->ngeoms; i++)
809  {
810  col = lwgeom_clip_to_ordinate_range(icol->geoms[i], ordinate, from, to, 0);
811  if (col)
812  {
813  if (col->type != icol->type)
814  lwgeom_out->type = COLLECTIONTYPE;
815  lwgeom_out = lwcollection_concat_in_place(lwgeom_out, col);
816  lwfree(col->geoms);
818  }
819  }
820  }
821 
822  if (icol->bbox)
823  lwgeom_refresh_bbox((LWGEOM *)lwgeom_out);
824 
825  return lwgeom_out;
826 }
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
Definition: lwgeom.c:689
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:291
#define COLLECTIONTYPE
Definition: liblwgeom.h:122
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:916
void lwfree(void *mem)
Definition: lwutil.c:242
void lwcollection_release(LWCOLLECTION *lwcollection)
Definition: lwcollection.c:36
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
Definition: lwcollection.c:92
LWCOLLECTION * lwcollection_concat_in_place(LWCOLLECTION *col1, const LWCOLLECTION *col2)
Appends all geometries from col2 to col1 in place.
Definition: lwcollection.c:241
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:187
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:923
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:186
LWCOLLECTION * lwgeom_clip_to_ordinate_range(const LWGEOM *lwin, char ordinate, double from, double to, double offset)
Given a geometry clip based on the from/to range of one of its ordinates (x, y, z,...
lwflags_t flags
Definition: liblwgeom.h:563
uint32_t ngeoms
Definition: liblwgeom.h:566
uint8_t type
Definition: liblwgeom.h:564
GBOX * bbox
Definition: liblwgeom.h:560
LWGEOM ** geoms
Definition: liblwgeom.h:561
int32_t srid
Definition: liblwgeom.h:562

References LWCOLLECTION::bbox, COLLECTIONTYPE, LWCOLLECTION::flags, FLAGS_SET_M, FLAGS_SET_Z, LWCOLLECTION::geoms, lwcollection_as_lwgeom(), lwcollection_concat_in_place(), lwcollection_construct_empty(), lwcollection_release(), lwfree(), lwgeom_clip_to_ordinate_range(), lwgeom_has_m(), lwgeom_has_z(), lwgeom_refresh_bbox(), LWCOLLECTION::ngeoms, LWCOLLECTION::srid, and LWCOLLECTION::type.

Referenced by lwgeom_clip_to_ordinate_range().

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