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

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

787{
788 LWCOLLECTION *lwgeom_out;
789
790 assert(icol);
791 if (icol->ngeoms == 1)
792 lwgeom_out = lwgeom_clip_to_ordinate_range(icol->geoms[0], ordinate, from, to, 0);
793 else
794 {
795 LWCOLLECTION *col;
796 char hasz = lwgeom_has_z(lwcollection_as_lwgeom(icol));
797 char hasm = lwgeom_has_m(lwcollection_as_lwgeom(icol));
798 uint32_t i;
799 lwgeom_out = lwcollection_construct_empty(icol->type, icol->srid, hasz, hasm);
800 FLAGS_SET_Z(lwgeom_out->flags, hasz);
801 FLAGS_SET_M(lwgeom_out->flags, hasm);
802 for (i = 0; i < icol->ngeoms; i++)
803 {
804 col = lwgeom_clip_to_ordinate_range(icol->geoms[i], ordinate, from, to, 0);
805 if (col)
806 {
807 if (col->type != icol->type)
808 lwgeom_out->type = COLLECTIONTYPE;
809 lwgeom_out = lwcollection_concat_in_place(lwgeom_out, col);
810 lwfree(col->geoms);
812 }
813 }
814 }
815
816 if (icol->bbox)
817 lwgeom_refresh_bbox((LWGEOM *)lwgeom_out);
818
819 return lwgeom_out;
820}
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
Definition lwgeom.c:735
#define COLLECTIONTYPE
Definition liblwgeom.h:108
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition lwgeom.c:962
void lwfree(void *mem)
Definition lwutil.c:248
void lwcollection_release(LWCOLLECTION *lwcollection)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
#define FLAGS_SET_M(flags, value)
Definition liblwgeom.h:173
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition lwgeom.c:969
#define FLAGS_SET_Z(flags, value)
Definition liblwgeom.h:172
LWCOLLECTION * lwcollection_concat_in_place(LWCOLLECTION *col1, const LWCOLLECTION *col2)
Appends all geometries from col2 to col1 in place.
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition lwgeom.c:337
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:577
uint32_t ngeoms
Definition liblwgeom.h:580
uint8_t type
Definition liblwgeom.h:578
GBOX * bbox
Definition liblwgeom.h:574
LWGEOM ** geoms
Definition liblwgeom.h:575
int32_t srid
Definition liblwgeom.h:576

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: